# subfigure: Missing number, treated as zero and Illegal unit of measure (pt inserted)

i use below code to view 2 images A & B:

\documentclass{article}
\usepackage{subcaption}
\usepackage{graphicx}

\begin{document}
\vspace*{4cm}
\begin{figure}[ht!]
\centering

\begin{subfigure}{0.5\linewidth}
\includegraphics[width=3cm]{example-image-a}
\end{subfigure}
\\
\vspace*{3cm}
\begin{subfigure}{0.5\linewidth}
\includegraphics[width=5cm]{example-image-b}
\end{subfigure}
\end{figure}
\end{document}


When i use above code, no error but when i insert this code to my big main.tex file, get 2 errors: Missing number, treated as zero and Illegal unit of measure (pt inserted)

And number 0.5 of {0.5\linewidth} displayed with image.

How can i remove number 0.5?

Thanks

• Sorry but how should we know what your big main file is doing to break the code? Make a copy of your main file add only the body of your example and then start to remove packages to find the culprit. – Ulrike Fischer Jan 28 at 9:33

I can reproduce the issue if I change \usepackage{subcaption} into \usepackage{subfigure} (or use both, with subfigure prior to subcaption).
Either use subfigure (but bear in mind it is obsolete) or subcaption, not both.
If you have to use a template that forces subfigure, then use the proper syntax that you find in its manual.