[Tex/LaTex] Caption in subfloat shifted to the right

captionshorizontal alignmentsubfloats

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 ?

Best Answer

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