find_pattern {parseLatex} | R Documentation |
Find a pattern in deparsed items
Description
Searches a LaTeX2 list for text using grepl()
on deparsed versions of parts of the code.
It attempts to find the narrowest match(es) that lie
within a single container.
Usage
find_pattern(items, pattern, ..., all = FALSE)
Arguments
items |
A list of latex items. |
pattern |
Pattern to use in |
... |
Additional parameters to pass to |
all |
Find all matching, or the first? |
Details
find_pattern()
does a recursive search in the order
items appear in the deparse. If the pattern matches,
it attempts to narrow the match by recursing into
containers and dropping earlier and later items.
It should always return syntactically correct LaTeX
code in which the pattern appears.
Value
find_pattern()
returns a LaTeX2range object
or (if all
is TRUE
) a list of them.
Examples
latex <- kableExtra::kbl(mtcars[1:2, 1:2], format = "latex", caption = "Sample table")
parsed <- parseLatex(latex)
parsed
loc <- find_pattern(parsed, "RX4 Wag", fixed = TRUE)
loc
print(loc, source = parsed)
[Package parseLatex version 0.4.1 Index]