Is there a way to find a specific sequence of tokens and add after it a command? Or is there a way to find a specific sequence of tokens and replace it with another one? And do it only if the sequence of tokens is in the input file, otherwise don't leave any error message.
For example the command \AtBeginDocument{\bfseries}
finds the string \begin{document}
and add to it \bfseries
. Is there a way to get a more general command that find any kind of string and add to it another one? Something like this:
\if@tokensequenceisgivenadd{<String to find>}% or more shortly \if@tokenadd
<Add after it this string>
\fi
and I would another command like the following:
\if@tokensequenceisgivenreplace{<String to find>}% or more shortly \if@tokenreplace
<Replace it with this string>
\fi
etoolbox
package, namely the\patchcmd
command.