Why is '#table(' producing incorrect output?

I’m experiencing a problem with the ‘table’ code.

My input looks like this:

#table(
	columns: 4,
	stroke: none,
	table.header[X], […], [Y],[ ],
	[ ], [W], […], [Z]
)

The preview looks like this:

X
… Y
W … Z

But what it should look like is this:

X … Y
  W … Z

And yet another table comes out perfectly:

Input:

#table(
    columns: 5,
    stroke: none,
    table.header[A][bigger][house][than][mine],
    	[\[D], […], [N\]], [ ], [ ],
    	[ ], [\[A], [N\]], [ ],[ ],
	[ ], [\[A], […], [P],[Prn\]]	
)

Output:

A   bigger  house  than  mine
[D  …       N]
    [A      N]
    [A      …      P     Prn]

What is wrong with the first table code above?

Hi @Andrew_van_der_Spuy, I have tagged and formatted the post. Please check your DMs as I have sent you a notice on how to properly post on this forum.

    table.header[X], […], [Y],[ ],

 

    table.header[A][bigger][house][than][mine],

These two headers are different: the first has commas while the second doesn’t. Both are using a trailing content block, but the second variant has multiple of them.

Written in code, the two lines of code are equivalent to the following:

    // header with one cell
    table.header([X]),
    // three cells in the next row
    […], [Y],[ ],

 

    // header with five cells
    table.header([A], [bigger], [house], [than], [mine]),

Although multiple trailing content blocks are allowed, here they result in code that is less readable, so I would recommend using parentheses for your header, which should fix your code:

    table.header([X], […], [Y],[ ]),
1 Like