Graphics, Figures & Tables ⇒ Caption?
Caption?
Hey all,
How can I change default caption behaviour for captions to be centered RELATIVE TO THEIR IMAGE instead of relative to page (see picture)?
Edit by localghost: Preferably no external links (see Board Rules). Attachments go onto the forum server where possible.
How can I change default caption behaviour for captions to be centered RELATIVE TO THEIR IMAGE instead of relative to page (see picture)?
Edit by localghost: Preferably no external links (see Board Rules). Attachments go onto the forum server where possible.
- Attachments
-
- latexcaption.png (478.88 KiB) Viewed 3447 times
NEW: TikZ book now 40% off at Amazon.com for a short time.

Caption?
Hi,
one possible solution would be to use a minipage; of course, now you can't use the floating environment figure, but you can still give a caption to your figure by using the \captionof command provided by the caption package. Alittle example (I used the demo option for the graphicx package just to make my example compilable for everyone; don't use this option in your actual code):
one possible solution would be to use a minipage; of course, now you can't use the floating environment figure, but you can still give a caption to your figure by using the \captionof command provided by the caption package. Alittle example (I used the demo option for the graphicx package just to make my example compilable for everyone; don't use this option in your actual code):
Code: Select all
\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{caption}
\begin{document}
\noindent\begin{minipage}{7cm}
\includegraphics[width=7cm]{name}
\captionof{figure}{Octopus}
\label{fig:test1}
\end{minipage}
\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
Caption?
...and another solution may be floatrow package, e.g.:
Code: Select all
\documentclass{book}
\usepackage{lipsum}
\usepackage[demo]{graphicx}
\usepackage{xcolor}
\usepackage{caption}
\captionsetup[figure]{justification=centering}% caption centered
\usepackage{floatrow}
\floatsetup[figure]{margins=raggedright}% figure placed on left
\begin{document}
\chapter{A chapter}
\lipsum[1]
\begin{figure}[!h]
\ffigbox[\FBwidth]
{\color{blue}\includegraphics[width=6cm,height=1cm]{test}}
{\caption{A caption when \textbackslash ffigbox and \textbackslash FBwidth are used (blue)}}
\end{figure}
\begin{figure}[!h]
{\color{red}\includegraphics[width=6cm,height=1cm]{test}}
\caption{A caption without \textbackslash ffigbox and \textbackslash FBwidth (red)}
\end{figure}
\end{document}
Re: Caption?
So standard behaviour in Latex documents for inserting graphics is centering the graphics, so as to have the caption neatly centered underneath?
Re: Caption?
No. Standard behaviour is to center captions spanning only one line.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
Re: Caption?
What?
My caption spans only one line, but isn't centered (by default) with the overlying image, hence my original problem and post.
My caption spans only one line, but isn't centered (by default) with the overlying image, hence my original problem and post.
Caption?
In standard LaTeX, captions spanning only one line are centered with respect to the page not with respect to the image. Your image was not centered (since you didn't use any centering mechanism for the image), and that caused your problem.
I misunderstood this question:
I misunderstood this question:
and thought (erroneously) that you meant that images automatically got centered by LaTeX when included. Now that I reread the question, I noticed the misunderstanding. Sorry for that.the_obs wrote:So standard behaviour in Latex documents for inserting graphics is centering the graphics, so as to have the caption neatly centered underneath?
1,1,2,3,5,8,13,21,34,55,89,144,233,...