Graphics, Figures & TablesProblem with subfloat and captions

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
julesneu
Posts: 2
Joined: Thu Feb 03, 2011 11:07 am

Problem with subfloat and captions

Post by julesneu »

Hi community,
first time I go public with problem, hopefully my MWE is sufficient:

Code: Select all

\documentclass[a4paper,11pt,%titlepage,
oneside, 
headsepline,headings=small
]{scrreprt}
\usepackage[pdftex]{graphicx}
\usepackage{%natbib, 
amsmath, epstopdf, hyperref, 
 xspace, array,delarray,tabularx, calc, amssymb, %pifont, 
rotating, csquotes, %nicefrac,
%epsfig, %a4wide, 
%makeidx,%times, 
%floatfig,
subfig, caption,
helvet, pdflscape, threeparttable}
\setkomafont{pagehead}{\footnotesize\scshape}
\setcapindent{0.03\textwidth}
\setcapwidth[l]{0.96\textwidth}
\begin{document}
\begin{figure}
\centering
\subfloat[captionfig1]{\includegraphics[width=0.25\textwidth]{figure1}}                
  \subfloat[captionfig2]{\includegraphics[width=0.25\textwidth]{figure2}}
  \subfloat[captionfig3]{\includegraphics[width=0.25\textwidth]{figure3}}
  \caption{caption entire figure}
  \label{graphC5}
\end{figure}
\end{document}
The objective is to place three figures next to each other, each with a different subtitle. It took the example from here:
http://en.wikibooks.org/wiki/LaTeX/Floa ... #Subfloats because it is exactly what I wanted.

The problem now ist that the [captionfig1] of figure 1 is placed beneath subfigure 2, the [captionfig3}] of figure 3 gets pushed towards the right and is placed at the edge of the deocument, outside of the box.

Any ideas?
Last edited by julesneu on Thu Feb 03, 2011 1:29 pm, edited 1 time in total.

Recommended reading 2024:

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

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

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Problem with subfloat and captions

Post by localghost »

julesneu wrote:[…] first time I go public with problem, hopefully my MWE is sufficient […]
Unfortunately your example is not a MWE because it is not anywhere near minimal. The culprit in this case seems to be your setting for the caption width. But that's not for sure. Perhaps the subfig package causes the trouble. Commenting the concerned line out makes the code work.

Code: Select all

\documentclass[%
  fontsize=11pt,
  paper=a4,
  headings=small
]{scrreprt}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[demo]{graphicx}
\usepackage{subfig}

\setkomafont{pagehead}{\footnotesize\scshape}
\setcapindent{0.03\textwidth}
%\setcapwidth{0.96\textwidth}

\begin{document}
  \begin{figure}[!ht]
    \centering
    \subfloat[caption fig1]{\includegraphics[width=0.25\textwidth]{figure1}}
    \subfloat[caption fig2]{\includegraphics[width=0.25\textwidth]{figure2}}
    \subfloat[caption fig3]{\includegraphics[width=0.25\textwidth]{figure3}}
    \caption{caption entire figure}\label{fig:graphC5}
\end{figure}
\end{document}
Note the demo option for the graphicx package which had to be added because the external graphics files where not present. Just drop it later.


Best regards and welcome to the board
Thorsten
julesneu
Posts: 2
Joined: Thu Feb 03, 2011 11:07 am

Re: Problem with subfloat and captions

Post by julesneu »

@Thorsten,

Somehow I knew I would not get the MWE right.

I threw the \setcapwitdh out and it worked properly.

Thank you and best regards.
Jules
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Problem with subfloat and captions

Post by localghost »

julesneu wrote:[…] I threw the \setcapwitdh out and it worked properly. […]
Then please mark the topic accordingly as you have already been directed in my last reply.
Post Reply