Change LaTeX Margins with Package geometry

http://web.image.ufl.edu/help/latex/margins.shtml

Changing the spacing on a document-wide basis is done for different document settings using different packages. The geometry package controls the overall margins and text area of the document. The package must be called in the preamble of the document and specified when called.

The geometry package is called with the use package command, followed by the options, and then the package name, like this:
usepackage[left=2cm,top=1cm,right=3cm,nohead,nofoot]{geometry}

Advertisement

LaTex tables with rotated column labels

Trying to get a huge correlation table into a readable pdf document using LaTeX i have to rotate the column lables since the variable names differ a lot in lenght. Dr. Andrew J. Page posted this solution on his blog:

The LaTeX package rotating is needed so include
\usepackage{rotating}
in the preample of the document.

Every single column label has to be included into
\begin{sideways}MyColumnLabel\end{sideways}
Thats a bit awkward, but thats the way it is….

An example from the blogpost mentioned above:
\begin{tabular}{rr}
\hline
\begin{sideways}Paper\end{sideways} &\begin{sideways}Static\end{sideways} \\
\hline
HAR1994j & Journal \\
SWRT1996c & Conference \\
\hline
\end{tabular}

Create LaTex tables from R output

Creating reasonable layouted LaTeX tables from R output was easier then expected. I should have googled it long ago…

install.packages("xtable")

Lets say you created a tabular output in R called “tab1”, e.g by doing:
data(CO2)
tab1 <- with(CO2, table(Treatment , Type))
tab1

your text output in R would look like

Type
Treatment Quebec Mississippi
nonchilled 21 21
chilled 21 21

Now you would like this or whatever table or data.frame as a nice LaTeX-table, the only thing to do is:
library(xtable)
xtable(tab1)

and the output will be:

% latex table generated in R 2.9.0 by xtable 1.5-5 package
% Wed Jul 08 16:20:54 2009
\begin{table}[ht]
\begin{center}
\begin{tabular}{rrr}
\hline
& Quebec & Mississippi \\
\hline
nonchilled & 21 & 21 \\
chilled & 21 & 21 \\
\hline
\end{tabular}
\end{center}
\end{table}

If you are using Sweave the usage becomes
<< echo = FALSE , results = tex >>
library(xtable)
data(CO2)
with(CO2, xtable(table(Treatment , Type)))
@

and a the result of the R run is a LaTeX document. Another post will give a hint how to paste R graphics into the same Sweave or LaTeX document… later…

The full usage of xtable() is
xtable(x, caption=NULL, label=NULL, align=NULL, digits=NULL, display=NULL)
.. add table captions
xtable(table , caption = "My table caption")
and labels
xtable(table , label = " MyLaTeXlable")
to the LaTeX tables.