TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. 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 a preprocesser to process some code before my verilog compiler.
All preprocesser words start with the ` character



unfortunately its possible to define your own preprocessor words. The only thing that is known is that the word starts with `.

How can I highlight any word starting with `?

share|improve this question
Welcome to TeX.SE. – Peter Grill Nov 21 '12 at 20:17
thank you...... – Rasmus Nov 22 '12 at 14:22
up vote 3 down vote accepted

You can adapt the solution from Listings language definition keyword suffixes and use the keywordsprefix=<prefix> to specify that anything beginning with tick is considered a keyword:

enter image description here


  • To obtain the a more reasonable display of leading tick, I added upquote=true which requires the textcomp package. There may be a better way to handle the issue of displaying the `.
  • There are limitations of using keywordsprefix=<prefix> which are noted in Listings language definition keyword suffixes.



    numbers=left, numberstyle=\tiny, stepnumber=2, numbersep=5pt,%

    `pp_if pp rr
    pp_if `mm zz
    xx `MM PP
    abc def ghi
share|improve this answer
I will try this thank you :) – Rasmus Nov 22 '12 at 11:47
Ok know it gets a bit tricky. i want to do the words starting with ` a different color than the other keywords. I tried with the emph, but then i can't do the prefix stuff.. any suggestions? – Rasmus Nov 22 '12 at 13:55
@Rasmus: Since it is called keywordprefix (and with the highlighting of restrictions as pointed out in Listings language definition keyword suffixes) this may not be easily doable, without much hackery (might be useful as a separate question). One solution might be to copy the code for keywordprefix and define emphstyleprefix and try to adapt that.. – Peter Grill Nov 22 '12 at 19:06
@Rasmus: Also, if this answered your question you should consider accepting it: How do you accept an answer? – Peter Grill Nov 22 '12 at 19:06
thank you i will do that :) – Rasmus Nov 23 '12 at 11:32

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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