Document Classes ⇒ caption package and
-
- Posts: 27
- Joined: Tue Sep 16, 2008 1:16 am
caption package and
Hi!
I am having problems with the caption package. I downloaded the new version and it seems that now my captions do not work right. This is part of the preamble
\documentclass[12pt,a4paper]{report}
\usepackage{natbib}
\usepackage{setspace}
\usepackage{threeparttable}
\usepackage{epsf}
\usepackage{supertabular}
\usepackage{picins}
\usepackage{longtable}
\usepackage{tabularx}
\usepackage[margin=10pt,{font=footnotesize,singlespacing},labelfont=bf,labelsep=endash,hang]{caption}
etc...
and what I am trying to do is to put a different caption in the table of figures by using :
\caption[blah blah]{blah blah blab blah}
However what I get in the dvi is that both [] {} are included in the caption, the numbering of the figure goes crazy and the log says:
! Package caption Error: \caption outside float.
Any advice would be greatly appreciated
Many thanks
Christina
I am having problems with the caption package. I downloaded the new version and it seems that now my captions do not work right. This is part of the preamble
\documentclass[12pt,a4paper]{report}
\usepackage{natbib}
\usepackage{setspace}
\usepackage{threeparttable}
\usepackage{epsf}
\usepackage{supertabular}
\usepackage{picins}
\usepackage{longtable}
\usepackage{tabularx}
\usepackage[margin=10pt,{font=footnotesize,singlespacing},labelfont=bf,labelsep=endash,hang]{caption}
etc...
and what I am trying to do is to put a different caption in the table of figures by using :
\caption[blah blah]{blah blah blab blah}
However what I get in the dvi is that both [] {} are included in the caption, the numbering of the figure goes crazy and the log says:
! Package caption Error: \caption outside float.
Any advice would be greatly appreciated
Many thanks
Christina
NEW: TikZ book now 40% off at Amazon.com for a short time.

caption package and
Hi,
can you please post some of the actual code you are using for one of your tables or figures (in the sense of a minimal working example)? It seems that you are using \caption outside a floating environment (as suggested by the error you are getting); if this is so, then maybe you could try using \captionof (provided by the caption package).
can you please post some of the actual code you are using for one of your tables or figures (in the sense of a minimal working example)? It seems that you are using \caption outside a floating environment (as suggested by the error you are getting); if this is so, then maybe you could try using \captionof (provided by the caption package).
1,1,2,3,5,8,13,21,34,55,89,144,233,...
-
- Posts: 27
- Joined: Tue Sep 16, 2008 1:16 am
Re: caption package and
hi!
thanks for the prompt reply
There are several figures with the same problem. one example:
\begin{minipage}{15cm}
\centering
\includegraphics[scale=0.8]{MVN08-112}
\caption[One figure]{One figure; photo courtesy ...}
\label{medium}
\end{minipage}
thanks for the prompt reply
There are several figures with the same problem. one example:
\begin{minipage}{15cm}
\centering
\includegraphics[scale=0.8]{MVN08-112}
\caption[One figure]{One figure; photo courtesy ...}
\label{medium}
\end{minipage}
caption package and
Hi,
just as I suspected. The \caption command can only be used inside floats (i.e., inside figure and table environments). Since you are buiding your figures without the floating environment, you cannot use \caption; you can use \captionof instead; take a look at the following example:
A similar remark applies also in the case of tables; if you do not enclose them with a table environment, then you still can have captions using
Edit: initially I forgot to delete some additional code I used to do my test.
Edit 2: just for completeness' sake I included the graphicx package in my code (thanks to Stefan_K).
just as I suspected. The \caption command can only be used inside floats (i.e., inside figure and table environments). Since you are buiding your figures without the floating environment, you cannot use \caption; you can use \captionof instead; take a look at the following example:
Code: Select all
\documentclass{report}
\usepackage{graphicx}
\usepackage{caption}
\begin{document}
\listoffigures
\begin{minipage}{15cm}
\centering
\includegraphics[scale=0.8]{MVN08-112}
\captionof{figure}[One figure]{One figure; photo courtesy ...}
\label{medium}
\end{minipage}
\end{document}
Code: Select all
\captionof{table}[Short caption.]{Long caption.}
Edit 2: just for completeness' sake I included the graphicx package in my code (thanks to Stefan_K).
Last edited by gmedina on Tue Sep 16, 2008 3:10 am, edited 2 times in total.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
-
- Posts: 27
- Joined: Tue Sep 16, 2008 1:16 am
Re: caption package and
Something really strange happenned
I did as you suggested and it was still not working, i had a black box above the figure and the same problem with the caption. however, once I deleted it (your suggested format) from the document, I did latex once and it just worked!! i do not understand this!
is there a problem if i use minipage instead of a figure environment? but how and why would it work now all of a sudden?? i did not change a thing!

