Is it possible to know how much a \resizebox
scales something for further use in a \scalebox
?
To clarify, take this example:
\documentclass{article}
\usepackage[paperwidth=12cm]{geometry}
\usepackage{graphicx}
\begin{document}
\def\figurea{\includegraphics[width=5cm]{example-image-a}}
\def\figureb{\includegraphics[width=2.5cm]{example-image-b}}
This is \texttt{fig-a} with its natural size:
\figurea
\bigskip
This is \texttt{fig-b} with its natural size:
\figureb
\bigskip
This is \texttt{fig-a} scaled to fit the page width:
\resizebox{\textwidth}{!}{\figurea}
\bigskip
How do I rescale \texttt{fig-b} to keep its relative size compared to \texttt{fig-a} without knowing its actual size?
\bigskip
\texttt{Insert a nice piece of code here :)}
\end{document}
I want to have fig-b
with the same relative size to fig-a
without actually knowing the size of any of them.
Also, as in the example, there will be text in between the figures, so putting them in the same \resizebox
is not an option.
Best Answer
\resizebox
is just\scalebox
with a scale factor being the number that you ask for. So you can just persuade it to expose that number rather than just use it in a local group and discard it.