2

I've got two subfigures below each other. They got the same aspect ratio but don't line up as they should. This is my LaTeX code and below is the produced image.

unity-slide.png is 1174 x 660 pixels big
unity-blue-drift.png is 1920 x 1080 pixels big

\begin{figure}[!ht]
    \begin{subfigure}[b]{0.8\linewidth}
      \includegraphics[width=\linewidth]{Pictures/unity-slyde.png}
      \caption{Slyde game prototype using Oculus Rift and a Wii Balance Board 

\cite{Dup2013}}
        \end{subfigure}\newline
        \begin{subfigure}[b]{0.8\linewidth}
          \includegraphics[width=\linewidth]{Pictures/unity-blue-drift.png}
          \caption{Blue Drift using Oculus Rift and Razer Hydra controllers \cite{Dup2014}}
        \end{subfigure}
        \centering
        \caption{Game prototypes created in Unity using gestural controls}
        \label{fig:other-unity-projects}
      \end{figure}     

enter image description here

Hedge
  • 969

1 Answers1

2

Change the \centering position (with your current settings it won't center both objects) and instead of \newline use \\ or \par:

\documentclass{article}
\usepackage{subcaption}
\usepackage[demo]{graphicx}

\begin{document}

\begin{figure}
\centering
\begin{subfigure}[b]{0.8\linewidth}      
  \includegraphics[width=\linewidth]{Pictures/unity-slyde.png}
  \caption{Slyde game prototype using Oculus Rift and a Wii Balance Board   \cite{Dup2013}}
\end{subfigure}\par
\begin{subfigure}[b]{0.8\linewidth}
  \includegraphics[width=\linewidth]{Pictures/unity-blue-drift.png}
  \caption{Blue Drift using Oculus Rift and Razer Hydra controllers \cite{Dup2014}}
\end{subfigure}
\caption{Game prototypes created in Unity using gestural controls}
\label{fig:other-unity-projects}
\end{figure}  

\end{document}

enter image description here

The demo option for graphicx simply replaces actual figures with black rectangles; do not use that option in your actual document.

Use a less restrictive float specifier than [!ht] or, even better, none at all.

Gonzalo Medina
  • 505,128
  • It should be [!htp] or the figure might block all subsequent ones. – egreg Sep 02 '15 at 22:33
  • @Gonzalo Thanks a lot for the awesome explanation. A lot of SE-sites can only dream about how helpful and dedicated the people on here are. @egreg: Can you explain why it might block without [!htp]? – Hedge Sep 03 '15 at 01:31
  • @Hedge Thank you for your kind words. Using [!ht] is too restrictive; if LaTeX algorithm can't place the float where the specification directed it, it will go to the unprocessed float stack and will force all subsequent fkoats to be unprocessed too. Once the unprocessed float number reaches 18, an error will be triggered. Adding p as egreg suggested, gives LaTeX the chance to move the float to a float-only page. – Gonzalo Medina Sep 03 '15 at 02:09