[R] Sweave: How to load available colors from pkg 'color'

Felipe Carrillo mazatlanmexico at yahoo.com
Fri Nov 7 19:30:26 CET 2008


Hi: Is there a shorter way to color the abstract,sections subsections and page headings of a document. I am using the code below in my preamble to accomplish some of it:

\ifx\pdfoutput\@undefined\usepackage[usenames,dvips]{color}
\else\usepackage[usenames,dvipsnames]{color}
% and fix pdf colour problems
\IfFileExists{pdfcolmk.sty}{\usepackage{pdfcolmk}}{}
\fi
%\renewcommand{\MakeUppercase}[1]{\color{OliveGreen}\textsf{#1}}
%\renewcommand{\abstractname}{\color{blue}Abstract}

 Also,'\usepackage[usenames]{color}' is suppossed to load all the available colors in the package 'color' but for some reason it doesn't  load them when running it trhough Sweave. It loads all the colors if I run it outside R though.
Here's a dummy document:

\documentclass[12pt]{article}
\usepackage{floatflt,graphicx,times,babel}
\usepackage[usenames]{color}
\usepackage{verbatim}
\usepackage[ps2pdf,
bookmarks=true,
bookmarksnumbered=false, 
bookmarksopen=false, 
colorlinks=true,
linkcolor=blue]{hyperref}

\pdfbookmark[1]{Contents}{table}
\title{BROOD-YEAR 2008 PINK SALMON RUN}
\author{Felipe D. Carrillo}
\pagestyle{headings}
\begin{document}
\setkeys{Gin}{width=0.9\textwidth}
\maketitle
\begin{abstract}
 This is my abstract
\end{abstract}
\tableofcontents
\section{list of figures}
\section{introduction}
here's my introduction
\section{study area}
This is my study area
\section{methods}
subsection{sampling gear}
I used this sampling gear
\subsection{data collection}
\end{document}


Felipe D. Carrillo  
Supervisory Fishery Biologist  
Department of the Interior  
US Fish & Wildlife Service  
California, USA



More information about the R-help mailing list