Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I use Emacs to edit LaTeX source. I preface notes which I have made with % as required, so that they are considered as comments. These lines appear in Emacs in a different face.

However, when working on a document, I sometimes would like to highlight/indicate/mark certain lines so that they appear in a different face. For example, if I am done with a section of notes I have made, but would like to keep these in the source file, I would like to "flag" these lines so that they appear in a different face in Emacs.

Is there a way to do this? Any solution would obviously still need to be considered valid LaTeX code. Maybe lines starting with %% could use a different face?

share|improve this question
up vote 2 down vote accepted

What a great idea, thanks for making me go and find a solution! What you need to do is add the following lines to your ~/.emacs file:

(add-hook 'tex-mode-hook
  (lambda ()
    (font-lock-add-keywords nil
       '(("\\(%%.*\\)" 1
        font-lock-warning-face t)))))

You can change the %% to anything else you want. Personally, I think I will use %# that way I can still have stretches of % for horizontal separators.

share|improve this answer
Thanks :) I changed it to 'LaTeX-mode-hook to get it to work on my system. I think I'll go with %# too, for the same reason. – SabreWolfy Oct 9 '12 at 16:20
Just for clarity: I'm using AUCTex and LaTeX-mode is what it calls it's LaTeX mode. I think the default LaTeX mode in Emacs may be called latex-mode. – SabreWolfy Oct 9 '12 at 16:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .