# Problems with using Riffle, Grid and TableForm

I have the following Table:

Clear["Global*"];
Module[{startX = 10, endX = 12, endJ = 5},
table1 = Table["", {j, 1, endJ}];
table2 = Table[x/j, {x, startX, endX}, {j, 1, endJ}];
table3 = Table[j/x, {x, startX, endX}, {j, 1, endJ}];
table4 = Table[N[Sqrt[x]/j^2 - j^2/x], {x, startX, endX}, {j, 1, endJ}];
table5 = Riffle[table2, table3];
table6 = Riffle[table5, table4, 3];
table7 = Riffle[table6, table1, 4];]


The idea is that there are four consecutive rows for each value x, each displaying the relevant values from table1, table2, table3 and table4. But I have a few problems:

1. table7 is missing its last line - here's a screenshot:

1. TableForm[table7] displays correctly, but

 TableForm [table7,
{{"x=1", "", "", "", "2", "", "", "", "3", "", "", ""},
{"j=1", "2", "3", "4", "5"}}]


does not — there are no dividers.

2. Although TableForm[table7] works, Grid [table7] does not. (Update: @kglr has solved this issue in the comments below)

Can anyone help me fix these issues?

Ideally, I would prefer a solution using Grid since this allows more flexibility with dividers.

• for problem 3: replace "" in table7 with {""}; that is, use Grid[table7 /. "" -> {""}]. – kglr Aug 30 '20 at 11:55
• Many thanks @kglr – Richard Burke-Ward Aug 30 '20 at 12:15
• Your 1st question is weird. There is no table6 used in the definition of table5`. Is that a typo or did I miss something? – halirutan Aug 30 '20 at 16:21
• Hi @halirutan. Question amended and clarified. Thanks for the heads-up. – Richard Burke-Ward Aug 31 '20 at 6:22