I am using figure
and subfigure
environment. Inside subfigure
I am using includegraphics
. The figure
and subfigure
structure looks like following:
\begin{figure}
\begin{subfigure}[b]{.25\textwidth}
\centering
\includegraphics[width=.9\linewidth,keepaspectratio]{building1}
\caption{\textit{\small{building1}}}
\label{fig:1a}
\end{subfigure}
\begin{subfigure}[b]{.75\textwidth}
\centering
\includegraphics[width=.9\linewidth,height=100\lineheight pt,keepaspectratio]{building2}
\caption{\textit{\small{building2}}}
\label{fig:1b}
\end{subfigure}
\caption{\textit{\small{Buildings}}}
\label{fig:1}
\end{figure}
For the first subfigure
, everything is OK. But for the second I am getting the build error: Undefined control sequence. ...t pt,keepaspectratio]{building2}
. It seems the problem lies with using the height
attribute in the second subfigure
, as when I removed the height
attribute from the second subfigure
, there was no build error.
What is the reason of this? Is there a way to keep using both height
and width
attributes in includegraphics
?
P.S.: I am using \usepackage{subcaption}
.
Best Answer
By default, LaTeX has no parameter
\lineheight
. I guess that may be you mean\baselineskip
instead which is the stand vertical space between the corresponding points of lines in text.Replacing
\lineheight
with\baselineskip
removes the error, but has no effect in your case, as you have also specified thewidth
andkeepaspectratio
. You should remove one of these extra specification to allow the resizing to take place. I have chose to removekeepaspectratio
below.You will then discover that
100\baselineskip
is more than a standard page height, so in the example below I have reduced this to10\baselinkeskip
.In the above, I have also used a
\captionsetup
command to specify uniform styling of the captions. This avoids having to write\small\textit
in each case, and leads to more consistency.