Misplaced noalign when centering tabularx cell

Clash Royale CLAN TAG#URR8PPP
I have a minimal LaTeX document like this:
documentclassarticle
usepackagetabularx
begindocument
noindent
begintabularxlinewidth X
centering A & B \ hline
1.0 & 2.0 \
endtabularx
enddocument

I would like to center the table headers but left-align the columns. However, when I add centering to the B header, like this:
documentclassarticle
usepackagetabularx
begindocument
noindent
begintabularxlinewidth X
centering A & centering B \ hline
1.0 & 2.0 \
endtabularx
enddocument
I get this error:
! Misplaced noalign.
hline ->noalign
ifnum 0=`fi hrule @height arrayrulewidth futurelet...
l.8 endtabularx
! Extra alignment tab has been changed to cr.
<recently read> endtemplate
l.8 endtabularx
! Misplaced noalign.
hline ->noalign
ifnum 0=`fi hrule @height arrayrulewidth futurelet...
l.8 endtabularx
! Extra alignment tab has been changed to cr.
<recently read> endtemplate
l.8 endtabularx
! Misplaced noalign.
hline ->noalign
ifnum 0=`fi hrule @height arrayrulewidth futurelet...
l.8 endtabularx
! Extra alignment tab has been changed to cr.
<recently read> endtemplate
l.8 endtabularx
horizontal-alignment tabularx
add a comment |
I have a minimal LaTeX document like this:
documentclassarticle
usepackagetabularx
begindocument
noindent
begintabularxlinewidth X
centering A & B \ hline
1.0 & 2.0 \
endtabularx
enddocument

I would like to center the table headers but left-align the columns. However, when I add centering to the B header, like this:
documentclassarticle
usepackagetabularx
begindocument
noindent
begintabularxlinewidth X
centering A & centering B \ hline
1.0 & 2.0 \
endtabularx
enddocument
I get this error:
! Misplaced noalign.
hline ->noalign
ifnum 0=`fi hrule @height arrayrulewidth futurelet...
l.8 endtabularx
! Extra alignment tab has been changed to cr.
<recently read> endtemplate
l.8 endtabularx
! Misplaced noalign.
hline ->noalign
ifnum 0=`fi hrule @height arrayrulewidth futurelet...
l.8 endtabularx
! Extra alignment tab has been changed to cr.
<recently read> endtemplate
l.8 endtabularx
! Misplaced noalign.
hline ->noalign
ifnum 0=`fi hrule @height arrayrulewidth futurelet...
l.8 endtabularx
! Extra alignment tab has been changed to cr.
<recently read> endtemplate
l.8 endtabularx
horizontal-alignment tabularx
Related/duplicate: Centering intabularxandXcolumns
– Werner
Feb 20 at 18:58
Not a duplicate, that's centering an entire column instead of individual cells.
– Nathaniel M. Beaver
Feb 20 at 22:15
1
So it's more general since the same procedure is applied to all cells within the same column. :-|
– Werner
Feb 20 at 22:21
add a comment |
I have a minimal LaTeX document like this:
documentclassarticle
usepackagetabularx
begindocument
noindent
begintabularxlinewidth X
centering A & B \ hline
1.0 & 2.0 \
endtabularx
enddocument

