cites_extract: Extract Single Citation Keys from LaTeX Text

View source: R/cites_extract.R

single_cites_extractR Documentation

Extract Single Citation Keys from LaTeX Text

Description

single_cites_extract function extracts all citation keys from a LaTeX string based on specific citation commands.

cites_extract function extracts all unique citation keys from a LaTeX document.

Usage

single_cites_extract(text)

cites_extract(tex)

Arguments

text

A character vector containing LaTeX content.

tex

A character vector where each element represents a line or section of LaTeX content.

Details

The function identifies citation commands such as cite, upcite, citep, and citet. It extracts the content within braces following these commands, and splits multiple keys separated by commas.

This function uses single_cites_extract to extract citation keys from each line or section of the LaTeX document. It removes duplicates and trims unnecessary whitespace.

Value

A character vector of citation keys, or NULL if no citations are found.

A unique character vector of citation keys.

Examples

tex= c("This is a citation \\upcite{key1,key2} and \\citep{key3-a }",
      "This is a citation \\citet{key1,key2} and \\citet{key3-a }",
      "this is no citation",
      "",
      "This is a citation \\upcite{key1,key4} and \\cite{key3-a }")
cites_extract(tex)



zoushucai/journalabbr documentation built on Dec. 6, 2024, 4:41 p.m.