6

I would like to add a figure, but I would like to control both width and length of figure. I know to control length and width separately but not together. Could anyone let me know the command to do that.

I am using the following commands:

\begin{figure}[H]
\centering
\includegraphics[height=8cm]{Images/abc}
\caption{abc}
\label{fig:abc}
\end{figure}
  • 3
    Welcome to TeX SX! You can use [height=…, width=…], but in general, it will change the aspect ratio of the figure. – Bernard Jan 11 '17 at 18:51
  • 2
    Do you wish to maintain the aspect ratio? Do you want to have some maximum width/height to fit the image in rather than fixing it absolutely? – Werner Jan 11 '17 at 20:16
  • Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. – Martin Schröder Jan 12 '17 at 20:30
9

Here you are:

\documentclass{report}
\usepackage[english]{babel}
\usepackage{graphicx}

\begin{document}
\includegraphics[height=3cm]{example-image-b}
\includegraphics[width=5cm]{example-image-b}

\includegraphics[height=3cm, width=3cm]{example-image-b}
\includegraphics[height=3cm, width=6cm]{example-image-b}
\includegraphics[keepaspectratio,height=3cm, width=6cm]{example-image-b}
\end{document}

And the result:

enter image description here

Be very careful! By defining both height and width, you will distort the aspect ratio of the images. See the manual of the graphics bundle for more details and how to avoid distortions. To avoid the distortion, you can use the keepaspectratio-option, as presented in the last command.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.