Here's a simple script that will mark up words that you specify by editing the script-- it was the simplest way to handle lots of words and lots of different colors. It requires perl, which is standard on Unix (Linux/OS X) and a single download away on Windows. I'm assuming you have lots and lots of keywords to mark, so I've used perl which makes it easy to manage lists. Save it as a file highlight.pl
, enter your keywords, and run it like this (commandline):
perl highlight.pl document.tex > edited-document.tex
The script builds lists of space-separated words with qw(...)
. If you need to highlight multi-word spans, ask me to add an example of the appropriate syntax. You can set it up for any number of colors. Note also that the words will be combined into a regular expression, so you could use wildcards if needed.
#!/usr/bin/perl # Enter all the keys to highlight here, separated by whitespace. The lists# can extend over any number of lines. $keywords = join("|", qw(foo bar));$trouble = join("|", qw(biz baz));while (<>) { if (m/\\begin\{document\}/..m/\\end\{document\}/) { s/\b($keywords)\b/\\keyword{$1}/g; s/\b($trouble)\b/\\needswork{$1}/g; } print;}
The script will skip the preamble and substitute only in the body of the document.I demonstrate with two kinds of highlighting, \keyword{..}
and \needswork{...}
. What they do is up to you; use whatever macro names you want, and define them in your document's preamble.