View source: R/cites_replace_order.R
single_replace_order | R Documentation |
single_replace_order
function modifies LaTeX citation commands to reorder citation keys based on a provided order.
cites_replace_order
function processes a LaTeX document to reorder all citation keys within citation commands
based on their first appearance in the document.
single_replace_order(
text,
citesall = NULL,
latex_prefix = c("cite", "upcite", "citep", "citet")
)
cites_replace_order(tex, citesall = NULL)
text |
A single string of LaTeX content. |
citesall |
A character vector containing all citation keys in the desired order. If not provided, default applies |
latex_prefix |
A character vector of LaTeX citation commands to be matched (default: |
tex |
A character vector where each element represents a line or section of LaTeX content. |
The function identifies LaTeX citation commands and reorders their arguments (e.g., \cite{key1,key2}
)
to match the order specified in citesall
. If a citation contains only one key, it remains unchanged.
Matched citation keys not found in citesall
are excluded from the reordered result.
The function extracts all citation keys using cites_extract
, determines their order based on first occurrence,
and applies single_replace_order
to reorder keys in each citation command.
A string with citation keys reordered within the specified citation commands.
A character vector with updated LaTeX content where citation keys in commands are reordered.
single_replace_order
, cites_extract
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 }")
citesall = cites_extract(tex)
citesall = c("key2", "key1", "key3-a", "key4")
cites_replace_order(tex, citesall)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.