2

I am writing a paper for one of my classes on Catalan numbers. I have a section where I'm trying to include three different figures that I would like to be centered with their corresponding descriptions centered under them. I'm not very experienced at Latex and I realize this code is probably a mess, but I use the same method for other figures later in the paper and those line up fine. I have included a screenshot of what the pdf looks like after I run the Latex document. As you can see, the figures and their descriptions are all there, but the images are off center and I'm not sure why. I've tried messing with their scales in case that was the problem but that didn't solve it. I've also tried it without the \begin{center} and \end{center} at the start and end of the code but that didn't work either. If anyone has any suggestions about how to fix the problem or what the issue is, it would be much appreciated.

\begin{center}

\begin{minipage}{.4\textwidth}  
\includegraphics[scale=.5]{StaircaseWalk1x1.png}  
\captionof{figure}{1x1 Grid}  
\end{minipage}  
\hspace{1.2cm}  
\begin{minipage}{.4\textwidth}  
\includegraphics[scale=.5]{StaircaseWalk2x2.png}  
\captionof{figure}{2x2 Grid}  
\end{minipage}

\vspace{1.2cm}

\begin{minipage}{.4\textwidth}  
\includegraphics[scale=.65]{StaircaseWalk3x3.png}  
\captionof{figure}{3x3 Grid}  
\end{minipage}

\end{center}

Figures not aligned properly

  • Just add \centering before \includegraphics. – user121799 Apr 24 at 23:03
  • That solved the issue for the first two figures but the third one is still out of line. – Alex Adinolfi Apr 24 at 23:10
  • You need to increase the width of the last minipage accordingly if you want to stay with what you have, There are simpler options like a tabular, but it is hard to spell this out because no one has your figures (apart from you). – user121799 Apr 24 at 23:20
  • Changing the width solved the problem. Thank you very much! – Alex Adinolfi Apr 24 at 23:23
  • You can measure the width of the image using \subfloat or a savebox. See tex.stackexchange.com/questions/481768/… for example. – John Kormylo Apr 25 at 3:22
2

Here is a way to do it with the floatrow package:

\documentclass[11pt,a4paper]{book}
\usepackage[utf8]{inputenc} %
\usepackage{geometry}
\usepackage{floatrow, graphicx, caption}

\begin{document}

\begin{figure}[!ht]
\floatsetup{style=plain, floatrowsep=qquad, heightadjust=object, valign=c, captionskip=2.5ex}
\captionsetup{justification=RaggedRight, labelfont=it, labelsep=endash}
\begin{floatrow}
\ffigbox[1.2\FBwidth]{\caption{Leonardo da Vinci: Lady with an Ermine}\label{vinci}}
{\includegraphics[scale = 0.8]{hermine}}
\ffigbox[\FBwidth]{\caption{Paolo Uccello: The battle of San Romano}\label{uccello}}
{\includegraphics[scale=0.8]{SanRomano}}
\end{floatrow}
\end{figure}

\end{document} 

enter image description here

1

you only need to insert \centering inside each minipage in the first two figures. for third figures you not need minipage for enclosing of image:

\documentclass[11pt,a4paper]{book}
\usepackage[demo]{graphicx}
\usepackage{caption}

\begin{document}
    \begin{figure}[htb]
\centering
\begin{minipage}{.4\textwidth}\centering
\includegraphics[scale=.5]{StaircaseWalk1x1.png}
\caption{1x1 Grid}
\end{minipage}
\hfil
\begin{minipage}{.4\textwidth}\centering
\includegraphics[scale=.5]{StaircaseWalk2x2.png}
\caption{2x2 Grid}
\end{minipage}
    \end{figure}

    \begin{figure}[htb]
\centering
\includegraphics[scale=.65]{StaircaseWalk3x3.png}
\caption{3x3 Grid}
   \end{figure}
\end{document}

enter image description here

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.