ReplacePreambleCommand: ReplacePreambleCommand

Description Usage Arguments Details Value See Also Examples

View source: R/PreambleAdjustment.R

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.

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.

Value

A character vector, with the preamble, replacing all instances of \newcommand\commandName{<random text>} with \newcommand\commandName{commandValue}

See Also

Other Preamble adjustment: ReplaceFromTable

Examples

1
new_preamble <- ReplacePreambleCommand( TexExamRandomizer::testdoc$preamble, "nickname", "Alex")

TexExamRandomizer documentation built on May 2, 2019, 3:18 a.m.