Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm seeing strange behavior when using subfloat. I have 6 figures that I want to display as 2 by 3 (2 lines, 3 columns). The caption (a, b, c etc.) is shifted to the right which means figure b) is labeled a) and c) appears on page margin where no image is located.

\usepackage{graphicx,subfig}

\begin{document}
    \begin{figure}[ht!]
        \centering
            \subfloat[Shield One]{\includegraphics[width=4cm]{figure/items/shield_1}}
            \subfloat[Shield Two]{\includegraphics[width=4cm]{figure/items/shield_2}}
            \subfloat[Shield Three]{\includegraphics[width=4cm]{figure/items/shield_3}}
            \newline
            \subfloat[Sword One]{\includegraphics[width=4cm]{figure/items/sword_1}}
            \subfloat[Sword Two]{\includegraphics[width=4cm]{figure/items/sword_2}}
            \subfloat[Sword Three]{\includegraphics[width=4cm]{figure/items/sword_3}}
            \caption[Items and their definition]{Items and their definition}
            \label{fig:items}
    \end{figure}
\end{document}

Does anyone have a clue ?

share|improve this question
1  
Newer use \newline inside a centered environment, i.e. \centering or center environment. Use \\ instead. (Since you did not give us a complete example document I cannot test if this will fix your problem.) –  Axel Sommerfeldt Aug 1 '11 at 15:39
    
I had the exact same problem. In my case it was a clash with the caption package. –  user13185 Apr 2 '12 at 1:32
1  
@KMAC The subfig documentation mentions compatibility with caption; even requiring it (see section 4.1 Caption package of 4 Compatibility with other packages, p 36). How did your usage clash with caption? –  Werner Apr 2 '12 at 2:11
    
Welcome to TeX.sx! Please add a minimal working example (MWE) that illustrates your problem. –  Martin Schröder Apr 2 '12 at 6:41
add comment

1 Answer

up vote 3 down vote accepted

Check images and if there's sufficient space, also look for warnings. Perhaps post a compilable example. This compilable example shows the expected correct behavior:

\documentclass{article}
\usepackage{graphicx,subfig}
\begin{document}
\begin{figure}[ht!]
    \centering
        \subfloat[Shield One]{\includegraphics[width=4cm]{figure/items/shield_1}}
        \subfloat[Shield Two]{\includegraphics[width=4cm]{figure/items/shield_2}}
        \subfloat[Shield Three]{\includegraphics[width=4cm]{figure/items/shield_3}}
        \newline
        \subfloat[Sword One]{\includegraphics[width=4cm]{figure/items/sword_1}}
        \subfloat[Sword Two]{\includegraphics[width=4cm]{figure/items/sword_2}}
        \subfloat[Sword Three]{\includegraphics[width=4cm]{figure/items/sword_3}}
        \caption[Items and their definition]{Items and their definition}
        \label{fig:items}
\end{figure}
\end{document}

subfloats example

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.