Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Is it possible and furthermore constructive to make LaTeX automatically format specific words in specific way? Let's say, for example, I'd like to have every occurrence of the word "hello" in a bold cyan monospaced serif font (whereas the rest of the document remains normal, sans serif and black).

How can I achieve that without having to do a search&replace to place "hello" into a custom command everytime before I compile the .tex file?

share|improve this question
    
You can, for example, run sed -i … by \write18 and modify text file before compiling it by latex. –  Eddy_Em Apr 5 '13 at 12:17
3  
Wouldn't it be easier, if possible, to do that type of formatting in advance in the input file itself, by defining a custom \hello macro? –  Jubobs Apr 5 '13 at 12:25
add comment

1 Answer

Compile this with XeLaTeX

\documentclass{article}
\usepackage{color,xesearch}

\SearchList*{redwords}{\textcolor{red}{#1}}{hello}

\begin{document}
This is hello and this is hellow.
\end{document}

enter image description here

But don't use it. If you want to specially mark a word, use a macro.

Why? Relying on automatic procedures is always risky: if I have a choice, I prefer explicit mark up. Another reason is that xesearch is resource hungry and currently unmaintained.

There's nothing similar for pdflatex; something can possibly be done with LuaLaTeX. I tried chickenize but it doesn't seem to offer the feature.

share|improve this answer
add comment

Your Answer

 
discard

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.