When should the tabularx environment be used or not?












15















I asked a question here and egreg replied that the tabularx environment was not the right tool. He solved the problem with the tabular environment.
Werner didn't use it either.
In this question Mico also says that the tabularx environment is not suitable.



I thought the tabularx environment was adapted to get columns of the same width, but this can be done in the tabular environment as egreg did.




  1. Is the tabularx environment useful?

  2. When should we use the tabularx environment?

  3. Do you have any examples where this environment is useful?










share|improve this question



























    15















    I asked a question here and egreg replied that the tabularx environment was not the right tool. He solved the problem with the tabular environment.
    Werner didn't use it either.
    In this question Mico also says that the tabularx environment is not suitable.



    I thought the tabularx environment was adapted to get columns of the same width, but this can be done in the tabular environment as egreg did.




    1. Is the tabularx environment useful?

    2. When should we use the tabularx environment?

    3. Do you have any examples where this environment is useful?










    share|improve this question

























      15












      15








      15


      2






      I asked a question here and egreg replied that the tabularx environment was not the right tool. He solved the problem with the tabular environment.
      Werner didn't use it either.
      In this question Mico also says that the tabularx environment is not suitable.



      I thought the tabularx environment was adapted to get columns of the same width, but this can be done in the tabular environment as egreg did.




      1. Is the tabularx environment useful?

      2. When should we use the tabularx environment?

      3. Do you have any examples where this environment is useful?










      share|improve this question














      I asked a question here and egreg replied that the tabularx environment was not the right tool. He solved the problem with the tabular environment.
      Werner didn't use it either.
      In this question Mico also says that the tabularx environment is not suitable.



      I thought the tabularx environment was adapted to get columns of the same width, but this can be done in the tabular environment as egreg did.




      1. Is the tabularx environment useful?

      2. When should we use the tabularx environment?

      3. Do you have any examples where this environment is useful?







      tabularx






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 3 at 7:31









      AndréCAndréC

      8,46411446




      8,46411446






















          3 Answers
          3






          active

          oldest

          votes


















          18















          Is the tabularx environment useful?




          Yes. But it's no environment intended to replace tabular with (i.e. it makes no sense to make every tabular a tabularx).




          When should we use the tabularx environment?




          You should use it when you need to calculate the width of a column with respect to a total width. Please note that if your columns are short and do not contain line breaks you do not gain anything from using tabularx. You can get fixed-width columns with regular p or wl specifiers.




          Do you have any examples where this environment is useful?





          • When you need to reproduce word processor tables it's quite useful as they are often using equally-sized columns.

          • When you are going to have several columns which should be of equal-size and which will have line breaks.

          • When you are in a hurry and do not want to do calculations.






          share|improve this answer































            15














            TeXnician already said when it's useful, I would like to add when it is detrimental.



            Never use tabularx without an X column!



            Sometimes I saw questions with this wrong usage here, never do that!



            documentclass{article} 
            usepackage{caption}
            usepackage{array}
            usepackage{booktabs}
            usepackage{tabularx}

            begin{document}
            begin{table}centering
            caption{Here it is useful}
            begin{tabularx}{linewidth}{Xcc}
            toprule
            Column A & Column B & Column C \
            midrule
            texttt{tabularx} is useful when there is one (or more) columns with long text which goes on more than one row & lions & ducks \
            bottomrule
            end{tabularx}
            end{table}
            begin{table}centering
            caption{label{tab:awful}Here it is useless and a bit awful (you only have short text in columns, there is too much blank space left)}
            begin{tabularx}{linewidth}{*3{>{centeringarraybackslash}X}}
            toprule
            Column A & Column B & Column C \
            midrule
            marmots & lions & ducks \
            bottomrule
            end{tabularx}
            end{table}
            begin{table}centering
            caption{label{tab:wrong}Here it is detrimental and horrible (never use texttt{tabularx} without an X column)}
            begin{tabularx}{linewidth}{ccc}
            toprule
            Column A & Column B & Column C \
            midrule
            marmots & lions & ducks \
            bottomrule
            end{tabularx}
            end{table}
            begin{table}centering
            caption{Instead of Table ref{tab:awful} or Table ref{tab:wrong}, this one is much better}
            begin{tabular}{ccc}
            toprule
            Column A & Column B & Column C \
            midrule
            marmots & lions & ducks \
            bottomrule
            end{tabular}
            end{table}
            end{document}


            enter image description here






            share|improve this answer


























            • Lions and ducks? Is that a good idea? After all, lions are cats and ducks are birds ;)

              – TeXnician
              Jan 3 at 9:54






            • 3





              @TeXnician But I put them in separate columns :)

              – CarLaTeX
              Jan 3 at 9:58






            • 1





              I'm normally against vertical lines in columns, in this specific case they might be useful to keep the ducks and marmots safe -- we don't want the lions to eat them, do we? :)

              – samcarter
              Jan 3 at 11:07








            • 1





              @samcarter We have found a proper use of vertical rules, lol!

              – CarLaTeX
              Jan 3 at 11:08



















            13














            The important thing to note about tabularx that it is all about automatically setting the target length for line breaking within a column. However the vast majority of data tables in scientific documents are (apart from the headings) tables of numerical data where there is no line breaking within the column, so I would say that tabularx is not suitable for those cases.



            An X column is a p column of an automatically determined width, but like any p column it is a parbox designed for paragraphs of text wrapped to the specified width.






            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%2f468363%2fwhen-should-the-tabularx-environment-be-used-or-not%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              3 Answers
              3






              active

              oldest

              votes








              3 Answers
              3






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              18















              Is the tabularx environment useful?




              Yes. But it's no environment intended to replace tabular with (i.e. it makes no sense to make every tabular a tabularx).




              When should we use the tabularx environment?




              You should use it when you need to calculate the width of a column with respect to a total width. Please note that if your columns are short and do not contain line breaks you do not gain anything from using tabularx. You can get fixed-width columns with regular p or wl specifiers.




              Do you have any examples where this environment is useful?





              • When you need to reproduce word processor tables it's quite useful as they are often using equally-sized columns.

              • When you are going to have several columns which should be of equal-size and which will have line breaks.

              • When you are in a hurry and do not want to do calculations.






              share|improve this answer




























                18















                Is the tabularx environment useful?




                Yes. But it's no environment intended to replace tabular with (i.e. it makes no sense to make every tabular a tabularx).




                When should we use the tabularx environment?




                You should use it when you need to calculate the width of a column with respect to a total width. Please note that if your columns are short and do not contain line breaks you do not gain anything from using tabularx. You can get fixed-width columns with regular p or wl specifiers.




                Do you have any examples where this environment is useful?





                • When you need to reproduce word processor tables it's quite useful as they are often using equally-sized columns.

                • When you are going to have several columns which should be of equal-size and which will have line breaks.

                • When you are in a hurry and do not want to do calculations.






                share|improve this answer


























                  18












                  18








                  18








                  Is the tabularx environment useful?




                  Yes. But it's no environment intended to replace tabular with (i.e. it makes no sense to make every tabular a tabularx).




                  When should we use the tabularx environment?




                  You should use it when you need to calculate the width of a column with respect to a total width. Please note that if your columns are short and do not contain line breaks you do not gain anything from using tabularx. You can get fixed-width columns with regular p or wl specifiers.




                  Do you have any examples where this environment is useful?





                  • When you need to reproduce word processor tables it's quite useful as they are often using equally-sized columns.

                  • When you are going to have several columns which should be of equal-size and which will have line breaks.

                  • When you are in a hurry and do not want to do calculations.






                  share|improve this answer














                  Is the tabularx environment useful?




                  Yes. But it's no environment intended to replace tabular with (i.e. it makes no sense to make every tabular a tabularx).




                  When should we use the tabularx environment?




                  You should use it when you need to calculate the width of a column with respect to a total width. Please note that if your columns are short and do not contain line breaks you do not gain anything from using tabularx. You can get fixed-width columns with regular p or wl specifiers.




                  Do you have any examples where this environment is useful?





                  • When you need to reproduce word processor tables it's quite useful as they are often using equally-sized columns.

                  • When you are going to have several columns which should be of equal-size and which will have line breaks.

                  • When you are in a hurry and do not want to do calculations.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jan 3 at 7:56









                  TeXnicianTeXnician

                  24.7k63187




                  24.7k63187























                      15














                      TeXnician already said when it's useful, I would like to add when it is detrimental.



                      Never use tabularx without an X column!



                      Sometimes I saw questions with this wrong usage here, never do that!



                      documentclass{article} 
                      usepackage{caption}
                      usepackage{array}
                      usepackage{booktabs}
                      usepackage{tabularx}

                      begin{document}
                      begin{table}centering
                      caption{Here it is useful}
                      begin{tabularx}{linewidth}{Xcc}
                      toprule
                      Column A & Column B & Column C \
                      midrule
                      texttt{tabularx} is useful when there is one (or more) columns with long text which goes on more than one row & lions & ducks \
                      bottomrule
                      end{tabularx}
                      end{table}
                      begin{table}centering
                      caption{label{tab:awful}Here it is useless and a bit awful (you only have short text in columns, there is too much blank space left)}
                      begin{tabularx}{linewidth}{*3{>{centeringarraybackslash}X}}
                      toprule
                      Column A & Column B & Column C \
                      midrule
                      marmots & lions & ducks \
                      bottomrule
                      end{tabularx}
                      end{table}
                      begin{table}centering
                      caption{label{tab:wrong}Here it is detrimental and horrible (never use texttt{tabularx} without an X column)}
                      begin{tabularx}{linewidth}{ccc}
                      toprule
                      Column A & Column B & Column C \
                      midrule
                      marmots & lions & ducks \
                      bottomrule
                      end{tabularx}
                      end{table}
                      begin{table}centering
                      caption{Instead of Table ref{tab:awful} or Table ref{tab:wrong}, this one is much better}
                      begin{tabular}{ccc}
                      toprule
                      Column A & Column B & Column C \
                      midrule
                      marmots & lions & ducks \
                      bottomrule
                      end{tabular}
                      end{table}
                      end{document}


                      enter image description here






                      share|improve this answer


























                      • Lions and ducks? Is that a good idea? After all, lions are cats and ducks are birds ;)

                        – TeXnician
                        Jan 3 at 9:54






                      • 3





                        @TeXnician But I put them in separate columns :)

                        – CarLaTeX
                        Jan 3 at 9:58






                      • 1





                        I'm normally against vertical lines in columns, in this specific case they might be useful to keep the ducks and marmots safe -- we don't want the lions to eat them, do we? :)

                        – samcarter
                        Jan 3 at 11:07








                      • 1





                        @samcarter We have found a proper use of vertical rules, lol!

                        – CarLaTeX
                        Jan 3 at 11:08
















                      15














                      TeXnician already said when it's useful, I would like to add when it is detrimental.



                      Never use tabularx without an X column!



                      Sometimes I saw questions with this wrong usage here, never do that!



                      documentclass{article} 
                      usepackage{caption}
                      usepackage{array}
                      usepackage{booktabs}
                      usepackage{tabularx}

                      begin{document}
                      begin{table}centering
                      caption{Here it is useful}
                      begin{tabularx}{linewidth}{Xcc}
                      toprule
                      Column A & Column B & Column C \
                      midrule
                      texttt{tabularx} is useful when there is one (or more) columns with long text which goes on more than one row & lions & ducks \
                      bottomrule
                      end{tabularx}
                      end{table}
                      begin{table}centering
                      caption{label{tab:awful}Here it is useless and a bit awful (you only have short text in columns, there is too much blank space left)}
                      begin{tabularx}{linewidth}{*3{>{centeringarraybackslash}X}}
                      toprule
                      Column A & Column B & Column C \
                      midrule
                      marmots & lions & ducks \
                      bottomrule
                      end{tabularx}
                      end{table}
                      begin{table}centering
                      caption{label{tab:wrong}Here it is detrimental and horrible (never use texttt{tabularx} without an X column)}
                      begin{tabularx}{linewidth}{ccc}
                      toprule
                      Column A & Column B & Column C \
                      midrule
                      marmots & lions & ducks \
                      bottomrule
                      end{tabularx}
                      end{table}
                      begin{table}centering
                      caption{Instead of Table ref{tab:awful} or Table ref{tab:wrong}, this one is much better}
                      begin{tabular}{ccc}
                      toprule
                      Column A & Column B & Column C \
                      midrule
                      marmots & lions & ducks \
                      bottomrule
                      end{tabular}
                      end{table}
                      end{document}


                      enter image description here






                      share|improve this answer


























                      • Lions and ducks? Is that a good idea? After all, lions are cats and ducks are birds ;)

                        – TeXnician
                        Jan 3 at 9:54






                      • 3





                        @TeXnician But I put them in separate columns :)

                        – CarLaTeX
                        Jan 3 at 9:58






                      • 1





                        I'm normally against vertical lines in columns, in this specific case they might be useful to keep the ducks and marmots safe -- we don't want the lions to eat them, do we? :)

                        – samcarter
                        Jan 3 at 11:07








                      • 1





                        @samcarter We have found a proper use of vertical rules, lol!

                        – CarLaTeX
                        Jan 3 at 11:08














                      15












                      15








                      15







                      TeXnician already said when it's useful, I would like to add when it is detrimental.



                      Never use tabularx without an X column!



                      Sometimes I saw questions with this wrong usage here, never do that!



                      documentclass{article} 
                      usepackage{caption}
                      usepackage{array}
                      usepackage{booktabs}
                      usepackage{tabularx}

                      begin{document}
                      begin{table}centering
                      caption{Here it is useful}
                      begin{tabularx}{linewidth}{Xcc}
                      toprule
                      Column A & Column B & Column C \
                      midrule
                      texttt{tabularx} is useful when there is one (or more) columns with long text which goes on more than one row & lions & ducks \
                      bottomrule
                      end{tabularx}
                      end{table}
                      begin{table}centering
                      caption{label{tab:awful}Here it is useless and a bit awful (you only have short text in columns, there is too much blank space left)}
                      begin{tabularx}{linewidth}{*3{>{centeringarraybackslash}X}}
                      toprule
                      Column A & Column B & Column C \
                      midrule
                      marmots & lions & ducks \
                      bottomrule
                      end{tabularx}
                      end{table}
                      begin{table}centering
                      caption{label{tab:wrong}Here it is detrimental and horrible (never use texttt{tabularx} without an X column)}
                      begin{tabularx}{linewidth}{ccc}
                      toprule
                      Column A & Column B & Column C \
                      midrule
                      marmots & lions & ducks \
                      bottomrule
                      end{tabularx}
                      end{table}
                      begin{table}centering
                      caption{Instead of Table ref{tab:awful} or Table ref{tab:wrong}, this one is much better}
                      begin{tabular}{ccc}
                      toprule
                      Column A & Column B & Column C \
                      midrule
                      marmots & lions & ducks \
                      bottomrule
                      end{tabular}
                      end{table}
                      end{document}


                      enter image description here






                      share|improve this answer















                      TeXnician already said when it's useful, I would like to add when it is detrimental.



                      Never use tabularx without an X column!



                      Sometimes I saw questions with this wrong usage here, never do that!



                      documentclass{article} 
                      usepackage{caption}
                      usepackage{array}
                      usepackage{booktabs}
                      usepackage{tabularx}

                      begin{document}
                      begin{table}centering
                      caption{Here it is useful}
                      begin{tabularx}{linewidth}{Xcc}
                      toprule
                      Column A & Column B & Column C \
                      midrule
                      texttt{tabularx} is useful when there is one (or more) columns with long text which goes on more than one row & lions & ducks \
                      bottomrule
                      end{tabularx}
                      end{table}
                      begin{table}centering
                      caption{label{tab:awful}Here it is useless and a bit awful (you only have short text in columns, there is too much blank space left)}
                      begin{tabularx}{linewidth}{*3{>{centeringarraybackslash}X}}
                      toprule
                      Column A & Column B & Column C \
                      midrule
                      marmots & lions & ducks \
                      bottomrule
                      end{tabularx}
                      end{table}
                      begin{table}centering
                      caption{label{tab:wrong}Here it is detrimental and horrible (never use texttt{tabularx} without an X column)}
                      begin{tabularx}{linewidth}{ccc}
                      toprule
                      Column A & Column B & Column C \
                      midrule
                      marmots & lions & ducks \
                      bottomrule
                      end{tabularx}
                      end{table}
                      begin{table}centering
                      caption{Instead of Table ref{tab:awful} or Table ref{tab:wrong}, this one is much better}
                      begin{tabular}{ccc}
                      toprule
                      Column A & Column B & Column C \
                      midrule
                      marmots & lions & ducks \
                      bottomrule
                      end{tabular}
                      end{table}
                      end{document}


                      enter image description here







                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited Jan 3 at 11:09

























                      answered Jan 3 at 9:40









                      CarLaTeXCarLaTeX

                      30.3k447127




                      30.3k447127













                      • Lions and ducks? Is that a good idea? After all, lions are cats and ducks are birds ;)

                        – TeXnician
                        Jan 3 at 9:54






                      • 3





                        @TeXnician But I put them in separate columns :)

                        – CarLaTeX
                        Jan 3 at 9:58






                      • 1





                        I'm normally against vertical lines in columns, in this specific case they might be useful to keep the ducks and marmots safe -- we don't want the lions to eat them, do we? :)

                        – samcarter
                        Jan 3 at 11:07








                      • 1





                        @samcarter We have found a proper use of vertical rules, lol!

                        – CarLaTeX
                        Jan 3 at 11:08



















                      • Lions and ducks? Is that a good idea? After all, lions are cats and ducks are birds ;)

                        – TeXnician
                        Jan 3 at 9:54






                      • 3





                        @TeXnician But I put them in separate columns :)

                        – CarLaTeX
                        Jan 3 at 9:58






                      • 1





                        I'm normally against vertical lines in columns, in this specific case they might be useful to keep the ducks and marmots safe -- we don't want the lions to eat them, do we? :)

                        – samcarter
                        Jan 3 at 11:07








                      • 1





                        @samcarter We have found a proper use of vertical rules, lol!

                        – CarLaTeX
                        Jan 3 at 11:08

















                      Lions and ducks? Is that a good idea? After all, lions are cats and ducks are birds ;)

                      – TeXnician
                      Jan 3 at 9:54





                      Lions and ducks? Is that a good idea? After all, lions are cats and ducks are birds ;)

                      – TeXnician
                      Jan 3 at 9:54




                      3




                      3





                      @TeXnician But I put them in separate columns :)

                      – CarLaTeX
                      Jan 3 at 9:58





                      @TeXnician But I put them in separate columns :)

                      – CarLaTeX
                      Jan 3 at 9:58




                      1




                      1





                      I'm normally against vertical lines in columns, in this specific case they might be useful to keep the ducks and marmots safe -- we don't want the lions to eat them, do we? :)

                      – samcarter
                      Jan 3 at 11:07







                      I'm normally against vertical lines in columns, in this specific case they might be useful to keep the ducks and marmots safe -- we don't want the lions to eat them, do we? :)

                      – samcarter
                      Jan 3 at 11:07






                      1




                      1





                      @samcarter We have found a proper use of vertical rules, lol!

                      – CarLaTeX
                      Jan 3 at 11:08





                      @samcarter We have found a proper use of vertical rules, lol!

                      – CarLaTeX
                      Jan 3 at 11:08











                      13














                      The important thing to note about tabularx that it is all about automatically setting the target length for line breaking within a column. However the vast majority of data tables in scientific documents are (apart from the headings) tables of numerical data where there is no line breaking within the column, so I would say that tabularx is not suitable for those cases.



                      An X column is a p column of an automatically determined width, but like any p column it is a parbox designed for paragraphs of text wrapped to the specified width.






                      share|improve this answer




























                        13














                        The important thing to note about tabularx that it is all about automatically setting the target length for line breaking within a column. However the vast majority of data tables in scientific documents are (apart from the headings) tables of numerical data where there is no line breaking within the column, so I would say that tabularx is not suitable for those cases.



                        An X column is a p column of an automatically determined width, but like any p column it is a parbox designed for paragraphs of text wrapped to the specified width.






                        share|improve this answer


























                          13












                          13








                          13







                          The important thing to note about tabularx that it is all about automatically setting the target length for line breaking within a column. However the vast majority of data tables in scientific documents are (apart from the headings) tables of numerical data where there is no line breaking within the column, so I would say that tabularx is not suitable for those cases.



                          An X column is a p column of an automatically determined width, but like any p column it is a parbox designed for paragraphs of text wrapped to the specified width.






                          share|improve this answer













                          The important thing to note about tabularx that it is all about automatically setting the target length for line breaking within a column. However the vast majority of data tables in scientific documents are (apart from the headings) tables of numerical data where there is no line breaking within the column, so I would say that tabularx is not suitable for those cases.



                          An X column is a p column of an automatically determined width, but like any p column it is a parbox designed for paragraphs of text wrapped to the specified width.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Jan 3 at 10:38









                          David CarlisleDavid Carlisle

                          485k4111201864




                          485k4111201864






























                              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%2f468363%2fwhen-should-the-tabularx-environment-be-used-or-not%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

                              android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

                              SQL update select statement

                              'app-layout' is not a known element: how to share Component with different Modules