I did as you suggested and it was still not working, i had a black box above the figure and the same problem with the caption. however, once I deleted it (your suggested format) from the document, I did latex once and it just worked!! i do not understand this!

is there a problem if i use minipage instead of a figure environment? but how and why would it work now all of a sudden?? i did not change a thing!
caption package and
Hi Christina,
my code works OK. Notice that since you are generating a list of figures (and possibly a list of tables) you must compile your document twice.
Edit: I just noticed that I put a \rule command in my code to do some tests and I forgot to delete it; here's how it should be:
I will correct the code that I posted above.
Moving tables and figures in LaTeX
Figure (or table) exactly where I want it
Edit 2: just for completeness' sake I included the graphicx package in my code (thanks to Stefan_K).
my code works OK. Notice that since you are generating a list of figures (and possibly a list of tables) you must compile your document twice.
Edit: I just noticed that I put a \rule command in my code to do some tests and I forgot to delete it; here's how it should be:
Code: Select all
\documentclass{report}
\usepackage{graphicx}
\usepackage{caption}
\begin{document}
\listoffigures
\begin{minipage}{15cm}
\centering
\includegraphics[scale=0.8]{MVN08-112}
\captionof{figure}[One figure]{One figure; photo courtesy ...}
\label{medium}
\end{minipage}
\end{document}
No, but your figures won't float. In the following links you can find information about floats in LaTeX:christina_t wrote:...is there a problem if i use minipage instead of a figure environment?...
Moving tables and figures in LaTeX
Figure (or table) exactly where I want it
Edit 2: just for completeness' sake I included the graphicx package in my code (thanks to Stefan_K).
Last edited by gmedina on Tue Sep 16, 2008 3:10 am, edited 2 times in total.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
- Stefan Kottwitz
- Site Admin
- Posts: 10345
- Joined: Mon Mar 10, 2008 9:44 pm
caption package and
Hi Christina,
using a minipage the picture will be centered inside the minipage of that certain width, not in relation to the surrounding text.
To achiev this one could use
or \begin{center} ... \end{center} instead of centering and minipage: \captionof also works in a center environment.
Stefan
using a minipage the picture will be centered inside the minipage of that certain width, not in relation to the surrounding text.
To achiev this one could use
Code: Select all
\noindent\begin{minipage}{\textwidth}
...
or \begin{center} ... \end{center} instead of centering and minipage: \captionof also works in a center environment.
Stefan
LaTeX.org admin
-
- Posts: 27
- Joined: Tue Sep 16, 2008 1:16 am
Re: caption package and
thanks a lot for your replies!
still the code you gave me does not work; i get the following from the log file
! Undefined control sequence.
l.57 \captionof
{figure}[One figure]{One figure; photo courtesy ...}
? h
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
whereas now what I was using before works out of the blue.
what mistake am i making? i am already using the graphicx package.
still the code you gave me does not work; i get the following from the log file
! Undefined control sequence.
l.57 \captionof
{figure}[One figure]{One figure; photo courtesy ...}
? h
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
whereas now what I was using before works out of the blue.
what mistake am i making? i am already using the graphicx package.
- Stefan Kottwitz
- Site Admin
- Posts: 10345
- Joined: Mon Mar 10, 2008 9:44 pm
Re: caption package and
You have to use the caption package too, \captionof belongs to it. gmedina used it in his examples above.
Stefan
Stefan
LaTeX.org admin
-
- Posts: 27
- Joined: Tue Sep 16, 2008 1:16 am
Re: caption package and

i was using it at first, then it was probably quite late at night and somehow deleted it from the preamble... that is why it was working without using captionof
apologies!