[Tex/LaTex] Best practices for setting figure width/height ratio across the document in a consistent fashion

graphics

When I have many plots in a document I usually lose a lot of time to individually set width and height of each pictures to make them appear right within the document. Additionally complicating the matter is that some figure is produced in R adding other variables to each final-size equation, but also that figures can't be simply of strictly the same size since (of course) content must always influence the aspect ratio (e.g. time-series could require a 1/3 height/width ratio while a simple bar chart might only require something close to 1/1).

According to Edward Tufte "[g]raphics should tend toward the horizontal" (Tufte, E. R. (2001). The visual display of quantitative information. P. 186). I agree. Tufte also proposes two ratios: the Golden rectangle–1/1.618 (the same used in Grecian temples)–or a simpler 1/1.5.

I know this could sound as a vague question but I wonder if someone has successfully experimented in this sense with any technique to consistently render figures across a LaTeX document (maybe by setting in the preamble base-line values as variable to be used across the document–still allowing locally for minor tweaks).

Best Answer

Here is another idea, slightly different from Jubobs' idea in the comments. It uses global key setting for the package graphicx:

\setkeys{Gin}{keepaspectratio,width=1in,height=1in}

What this does is sets these keys globally for all instances of \includegraphics. The meaning here is that, unless specifically overridden, all images will be included at their native aspect ratio, with a maximum width and height of 1in (obviously these values can be adjusted to your preference).

The slight wrinkle in this is that if you want a certain image to be included larger than your default settings, you have to locally set both width=<your-desired-width> and height=<some-large-value> (or vice-versa), otherwise the maximum constraint in the other dimension is reached.

Also: a figure can be distorted by setting keepaspectratio=false locally and setting width/height to the desired values.

\documentclass{article}
\usepackage{mwe}
\setkeys{Gin}{keepaspectratio,width=1in,height=1in}

\newcommand{\test}[2][]{\begin{center}\includegraphics[#1]{#2}\end{center}}

\begin{document}
A plain old image with default settings:
\test{image-a}

A tall image with default settings:
\test{image-10x16}

Illustration of ``local tweaks'' 
(note that full specified width is not reached because of the 
\verb+height=1in+ and \verb+keepaspectratio+ constraints):
\test[width=4in]{image-b}

Illustration of unconstrained ``local tweaks'' without distortion:
\test[width=4in,height=\textheight]{image-c}
\end{document}

enter image description here