Given a 'LaTeX' file represented as a character vecotr with x
, it replaces from a table the commands given by commandNames
. for the values found on the table.
\newcommand{\commandName[i]}{table[tableRow, columnName[i]]}
.
Arguments
- x
A character vector, each element is suppose to represent a line
- table
Data frame from which to extract the information
- tableRow
Integer, row of the
table
to be used- columnNames
Character vector with the names of the columns to be used
- commandNames
Character vector with the same length as
columnNames
. Contains the names of the 'LaTeX' commands to be replaced.
Value
A character vector, representing the text x
, where all instances of
\newcommand\commandNames[i]{<random text>}
have been replaced with
\newcommand\commandNames[i]{table[tableRow, columnName[i]}
.
Details
To do the replacement for each item, it uses the function ReplacePreambleCommand
. See the details in that function for more information.
See also
Other Preamble adjustment:
ReplacePreambleCommand()
Examples
custom_preambles <- list()
for (i in 1:nrow(TexExamRandomizer::testclass)) {
custom_preambles <-
c(
custom_preambles,
list(
TexExamRandomizer::ReplaceFromTable(
TexExamRandomizer::testdoc$preamble,
table = TexExamRandomizer::testclass,
tableRow = i,
columnNames = c("Class", "Roll.Number", "Nickname"),
commandNames = c("class", "rollnumber", "nickname")
)
)
)
}