I would like to center the table headers but left-align the columns. However, when I add centering to the B header, like this:
documentclassarticle
usepackagetabularx
begindocument
noindent
begintabularxlinewidth X
centering A & centering B \ hline
1.0 & 2.0 \
endtabularx
enddocument
I get this error:
! Misplaced noalign.
hline ->noalign
ifnum 0=`fi hrule @height arrayrulewidth futurelet...
l.8 endtabularx
! Extra alignment tab has been changed to cr.
<recently read> endtemplate
l.8 endtabularx
! Misplaced noalign.
hline ->noalign
ifnum 0=`fi hrule @height arrayrulewidth futurelet...
l.8 endtabularx
! Extra alignment tab has been changed to cr.
<recently read> endtemplate
l.8 endtabularx
! Misplaced noalign.
hline ->noalign
ifnum 0=`fi hrule @height arrayrulewidth futurelet...
l.8 endtabularx
! Extra alignment tab has been changed to cr.
<recently read> endtemplate
l.8 endtabularx
horizontal-alignment tabularx
I have a minimal LaTeX document like this:
documentclassarticle
usepackagetabularx
begindocument
noindent
begintabularxlinewidth X
centering A & B \ hline
1.0 & 2.0 \
endtabularx
enddocument

I would like to center the table headers but left-align the columns. However, when I add centering to the B header, like this:
documentclassarticle
usepackagetabularx
begindocument
noindent
begintabularxlinewidth X
centering A & centering B \ hline
1.0 & 2.0 \
endtabularx
enddocument
I get this error:
! Misplaced noalign.
hline ->noalign
ifnum 0=`fi hrule @height arrayrulewidth futurelet...
l.8 endtabularx
! Extra alignment tab has been changed to cr.
<recently read> endtemplate
l.8 endtabularx
! Misplaced noalign.
hline ->noalign
ifnum 0=`fi hrule @height arrayrulewidth futurelet...
l.8 endtabularx
! Extra alignment tab has been changed to cr.
<recently read> endtemplate
l.8 endtabularx
! Misplaced noalign.
hline ->noalign
ifnum 0=`fi hrule @height arrayrulewidth futurelet...
l.8 endtabularx
! Extra alignment tab has been changed to cr.
<recently read> endtemplate
l.8 endtabularx
horizontal-alignment tabularx
horizontal-alignment tabularx
asked Feb 20 at 18:34
Nathaniel M. BeaverNathaniel M. Beaver
24517
24517
Related/duplicate: Centering intabularxandXcolumns
– Werner
Feb 20 at 18:58
Not a duplicate, that's centering an entire column instead of individual cells.
– Nathaniel M. Beaver
Feb 20 at 22:15
1
So it's more general since the same procedure is applied to all cells within the same column. :-|
– Werner
Feb 20 at 22:21
add a comment |
Related/duplicate: Centering intabularxandXcolumns
– Werner
Feb 20 at 18:58
Not a duplicate, that's centering an entire column instead of individual cells.
– Nathaniel M. Beaver
Feb 20 at 22:15
1
So it's more general since the same procedure is applied to all cells within the same column. :-|
– Werner
Feb 20 at 22:21
Related/duplicate: Centering in
tabularx and X columns– Werner
Feb 20 at 18:58
Related/duplicate: Centering in
tabularx and X columns– Werner
Feb 20 at 18:58
Not a duplicate, that's centering an entire column instead of individual cells.
– Nathaniel M. Beaver
Feb 20 at 22:15
Not a duplicate, that's centering an entire column instead of individual cells.
– Nathaniel M. Beaver
Feb 20 at 22:15
1
1
So it's more general since the same procedure is applied to all cells within the same column. :-|
– Werner
Feb 20 at 22:21
So it's more general since the same procedure is applied to all cells within the same column. :-|
– Werner
Feb 20 at 22:21
add a comment |
2 Answers
2
active
oldest
votes
Page 2 of the tabularx documentation says that you have to use arraybackslash after centering (or raggedright or ragggedleft). Use like this:
documentclassarticle
usepackagetabularx
begindocument
noindent
begintabularxlinewidth X
centeringarraybackslash A & centeringarraybackslash B \ hline
1.0 & 2.0 \
endtabularx
enddocument
LaTeX's text alignment commands redefine \ so that they don't mean “a new line in the table” anymore. The arraybackslash command does let\tabularnewline so that it will work again.
add a comment |
You can simply use a multicolumn1c... for the column heads. Or load makecell and use its thead command (by default, its content is centred, both horizontally and vertically), which has the possibility to define a common formatting of all theads arguments. Here is an example of both methods:
documentclassarticle
usepackagetabularx, makecell, xcolor
renewcommandtheadfontnormalsizebfseriescolorred
begindocument
noindent
begintabularxlinewidth X
multicolumn1cA & multicolumn1cB \ hline
1.0 & 2.0 \
endtabularx
vspace4ex
noindent
begintabularxlinewidth X
theadA & theadB \ hline
1.0 & 2.0 \
endtabularx
enddocument

