View source: R/PreambleAdjustment.R
ReplacePreambleCommand | R Documentation |
This functions gets a character vector in which each element represents a line of
a preamble of a 'LaTeX' document, and it replaces the definition of the command \commandName
to have the value commandValue
.
ReplacePreambleCommand(x, commandName, commandValue)
x |
A character vector, each element is suppose to represent a line |
commandName |
A string identifying either the command name |
commandValue |
Replacement for the definition of commandName |
It only modifies the value of the command by replacing instances of
\newcommand{\commandName}{<previous definition>}
with instances of
\newcommand{\commandName}{<commandValue>}
.
Keep in mind that both commandName
and commandValue
are placed directly inside a regex.
If you want to "hide" a certain definition of a command from being found and replaced by this function, simply define it by using \def
or \newcommand*
or a \renewcommand
when you define them.
Make sure you are using a one-line definition in commands that you want replaced, since this won't be able to detect commands that are defined in multiple lines in 'LaTeX'.
Also, note how certain invalid things in 'LaTeX' would still be matched by this regex, however you should find those errors before you start using this program since those errors would not allow you to compile the 'LaTeX' document on the first place.
Lastly, if it doesn't find a command on the document, it silently ignores it.
A character vector, with the preamble, replacing all instances of
\newcommand\commandName{<random text>}
with
\newcommand\commandName{commandValue}
Other Preamble adjustment:
ReplaceFromTable()
new_preamble <- ReplacePreambleCommand( TexExamRandomizer::testdoc$preamble, "nickname", "Alex")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.