3

This is how i add the graph in latexila

 \centerline{\includegraphics[scale=0.5]{e1.png}}

Question is can I also reduce its height after I scale it?

The reason I want to do this is because I don't want to change the height of the png .

6
  • do you mean you want to clip? (adjustbox package adds clipping features) also, it is best not to use \centerline in latex (it isn't really a latex command, just a left over from plain) Nov 6 '14 at 16:47
  • 1
    your question is not clear, if you do not want to change the height why are you scaling it? Nov 6 '14 at 17:06
  • The question does not say that the height of the image is not to be changed, only that the height of the original png should not be changed. I interpret this as meaning that all resizing should happen in LaTeX rather than Photoshop.
    – Ubiquitous
    Nov 6 '14 at 17:25
  • Thanks everybody. Ubiquitous' answer was exactly what I wanted. I didn't want to change the dimensions of the original .png . Worked!
    – ourania
    Nov 6 '14 at 17:50
  • @ourania the answer uses far more code than is needed you just need [width=...] on the \includegraphics, it seems. Nov 6 '14 at 17:50
4

This can be achieved by putting your \includegraphics command inside of a \resizebox.

\resizebox{\width}{1cm}{\includegraphics[scale=0.5]{e1.png}}

will resize your graphic to maintain its original (after scaling) width, but have a height of 1cm. Here's an example:

\documentclass{article}
\usepackage{graphicx}
\begin{document}

\includegraphics{wikipedia.jpg}
\includegraphics[scale=0.5]{wikipedia.jpg}   
\resizebox{\width}{1cm}{\includegraphics[scale=0.55]{wikipedia.jpg}}

\end{document}

enter image description here

2
  • why use a resizebox rather than just \includegraphics[width=1cm]{wikipedia.jpg} ?????? Nov 6 '14 at 17:49
  • \includegraphics[width=1cm]{wikipedia.jpg} would scale the width to be 1cm and scale the height to maintain the aspect ratio. orania wants to scale the width to be half of its original dimension but then break the aspect ratio by changing the height of the scaled image (but leaving the new width unchanged). One could, of course, do this in one step with \includegraphics[width=2cm,height=1cm]{wikipedia.jpg}, provided that the absolute target width is known.
    – Ubiquitous
    Nov 6 '14 at 18:11

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.