Graphics, Figures & TablesCaption widths for sideways tables

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
alman9898
Posts: 2
Joined: Mon Apr 12, 2010 8:02 pm

Caption widths for sideways tables

Post by alman9898 »

I am trying to create a caption for this sideways table; however, it is too wide. I would like the caption to be only a certain width. I have used a parbox of varying sizes, but when I put the \caption inside a \parbox, the caption gets aligned to the side rather than above the table. I am new user to Latex and have been using a WYSIWYG editor. here is the relevant code:

Code: Select all

\documentclass{article}%
\usepackage{amsmath}%
\usepackage{amsfonts}%
\usepackage{amssymb}%
\usepackage{graphicx}
\usepackage{rotating}
\begin{document}
\begin{sidewaystable}[tbp]
\parbox{3in}{\caption{This is a caption that is too long to be wrapped properly, but parboxes do not produce correct output, so what am I to do?}}
\begin{tabular}{|c|c|c|c|c|c|c|c|}
\hline
Row headings & Row headings & Row headings & Row headings & Row headings & Row headings & more headings & Yep heading \\
&  & right here & here too & and here &  &  & in \\
&  & ok? &  & &  &  &  \\ \hline
Sample 1 & Mr Person & 7.0 & 50 & 2.64 & 11,929 & 3.72 &
\\
& et al. (1979) & 10.0 & 50 & 3.78 & 11,929 & 3.72 &
\\ \hline
Sample 2 & Dr Guy & 13.1 & 40 & 4.90 & 19,846 & 4.0 &
\\
& et al. (1983) & 13.1 & 60 & 5.0 & 7562 & 3.49 &
\\
&  & 13.1 & 100 & 5.23 & 1597 & 2.81 &
\\ \hline
Sample 3 & John Doe and & 17.0 & 30 & 6.29 & 34,268 & 4.31 &
\\
& Doe (1981) & 17.0 & 40 & 6.35 & 19,846 & 4.0 &
\\
&  & 17.0 & 60 & 6.49 & 7562 & 3.49 &
\\ \hline
Sample 4 & James Doe and & 34.0 & 50 & 12.84 & 11,929 & 3.72 &
\\
& Doe (1984) & 34.0 & 90 & 13.42 & 2297 & 2.96 &
\\ \hline
Sample 5 & Doe et al. & 15.9 & 56.5 & 15.54 & 135 & 2.01 &
\\
& (1989) & 15.9 & 53.4 & 15.30 & 151 & 1.96 &
\\ \hline
Sample 6 & Dr Guy & 13.1 & 50 & 12.46 & 171 & 2.05 &
\\
& et al. (1983) & 13.1 & 65 & 12.96 & 108 & 1.93 &
\\ \hline
Sample 7 & Dr Man & 19.4 & 70 & 11.23 & 184 & 2.43 &
\\
& et al. (1983) & 19.4 & 90 & 11.43 & 280 & 2.20 &
\\ \hline
Sample 8 & Dr Dude & 20.9 & 77 & 13.23 & 364 & 1.62 &
\\
& et al. (1983) &  &  &  &  &  &  \\ \hline
\end{tabular}
\end{sidewaystable}
\end{document}
To illustrate what I see when I compile using pdflatex,

with a \parbox enclosing a \caption:
withparbox.PNG
withparbox.PNG (51.87 KiB) Viewed 5300 times
and without:
withoutparbox.PNG
withoutparbox.PNG (75.46 KiB) Viewed 5300 times
thanks for any help

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Caption widths for sideways tables

Post by gmedina »

Hi,

you could use the \captionsetup command provided by the caption package and the width key to set the width for the table caption:

Code: Select all

\documentclass{article}%
\usepackage{amsmath}%
\usepackage{amsfonts}%
\usepackage{amssymb}%
\usepackage{graphicx}
\usepackage{rotating}
\usepackage{caption}

\begin{document}
\begin{sidewaystable}[tbp]
\captionsetup{width=3in}
\caption{This is a caption that is too long to be wrapped properly, but parboxes do not produce correct output, so what am I to do?}
\begin{tabular}{|c|c|c|c|c|c|c|c|}
\hline
Row headings & Row headings & Row headings & Row headings & Row headings & Row headings & more headings & Yep heading \\
&  & right here & here too & and here &  &  & in \\
&  & ok? &  & &  &  &  \\ \hline
Sample 1 & Mr Person & 7.0 & 50 & 2.64 & 11,929 & 3.72 &
\\
& et al. (1979) & 10.0 & 50 & 3.78 & 11,929 & 3.72 &
\\ \hline
Sample 2 & Dr Guy & 13.1 & 40 & 4.90 & 19,846 & 4.0 &
\\
& et al. (1983) & 13.1 & 60 & 5.0 & 7562 & 3.49 &
\\
&  & 13.1 & 100 & 5.23 & 1597 & 2.81 &
\\ \hline
Sample 3 & John Doe and & 17.0 & 30 & 6.29 & 34,268 & 4.31 &
\\
& Doe (1981) & 17.0 & 40 & 6.35 & 19,846 & 4.0 &
\\
&  & 17.0 & 60 & 6.49 & 7562 & 3.49 &
\\ \hline
Sample 4 & James Doe and & 34.0 & 50 & 12.84 & 11,929 & 3.72 &
\\
& Doe (1984) & 34.0 & 90 & 13.42 & 2297 & 2.96 &
\\ \hline
Sample 5 & Doe et al. & 15.9 & 56.5 & 15.54 & 135 & 2.01 &
\\
& (1989) & 15.9 & 53.4 & 15.30 & 151 & 1.96 &
\\ \hline
Sample 6 & Dr Guy & 13.1 & 50 & 12.46 & 171 & 2.05 &
\\
& et al. (1983) & 13.1 & 65 & 12.96 & 108 & 1.93 &
\\ \hline
Sample 7 & Dr Man & 19.4 & 70 & 11.23 & 184 & 2.43 &
\\\
& et al. (1983) & 19.4 & 90 & 11.43 & 280 & 2.20 &
\\ \hline
Sample 8 & Dr Dude & 20.9 & 77 & 13.23 & 364 & 1.62 &
\\
& et al. (1983) &  &  &  &  &  &  \\ \hline
\end{tabular}
\end{sidewaystable}
\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
Post Reply