9

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).

  • 5
    I don't think sticking to the same aspect ratio throughtout the document is wise. As you wrote, different images will likely call for different aspect ratios. However, you may want most of your images to have the same width throughout. To do so, nothing prevents you from defining a length (say, \newlength\myimagewidth and \setlength\myimagewidth{.9\textwidth}) in your preamble, and use \includegraphics[width=\myimagewidth]{...}. This tactic still allows for local tweaks, if needed. – jub0bs Oct 13 '13 at 10:11
  • @Jubobs this looks near enough to an answer, to me. :-) – Paul Gessler Jan 10 '15 at 13:51
  • 1
    @PaulGessler Sorry for getting back to you so late, Paul. I'll try to write an answer within the next few days. – jub0bs Jan 13 '15 at 23:20
2

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

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.