ReplacePreambleCommand: ReplacePreambleCommand In TexExamRandomizer: Personalizes and Randomizes Exams Written in 'LaTeX'

Description

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.

Usage

 1 ReplacePreambleCommand(x, commandName, commandValue) 

Arguments

 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

Details

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.


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.

Value


Other Preamble adjustment: ReplaceFromTable
 1 new_preamble <- ReplacePreambleCommand( TexExamRandomizer::testdoc\$preamble, "nickname", "Alex")