This is to indicate changes for a LaTeX file. Say, I wanted to add a vertical line to the beginning of a line whenever"word 1", "word 2", …", or "word 100" appears. Manually this can be done in order to determine where "word 1" appears, but it can be tedious if there are many "word" and if the process needs to be repeated again. So what is the intelligent way to do this?
I use this as an example to add vertical line
| when word 1 appears and another vertical line
| word 2 appears.
Best Answer
I use an adaptation of my
titlecaps
package, normally used for capitalizing the first letter of each word, given a string of words (with user-specified exceptions). Therefore, instead of capping words, I leave them unchanged. However, I use the code that searches for the user-specified exceptions to both place a rule in the left margin and to change the color of the highlighted word (those two features operate independently and either can be disabled without affecting the other).I use the
tabto
package to facilitate the marginal line notation.Words to be searched for are specified by the macro
\WordsToNote{word1 word2 word3}
, a space-separated list. Subsequent invocations are cumulative, so that\WordsToNote{word1 word2}\WordsToNote{word3}
is functionally equivalent to the former invocation. The list of words may be reset with\Resetlcwords
.The macro invocation on the paragraph is simply
\NoteWords{<text>}
.As with the
titlecaps
package, it can handle a limited subset of macro invocations including text size changes and style changes.EDITED to handle multiple paragraphs at a time. FIXED so that a new
\par
is not automatically issued at the end of the macro.Please note: the line
\textwidth4in\relax\sloppy
I purposefully placed in the MWE code to reduce the margins and eliminate overfull boxes. Please remove them before using this code in other venues.