General ⇒ \newline (or equivalent) inside a \caption
Re: \newline (or equivalent) inside a \caption
Consider the following two files.
\documentclass[12pt]{article}
\usepackage[font=sl,labelfont=bf]{caption}
\begin{document}
\begin{table}[!ht]
\centering
\caption[]{\bfseries Iowa State University\\College of Liberal Arts \& Sciences \\Replacement Costs}\label{Ta:ISUReplace}
\begin{tabular}{|l|l|} \hline
\bfseries Department & \bfseries Typical Replacement Cost \\ \hline
Anthropology & \$6,000.00 \\ \hline
BBMB & \$10,000.00 \\ \hline
\end{tabular}
\end{table}
The first does not center the caption while the second does.
\usepackage[lmargin=0.5in, rmargin=0.5in, vmargin=1.0in]{geometry}
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
\newline (or equivalent) inside a \caption
I only see a snippet of one file...ahallam wrote:Any idea about margins and the use of caption.
Consider the following two files.
\documentclass[12pt]{article}
\usepackage[font=sl,labelfont=bf]{caption}
\begin{document}
\begin{table}[!ht]
\centering
\caption[]{\bfseries Iowa State University\\College of Liberal Arts \& Sciences \\Replacement Costs}\label{Ta:ISUReplace}
\begin{tabular}{|l|l|} \hline
\bfseries Department & \bfseries Typical Replacement Cost \\ \hline
Anthropology & \$6,000.00 \\ \hline
BBMB & \$10,000.00 \\ \hline
\end{tabular}
\end{table}
The first does not center the caption while the second does.
\usepackage[lmargin=0.5in, rmargin=0.5in, vmargin=1.0in]{geometry}
Re: \newline (or equivalent) inside a \caption
\usepackage[lmargin=0.5in, rmargin=0.5in, vmargin=1.0in]{geometry}
\documentclass[12pt]{article}
\usepackage[font=sl,labelfont=bf]{caption}
\begin{document}
\begin{table}[!ht]
\centering
\caption[]{\bfseries Iowa State University\\College of Liberal Arts \& Sciences \\Replacement Costs}\label{Ta:ISUReplace}
\begin{tabular}{|l|l|} \hline
\bfseries Department & \bfseries Typical Replacement Cost \\ \hline
Anthropology & \$6,000.00 \\ \hline
BBMB & \$10,000.00 \\ \hline
\end{tabular}
\end{table}
\newline (or equivalent) inside a \caption
Well, that depends on what you mean by "correctly". The standard LaTeX document classes (article, report, and book) automatically center a caption if it fits in one single line, but treat it as a normal text paragraph if it occupies two or more lines (and the caption package adopts this behaviour).ahallam wrote:If you add this line to the file I posted, then the caption appears correctly...
In your case, the caption will be treated as a paragraph with three manually created lines, since you used the \\ command. If you want to center the text, you can use the justification=centering option.
In the example below I included that option locally, so that it will only affect the current float (but, of course, you can set that option globally).
Please refer to the package documentation for further information.
Code: Select all
\documentclass[12pt]{article}
\usepackage[font=sl,labelfont=bf]{caption}
\begin{document}
\begin{table}[!ht]
\centering
\captionsetup{font=bf,justification=centering}
\caption{Iowa State University\\College of Liberal Arts \& Sciences \\Replacement Costs}\label{Ta:ISUReplace}
\begin{tabular}{|l|l|} \hline
\bfseries Department & \bfseries Typical Replacement Cost \\ \hline
Anthropology & \$6,000.00 \\ \hline
BBMB & \$10,000.00 \\ \hline
\end{tabular}
\end{table}
\end{document}
\newline (or equivalent) inside a \caption
This is not a problem of the caption package but a "feature" of LaTeX instead:thrillRseekR wrote:and that \newline does not always perform the same function as \\ does (or at least I don't think it did for me).
Code: Select all
\documentclass{article}
\begin{document}
\noindent\parbox\linewidth{\centering one\\two three}
\par\bigskip
\noindent\parbox\linewidth{\centering one\newline two three}
\end{document}
\newline (or equivalent) inside a \caption
gmedina wrote:Well, that depends on what you mean by "correctly". The standard LaTeX document classes (article, report, and book) automatically center a caption if it fits in one single line, but treat it as a normal text paragraph if it occupies two or more lines (and the caption package adopts this behaviour).ahallam wrote:If you add this line to the file I posted, then the caption appears correctly...
In your case, the caption will be treated as a paragraph with three manually created lines, since you used the \\ command. If you want to center the text, you can use the justification=centering option.
In the example below I included that option locally, so that it will only affect the current float (but, of course, you can set that option globally).
Please refer to the package documentation for further information.
Code: Select all
\documentclass[12pt]{article} \usepackage[font=sl,labelfont=bf]{caption} \begin{document} \begin{table}[!ht] \centering \captionsetup{font=bf,justification=centering} \caption{Iowa State University\\College of Liberal Arts \& Sciences \\Replacement Costs}\label{Ta:ISUReplace} \begin{tabular}{|l|l|} \hline \bfseries Department & \bfseries Typical Replacement Cost \\ \hline Anthropology & \$6,000.00 \\ \hline BBMB & \$10,000.00 \\ \hline \end{tabular} \end{table} \end{document}
If I run LaTeX on the file you suggest, I get the following errors.
! Use of \caption@@settype doesn't match its definition.
\@ifnextchar ... \reserved@d =#1\def \reserved@a {
#2}\def \reserved@b {#3}\f...
l.9 ...beral Arts \& Sciences \\Replacement Costs}
\label{Ta:ISUReplace}
! Argument of \@firstoftwo has an extra }.
<inserted text>
\par
l.9 ...beral Arts \& Sciences \\Replacement Costs}
\label{Ta:ISUReplace}
I also updated the caption package to 2008/08/24 v3.1j.
\newline (or equivalent) inside a \caption
The file runs fine here, using caption package 3.1j. And I get exactly the same errors as you when using the caption package 3.0k instead. So I assume that you use the caption package 3.0k or a similar version, but not the actual version 3.1.ahallam wrote:If I run LaTeX on the file you suggest, I get the following errors.
But are you sure it's actually used? Please add a \listfiles to the very top of the document and process it again. Afterwards you should see the following lines in the log file:I also updated the caption package to 2008/08/24 v3.1j.
Code: Select all
*File List*
article.cls 2005/09/16 v1.4f Standard LaTeX document class
size12.clo 2005/09/16 v1.4f Standard LaTeX file (size option)
caption.sty 2008/08/24 v3.1j Customizing captions (AR)
caption3.sty 2008/08/24 v3.1j caption3 kernel (AR)
keyval.sty 1999/03/16 v1.13 key=value parser (DPC)
***********