Skip to content
Prev 180431 / 398503 Next

Centering R output in Sweave/LaTeX

Jean-Louis Abitbol-2 wrote:
I believe the problem arises because the R output is encased in fancyvrb
Verbatim environments after processing by Sweave. These environments have
implement their own justification rules which override the alignment
specified by \centering. A way to get around this would be to wrap the
output in another environment that does respect justification such as the
minipage:

\begin{table}
\centering

\begin{minipage}{0.5\textwidth}

<<echo=FALSE>>=
ftable(ifmtm$type, ifmtm$gender, ifmtm$marche , ifmtm$nfic,
dnn=c("Type","Gender","Ambulant","Visit"))
@

\end{minipage}


\caption{Four-way cross-tabulation on all data}
\label{tab:crosstab}
\end{table}


You may have to adjust the width of the minipage in order to achieve the
results you desire. Hope this helps!

-Charlie


-----
Charlie Sharpsteen
Undergraduate
Environmental Resources Engineering
Humboldt State University