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




  # commented text

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)
    – Yihui Xie
    Dec 22 '13 at 2:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.