find_caption: Find or drop captions

View source: R/captions.R

find_captionR Documentation

Find or drop captions

Description

Find or drop captions

Usage

find_caption(items)

drop_caption(items, idx = NULL)

path_to_caption(items)

Arguments

items

A LaTeX2 or other list of LaTeX2items.

idx

NULL or a vector of the same length as items

Value

find_caption() returns a LaTeX2range object for any caption text, with an attribute extra holding the range of associated macros and whitespace.

drop_caption() returns the items with captions dropped as a LaTeX2 object. It has an attribute named idx that is the idx argument with corresponding elements dropped.

path_to_caption() returns a path containing the location of the first caption block within items. It has an attribute extra containing a LaTeX2range object for the associated macros and whitespace.

Examples

parsed <- parseLatex("before \\caption{This is a caption} \\\\ after")
idx <- find_caption(parsed)
get_range(parsed, idx)
get_range(parsed, attr(idx, "extra"))
drop_caption(parsed)
path_to_caption(parsed)

parseLatex documentation built on June 8, 2025, 10:19 a.m.