Figure Margins in R and LaTex

Just in case Sweave isn’t an option and you find yourself tweaking figure margins in both R and LaTex don’t forget that the editing order is different for each program.

In R you edit margins using par() parameters “mar” (margins specified in lines) or “mai” (margins specified in inches) as a vector of the form c(bottom, left, top, right).

For example, the default “mar” looks like this:

par(mar=c(5.1, 4.1, 4.1, 2.1))

In LaTex it’s important to remember that, when inserting a figure you plan to clip & trim, the order of the trim specification is “top left bottom right”. Be sure to specify the scale of each input (in, mm, etc.) and to include the “clip” argument.

For example:

\includegraphics[trim= .4in .4in .4in .4in, clip]{figure1.ps}

I have no idea why they are different although I suspect a massive conspiracy and expect it to be explored more fully in the forthcoming Dan Brown novelization titled “Please Stop Complaining, It’s Free Software and It’s Not Like You’ve Contributed Any Code Anyway”. Pithy.

R: b, l, t, r
LaTex: t, l, b, r

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s