# subcaption width is not registered [closed]

I am trying to use subcaption in order to show two aligned images. This is my code

\documentclass{article}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{graphicx}
\begin{document}
\begin{figure}
\begin{subfigure}[b]{0.3\textwidth}
\includegraphics[width=.4\linewidth]{Figures/fig.png}
\caption{1a}
\label{fig:sfig1}
\end{subfigure}%
\begin{subfigure}[b]{.3\textwidth}
\includegraphics[width=.4\linewidth]{Figures/fig.png}
\caption{1b}
\label{fig:sfig2}
\end{subfigure}
\caption{plots of....}
\label{fig:fig}
\end{figure}
\end{document}


Everything works except one thing: The width of the subfigures are not registered. Whenever I compile it, the 0.4 appears on the document instead of being registered as a factor. This is the result:

I have been looking for some answers online for the past hour and everyone suggests the same lines of code as I have. Is there something I am missing out?

## closed as off-topic by egreg, Adam Liter, Werner, Mensch, AndrewFeb 4 '16 at 23:45

• This question does not fall within the scope of TeX, LaTeX or related typesetting systems as defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

• Welcome to SE! Please make yor code snipped compilable, i.e. add \documentclass{...} and used package. – Zarko Jan 5 '16 at 15:50
• Sorry, but I can't reproduce the behavior. – egreg Jan 5 '16 at 16:22
• Perhaps you have an outdated distribution. Update it and try again by following the instructions listed in How do I update my TeX distribution? – Werner Jan 5 '16 at 18:56
• I can reproduce the output if I replace subcaption with subfigure and ignore the compilation errors. Is there a \usepackage{subfigure} lurking in your code somewhere. – Torbjørn T. Jan 5 '16 at 19:11
• I'm voting to close this question as off-topic because the issue was due to a wrongly loaded conflicting package – egreg Feb 4 '16 at 23:05

Edit:. It is not clear to me, what is you thing that is wrong with your code. If you like to have captions and sub captions centered belong images, you need to add \centering as you can see in code below. Otherwise, "scaling" works as expected. To see this, I add rule in the first sub figure width length of \linewidth.

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

\usepackage[active,floats,tightpage]{preview}
\setlength\PreviewBorder{1em}

\begin{document}
\begin{figure}[h]
\centering%<---
\begin{subfigure}[b]{0.3\textwidth}
\centering%<---
\rule{\linewidth}{1pt}
\includegraphics[width=.4\linewidth]{example-image-a}
\caption{1a}
\label{fig:sfig1}
\end{subfigure}%
\begin{subfigure}[b]{.3\textwidth}
\centering%<---
\includegraphics[width=.4\linewidth]{example-image-b}
\caption{1b}
\label{fig:sfig2}
\end{subfigure}
\caption{plots of....}
\label{fig:fig}
\end{figure}
\end{document}


In code I add packageshowframe that the position of figure on the page is better seen. Is this what you looking for? I was not able to reproduce your image width your code.

• Hi Zarko, Thank you for your answer. Unfortunately the behaviour is the same as previously. The proportion values of \textwidth are still shown on the figure meaning that they are not having any effect on the sizing of the subfigures – ShEsKo Jan 5 '16 at 17:02
• @ShEsKo, see edit of my answer. – Zarko Jan 5 '16 at 18:47