Tabellebreite und Zeilenumbruch

Tabellen und Grafiken erstellen und anordnen


gill88
Forum-Anfänger
Forum-Anfänger
Beiträge: 22
Registriert: Fr 8. Feb 2013, 13:17

Tabellebreite und Zeilenumbruch

Beitrag von gill88 »

Hallo,

ich komme mal wieder bei der Erstellung einer Tabelle nicht weiter. Ich habe versucht, folgende Tabelle der Textbreite anzupassen, aber leider ohne Erfolg. Bekomme ständig eine Fehlermeldung, wenn ich versuche einen Zeilenumbruch zu erzeugen, sodass die Gesamtbreite schmaler wird.
%
\documentclass[a4paper,12pt]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{makeidx}
\usepackage{graphicx}
\usepackage{mathptmx}
\usepackage{psfrag} 
\usepackage{booktabs}
\usepackage{array}
\usepackage{geometry}
\geometry{a4paper,top=25mm,bottom=20mm,left=40mm,right=20mm,footskip=15mm,includefoot}

\begin{table}[htbp]
  \centering
  \caption{Add caption}
    \begin{tabular}{l{3cm}l{3cm}l{3cm}}
    \toprule
    \multicolumn{1}{l} & \multicolumn{3}{m{3\textwidth}|} Confidence in observed changes (latter half of the 20th century) & Changes in Phenomenon & Confidence in projected changes (during the 21st century) \\
    \midrule
    Likely & Higher maximum temperatures and more hot days\up{1} over all land areas & Very likely \\
    Very likely & Higher minimum temperatures, fewer cold days and frost days over nearly all land areas & Very likely \\
    Very likely & Reduced diurnal temperature range over most land areas & Very likely \\
    Likely, over many areas & Increase of heat index\up{2} over land areas & Very likely, over most areas \\
\multicolumn{1}{l} & \multicolumn{3}{m{3\textwidth}|}{Likely, over many Northern Hemisphere mid- to high latitude landareas} & \multicolumn{1}{l}{More intense precipitation events\up{3}} & Very likely, over many areas \\
    \multicolumn{1}{l}{Likely, in a few areas} & \multicolumn{1}{l}{Increased summer continental drying and associated risk of drought} & Likely, over most mid-latitude continental interiors. (Lack of consistent projections in other areas) \\
    Not observed in the few analyses available & Increase in tropical cyclone peak wind intensities\up{4} & Likely, over some areas \\
    Insufficient data for assessment & Increase in tropical cyclone mean and peak precipitation intensities\up{4} & Likely, over some areas \\
    \multicolumn{3}{r}{\up{1}Hot days refer to a day whose maximum temperaturereaches or exceeds some temperature that is considered a critical threshold for impacts on human and natural systems. Actual thresholds vary regionally, but typical values include 32$^{\circ}$C, 35$^{\circ}$C or 40$^{\circ}$C.} \\
    \up{2}Heat index refers to a combination of temperature and humidity that measures effects on human comfort. &       &  \\
    \multicolumn{3}{l}{\up{3}For other areas, there are either insufficient data or conflicting analyses.} \\
    \up{4}Past and future changes in tropical cyclone location and frequency are uncertain. &       &  \\
    \bottomrule
    \end{tabular}
  \label{tab:addlabel}
\end{table}%Ende des Dokumentes
Hat hier im Forum vielleicht jemand eine Idee, wie man das Problem lösen könnte? Wäre echt super!

Danke!

dknof
Forum-Anfänger
Forum-Anfänger
Beiträge: 48
Registriert: So 29. Jul 2012, 13:30

Beitrag von dknof »

Hallo gill88,

