2

I am trying to create linebreaks in some of the cells of my table, since I have long sentences and the table doesn't fit on an A4 page. How to let LaTeX choose the linebreaks?

Here is my code

\begin{table}[hbt]
\centering
\begin{tabular}{lllllll}
    \toprule
    &  Raumgewicht $\gamma$'$_m$ and [$\frac{kN}{m^3}$] &Reibungswinkel $\phi$'$_m$[]& Kohäsion c'[] & M$_E$-Wert []& N$_SPT$ [] & k-Wert []  \\
    \midrule
    Auffüllungen/Deckschicht& 18& 27 & 0 & 10* & 17 & -\\
    Rückstausedimente nicht vorbelastes& 21 & 28 & 10 & 10 & 15 & $5\times10^-8$ - $1\times10^-6$ \\
    Rückstausedimente vorbelastet & 22 & 32 & 10 & >50 & 91 & $5\times10^-8$ - $1\times10^-6$ \\
    Moräne & 22 & 36 & 5 & >50 & >100 & $1\times10^-8$ - $5\times10^-6$\\
    \bottomrule
\end{tabular}
\caption{Bodenkennwerte}
\label{tab:Bodenkennwerte}
\end{table}

My preamble is

\documentclass[12pt,a4paper]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{stackengine}
\usepackage[top=3cm, bottom=2.5cm, left=2.5cm, right=2.5cm, footskip = 1cm]{geometry}
\usepackage{hyperref}
  • 1
    You can add line breaks by using a columns of a specific width, i.e. replace l with p{2cm}. However this will not be enough to squeeze this large table on a normal page, maybe use a landscape page instead. – user36296 Mar 18 '18 at 13:54
5

Here is a suggesstion on how to change your code in order to display the table on one page:

What I changed in comparison to your original code:

  • Added \usepackage[T1]{fontenc} in order to display > signs correctly.
  • Used sidewaystable from the rotating package in order to rotate the table as it is too wide to fit on a portrait page.
  • Included makecell in order to insert linebreaks in cells where needed
  • Included the siunitx package to
    • align numerical values in their columns
    • easier input and format units
    • easier input and format ranges of numbers

enter image description here

\documentclass[12pt,a4paper]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{booktabs}
\usepackage[top=3cm, bottom=2.5cm, left=2.5cm, right=2.5cm, footskip = 1cm]{geometry}
\usepackage{rotating}
\usepackage{makecell}
\usepackage{siunitx}
\sisetup{range-phrase=--}

\begin{document}

\begin{sidewaystable}[hbt]
\centering
\begin{tabular}{lS[table-format=2]S[table-format=2]S[table-format=2]S[table-format=>2]S[table-format=>3]S}
    \toprule
    &  {\makecell{Raumgewicht \\ $\gamma$'$_m$ and [\si{\kilo\newton\per\cubic\meter}]}} & {\makecell{Reibungswinkel \\ $\phi$'$_m$[]}}& {\makecell{Kohäsion \\ c'[]}} & {M$_E$-Wert []}& {N$_SPT$  []} & {k-Wert []}  \\
    \midrule
    Auffüllungen/Deckschicht& 18& 27 & 0 & 10* & 17 & {-}\\
    Rückstausedimente nicht vorbelastet  & 21 & 28 & 10 & 10 & 15 & \numrange{5e-8}{1e-6} \\
    Rückstausedimente vorbelastet & 22 & 32 & 10 & >50 & 91 & \numrange{5e-8}{1e-6} \\
    Moräne & 22 & 36 & 5 & >50 & >100 & \numrange{1e-8}{5e-6}\\
    \bottomrule
\end{tabular}
\caption{Bodenkennwerte}
\label{tab:Bodenkennwerte}
\end{sidewaystable}

\end{document}
4

Automatic line breaking is needed in the first column as well as in 3 of the 6 data columns. I suggest you employ a tabularx environment to achieve this objective.

I'd also like to suggest that you (a) center the contents of the 6 data columns, (b) place the units (in square brackets) on a separate row from the rest of the header material, and (c) use the \num and \si macros of the siunitx package to typeset (formatted) numbers and scientific units.

enter image description here

\documentclass[12pt,a4paper]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\usepackage[top=3cm, bottom=2.5cm, hmargin=2.5cm, footskip = 1cm]{geometry}
\usepackage{amsmath,amssymb}
\usepackage{graphicx,booktabs,tabularx,ragged2e,siunitx}
\newcolumntype{C}{>{\Centering\arraybackslash\hspace{0pt}}X}
\newcolumntype{L}{>{\RaggedRight\arraybackslash\hspace{0pt}}X}

\usepackage{hyperref}

\hyphenation{Rück-stau-sedi-mente}

\begin{document}
\begin{table}[hbt]
\setlength\tabcolsep{4pt}
\sisetup{tight-spacing=true,per-mode=symbol}
\begin{tabularx}{\textwidth}{@{} L CCcccC @{}}
    \toprule
    & Raumgewicht $\gamma'_m$
    & Reibungswinkel $\phi'_m$
    & Kohäsion $c'$ 
    & $M_E$\kern1pt-Wert 
    & $N_{SPT}$ 
    & $k$-Wert \\
    & [\si{\kilo\newton\per\meter\cubed}] 
    & [${}\cdot{}$] & [${}\cdot{}$] & [${}\cdot{}$] & [${}\cdot{}$] & [${}\cdot{}$] \\
    \midrule
    %% Aside: One must break up the f-f ligature in "Auffüllungen"
    Auf"|fül\-lungen\slash Deckschicht& 18& 27 & 0 & 10* & 17 & -- \\ \addlinespace
    Rückstausedimente nicht vorbelastet& 21 & 28 & 10 & 10 & 15 
    & \num{5e-8}~-- \num{1e-6} \\ \addlinespace
    Rückstausedimente vorbelastet & 22 & 32 & 10 & $>50$ & 91 
    & \num{5e-8}~-- \num{1e-6} \\ \addlinespace
    Moräne & 22 & 36 & 5 & $>50$ & $>100$ 
    & \num{1e-8}~-- \num{5e-6} \\
    \bottomrule
\end{tabularx}
\caption{Bodenkennwerte}
\label{tab:Bodenkennwerte}
\end{table}
\end{document} 

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.