Quantcast
Channel: Question and Answer » programming
Viewing all articles
Browse latest Browse all 103

Is there a way to have xesearch search and replace a term and have the replacement compiled as LaTeX command?

$
0
0

I have used the package xesearch https://www.ctan.org/pkg/xesearch?lang=en xesearch in my header to automatically replace shorthand notations:

usepackage{xesearch}
SearchList{list1}{Very Long Search Replacement 1}{SRa}
SearchList{list2}{Very Long Search Replacement 2}{SRb}

Which when put into the header acts to search and replace:

“SRa and SRb” into

“Very Long Search Replacement 1 and Very Long Search Replacement 2″

in the resulting document.

Which is great!

But it did occur to me that if I could have xesearch replace the placeholders with LaTeX commmands, and run them, at compile time that would be useful, eg:

usepackage{xesearch}
SearchList{list1}{SomeGreatLaTeXCommand[with options]}{SRa}
SearchList{list2}{AReallyFantasticLaTeXCommand}{SRb}

So that putting SRa in your code would result in SomeGreatLaTeXCommmand[with options] being compiled and same with SRb compiling as AReallyFantasticLaTeXCommand

I am aware that one can make substitute LaTeX commands as follows:

 newcommand{bc}{begin{center}}

Does anybody know a way for the xesearch package to be used in this manner? If xesearch cannot be put to work this way, is there another package that could do this type of automatic search and replace? Is there a way to do this without XeLaTeX? Or, is this a really very stupid question, because LaTeX/TEX is a programming language?


Viewing all articles
Browse latest Browse all 103

Trending Articles