View source: R/cites_replace_author.R
single_replace_author | R Documentation |
single_replace_author
function modifies LaTeX citation commands to add parentheses around them,
transforming commands such as \cite{...}
into (\cite{...})
.
cites_replace_author
function processes a LaTeX document to transform all numeric citations into author-year style
by wrapping citation commands in parentheses.
single_replace_number
function transforms LaTeX citation commands from an author-year style (e.g., (\cite{...})
)
back to their original form (e.g., \cite{...}
).
cites_replace_number
function processes a LaTeX document to remove parentheses around citation commands,
converting citations from an author-year style back to numeric style.
single_replace_author(
text,
latex_prefix = c("cite", "upcite", "citep", "citet")
)
cites_replace_author(tex)
single_replace_number(
text,
latex_prefix = c("cite", "upcite", "citep", "citet")
)
cites_replace_number(tex)
text |
A single string of LaTeX content. |
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 searches for LaTeX citation commands using regular expressions. For each matched command, it appends and prepends parentheses to create the author-year citation style. Excessive whitespace in the resulting text is removed to ensure formatting consistency.
If no matching citation commands are found, the input text is returned unchanged.
This function applies single_replace_author
to each line or section of the LaTeX document,
ensuring that citation commands such as \cite{...}
and \citet{...}
are converted into
(\cite{...})
and (\citet{...})
, respectively.
The function identifies citation commands enclosed in parentheses and removes the parentheses, restoring the original citation format. Excessive whitespace in the resulting text is removed for formatting consistency.
If no matching citation commands are found, the input text is returned unchanged.
This function applies single_replace_number
to each line or section of the LaTeX document,
ensuring that citations like (\cite{...})
are transformed back into \cite{...}
.
A string where all matched citation commands are wrapped in parentheses.
A character vector with LaTeX content where all citation commands are converted to author-year style.
A string where parentheses around matched citation commands are removed.
A character vector with LaTeX content where parentheses around citation commands are removed.
single_replace_author
single_replace_number
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 }")
tex = cites_replace_author(tex)
print(tex)
tex2 = cites_replace_number(tex)
print(tex2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.