latex
thmd.post.latex
¶
Functions:
-
get_citekeys–Extract all citekeys from a list of
.texfiles. -
select_entries–Select bibliography entries from a Bibtex
.bibfile -
write_bibtex–Write bibliography data to a Bibtex
.bibfile -
minimize_bibtex–Minimize the
.bibfile so that it contains only entries that are cited in the.texfiles. -
check_bibtex–Check for missing fields in the bibtex entries. Based on the
typeof the entry, there are mandatory fields. This function is to check if any of mandatory fields is missing. -
tex2doc–Convert a Latex source
.texfile to a Microsoft Word.docxfile. -
tex2pdf–Convert a Latex source
.texfile to a Microsoft Word.docxfile. -
replace_acronyms–Check and replace if acronyms are used in a
.texfile. -
count_cited_journals–Count the number of times each journal is cited in the
.bibfile.
get_citekeys(tex_files: Union[str, list]) -> list
¶
Extract all citekeys from a list of .tex files.
Parameters:
-
tex_files(Union[str, list]) –paths to
.texfiles
Returns:
-
citekeys(list) –list of citekeys
select_entries(citekeys: list, bib_file: str) -> BibliographyData
¶
Select bibliography entries from a Bibtex .bib file
Parameters:
-
citekeys(list) –list of citekeys
-
bib_file(str) –path to a
.bibfile
Returns:
-
BibliographyData(BibliographyData) –selected bibliography entries. See pybtex.database.BibliographyData
write_bibtex(bib_data: BibliographyData, out_file: str = 'reference.bib') -> None
¶
Write bibliography data to a Bibtex .bib file
Parameters:
-
bib_data(BibliographyData) –bibliography entries. See pybtex.database.BibliographyData
-
out_file(str, default:'reference.bib') –path to the output
.bibfile
minimize_bibtex(tex_files: Union[str, list], bib_file: str, out_file: str = 'reference_min.bib') -> None
¶
Minimize the .bib file so that it contains only entries that are cited in the .tex files.
Parameters:
-
tex_files(Union[str, list]) –path to
.texfiles -
bib_file(str) –path to the original
.bibfile -
out_file(str, default:'reference_min.bib') –path to the new
.bibfile
check_bibtex(bib_file: str, verbose: bool = True, logfile: bool = False, lower_key=False) -> list
¶
Check for missing fields in the bibtex entries. Based on the type of the entry, there are mandatory fields. This function is to check if any of mandatory fields is missing.
Parameters:
-
bib_file(str) –path to the original
.bibfile. -
verbose(bool, default:True) –print output to the console.
-
logfile(bool, default:False) –write output to a log file.
-
lower_key(bool, default:False) –convert the keys in
bib_fileto lower case.
Examples:
tex2doc(tex_file: str, out_file: str = 'output.docx', bib_file: str = None, **kwargs)
¶
Convert a Latex source .tex file to a Microsoft Word .docx file.
Need to install pandoc and panflute first.
Parameters:
-
tex_file(str) –path to the
.texfile -
out_file(str, default:'output.docx') –path to the output
.docxfile -
bib_file(str, default:None) –path to the
.bibfile
Other Parameters:
-
cite_style(str = 'elsevier_vancouver.csl') –path to the citation style
.cls' file. Can download from [here](https://github.com/citation-style-language/styles) or inZotero_folder/styles` -
reference_doc(str) –path to the reference
.docxfile -
resource_path(str = './figure') –path to the folder containing the figures and other resources.
-
verbose(bool = False) –print the output of the command
-
pandoc-crossref(bool = True) –use the
pandoc-crossrefextension for equation numbering
tex2pdf(tex_file: str, out_file: str = 'output.pdf', bib_file: str = None, **kwargs)
¶
Convert a Latex source .tex file to a Microsoft Word .docx file.
Parameters:
-
tex_file(str) –path to the
.texfile -
out_file(str, default:'output.pdf') –path to the output
.docxfile -
bib_file(str, default:None) –path to the
.bibfile
Other Parameters:
-
cite_style(str = 'elsevier_vancouver.csl') –path to the citation style `.cls' file. Can download from here
-
resource_path(str = './figure') –path to the folder containing the figures and other resources.
-
verbose(bool = False) –print the output of the command
replace_acronyms(tex_file: str, acronyms: dict) -> list
¶
Check and replace if acronyms are used in a .tex file.
Not implemented yet.
count_cited_journals(bib_file: str) -> dict
¶
Count the number of times each journal is cited in the .bib file.
Parameters:
-
bib_file(str) –path to the
.bibfile
Returns:
-
dict(dict) –a dictionary containing the journal names and the number of times they are cited.