Replacing all instances of one set of words with another word
3,824
Solution 1
In Texmaker, you can use Replace All. You use hot key Ctrl + R.
Solution 2
If you're willing and able to use LuaLaTeX, one could write a Lua function that performs the string replacement job "on the fly".
That said, I'd say it must be easier to do this replacement once and for all in one's text editor.
% !TeX program = lualatex
\documentclass{article}
\usepackage{luacode}
\begin{luacode}
function bezier ( s )
return ( string.gsub ( s , "[Bb]ezier", "B\\'ezier" ) )
end
\end{luacode}
\AtBeginDocument{\directlua{luatexbase.add_to_callback(
"process_input_buffer", bezier, "bezier" )}}
\begin{document}
aaa bezier bbb Bezier ccc
\end{document}
Related videos on Youtube
Author by
Sam Harper
Updated on December 29, 2020Comments
-
Sam Harper almost 3 years
I wish to replace all instances of
Bezier
andbezier
withB\'{e}zier
in my LaTeX document. It's in a masters thesis of 30 pages.Two questions. How could one achieve the above with a new command or similar approach? And, is it going to be worth the amount of time i save or will it likely cause some issues further down the line?
-
Au101 almost 7 yearsSurely it's much much easier to do this with the editor. Simple find and replace
-
Sam Harper almost 7 yearsi would agree @Au101 but i have probably used the following about 150 times throughout the paper, so just tying to find a time effiecient possibility
-
jon almost 7 yearsRepetitive tasks are better left to a computer than a human, but that doesn't mean TeX is always the way to do it. In this case, things like
sed
orawk
(or etc.) are the better choice. (And, off-topic, but, in 2016, use UTF-8 and input ané
directly rather than\'{e}
.)
-