nth_arg_positions(
tex_lines,
command_name,
n = 1L,
optional = FALSE,
star = TRUE,
data.tables = TRUE,
allow_stringi = TRUE
)
Arguments
tex_lines
A character vector of a LaTeX file (as read in from readLines or readr::read_lines).
command_name
The command name,
or the pattern of the command, without the initial backslash.
n
Which argument of the command.
replacement
What to replace the nth argument with.
optional
If FALSE, the default, the nth mandatory argument is extracted.
If TRUE, the nth optional argument is extracted.
warn
If the nth argument is not present, emit a warning? Set to FALSE for n-ary commands.
.dummy_replacement
An intermediate replacement value.
This value cannot be present in tex_lines.
star
Assume the starred version of the command. That is, assume that the contents of
the argument lies on a single line.
data.tables
Should each element of the list be a data.table? Set to FALSE
for performance.
allow_stringi
(logical, default: TRUE) If FALSE, non-stringi
functions are allowed.
Details
nth_arg_positions reports the starts and stops of the command for every line.
This includes the braces (in order to accommodate instances where the argument is empty).
If the line is empty or does not contain the command the values of starts and stops are NA_integer_.