4

I'm using tabu for creating a table, however I can't seem to find the way to make the two left columns narrower and the most right one wider for text.

The code I'm using is:

\begin{table}[H]
    \centering
    \caption{Kepler orbit parameters}
    \begin{tabu}{*{3}{X[c]}}
        \toprule
        Parameter & Name & Description \\
         \midrule
         a & semi-major axis & The axis that coincides with both focus points of the ellipse \\
         E & Eccentric Anomaly & The angle between the center of equivalent circle with radius $r$ \\
         \bottomrule
    \end{tabu}
    \label{tab:Kepler}
\end{table}

I want to keep the two leftmost columns centered, and the right one wider and not centered so the text will be easier to read. Any suggestions?

4
  • 2
    don't use the tabu package, it is buggy and unmaintained. See the readme here github.com/tabu-issues-for-future-maintainer/tabu Mar 15, 2022 at 21:03
  • Is there another package that can create the same style as I'm using here? with the horizontal lines? Mar 15, 2022 at 21:04
  • 2
    well personally I manage all tabulars with tabular or sometimes tabularx. But you can also check the new tabularray. Mar 15, 2022 at 21:07
  • 1
    Something like \begin{tabularx}{\linewidth}{llX} should work perfectly fine for this kind of table as there really is no need to allow line breaks in the first two columns.
    – leandriis
    Mar 15, 2022 at 21:15

4 Answers 4

3

As mentioned by Ulrike Fischer in the comment, the tabu package should be avoided. You may use the relatively new tabularray package. (You will find similarities between tabu and tabularray packages.)

enter image description here

\documentclass{article}

\usepackage{tabularray}
\UseTblrLibrary{booktabs} %to use booktabs rules 

\begin{document}
\begin{table}
    \centering
    \caption{Kepler orbit parameters}
    \begin{tblr}{
        width = {\textwidth}, %width of the table
        colspec = {@{}ccX[l]@{}}, %column types
        rows = {m} %vertical alignment
    }
        \toprule
        Parameter & Name & Description \\
        \midrule
        a & semi-major axis & The axis that coincides with both focus points of the ellipse \\
        E & Eccentric Anomaly & The angle between the center of equivalent circle with radius $r$ \\
        \bottomrule
    \end{tblr}
\end{table}

\end{document}
2
  • Thank you! Any chance you can explain the column types line colspec = {@{}ccX[l]@{}}? Mar 16, 2022 at 3:37
  • The c columns are centered columns (i.e. their contents are centered) and their width is loosely equal to the width of the content. The X column is like fixed-width column where the width is automatically calculated. @{}s are used to remove the spaces before the first column and after the last column.
    – Imran
    Mar 16, 2022 at 7:18
2

I'd like to suggest that you employ a tabularx environment.

enter image description here

\documentclass{article} % or some other suitable document class
\usepackage{tabularx,ragged2e,booktabs}
\newcolumntype{L}{>{\RaggedRight}X}

\begin{document} 
\begin{table}[ht]
\caption{Kepler orbit parameters\strut}\label{tab:Kepler}
\begin{tabularx}{\textwidth}{@{} llL @{}}
      \toprule
      Parameter & Name & Description \\
      \midrule
      $a$ & semi-major axis & The axis that coincides with both focus points of the ellipse \\
      $E$ & Eccentric Anomaly & The angle between the center of equivalent circle with radius $r$ \\
      \bottomrule
\end{tabularx}
\end{table}
\end{document}
0
1

just for nostalgia, an example using tabu, of course it is no longer viable to use it, as mentioned it has some errors since the implementation was not finished and the package has been abandoned for a long time, even it is no longer possible to shade the cells , but at the time it was very useful to me since I could manipulate the width of the tables, the cells and their distribution relative to factors, in addition to manipulating styles it allowed me to make tables with a better style than those made in the office suite, or other similar WYSIWYG. Unfortunately I used this package for a long time until the cell shading bug, and I have only recently used the traditional packages so I don't know if they can reach styles like the ones that tabu can do since I currently make more serious texts that they don't use colorful styles but clean and readable. As always it is a matter of taste.

RESULT:

enter image description here

MWE:

\documentclass{article}
\usepackage{graphicx} % to rotate text
%Ex-Package for beautifull tables.
\usepackage{tabu}
\usepackage[table]{xcolor}
\definecolor{myblue}{HTML}{002fa7}
\begin{document}
    \begin{table}[!h]
        \def\TableLineSize{3pt}   
        \tabulinesep = 5pt 
        \tabulinestyle{\TableLineSize myblue}
        \caption{Kepler orbit parameters\strut}\label{tab:Kepler}
        \begin{tabu} to \linewidth {|X[1cm]|X[3cm]|X[20lm]|} %note cm is center+middle.
            %tabu sintax X column "|" to indicate vertical line.
            %X[Relative_to_total_factor+horizontal_align(l,c,r)+Vertical_align(m,b,p)], example : 3bm, 0.5lb, etc.
            \tabucline - % Lines musrt be defined using \tabucline. but not in discontinous line.
             \rotatebox{90}{Parameter} & Name & Description \\ \tabucline - 
            $a$ & semi-major axis & The axis that coincides with both focus points of the ellipse \\ \tabucline[0.5pt,myblue] -
            $E$ & Eccentric Anomaly & The angle between the center of equivalent circle with radius $r$ \\ \tabucline -     
        \end{tabu}
    \end{table} 
\end{document}
0

With {NiceTabular} of nicematrix (which is similar the classical {tabular} but with more functionnalities).

\documentclass{article}
\usepackage{nicematrix,booktabs}

\begin{document} 
\begin{table}[ht]
\caption{Kepler orbit parameters\strut}\label{tab:Kepler}
\begin{NiceTabular}{@{}llX[l]@{}}
      \toprule
      Parameter & Name & Description \\
      \midrule
      $a$ & semi-major axis & The axis that coincides with both focus points of the ellipse \\
      $E$ & Eccentric Anomaly & The angle between the center of equivalent circle with radius $r$ \\
      \bottomrule
\end{NiceTabular}
\end{table}
\end{document}

Output of the above code

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .