2

I am new at LaTeX and I have been some problems with the subcaption text, since I have to put five images in a singe row. I have the follow code for this:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{subfig}
\usepackage{graphicx}

\begin{document}

\begin{figure}[h!]
  \centering
  \subfloat[Standart Reification]{\includegraphics[width=0.2\textwidth]{example-image-a}}
  \subfloat[Named Graphs]{\includegraphics[width=0.2\textwidth]{example-image-b}}
  \subfloat[n-ary  Relations]{\includegraphics[width=0.2\textwidth]{example-image-c}}
  \subfloat[Singleton Properties]{\includegraphics[width=0.2\textwidth]{example-image-a}}
  \subfloat[NdFluents]{\includegraphics[width=0.2\textwidth]{example-image-b}}
  \caption{RDF Approaches}
  \label{fig:subfigures}
\end{figure}

\end{document}

And my output image, have been looking like this: output

The first four subcaptions has a weird alignment. How can I resolve this alignment problem, making the subcaptions looking like the last subcaption?

  • 1
    Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. – Stefan Pinnow Jul 23 '18 at 14:16
  • Oh, really sorry, from now my code is compiling. Thanks for the advice :) – Romão Martines Jul 23 '18 at 14:28
  • The first four sub-captions are simply too long to fit in 1/5 of \textwidth. P.S. Your code is still not compilable to us because we don’t have your image files .png. – Ruixi Zhang Jul 23 '18 at 14:31
2

You can achieve the alignment of the sub-captions by explicitly setting the alignment for the sub-captions.

\captionsetup[subfigure]{format=hang,justification=raggedright}

If you really want the captions all in one line, you would have to change the fontsize.

With the more recent subcaption package and it's provided subfigure this would look like:

Result

enter image description here

Code

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{subcaption}
\usepackage{graphicx}

\captionsetup[subfigure]{format=hang,justification=raggedright}
\begin{document}
\begin{figure}[h!]
\centering
\begin{subfigure}[t]{0.2\textwidth}
 \includegraphics[width=\textwidth]{example-image-a}
 \caption{Standart Reification}
 \label{fig:ExampleA}
\end{subfigure}%
\begin{subfigure}[t]{0.2\textwidth}
 \includegraphics[width=\textwidth]{example-image-b}
 \caption{Named Graphs}
 \label{fig:ExampleB}
\end{subfigure}%
\begin{subfigure}[t]{0.2\textwidth}
 \includegraphics[width=\textwidth]{example-image-c}
 \caption{n-ary  Relations}
 \label{fig:ExampleC}
\end{subfigure}%
\begin{subfigure}[t]{0.2\textwidth}
\includegraphics[width=\textwidth]{example-image-c}
\caption{Singleton Properties}
\label{fig:ExampleD}
\end{subfigure}%
\begin{subfigure}[t]{0.2\textwidth}
 \includegraphics[width=\textwidth]{example-image-b}
 \caption{NDFlunents}
 \label{fig:ExampleE}
\end{subfigure}
\caption{RDF Approaches}
\end{figure}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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