Misplaced noalign when centering tabularx cell

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












2















I have a minimal LaTeX document like this:



documentclassarticle
usepackagetabularx
begindocument
noindent
begintabularxlinewidth X
centering A & B \ hline
1.0 & 2.0 \
endtabularx
enddocument


A B 1.0 2.0



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









share|improve this question






















  • 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






  • 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















2















I have a minimal LaTeX document like this:



documentclassarticle
usepackagetabularx
begindocument
noindent
begintabularxlinewidth X
centering A & B \ hline
1.0 & 2.0 \
endtabularx
enddocument


A B 1.0 2.0



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









share|improve this question






















  • 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






  • 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













2












2








2








I have a minimal LaTeX document like this:



documentclassarticle
usepackagetabularx
begindocument
noindent
begintabularxlinewidth X
centering A & B \ hline
1.0 & 2.0 \
endtabularx
enddocument


A B 1.0 2.0



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









share|improve this question














I have a minimal LaTeX document like this:



documentclassarticle
usepackagetabularx
begindocument
noindent
begintabularxlinewidth X
centering A & B \ hline
1.0 & 2.0 \
endtabularx
enddocument


A B 1.0 2.0



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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Feb 20 at 18:34









Nathaniel M. BeaverNathaniel M. Beaver

24517




24517












  • 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






  • 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











  • 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










2 Answers
2






active

oldest

votes


















3














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.






share|improve this answer






























    3














    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


    enter image description here






    share|improve this answer
























      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
      );



      );













      draft saved

      draft discarded


















      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









      3














      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.






      share|improve this answer



























        3














        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.






        share|improve this answer

























          3












          3








          3







          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.






          share|improve this answer













          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.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Feb 20 at 18:40









          Phelype OleinikPhelype Oleinik

          24.2k54688




          24.2k54688





















              3














              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


              enter image description here






              share|improve this answer





























                3














                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


                enter image description here






                share|improve this answer



























                  3












                  3








                  3







                  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


                  enter image description here






                  share|improve this answer















                  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


                  enter image description here







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Feb 20 at 19:28

























                  answered Feb 20 at 19:09









                  BernardBernard

                  173k776204




                  173k776204



























                      draft saved

                      draft discarded
















































                      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.




                      draft saved


                      draft discarded














                      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





















































                      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






                      Popular posts from this blog

                      How to check contact read email or not when send email to Individual?

                      Bahrain

                      Postfix configuration issue with fips on centos 7; mailgun relay