2

I'm trying to typeset a table in LaTeX. So far I have the following:

\documentclass{scrreprt}

\usepackage{booktabs}
\usepackage{siunitx}

\begin{document}

\begin{table}[ht]
  \centering
  \caption{Table with different values}
  \begin{tabular}{lScSS}
    \toprule
    Model & \multicolumn{1}{p{0.1\textwidth}}{\centering Mass} & \multicolumn{1}{p{0.18\textwidth}}{\centering Dim.\\(X\,\(\times\)\,Y\,\(\times\)\,Z)} & \multicolumn{1}{p{0.3\textwidth}}{\centering Moment of Inertia\\(small comment)} & \multicolumn{1}{p{0.2\textwidth}}{\centering Nominal Torque} \\
              & [\si{\kilogram}] & [\si{mm}] & [\si{\kilogram\meter\squared}] & [\si{\newton\meter}] \\
    \midrule
    A12345678 & 11e-6 & 11\,\(\times\)\,22\,\(\times\)\,33   & 111,1e-6 & 11e-9 \\
    B12345678 & 22e-6 & 44\,\(\times\)\,55\,\(\times\)\,66   & 222,2e-6 & 22e-9 \\
    B12345678 & 0,3   & 77\,\(\times\)\,88\,\(\times\)\,99   & 3,33e-3  & 3e3   \\
    B12345678 & 0,4   & 11\,\(\times\)\,22\,\(\times\)\,33   & 4,44e-3  & 4e-3  \\
    B12345678 & 5,51  & 111\,\(\times\)\,222\,\(\times\)\,33 & 5,552e-3 & 55e30 \\
    B12345678 & 6,7   & 444\,\(\times\)\,555\,\(\times\)\,66 & 6,666e-3 & 6e-3  \\
    B12345678 & 8,9   & 777\,\(\times\)\,888\,\(\times\)\,99 & 7,77e-3  & 0,7   \\
    \bottomrule
  \end{tabular}
\end{table}

Normal lines ot text:
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor 
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis 
nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. 
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu 
fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia 
deserunt mollit anim id est laborum.

\end{document}

Table produced by the MWE above

While this is approximately what I want, I'm still unsatisfied with the result. Especially the text alignment is still odd. So basically, I want to beautify the table.

I want to achieve the following:

  • The table width should not exceed the normal text width on the page (A4 paper size)
  • Text wrapping in the header row (as I did in the MWE)
  • Decimal delimiter alignment (and also alignment of the scientific notation, if possible)
  • Footnotes within the cells, with their detailed explanation directly below the table

As a plus:
The caption is set quite close to the tables top rule. Is this normal behavior and if not, how to achieve proper spacing?

Any other improvements are welcomed as well.

Many thanks for your help!

3

I'd suggest the following:

\documentclass{scrreprt}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage{tabularx}
\usepackage{makecell}
\usepackage{threeparttable}

\begin{document}

\begin{threeparttable}[ht]
  \centering
  \caption{Table with different values}
  \begin{tabularx}{\textwidth}{
  X
  S[table-format=2.2e-1]
  r@{$\times$}c@{$\times$}l
  S[table-format=3.3 E-1]
  S[table-format=2.1e-1]
  }
    \toprule
    Model & {Mass} & \multicolumn{3}{c}{{\makecell{Dim. \\(X$\times$Y$\times$Z)}}} & {\makecell{ Moment of Inertia  \\ (small comment)}} & { Nominal Torque} \\
              & [\si{\kilogram}] & \multicolumn{3}{c}{[\si{mm}]} & [\si{\kilogram\meter\squared}] & [\si{\newton\meter}] \\
    \midrule
    A12345678\tnote{1} & 11e-6 & 11 & 22 & 33   & 111,1e-6 & 11e-9 \\
    B12345678 & 22e-6 & 44&55 & 66   & 222,2e-6 & 22e-9 \\
    B12345678 & 0,3   & 77 & 88 & 99   & 3,33e-3  & 3e3   \\
    B12345678 & 0,4   & 11 & 22 & 33   & 4,44e-3  & 4e-3  \\
    B12345678 & 5,51  & 111 & 222 & 33 & 5,552e-3 & 55e30 \\
    B12345678 & 6,7   & 444 & 555 & 66 & 6,666e-3 & 6e-3  \\
    B12345678 & 8,9   & 777 & 888 & 99 & 7,77e-3  & 0,7   \\
    \bottomrule
  \end{tabularx}
  \begin{tablenotes}
\item[1] a table note to demonstrate the functionality
\end{tablenotes}
\end{threeparttable}
\vspace{\baselineskip}

Normal lines ot text:
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor 
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis 
nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. 
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu 
fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia 
deserunt mollit anim id est laborum.

\end{document}

enter image description here

Changes I made in comparison to the original code:

  • Used [table-format] option form siunitx's S columns to ensure alignment with respect to the decimal separators and exponents.
  • Used tabularx (and an X column) instead of tabular to ensure that the width of the table is equal to the textwidth.
  • Used makecell for linebreaks in table cells.
  • Used threeparttable instead of table to add tablenotes.
  • Redesigned the 'Dim. column' to consist of three columns with $\times$ as a column separator in order to align the numbers with respect to the multiplication symbol.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.