The code below is executing properly:
\begin{figure}
\includegraphics{name1}
\caption{Figure 1}\label{name1}
\end{figure}
However when I add width
and height
:
\begin{figure}
\includegraphics[width=15cm,height=6cm]{name1}
\caption{Figure 1}\label{name1}
\end{figure}
I get this error:
! Missing number, treated as zero.<to be read again>
How do I solve this problem?
Best Answer
The optional argument with key value options are added by package
graphicx
, note thex
at the end. Packagegraphics
has a different syntax and meaning of the optional arguments, from the documentation of packagesgraphics
andgraphicx
,grfguide
:graphics
:\includegraphics[
⟨llx,lly⟩][
⟨urx,ury⟩]{
⟨file⟩}
graphicx
:\includegraphics[
⟨key val list⟩]{
⟨file⟩}
Solution:
This might distort the image, if the specifications do not hit the aspect ratio of the image. Option
keepaspectratio
scales the image down if necessary to fit the available space but without distorting the image: