LaTeX - Automatically scale down an area so that it will be inside a page if it's too big?
Asked Answered
M

3

11

I'm making a document in LaTeX. It includes a set of images in a row. A small percentage are quite wide and will stretch and push off the page. If I shrink all the image sequences then most of them will look too small. However it's not easy to figure out what sets are going to be too large. I'd like some automatic way to resize these sets.

Is there anyway to surround something with a command which will shrink it enough so that it fits within the width of the page? If it's already narrower than the page, then no shrinking is necessary?

Meneau answered 28/7, 2010 at 10:42 Comment(0)
S
9

you can do something like

\includegraphics[width=\textwidth]{figure}

or

\includegraphics[width=0.33\textwidth]{figure}
\includegraphics[width=0.33\textwidth]{figure}
\includegraphics[width=0.33\textwidth]{figure}
Sexton answered 28/7, 2010 at 10:45 Comment(1)
This isn't automatic?Chrischrism
T
5

You may try the following macro:

\maxsizebox{〈width〉}{〈height〉}{〈content〉}

It only resizes the content if its natural size is larger than the given 〈width〉 or 〈height〉, but does not change the aspect ratio. It is part of the adjustbox package. So you need to append to the preamble of your document:

\usepackage{adjustbox}

You can further read about it here.

Testator answered 19/3, 2015 at 11:27 Comment(3)
The link is broken.Dote
@PaulWintz It indeed has been deprecated. Thanks for reporting. Updated with a relevant alternative.Testator
@Testator It is safer to not link to a specific mirror, but use the canonical url. This way you minimise the risk of broken links, See ctan.org/file/help/ctan/CTAN-upload-addendum?lang=en for more informationJarvey
S
4

The best way to scale down a big figure is this

\begin{figure}[!ht] \centering
\includegraphics[width=\textwidth,height=\textheight,keepaspectratio]{"path to your figure"}
\caption{"your caption"}
\label{"your label"}
\end{figure}
Shermanshermie answered 30/9, 2019 at 15:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.