2

In my copy editing work I often need to resize figures to make them fit the pagewidth (remove "Overfull \hbox..."). I always try to keep the author's layout and the proportion between the figures.

Here's a MWE:

\documentclass[11pt]{article}
\usepackage{amsmath}
\pagestyle{empty}
\usepackage{graphicx}
\usepackage{subfigure}
\usepackage{blindtext}

\overfullrule=1mm
\begin{document}
   
\begin{figure}
  \subfigure[]{\includegraphics[scale=.55]{example-image-a}}\subfigure[]{\includegraphics[scale=.6]{example-image-b}}
  \caption{Image.}

\end{figure}

\blindtext
\end{document}

enter image description here

Below I'll post a solution that I figured out to quickly handle these cases. I'm open to other tips and solutions.

Clarification. I begin to suspect that my question isn't clear enough (maybe for my poor english). My solution is focused in keeping the proportions between all the images' size (not the ratio of heigth and width in the single image). I need to scale all figures by the same value as fast as possible.

In the absence of "subfigure" my solution, in this particular case, would have been:

\begin{figure}
  \resizebox*{1\textwidth}{!}{\includegraphics[scale=.55]{example-image-a}}\subfigure[]{\includegraphics[scale=.6]{example-image-b}}
  \caption{Image.}

\end{figure}
  • 2
    Why not use the width option instead of the scale option? For two side by side images you wan chose widths relative to the textwidth. Both widths should add up to q value smaller than or equal to the textwidth. – leandriis Jun 21 at 19:14
  • I'm a copy editor. I do not write documents by myself and this is a MWE. Using width keeping the original proportion of the figures may be very tricky/boring. – Gabriele Nicolardi Jun 21 at 19:21
  • 2
    If you just supply the width option, the aspect ratio of the image stays unchanged. – leandriis Jun 21 at 19:27
  • @leandriis I mean the proportion between the two (or more) figures. – Gabriele Nicolardi Jun 21 at 19:44
  • Thanks for the clarification. – leandriis Jun 21 at 19:49
7

The scale, or "natural width", of a graphics file may be of relevance at the time the file was created. E.g., the scale may have been chosen to make the image fit in a certain window on a monitor controlled by the file's creator. Outside of this context, I'd argue that the scale is of little direct relevance for further users or viewers of the image.

Thus, instead of modifying the scale parameter of the \includegraphics statement, I'd focus on the width parameter. E.g., if the objective is to place two equally-wide images side by side, I'd replace

\subfigure[]{\includegraphics[scale=.6]{example-image-a}}%
\subfigure[]{\includegraphics[scale=.6]{example-image-b}}

with

\subfigure[]{\includegraphics[width=0.5\textwidth]{example-image-a}}%
\subfigure[]{\includegraphics[width=0.5\textwidth]{example-image-b}}

Or, if I also wanted to insert a bit of whitespace -- in the amount of 0.05\textwidth -- between the images, I might run

\subfigure[]{\includegraphics[width=0.475\textwidth]{example-image-a}}\hfill
\subfigure[]{\includegraphics[width=0.475\textwidth]{example-image-b}}
| improve this answer | |
  • Your example works in the case of figure with the same width (or height...). But how to keep the proportions of figures having different widths expressed, e.g., in cm (and not in a relative factor as \textwidth)? – Gabriele Nicolardi Jun 21 at 19:41
  • I mean the proportion between the two (or more) figures – Gabriele Nicolardi Jun 21 at 19:46
  • @GabrieleNicolardi - The usefulness of my answer is not limited to cases where the graphs have the same height or width. (E.g., reset the first width to 0.3\textwidth and the second to 0.7\textwidth and recompile.) If the two graphs must be output at different (relative or absolute) widths, say, 9cm and 6cm, and if they are supposed to span the entire textblock (implying that the width of the text block is 15cm), just set width=0.6\textwidth and \width=0.4\textwidth, respectively. No trial and error, just set the relative proportions and you're good. – Mico Jun 21 at 19:50
  • 1
    I never told about 10 images side-by-side... They could be in rows of 4, 3, 2 and 1 images... I think that my solution is faster then yours and formally correct but I'm still open to better ideas. (I also think that none of us wants to inflict typographic calamities to its readers but, sometimes, authors have their reasons to keep their layout) – Gabriele Nicolardi Jun 21 at 20:34
  • 1
    @GabrieleNicolardi - I think that we've begun to largely talk past each other. I may be taking the view of an author, who doesn't know the width of the textblocks employed by journals and book publishers and hence prefers to think of image widths as relative widths -- fractions of the overall available width. You may be taking the view of an editorial specialist of a specific publication, for whom \textwidth is fixed constant and for whom it is very natural to think in terms of absolute widths. My point is that the width=... approach to \includegraphics can handle both width types. – Mico Jun 21 at 20:56
1

My idea is to redefine the \includegraphics command inside the figure environment:

\documentclass[11pt]{article}
\usepackage{amsmath}
\pagestyle{empty}
\usepackage{graphicx}
\usepackage{subfigure}
\usepackage{blindtext}

\overfullrule=1mm
\begin{document}


\begin{figure}
 \centering
\let\oldincludegraphics\includegraphics
\def\includegraphics#1#{\includegraphicsaux{#1}}
\newcommand*\includegraphicsaux[2]{{\scalebox{.78}{\oldincludegraphics#1{#2}}}}
\subfigure[]{\includegraphics[scale=.55]{example-image-a}}\subfigure[]{\includegraphics[scale=.6]{example-image-b}}
  \caption{Image.}

\end{figure}

\blindtext
\end{document}

enter image description here

You'll need some attempt to find the right scale value... but that's the best I found.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.