1

I'm attempting to build a simple three column table using tabularx, but I must be misunderstanding some aspect of the code because my table is visibly not working out.
Table With Spacing Errors

My goal is to have three equal column widths but no matter what I try the lines do not seem to match up. (I will also need to work on centering the text and keeping 'information' as a single word, but those problems are comparatively minor!)

My code for creating the table is below.

    \caption{Common Curriculum}
    \centering
    \begin{tabularx}{0.9\linewidth}[ht]{||p{0.3\linewidth} | p{0.3\linewidth} | p{0.3\linewidth}||} 
        \hline
        Physical Concepts & Mathematical Skills and Notation & Application in Quantum Information  \\  
        \hline\hline
        1 & 6 & 87837  \\ 
        \hline
        2 & 7 & 78  \\
        \hline
        3 & 545 & 778  \\
        \hline
        4 & 545 & 18744  \\
        \hline
        5 & 88 & 788  \\ 
        \hline
    \end{tabularx}
    \label{tab:CommonCurr}.
\end{table}

I've tried using {\textwidth} instead of {0.9\linewidth}. I've also tried using thirds of the textwidth, but I assumed the problem with that idea was due to rounding as my horizontal lines then extended beyond the table giving me an opposite problem.

Any help would be appreciated!

6
  • Welcome to TeX.SE!
    – Mensch
    Oct 10, 2022 at 14:12
  • 1
    with tabularx a colon X make the job \begin{tabularx}{0.9\linewidth}[ht]{||X | X | X||}
    – pascal974
    Oct 10, 2022 at 14:14
  • @pascal974 Thanks! That worked! I didn't realize that by using the X it would assume equal proportions for each piece!
    – PGibbon
    Oct 10, 2022 at 14:19
  • 1
    tabularx does not have a [ht] option (and must have at least one X column) Oct 10, 2022 at 14:38
  • currently you are specifying total width as 0.9\linewidth but the content has a fixed width of 0.9\linewidth+6\tabcolsep+6\arrayrulewidth+2\arrayrulesep Oct 10, 2022 at 14:41

1 Answer 1

0

I wonder if may liked the following table form:

enter image description here

Az writing of the above "professional looking" table are used the tabularraypackage with libraries (which load packages of the same names) and a bit narrower table:

\documentclass{article}
\usepackage[skip=0.33\baselineskip]{caption}
\usepackage{tabularray}
\UseTblrLibrary{booktabs, siunitx}

\begin{document}
    \begin{table}[ht]
\caption{Common Curriculum}
\label{tab:CommonCurr}
    \centering
\begin{tblr}{width=0.75\linewidth,
             colspec = {X[c] 
                        X[c, si={table-format=3.0}] 
                        X[c, si={table-format=5.0}]},
             row{even}  = {belowsep=-2pt},
             row{1} = {guard, c}
             }
    \toprule
{Physical\\ Concepts}
    & Mathematical Skills and Notation 
        & Application in Quantum Information  \\
    \midrule
1   & 6     & 87837     \\
2   & 7     & 78        \\
3   & 545   & 778       \\
4   & 545   & 18744     \\
5   & 88    & 788       \\
    \bottomrule
\end{tblr}
    \end{table}
\end{document}

However, if you more prefer each cells in "jail" of horizontal and vertical lines as you show in your question, than MWE is:

\documentclass{article}
\usepackage[skip=0.33\baselineskip]{caption}
\usepackage{tabularray}
\UseTblrLibrary{siunitx}

\begin{document}
    \begin{table}[ht]
\caption{Common Curriculum}
\label{tab:CommonCurr}
    \centering
\begin{tblr}{width=0.75\linewidth,
             hlines, vlines,
             colspec = {X[c] 
                        X[c, si={table-format=3.0}] 
                        X[c, si={table-format=5.0}]},
             row{1} = {guard, c}
             }
{Physical\\ Concepts}
    & Mathematical Skills and Notation 
        & Application in Quantum Information  \\
1   & 6     & 87837     \\
2   & 7     & 78        \\
3   & 545   & 778       \\
4   & 545   & 18744     \\
5   & 88    & 788       \\
\end{tblr}
    \end{table}
\end{document}

and table is than:

enter image description here

1
  • I appreciate the alternatives. This makes it much easier to chose something that suits my context, where I was simply trying to survive table building before. Thanks!
    – PGibbon
    Oct 10, 2022 at 19:11

You must log in to answer this question.

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