# MIssing Number Treated as Zero in Subfigure

I know that this question has been asked multiple times here. But I am using subcaption package. But still it is giving the error. specifically I want 2 row and 2 column table of images.

\begin{figure}[htb!]
\centering % <-- added
\begin{subfigure}[a]{0.42\textwidth}
\includegraphics[width=\linewidth]{one.pdf}
\end{subfigure}
\begin{subfigure}[b]{0.42\textwidth}
\includegraphics[width=\linewidth]{two.pdf}
\end{subfigure} % <-- added

\begin{subfigure}[c]{0.42\textwidth}
\includegraphics[width=\linewidth]{three.pdf}
\end{subfigure} % <-- added
\begin{subfigure}[d]{0.42\textwidth}
\includegraphics[width=\linewidth]{four.pdf}
\end{subfigure} % <-- added
\caption{Truncation of points}
\label{fig:images}
\end{figure}

• Are you adding subcaptions? If not, I don't think you need the subfigure environments. – Torbjørn T. Jul 11 '20 at 6:20
• Note that the optional argument to subfigure is for vertical alignment (same as a minipage), so the valid options are t(op), c(enter) and b(ottom). Edit: also, your snippet when added to a minimal document doesn't cause any errors, can you make a complete example? – Torbjørn T. Jul 11 '20 at 6:21
• @TorbjørnT. then how does the code look like Can you please write an answer – viru Jul 11 '20 at 6:24
• So you don't want subcaptions? Literally just remove all \begin{subfigure} and \end{subfigure}, so you have \includegraphics{1} \includegraphics{2} <empty line> \includegraphics{3} \includegraphics{4} – Torbjørn T. Jul 11 '20 at 6:26
• I've asked you twice if wanted subcaptions ... Use the code you originally had, remove [a], [b], [c] and [d], and add a \caption{} inside each subfigure. As I edited into my second comment, your code as is works fine for me (no errors), so we probably need a complete but minimal example (tex.meta.stackexchange.com/questions/228) to figure out why you get the error. – Torbjørn T. Jul 11 '20 at 6:40

It looks like you're completely mis-using the optional argument of the subfigure environments. As it happens, the optional arguments a, and d are not valid and are thus simply ignored, c (short for "center") is the default and does nothing in the second row, and b (short for "bottom") is interpreted as requiring bottom alignment of the image with respect to the other items in the row (here: a single subfigure environment).

The three valid optional arguments of subfigure environments are the same as for minipage environments: t ("top"), c ("center"), and b ("bottom").

If you want to set dummy captions of the type (a), (b) for each subfigure, just insert \caption{} directives inside each subfigure.

The following screenshot displays two figure environments. The first, with caption "Before", is based on your code, with red highlighting applied to the misplaced upper-right image. The second, with caption "After", gets rid of the [a], [b], etc optional arguments, uses four \caption{} directives, and arranges for a bit of horizontal and vertical visual separation of the images.

\documentclass[demo]{article} % remove 'demo' option in real doc.
\usepackage{subcaption,graphicx,color}

\begin{document}
\begin{figure}[t!]
\centering
\begin{subfigure}[a]{0.42\textwidth}
\includegraphics[width=\linewidth]{one.pdf}
\end{subfigure}
\begin{subfigure}[b]{0.42\textwidth}
\color{red}\includegraphics[width=\linewidth]{two.pdf}
\end{subfigure}

\begin{subfigure}[c]{0.42\textwidth}
\includegraphics[width=\linewidth]{three.pdf}
\end{subfigure}
\begin{subfigure}[d]{0.42\textwidth}
\includegraphics[width=\linewidth]{four.pdf}
\end{subfigure}
\caption{Before}
\label{fig:images-before}
\end{figure}

\bigskip
\begin{figure}[h!]
\centering
\begin{subfigure}{0.42\textwidth}
\includegraphics[width=\linewidth]{one.pdf}
\caption{} % <-- new
\end{subfigure}%
\qquad % <-- new
\begin{subfigure}{0.42\textwidth}
\includegraphics[width=\linewidth]{two.pdf}
\caption{} % <-- new
\end{subfigure}

\medskip % <-- new
\begin{subfigure}{0.42\textwidth}
\includegraphics[width=\linewidth]{three.pdf}
\caption{} % <-- new
\end{subfigure}%
\qquad % <-- new
\begin{subfigure}{0.42\textwidth}
\includegraphics[width=\linewidth]{four.pdf}
\caption{} % <-- new
\end{subfigure}
\caption{After}
\label{fig:images-after}
\end{figure}

\end{document}

• Got It . Thanks so much :) cleared the errror – viru Jul 11 '20 at 6:55