add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "85"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f475871%2fmisplaced-noalign-when-centering-tabularx-cell%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Page 2 of the tabularx documentation says that you have to use arraybackslash after centering (or raggedright or ragggedleft). Use like this:
documentclassarticle
usepackagetabularx
begindocument
noindent
begintabularxlinewidth X
centeringarraybackslash A & centeringarraybackslash B \ hline
1.0 & 2.0 \
endtabularx
enddocument
LaTeX's text alignment commands redefine \ so that they don't mean “a new line in the table” anymore. The arraybackslash command does let\tabularnewline so that it will work again.
add a comment |
Page 2 of the tabularx documentation says that you have to use arraybackslash after centering (or raggedright or ragggedleft). Use like this:
documentclassarticle
usepackagetabularx
begindocument
noindent
begintabularxlinewidth X
centeringarraybackslash A & centeringarraybackslash B \ hline
1.0 & 2.0 \
endtabularx
enddocument
LaTeX's text alignment commands redefine \ so that they don't mean “a new line in the table” anymore. The arraybackslash command does let\tabularnewline so that it will work again.
add a comment |
Page 2 of the tabularx documentation says that you have to use arraybackslash after centering (or raggedright or ragggedleft). Use like this:
documentclassarticle
usepackagetabularx
begindocument
noindent
begintabularxlinewidth X
centeringarraybackslash A & centeringarraybackslash B \ hline
1.0 & 2.0 \
endtabularx
enddocument
LaTeX's text alignment commands redefine \ so that they don't mean “a new line in the table” anymore. The arraybackslash command does let\tabularnewline so that it will work again.
Page 2 of the tabularx documentation says that you have to use arraybackslash after centering (or raggedright or ragggedleft). Use like this:
documentclassarticle
usepackagetabularx
begindocument
noindent
begintabularxlinewidth X
centeringarraybackslash A & centeringarraybackslash B \ hline
1.0 & 2.0 \
endtabularx
enddocument
LaTeX's text alignment commands redefine \ so that they don't mean “a new line in the table” anymore. The arraybackslash command does let\tabularnewline so that it will work again.
answered Feb 20 at 18:40
Phelype OleinikPhelype Oleinik
24.2k54688
24.2k54688
add a comment |
add a comment |
You can simply use a multicolumn1c... for the column heads. Or load makecell and use its thead command (by default, its content is centred, both horizontally and vertically), which has the possibility to define a common formatting of all theads arguments. Here is an example of both methods:
documentclassarticle
usepackagetabularx, makecell, xcolor
renewcommandtheadfontnormalsizebfseriescolorred
begindocument
noindent
begintabularxlinewidth X
multicolumn1cA & multicolumn1cB \ hline
1.0 & 2.0 \
endtabularx
vspace4ex
noindent
begintabularxlinewidth X
theadA & theadB \ hline
1.0 & 2.0 \
endtabularx
enddocument

add a comment |
You can simply use a multicolumn1c... for the column heads. Or load makecell and use its thead command (by default, its content is centred, both horizontally and vertically), which has the possibility to define a common formatting of all theads arguments. Here is an example of both methods:
documentclassarticle
usepackagetabularx, makecell, xcolor
renewcommandtheadfontnormalsizebfseriescolorred
begindocument
noindent
begintabularxlinewidth X
multicolumn1cA & multicolumn1cB \ hline
1.0 & 2.0 \
endtabularx
vspace4ex
noindent
begintabularxlinewidth X
theadA & theadB \ hline
1.0 & 2.0 \
endtabularx
enddocument

add a comment |
You can simply use a multicolumn1c... for the column heads. Or load makecell and use its thead command (by default, its content is centred, both horizontally and vertically), which has the possibility to define a common formatting of all theads arguments. Here is an example of both methods:
documentclassarticle
usepackagetabularx, makecell, xcolor
renewcommandtheadfontnormalsizebfseriescolorred
begindocument
noindent
begintabularxlinewidth X
multicolumn1cA & multicolumn1cB \ hline
1.0 & 2.0 \
endtabularx
vspace4ex
noindent
begintabularxlinewidth X
theadA & theadB \ hline
1.0 & 2.0 \
endtabularx
enddocument

You can simply use a multicolumn1c... for the column heads. Or load makecell and use its thead command (by default, its content is centred, both horizontally and vertically), which has the possibility to define a common formatting of all theads arguments. Here is an example of both methods:
documentclassarticle
usepackagetabularx, makecell, xcolor
renewcommandtheadfontnormalsizebfseriescolorred
begindocument
noindent
begintabularxlinewidth X
multicolumn1cA & multicolumn1cB \ hline
1.0 & 2.0 \
endtabularx
vspace4ex
noindent
begintabularxlinewidth X
theadA & theadB \ hline
1.0 & 2.0 \
endtabularx
enddocument

edited Feb 20 at 19:28
answered Feb 20 at 19:09
BernardBernard
173k776204
173k776204
add a comment |
add a comment |
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f475871%2fmisplaced-noalign-when-centering-tabularx-cell%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Related/duplicate: Centering in
tabularxandXcolumns– Werner
Feb 20 at 18:58
Not a duplicate, that's centering an entire column instead of individual cells.
– Nathaniel M. Beaver
Feb 20 at 22:15
1
So it's more general since the same procedure is applied to all cells within the same column. :-|
– Werner
Feb 20 at 22:21