Quantcast
Channel: Highlight every occurrence of a list of words? - TeX - LaTeX Stack Exchange
Viewing all articles
Browse latest Browse all 7

Answer by Aditya for Highlight every occurrence of a list of words?

$
0
0

ConTeXt provides a proof of concept module for such translations: m-translate. You could use it to translate text, but the translation takes place before macro expansion. So, the method will fail if the translation string is part of a macro name.

The translation can be enabled and disabled using \enableinputtranstion and \disableinputtranslation. Here is an example, which a little wrapper macro for ease of input.

\usemodule[translate]\define\defineautocoloring    {\dodoubleargument\dodefineautocoloring}\def\dodefineautocoloring[#1][#2]%    {\def\dododefineautocoloring##1%          {\translateinput[##1][{\color[#1]{##1}}]}%     \processcommalist[#2]\dododefineautocoloring}\defineautocoloring[red][foo, bar]\defineautocoloring[blue][color]\setuppapersize[A5]\starttext\enableinputtranslationThis is a foo example of coloring random bar text. What is foobar? Thetranslation is done before macro expansion, so weird stuff can happen:\type{foobar}\disableinputtranslationThis is a foo example of coloring random bar text. What is foobar? Thetranslation is done before macro expansion, so weird stuff can happen:\type{foobar}\stoptext

which gives

enter image description here


Viewing all articles
Browse latest Browse all 7

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>