Following this question I asked a few years ago, I'm looking for a way to find the width of the largest picture (in width) in my document.
Typically, this requires a for loop and some TeX programming. Since my compilation process already includes 3 parsing steps (required to compute the last page number and bibliography items with biber), this isn't really a problem for me if this requires yet another one. If I can rely on an existing compilation pass, that would be even greater though.
Any idea how I can write this parser? My solution would have to use some regexes and manual parsing using Python, but I would like to avoid to require yet another engine.
Why this parser? Let me explain what I want by an example.
Considering
a full screen screenshot displayed with
\includegraphics
with a with specified by\textwidth
.another screenshot taken on the same computer, but cropped to a specific size (e.g. to only have a specific dialog or a subset of the first image to focus on something specific).
The idea is to get the size of the first picture to be able to determine the ratio I need to specify to the second picture (how to compute it in the \includegraphics
statement? do we have support for some mathematics computation in this context?).
In this use case, the first picture is the one one, but I would like to be able to specify the pictures kept to determine which one is the largest (in width, with a special tag for example).
As you can see, the way the pictures are presented here above in this question are incorrect. I want the second picture representing only the dialog from the first image to be the same size as it is in the first image. Typically, this is what I want (screenshot taken on LibreOffice Writer):
As you can see the dialog in the second image has the same width size as the first image (I don't know if we can call dpi in this context).
0.75\textwidth
? Or do you want to show the all at the same resolution (dpi)? – Michael Palmer Sep 3 '17 at 22:41convert
from theimagemagick
library:for pic in *.png; do convert -units PixelsPerInch $pic -density 300 $pic; done
. Either experiment with the DPI number, or define a custom scaling factor inside LaTeX\newcommand{\myscale}{0.75}
, which you then use with every screenshot:\includegraphics[scale=\myscale]{screenshot1}
. – Michael Palmer Sep 4 '17 at 14:06! Undefined control sequence. <recently read> \pdfimageresolution
. Actually digging in my own class implementation is what I do from the beginning, but sbox/mboxes are still not very clear for me in this context. Parsing a *TeX file isn't something I already performed either. – wget Sep 4 '17 at 14:45