paperweight.texutils¶
Utilities for maniuplating latex documents.
- paperweight.texutils.find_root_tex_document(base_dir='.')¶
Find the tex article in the current directory that can be considered a root. We do this by searching contents for '\documentclass'.
Parameters: base_dir : str
Directory to search for LaTeX documents, relative to the current working directory.
Returns: tex_path : str
Path to the root tex document relative to the current working directory.
- paperweight.texutils.iter_tex_documents(base_dir='.')¶
Iterate through all .tex documents in the current directory.
- paperweight.texutils.inline(root_text, base_dir='', replacer=None, ifexists_replacer=None)¶
Inline all input latex files.
The inlining is accomplished recursively. All files are opened as UTF-8 unicode files.
Parameters: root_txt : unicode
Text to process (and include in-lined files).
base_dir : str
Base directory of file containing root_text. Defaults to the current working directory.
replacer : function
Function called by re.sub() to replace \input expressions with a latex document. Changeable only for testing purposes.
ifexists_replacer : function
Function called by re.sub() to replace \InputIfExists expressions with a latex document. Changeable only for testing purposes.
Returns: txt : unicode
Text with referenced files included.
- paperweight.texutils.inline_blob(commit_ref, root_text, root_path, repo_dir='')¶
Inline all input latex files that exist as git blobs in a tree object.
The inlining is accomplished recursively. All files are opened as UTF-8 unicode files.
Parameters: commit_ref : str
String identifying a git commit/tag.
root_text : unicode
Text of tex document where referenced files will be inlined.
root_path : str
Path of file containing root_text relative to the git directory.
repo_dir : str
Directory of the containing git repository.
Returns: txt : unicode
Text with referenced files included.
- paperweight.texutils.inline_bbl(root_tex, bbl_tex)¶
Inline a compiled bibliography (.bbl) in place of a bibliography environment.
Parameters: root_tex : unicode
Text to process.
bbl_tex : unicode
Text of bibliography file.
Returns: txt : unicode
Text with bibliography included.
- paperweight.texutils.remove_comments(tex)¶
Delete latex comments from a manuscript.
Parameters: tex : unicode
The latex manuscript
Returns: tex : unicode
The manuscript without comments.