Deinen Fehler habe ich noch nicht entdeckt, dafür hat mein LaTeX mehrere Probleme.
! LaTeX Error: Missing \begin{document}.
ist dabei der erste.
Dann ist
\begin{tabular}{l{3cm}l{3cm}l{3cm}}
falsch (nimm „p“ statt „l“).
Bei
\multicolumn{1}{l}
fehlt das dritte Argument (siehe zum Beispiel http://www.weinelt.de/latex/multicolumn.html).

Vielleicht hat sich Dein Problem dann schon gelegt. Ansonsten zeige bitte ein Minimalbeispiel, das mit LaTeX ohne Fehler und ohne Warnung durchläuft.

Gruß
Diether

gill88
Forum-Anfänger
Forum-Anfänger
Beiträge: 22
Registriert: Fr 8. Feb 2013, 13:17

Beitrag von gill88 »

Hallo Diether,

danke für die Antwort. Ja das dritte Argument wäre ja dann der Text. Den habe ich eigentlich.

Ich habe die Tabelle jetzt noch mal gedreht und gehofft das Problem würde sich dadurch lösen. Die eine Zeile steht aber immer noch über.
Hier noch mal mein aktueller Code
\begin{sidewaystable}[htbp]
  \centering
  \caption{Add caption}
    \begin{tabular}{p{6cm}p{7cm}p{6cm}}
    \toprule
    Confidence in observed changes (latter half of the 20th century) & Changes in Phenomenon & Confidence in projected changes (during the 21st century) \\
    \midrule
    Likely & Higher maximum temperatures and more hot days\up{1} over all land areas & Very likely \\
    Very likely & Higher minimum temperatures, fewer cold days and frost days over nearly all land areas & Very likely \\
    Very likely & Reduced diurnal temperature range over most land areas & Very likely \\
    Likely, over many areas & Increase of heat index\up{2} over land areas & Very likely, over most areas \\
Likely, over many Northern Hemisphere mid- to high latitude landareas & \multicolumn{1}{l}{More intense precipitation events\up{3}} & Very likely, over many areas \\
    \multicolumn{1}{l}{Likely, in a few areas} & \multicolumn{1}{l}{Increased summer continental drying and associated risk of drought} & Likely, over most mid-latitude continental interiors. (Lack of consistent projections in other areas) \\
    Not observed in the few analyses available & Increase in tropical cyclone peak wind intensities\up{4} & Likely, over some areas \\
    Insufficient data for assessment & Increase in tropical cyclone mean and peak precipitation intensities\up{4} & Likely, over some areas \\
    \multicolumn{ 3}{l}{\up{1}Hot days refer to a day whose maximum temperaturereaches or exceeds some temperature that is considered a critical threshold for impacts \\& on human and natural systems. Actual thresholds vary regionally, but typical values include 32$^{\circ}$C, 35$^{\circ}$C or 40$^{\circ}$C.} \\
  \multicolumn{3}{l}{\up{2}Heat index refers to a combination of temperature and humidity that measures effects on human comfort.} \\
    \multicolumn{3}{l}{\up{3}For other areas, there are either insufficient data or conflicting analyses.} \\
   \multicolumn{3}{l} {\up{4}Past and future changes in tropical cyclone location and frequency are uncertain.}\\
    \bottomrule
    \end{tabular}
  \label{tab:addlabel}
\end{sidewaystable}
Und hier noch mal eine Tabelle, die sich problemlos darstellen lässt (trotz Zeilenumbrüche):
\documentclass[a4paper,12pt]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{makeidx}
\usepackage{mathptmx}
\usepackage{booktabs}
\usepackage{array}
\usepackage{geometry}
\usepackage{rotating}
\geometry{a4paper,top=25mm,bottom=20mm,left=40mm,right=20mm,footskip=15mm,includefoot}

\begin{table}[htbp]
\caption{}
\begin{flushleft}
\begin{tabular}{|l|p{0.6cm}|c|c|c|c|c|c|c|c|c|c|p{0.4cm}|}
\hline
\multicolumn{ 1}{|l|}{} & \multicolumn{ 3}{l|}{Number of} & \multicolumn{ 3}{l|}{Projected population,} & \multicolumn{ 4}{l|}{Change in cereal-production } \\ 
\multicolumn{ 1}{|l|}{} & \multicolumn{ 3}{l|}{countries} & \multicolumn{ 3}{l|}{2080 (billions)} & \multicolumn{ 4}{l|}{potential (\% of global potential)} \\ \hline
Scenario & G & N & L & G & N & L & G & N & L & Total \\ \hline
A1Fl & 54 & 23 & 73 & 3.0 & 2.2 & 3.3 & 5.5 & -0.4 & -7.9 & -2.8 \\ \hline
A2 & 61 & 32 & 57 & 3.3 & 1.4 & 3.8 & 4.1 & 0.5 & -6.8 & -2.1 \\ \hline
B2 & 71 & 36 & 43 & 3.8 & 2.0 & 2.7 & 4.2 & -0.9 & -4.3 & -1.0 \\ \hline
B1 & 67 & 41 & 42 & 2.3 & 4.5 & 1.6 & 3.6 & -0.6 & -3.0 & 0.0 \\ \hline
\multicolumn{ 11}{|l|}{G = countries gaining 5\% or more; N = small change of -5\% to +5\%; L = countries } \\ 
\multicolumn{ 11}{|l|}{losing 5\% or more.} \\ \hline
\end{tabular}
\end{flushleft}
\label{}
\end{table}
Kann man die Zeile "\multicolumn{ 3}{l}{\up{1}Hot days refer to a day whose maximum temperature reaches" irgendwie umbrechen und zwei Zeilen draus machen?
Ich denke, dann müsste es passen.

dknof
Forum-Anfänger
Forum-Anfänger
Beiträge: 48
Registriert: So 29. Jul 2012, 13:30

Beitrag von dknof »

Hallo gill88,

die Tabelle finde ich gräuselig. Außerdem ist Dein Code immer noch nicht lauffähig, das macht das Nachvollziehen schwierig.

Für Deine erste Tabelle habe ich den Vorschlag im Anhang (siehe meine Kommentare im Quelltext). Nur die Spaltenbreite bekomme ich nicht automatich gleich breit (für eine manuelle Lösung siehe die zweite Tabelle).

Auch die neue Tabelle lässt sich so nicht kompilieren (\\& im Argument von \multicolumn}. Zu Deinem Problem: Du kannst auch \multicolumn ein p-Argument übergeben, also in Deinem Fall
\multicolumn{3}{p{19cm}}{Ganz viel Text}
Aber verwende doch lieber richtige Fußnoten, siehe zum Beispiel http://www.mrunix.de/forums/showthread.php?t=43559.

Viele Grüße
Diether

dknof
Forum-Anfänger
Forum-Anfänger
Beiträge: 48
Registriert: So 29. Jul 2012, 13:30

Beitrag von dknof »

Das Hochladen klappt nicht. Hier ist der Code:
\documentclass[a4paper,12pt]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage{mathptmx}
\usepackage{booktabs} % Lies Dir die Anleitung durch, die gibt viel Hilfe für eine gute Tabellengestaltung.
\usepackage{tabu} % Mehr Flexibilität in der Tabellengestaltung
\usepackage{rotating}
\usepackage{geometry}
\geometry{a4paper,top=25mm,bottom=20mm,left=40mm,right=20mm,footskip=15mm,includefoot}
% Überflüssige Pakete raus (Minimalbeispiel)
\newcommand{\up}[1]{{\small #1}}
\usepackage{textcomp} % für \textcelsius

\begin{document}
\begin{table}[htbp]
% Tabellen in eine Gleitumgebung zentriere ich immer.
% Außerdem keine Umgebung für die Ausrichtung verwenden, da die noch Abstände einfügt (siehe l2tabu).
  \centering
% Sparsam mit Strichen umgehen, die machen die Tabelle nur unübersichtlicher.
  \begin{tabular}{l@{\quad}*{3}{c}@{\quad}*{3}{c}@{\quad}*{4}{c}}
    \toprule
  % Überschriften zentrieren
    & \multicolumn{3}{c}{Number of}
    & \multicolumn{3}{c}{Projected population,}
    & \multicolumn{4}{c}{Change in cereal-production } \\
    & \multicolumn{3}{c}{countries}
    & \multicolumn{3}{c}{2080}
    & \multicolumn{4}{c}{potential} \\
 % Einheiten in eine extra-Zeile
    & \multicolumn{3}{c}{}
    & \multicolumn{3}{c}{(billions)}
    & \multicolumn{4}{c}{(\% of global potential)} \\
  \cmidrule(r){2-4}
  \cmidrule(r){5-7}
  \cmidrule(r){8-11}
    Scenario & G & N & L & G & N & L & G & N & L & Total \\
    \midrule % Die Überschrift vom Inhalt trennen
% Die Zellen auch im Quelltext untereinander ausrichten, damit Du die Übersicht behälst.
    A1Fl & 54 & 23 & 73 & 3.0 & 2.2 & 3.3 & 5.5 & -0.4 & -7.9 & -2.8 \\
    A2   & 61 & 32 & 57 & 3.3 & 1.4 & 3.8 & 4.1 &  0.5 & -6.8 & -2.1 \\
    B2   & 71 & 36 & 43 & 3.8 & 2.0 & 2.7 & 4.2 & -0.9 & -4.3 & -1.0 \\
    B1   & 67 & 41 & 42 & 2.3 & 4.5 & 1.6 & 3.6 & -0.6 & -3.0 &  0.0 \\
    \bottomrule
  \end{tabular}

% Die Legende kommt unter die Tabelle mit Abstand und kleiner
  \medskip
  {\small
    % Trick, um die Legende insgesamt zentriert, aber zeilenweise linksbündig zu bekommen
    \begin{tabular}{lll}
    G = countries gaining 5\,\% or more\\
    N = small change of -5\,\% to +5\,\%\\
    L = countries losing 5\,\% or more
  \end{tabular}
  }
% Die Bezeichnung nach unten
  \caption{statistic}
% Das leere Label raus
\end{table}

% Wenn Du die Tabelle in mehrere aufteilst und nebeneinander packst, dann geht die Gestaltung (mit tabu) noch besser.
\begin{table}[htbp]
% Tabellen in eine Gleitumgebung zentriere ich immer.
% Außerdem keine Umgebung für die Ausrichtung verwenden, da die noch Abstände einfügt (siehe l2tabu).
  \centering
% Sparsam mit Strichen umgehen, die machen die Tabelle nur unübersichtlicher.
  \begin{tabu}{l@{\quad}}
    \toprule
    \\
    \\
    \\
    \addlinespace[\defaultaddspace]
    Scenario \\
    \midrule
    A1Fl \\
    A2   \\
    B2   \\
    B1   \\
    \bottomrule
  \end{tabu}% Wichtiges Prozentzeichen
  \begin{tabu}{@{\quad}*{3}{c}@{\quad}}
    \toprule
    \multicolumn{3}{c}{Number of} \\
    \multicolumn{3}{c}{countries} \\
    \\
    \cmidrule(lr){1-3}
    G & N & L \\
    \midrule
    54 & 23 & 73 \\
    61 & 32 & 57 \\
    71 & 36 & 43 \\
    67 & 41 & 42 \\
    \bottomrule
  \end{tabu}%a
  \begin{tabu} spread 0pt{@{\hfill}*{3}{X[c]}@{\hfill}}
    \toprule
    \multicolumn{3}{c}{Projected population,} \\
    \tabuphantomline
    \multicolumn{3}{c}{2080}\\
    \tabuphantomline
    \multicolumn{3}{c}{(billions)} \\
  \cmidrule(lr){1-3}
    \tabuphantomline
    G & N & L \\
    \midrule
    3.0 & 2.2 & 3.3 \\
    3.3 & 1.4 & 3.8 \\
    3.8 & 2.0 & 2.7 \\
    2.3 & 4.5 & 1.6 \\
    \bottomrule
  \end{tabu}%
  \begin{tabu}{@{\quad}*{4}{c}}
    \toprule
    \multicolumn{4}{c}{Change in cereal-production } \\
    \multicolumn{4}{c}{potential} \\
    \multicolumn{4}{c}{(\% of global potential)} \\
  \cmidrule(lr){1-4}
    G & N & L & Total \\
    \midrule
    5.5 & -0.4 & -7.9 & -2.8 \\
    4.1 &  0.5 & -6.8 & -2.1 \\
    4.2 & -0.9 & -4.3 & -1.0 \\
    3.6 & -0.6 & -3.0 &  0.0 \\
    \bottomrule
  \end{tabu}

  \medskip
  {\small
    \begin{tabular}{lll}
    G = countries gaining 5\,\% or more\\
    N = small change of -5\,\% to +5\,\%\\
    L = countries losing 5\,\% or more
  \end{tabular}
  }
  \caption{statistic}
\end{table}
\end{document}

gill88
Forum-Anfänger
Forum-Anfänger
Beiträge: 22
Registriert: Fr 8. Feb 2013, 13:17

Beitrag von gill88 »

Dankeschön! Allerdings hatte die erste Tabelle, also die mit den vielen Zahlen, schon ohne Probleme bei mir funktioniert.
Die zweite habe ich jetzt auch hinbekommen. Gibt nur noch eine kleine Zeilenverschiebung in der 3.Spalte, was aber nicht so schlimm ist.
Hier nochmal mein Ergebnis
\documentclass[a4paper,12pt]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{makeidx}
\usepackage{mathptmx}
\usepackage{psfrag} 
\usepackage{bigstrut}
\usepackage{booktabs}
\usepackage{array}
\usepackage{geometry}
\usepackage{rotating}

\newcommand{\up}[1]{\ensuremath{^\textrm{\scriptsize#1}}}

\begin{document}
\begin{sidewaystable}[htbp]
  \centering
  \caption{Add caption}
    \begin{tabular}{p{7cm}p{7cm}p{7cm}}
    \toprule
    Confidence in observed changes (latter half of the 20th century) & Changes in Phenomenon & Confidence in projected changes (during the 21st century) \\
    \midrule
    Likely & Higher maximum temperatures and more hot days\up{1} over all land areas & Very likely \\
    Very likely & Higher minimum temperatures, fewer cold days and frost days over nearly all land areas & Very likely \\
    Very likely & Reduced diurnal temperature range over most land areas & Very likely \\
    Likely, over many areas & Increase of heat index\up{2} over land areas & Very likely, over most areas \\
Likely, over many Northern Hemisphere mid- to high latitude landareas & \multicolumn{1}{l}{More intense precipitation events\up{3}} & Very likely, over many areas \\
    \multicolumn{1}{l}{Likely, in a few areas} & \multicolumn{1}{p{7cm}}{Increased summer continental drying and associated risk of drought} & Likely, over most mid-latitude continental interiors. (Lack of consistent projections in other areas)\\
    \multicolumn{1}{m{7cm}} {Not observed in the few analyses available} & \multicolumn{1}{m{7cm}} {Increase in tropical cyclone peak wind intensities\up{4}} & Likely, over some areas \\
    Insufficient data for assessment & Increase in tropical cyclone mean and peak precipitation intensities\up{4} & Likely, over some areas \\ \hline
\multicolumn{ 3}{m{0.9\textwidth}} {\up{1}Hot days refer to a day whose maximum temperaturereaches or exceeds some temperature that is considered a critical threshold \up{} for impacts on human and natural systems. Actual thresholds vary regionally, but typical values include 32$^{\circ}$C, 35$^{\circ}$C or 40$^{\circ}$C.} \\
  \multicolumn{3}{l}{\up{2}Heat index refers to a combination of temperature and humidity that measures effects on human comfort.} \\
    \multicolumn{3}{l}{\up{3}For other areas, there are either insufficient data or conflicting analyses.} \\
   \multicolumn{3}{l} {\up{4}Past and future changes in tropical cyclone location and frequency are uncertain.}\\
    \bottomrule
    \end{tabular}
  \label{tab:addlabel} 
\end{sidewaystable}
\end{document}

dknof
Forum-Anfänger
Forum-Anfänger
Beiträge: 48
Registriert: So 29. Jul 2012, 13:30

Beitrag von dknof »

Hallo gill88,

dieses Beispiel ließ sich direkt bei mir compilieren.
Du hast zweimal
\multicolumn{1}{m{7cm}}
drin. Werf die beiden raus, dann erfolgt die Ausrichtung immer nach oben.

Gruß
Diether

gill88
Forum-Anfänger
Forum-Anfänger
Beiträge: 22
Registriert: Fr 8. Feb 2013, 13:17

Beitrag von gill88 »

super, hat geklappt.

vielen vielen Dank!!!

Antworten