Strange problem with centring headers in "p{wd}" columns in "tabular".
Rolf Turner
r.turner at auckland.ac.nz
Wed Jun 2 04:45:42 CEST 2021
I wanted to create a form with columns 2 through 5 all of width 2 cm.
I tried using "p{2cm}" as the "cols" specifier, and that worked
fine, but then I decided that I'd like to have the column headers
*centred* in the columns as well.
So I preceded each column header by "\centering". This produces (in
my minimal reproducible example) an error:
> ! Misplaced \noalign.
> \hline ->\noalign
> {\ifnum 0=`}\fi \hrule \@height \arrayrulewidth
> \futurelet... l.8 \centering Yak \\ \hline
("Yak" being the header of the last column).
I cannot parse this error message.
I then removed the "\centering" command that preceded "Yak" (but
left the other "\centering" commands as they were). The *.tex file
then compiled just fine and the headings of columns 2, 3 and 4 were
duly centred, but the heading of the last column, "Yak", was of course
not centred.
Can anyone explain to me what is going on, and how (if it is indeed
possible) to get the headings of all of the "p{wd}" columns centred?
I have attached minimal reproducible examples; mre01.tex throws
the error shown above when I try to compile it; mre02.tex has
the "\centering" command preceding "Yak" removed, and compiles but does
not of course have the heading of the last column centred.
Thanks for any insights.
cheers,
Rolf Turner
--
Honorary Research Fellow
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mre01.tex
Type: text/x-tex
Size: 487 bytes
Desc: not available
URL: <https://tug.org/pipermail/texhax/attachments/20210602/bb15ec5a/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mre02.tex
Type: text/x-tex
Size: 476 bytes
Desc: not available
URL: <https://tug.org/pipermail/texhax/attachments/20210602/bb15ec5a/attachment-0001.bin>
More information about the texhax
mailing list.