tex_funs: Clean up and standardize spacing in a given text

View source: R/tex_funs.R

single_add_spaceR Documentation

Clean up and standardize spacing in a given text

Description

This function processes a given string by cleaning up extra spaces, handling punctuation, and adjusting mathematical symbols according to specific formatting rules.

This function takes a vector of LaTeX-formatted strings and applies the single_add_space function to each string to standardize spacing throughout the document.

Usage

single_add_space(text)

tex_funs(tex, fun = single_add_space, ...)

Arguments

text

A single character string (input text) that needs to be processed.

tex

A vector of strings (LaTeX document or text) to be processed.

fun

The function to be applied to each string in the vector (default is single_add_space).

...

Additional arguments to be passed to the function.

Details

see function single_add_space source code for details.

Value

A cleaned-up string where multiple spaces are reduced to one, unnecessary spaces are removed, and spaces are appropriately added around certain punctuation and mathematical symbols.

A vector of processed strings where unnecessary spaces have been removed or adjusted.

Examples

tex =c("This is a citation,and.",
       "This is a citation2 $x ^ 2+y^ 2 = z^2.$ and this is equ",
       "this is no , citation")
tex = tex_funs(tex)
print(tex)

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