from trouver.helper.tests import _test_directory
# from trouver.latex.preamble import divide_preamble
latex
The latex
module contains the following submodules:
latex.convert
- Combines the functionalities of the below modules to convert a LaTeX file into folder is an
Obsidian.md
vault.
- Combines the functionalities of the below modules to convert a LaTeX file into folder is an
latex.divide
- Divide the LaTeX file into parts
latex.folders
- Based on the division of the LaTeX files into parts via
latex.divide
, creates folders to house notes that are to be made from these parts.
- Based on the division of the LaTeX files into parts via
latex.formatting
- Modifies formatting for the parts and warns users of unexpected formatting in the LaTeX documents.
Identify the main tex file in a folder
find_main_latex_file
find_main_latex_file (directory:os.PathLike)
*Identify the main LaTeX file in a given directory.
The main LaTeX file is determined based on the presence of: - A \documentclass command - A \begin{document} command
Parameters: - directory: The path to the directory containing LaTeX files.
Returns: - The full path to the main LaTeX file if found; otherwise, raises an error.
Raises: - FileNotFoundError: If no suitable main LaTeX file is found.*
Type | Details | |
---|---|---|
directory | PathLike | |
Returns | Path | The full path to the main LaTeX file if found; otherwise, raises an error. |
= _test_directory() / 'latex_examples' / 'latex_example_with_inputs_and_includes'
latex_folder
find_main_latex_file(latex_folder)# main_file = latex_folder / 'main.tex'
# with open(main_file, 'r', encoding='utf-8') as file:
# document = file.read()
# preamble, body = divide_preamble(document)
# commands = custom_commands(preamble)
# output = replace_input_and_include(body, latex_folder, commands)
WindowsPath('c:/Users/hyunj/Documents/Development/Python/trouver/nbs/_tests/latex_examples/latex_example_with_inputs_and_includes/main.tex')