1

I have the following MWE:

\documentclass{standalone}
    
    \usepackage{tabularx}
    \begin{document}
    \begin{tabularx}{\textwidth}{c ccc c cccc}
     & \multicolumn{5}{c}{N} &  \\ 
    W & 7 & 9 & 13 & 17 & 19 & 1 \\ \hline
    0.6078 & 1.0592 (4)& 1.0646 (4) & 1.0647 (6) & 1.0647 (5) & 1.0647 (5) & 1.0647 \\ 
    1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668 \\ 
    1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668 \\ 
    1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668 \\ 
    1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668 \\ 
    1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668 \\ 
    1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668 \\ 
    1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668 \\ 
    1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668 \\ 
    1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668 \\ 
    \end{tabularx}
    \end{document}

I would like to add a column in front of the table with a label for all those 10 rows containing an S.

I know that I can do that using \multirow, but honestly I cannot figure out how.

Any help? Thanks in advance

6
  • 2
    unrelated to multirow \begin{tabularx}{\textwidth}{c ccc c cccc} is wrong, use a standard tabular or use an X column Dec 14, 2022 at 14:49
  • @DavidCarlisle Thanks for your answer. Could you please elaborate more about it, so I can understand what you mean?
    – Dario
    Dec 14, 2022 at 14:51
  • see texdoc tabularx the only thing tabularx does is achieve a specfied table width by adjusting the widths of X columns. You only have c columns so the package can do nothing useful Dec 14, 2022 at 14:58
  • There are a few things wrong with your usage of tables. Here is a list: Using tabular or tabularx out of a table environment. Using standalone with the problem isn't specific to that document class See David Carliste's comment about using column specification. Using tabularx instead of tabular for no clear reason. What are those rows? > all those 10 rows containing an S. I can't figure out what the question is
    – anis
    Dec 14, 2022 at 15:24
  • @anis There is nothing wrong with using a tabular outside of a table environment. Dec 14, 2022 at 15:51

2 Answers 2

1
  • For use of ˛tabularxpackage you should define\textwidthof page layout, for example with optionvarwidth=34em`
  • tabularx table should have at least one X or from it derived column type with new column, your table have 8 columns, but you define 0 (without new column).
  • it is not entirely clear how column headers should be. So I add one \cline below multi column cell:
\documentclass[margin=3mm, varwidth=34em]{standalone}
\usepackage{multirow, tabularx}
\newcolumntype{C}{>{\centering\arraybackslash}X}

\begin{document}
\setlength\tabcolsep{4pt}
    \begin{tabularx}{\linewidth}{@{} c c CCCCC c @{}}
    &        & \multicolumn{5}{c}{N}                                          &         \\
    \cline{3-7}
    & W      & 7          & 9          & 13         & 17         & 19         & 1       \\
    \hline
\multirow{10}{*}{S}
    & 0.6078 & 1.0592 (4) & 1.0646 (4) & 1.0647 (6) & 1.0647 (5) & 1.0647 (5) & 1.0647  \\
    & 1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668  \\
    & 1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668  \\
    & 1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668  \\
    & 1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668  \\
    & 1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668  \\
    & 1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668  \\
    & 1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668  \\
    & 1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668  \\
    & 1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668  \\
\end{tabularx}
\end{document}

enter image description here

Addendum:
Withtblr of tabularray package you can write a bit more fancy (easy to read) table with c columns (similar as is used in @Pieter van Oostrum answer) with grouping of rows:

\documentclass[margin=3mm]{standalone}
\usepackage{tabularray}

\begin{document}
    \begin{tblr}{colsep=4pt,
                 colspec={@{} *{8}{c} @{}},
                 rowsep=1pt,
                 row{even[3]} = {belowsep=1ex}
                 }
    &        & \SetCell[c=5]{c} N                                             
                          &            &            &            &            &         \\
    \cline{3-7}
tip & W      & 7          & 9          & 13         & 17         & 19         & 1       \\
    \hline
\SetCell[r=10]{c}   S
    & 0.6078 & 1.0592 (4) & 1.0646 (4) & 1.0647 (6) & 1.0647 (5) & 1.0647 (5) & 1.0647  \\
    & 1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668  \\
    & 1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668  \\
    & 1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668  \\
    & 1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668  \\
    & 1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668  \\
    & 1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668  \\
    & 1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668  \\
    & 1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668  \\
    & 1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668  \\
\end{tblr}
\end{document}

enter image description here

1
  • Thanks a lot. Much clearer now.
    – Dario
    Dec 14, 2022 at 22:00
2

Like this? Note: I adapted the number of cs in the column spec, because it was wrong, and the \multicolumn to 7.

\documentclass{standalone}
    
    \usepackage{multirow}
    \begin{document}
    \begin{tabular}{ ccc c cccc}
     & \multicolumn{7}{c}{N} \\ 
    & W & 7 & 9 & 13 & 17 & 19 & 1 \\ \hline
    \multirow{10}{*}{S} & 0.6078 & 1.0592 (4)& 1.0646 (4) & 1.0647 (6) & 1.0647 (5) & 1.0647 (5) & 1.0647 \\ 
    & 1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668 \\ 
    & 1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668 \\ 
    & 1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668 \\ 
    & 1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668 \\ 
    & 1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668 \\ 
    & 1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668 \\ 
    & 1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668 \\ 
    & 1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668 \\ 
    & 1.0012 & 1.1614 (7) & 1.1666 (4) & 1.1668 (6) & 1.1668 (5) & 1.1668 (5) & 1.1668 \\ 
    \end{tabular}
    \end{document}

enter image description here

1
  • Thanks. Simple but quite effective!
    – Dario
    Dec 14, 2022 at 22:01

You must log in to answer this question.

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