1

I have a problem with a table. I want the first row to have a linebreak, so that the table doesn't get too wide. I tried, like I read somewhere, inserting another table in one cell, but it doesn't work. The text now flows over one another. Also the first cell is kind of too high. Does someone know, how to do it?

Here is my code

\documentclass[ngerman,11pt,twoside,a4paper,final,titlepage,openany]{amsbook}
\usepackage[ngerman]{babel}
\begin{document}

\begin{tabular}{p{6cm}p{3cm}p{3cm}}
 \textbf{
\begin{tabular}{@{}c@{}}
bla
\end{tabular}} &
\textbf{
\begin{tabular}{@{}c@{}}
here comes a lot of text
\end{tabular}} & \textbf{
\begin{tabular}{@{}c@{}}
and here also a lot of text
\end{tabular}}\\
 \hline bla & yes &no\\
bla& yes & no\\
\end{tabular}
\end{document}
3
  • huh, why don't you just use \newline (\\ cannot be used in tables as it means new row), only works in p cells and other fixed width cells.
    – daleif
    Commented Dec 20, 2013 at 8:59
  • Ok great thanks a lot. This easy way I couldn't find anywhere...-.-'
    – Nina
    Commented Dec 20, 2013 at 9:17
  • Or just no mark at all as line breaking is automatic to your specified width in a p column Commented Dec 20, 2013 at 10:49

1 Answer 1

1

This might be overkill, but let me expand on @DavidCarlisle's comment. I am doing this:

  1. Used array to be able to specify new columns

  2. used ragged2e in order to have ragged right columns, and allow hyphenation which is usually the best choice for long texts in small columns. This is done defining the new P column type to be ragged right

  3. used inputenc with the utf8 option to be able to insert unicode characters

  4. used booktabs to have fancy lines (your single hline is fine, but I prefer this way)

  5. used some "random" german text, courtesy of @ChristianHupfer

  6. removed the space before the first column and after the last one, using array's @{}

  7. reduced the size of your columns (the table was too wide for the specified page

I really think you don't need to specify manual breaks, should you need to, please refer to @daleif's suggestions, and break it with \newline

So here is the code:

\documentclass[ngerman,11pt,twoside,a4paper,final,titlepage,openany]{amsbook}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage{array,ragged2e,booktabs}
\newcolumntype{P}[1]{>{\RaggedRight\arraybackslash}p{#1}}
\begin{document}

\begin{tabular}{@{}P{5.75cm}P{2.8cm}P{2.8cm}@{}}
\toprule
Mein Vater&Mein Vater erklärt mir jeden Sonntag unsere neun Planeten &Mein Vater erklärt mir jeden Sonntag unsere neun Planeten\\
\midrule
   bla & ja &nein\\
bla& ja & nein\\
\bottomrule
\end{tabular}
\end{document}

enter image description here

You must log in to answer this question.

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