# Align two subfigures vertically

I'm writing a LaTeX document where I want two or three QR codes vertically aligned with caption on each. Unfortunately the first QR code is always one line lower than the other QR codes and I can't figure out why.

I have a workaround with negative \vspace, but I'm hoping to find the error or something neater.

## MWE

\documentclass[12pt,a5paper]{book}
\usepackage[]{qrcode}
\usepackage{subcaption}
\begin{document}

\begin{figure}[ht]
\centering
\begin{subfigure}[t]{0.2\textwidth}
\centering
\qrcode[]{Text1}
\caption*{Text1}
\end{subfigure}
\begin{subfigure}[ht]{0.2\textwidth}
\centering
\qrcode[]{Text2}
\caption*{Text2}
\end{subfigure}

\end{figure}
\end{document}


• Welcome to TeX.SX! Thank you for your example. You don't need to load caption when you use subcaption. Latter one does \RequirePackage{caption}. – Ruben Apr 17 '16 at 19:10
• Thanks, the example was not minimal, I removed the \usepackage{caption}, the problem with horizontal alignment however persists. – Richard Apr 17 '16 at 19:14
• Sure, dont worry. Your example was totally fine. Just a fineness on the use of the caption package bundle I was pointing to... I posted an answer that solves the issue. – Ruben Apr 17 '16 at 19:17
• @Richard I removed the [solved] part of the title, as the way we mark questions solved on this site is to accept answers. See this question for how to do it. – sodd Apr 17 '16 at 19:22

You can use \subcaptionboxes as they get vertically aligned automatically:

\documentclass[12pt,a5paper]{article}
\usepackage{qrcode}
\usepackage{subcaption}

\begin{document}
\begin{figure}[ht]
\centering
\subcaptionbox{Text1}{\qrcode{Text1}}