Resize all images in Latex to a percentage width
You can redefine the existing \includegraphics
macro to apply any options you desire.
Below, I placed the \renewcommand
in the main document just so that you can see the effect before and after. The \renewcommand
below ensures that all subsequent usages of \includegraphics
have the width=9cm
option applied. Here is a before and after comparrison:
Notes:
Normally one could use the
\let\OldIncludegraphics{\includegraphics}
syntax, but since\includegraphics
has an optional parameter we need to useLetLtxMacro
from theletltxmacro
package A detailed description of\LetLtxMacro
can be found at this question about a closed square root symbol.The
[demo]
option is used so as to place a black box where the figure would go for demo purposes, in your real usage (when you actually have the figures available), you need to remove this option.
Code:
\documentclass{article}
\usepackage[demo]{graphicx}% Remove [demo] option in real usage.
\usepackage{letltxmacro}
\LetLtxMacro{\OldIncludegraphics}{\includegraphics}
\begin{document}
\begin{figure}[htbp]
\centering
\includegraphics{images/flock_of_birds.JPG}
\caption{A flock of storks rush to fill orders during the Baby Boom.}
\end{figure}
\renewcommand{\includegraphics}[2][]{\OldIncludegraphics[width=9cm, #1]{#2}}
\begin{figure}[htbp]
\centering
\includegraphics{images/flock_of_birds.JPG}
\caption{A flock of storks rush to fill orders during the Baby Boom.}
\end{figure}
\end{document}
\documentclass{article}
\usepackage{graphicx}
\makeatletter\def\Gin@i{\Gin@ii[scale=0.2]}\makeatother
\begin{document}
\includegraphics{tiger}
\end{document}
scales every image down to 20%. You can also define width=0.3\linewidth
or something else.