# Making comments stand out when using Sweave and R

Is there any way to bold or highlight all comments when using Sweave? Maybe a command to make all lines starting with # be bolded?

<<>>=
# I want this to be bold automatically
@


You can redefine \hlcom command.

% !Rnw weave = knitr
% !TeX program = pdfLaTeX

\documentclass[final,12pt]{article}

\usepackage[a4paper]{geometry}

\renewcommand{\hlcom}[1]{\textcolor[rgb]{0.678,0.584,0.686}{\textbf{#1}}}%

\begin{document}
<<>>=
# commented text
@
\end{document}


And the result:

• ! LaTeX Error: \hlcom undefined. Dec 1 '13 at 20:26
• I'm using Sweave and not knitr. Is that the problem? (Would switching over be easy?) Dec 1 '13 at 20:47
• @EarlBellinger It should be easy and you definitely should switch: yihui.name/knitr/demo/sweave (Disclaimer: I'm the knitr author, so I'm biased by definition) Dec 22 '13 at 2:41