3

So now this table has been an uphill battle, but I'm not progressing anymore. When you see the image you know where I want to go =) I want the columuns 2-9 to assume the same width.

So this is what I have so far: So this is what I have so far:

\documentclass[a4paper,11pt,oneside]{report}
\usepackage{tabulary}
\usepackage{multirow}
\usepackage{tabulary}
\usepackage{gensymb}
\begin{document}

\begin{tabulary}{1.0\textwidth}{|c|c|c|c|c|c|c|c|} \hline
Gas             & \multicolumn{ 7}{p{\linewidth}|}{Technischer Löslichkeitskoeffizient \lambda~in mL Gas/(1000~g Wasser $\cdot$ 1~bar) bei einer Temperatur in $\degree$C }   \\ \cline{2-8}
                & 0     & 5     & 10    & 15    & 20    & 25    & 30    \\     \hline
Sauerstoff      & 48,4  & 42,3  & 37,5  & 33,6  & 30,6  & 28,0  & 26,0  \\
Luft            & 28,6  & 25,5  & 22,4  & 20,4  & 18,3  & 16,3  & 15,3  \\
\hline
\end{tabulary}
\end{document}

Thankful for any help!

  • 1
    Welcome to TeX.SX! Please make your example compilable (MWE). Btw: You seem to miss some math-mode around cdot. – TeXnician Jan 5 '18 at 16:57
  • done. ahh, so this is what the dollar signs do... already learned something =) – Viktor Gruber Jan 5 '18 at 17:14
8

You can measure the width of the widest element in the first column, and then use that to calculate how wide the span from columns 2-8 should be:

enter image description here

\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage{tabularx}

\newcolumntype{C}{ >{\centering\arraybackslash} X }
\newlength{\tmplen}

\begin{document}

\settowidth{\tmplen}{Sauerstoff}%
\noindent
\begin{tabularx}{\linewidth}{ | c *{7}{| C} |}
  \hline
  Gas             & \multicolumn{7}{ p{\dimexpr\linewidth-\tmplen-4\tabcolsep-3\arrayrulewidth} | }{%
    Technischer Löslichkeitskoeffizient $\lambda$ in mL Gas/(1000~g Wasser $\cdot$ 1~bar) bei einer Temperatur in $^\circ$C } \\
  \cline{2-8}
                  & 0     & 5     & 10    & 15    & 20    & 25    & 30    \\
  \hline
  Sauerstoff      & 48,4  & 42,3  & 37,5  & 33,6  & 30,6  & 28,0  & 26,0  \\
  Luft            & 28,6  & 25,5  & 22,4  & 20,4  & 18,3  & 16,3  & 15,3  \\
  \hline
\end{tabularx}

\end{document}

Here is a booktabs version:

enter image description here

\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage{tabularx,booktabs,makecell}

\newcolumntype{C}{ >{\centering\arraybackslash} X }
\newlength{\tmplen}

\begin{document}

\settowidth{\tmplen}{Sauerstoff}%
\noindent
\begin{tabularx}{\linewidth}{ c *{7}{C} }
  \toprule
  Gas             & \multicolumn{7}{ p{\dimexpr\linewidth-\tmplen-4\tabcolsep} }{%
    \makecell[t]{Technischer Löslichkeitskoeffizient $\lambda$ \\
      in mL Gas/(1000~g Wasser $\cdot$ 1~bar) bei einer Temperatur in $^\circ$C }} \\
  \cmidrule{2-8}
                  & 0     & 5     & 10    & 15    & 20    & 25    & 30    \\
  \midrule
  Sauerstoff      & 48,4  & 42,3  & 37,5  & 33,6  & 30,6  & 28,0  & 26,0  \\
  Luft            & 28,6  & 25,5  & 22,4  & 20,4  & 18,3  & 16,3  & 15,3  \\
  \bottomrule
\end{tabularx}

\end{document}
  • Upvote for booktabs! I'd like to mention siunitx to the OP in the context values with decimal dot or comma. It might be useful in further tables. – Oleg Lobachev Jan 5 '18 at 18:48
4

In my opinion the long text should be an explanatory caption to the table.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}

\usepackage{siunitx,booktabs,caption}

\sisetup{locale=DE}

\begin{document}

\begin{table}
\centering

\caption{Technischer Löslichkeitskoeffizient $\lambda$ in 
\si{\milli\liter} Gas/(\SI{1000}{\gram} Wasser at \SI{1}{\bar}) 
bei einer Temperatur in \si{\celsius}.}

\begin{tabular}{l *{7}{S[table-format=2.1]} }
\toprule
Gas             & \multicolumn{7}{c}{Temperatur (\si{\celsius})}\\
\cmidrule{2-8}
                & {0}   & {5}   & {10}  & {15}  & {20}  & {25}  & {30}  \\
\midrule
Sauerstoff      & 48,4  & 42,3  & 37,5  & 33,6  & 30,6  & 28,0  & 26,0  \\
Luft            & 28,6  & 25,5  & 22,4  & 20,4  & 18,3  & 16,3  & 15,3  \\
\bottomrule
\end{tabular}

\end{table}

\end{document}

enter image description here

  • I like that idea. Didn't think of it, I might do it that way. – Viktor Gruber Jan 5 '18 at 17:59

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.