I automatically generate a bunch of diagrams, and I'd like them to be automatically formatted to fit the page according to the following style:
- If the diagram (in the form of a
.pngfigure) is smaller than a certain linewidth factorb=1.11\linewidth, then I'd like it to have a fixed scalea=0.5, for examplescale=0.5. - If the diagram is larger (at that scale of 0.5) than
1.11\linewidth, I'd like the image to be scaled to have a maximum linewidth of1.11\linewidth. - If the image has
1.11\linewidthI'd like it to be centered on the page.
The latter can be done using \makebox or [adjustbox] according to this answer:
\begin{figure}[H]
\makebox[\linewidth][c]{\includegraphics[width=1.11\linewidth]{latex/project6/Images/some_image.png}}%
\caption{Some caption.}\label{fig:some_reference}
\end{figure}
My question is: how can I automatically detect whether the image width is larger than 1.11\linewidth at scale=0.5 (ideally parametrically) and automatically adjust the image width accordingly?
pngis a bitmap figure, so it's size is dependent on the density you want, i.e., it has no "natural" size. At 300dpi it is smaller than at 150dpi... Besides, maybe you just needmax width? https://tex.stackexchange.com/a/32902/38080 – Rmano Jan 11 '22 at 10:19.pngfiles that are generated have a fixed dpi and variable sizes, for example one image may have dimensions300x123, whereas another may have dimensions200x2354. So if the images in the pdf are below a certain linewidth, I would like to keep them at a fixedscale=0.5however, if that makes them to large for the page, I would like to limit their width to a1.11\linewidth. Thank you, I will look intomax width! – a.t. Jan 11 '22 at 10:26