A convenient wrapper for latexpand
and bibtex
that flattens your complicated LaTeX project into a single .tex
file.
The following animation replicates the image shown above.
This step is also exactly the one shown in Example > RevTeX4-2 tex project (without .bbl embedding)
below.
test_revtex4-2_no_embed_bbl.mp4
You should have both latexpand
and bibtex
installed and added to your system path. If not, you should install TeX Live 2023 (or later) which includes all necessary LaTeX tools.
Obtain an .iso
image file from https://ftp.fau.de/ctan/systems/texlive/Images/
, mount it, and run the installer .bat
file. Installation should take about an hour depending on the specs of your computer.
TeX Live has a version specifically for macOS users, called MacTeX
. You can obtain the installer from https://tug.org/mactex/mactex-download.html
and follow the steps to install it. The tools should automatically be added to your system path.
You're using Linux, ∴ you should know what you're doing ;)
After you have both latexpand
and bibtex
installed, you can proceed to installing pylatexpand
. The steps listed here should apply to Windows, macOS, and Linux.
pip install pylatexpand
pip install https://github.com/bernwo/pylatexpand/archive/main.zip
To uninstall, simply run
pip uninstall -y pylatexpand
If installation is successful, you can run the following in your terminal
pylatexpand --help
and you should see the following output
usage: pylatexpand [-h] -i INPUT_MAIN_TEX_FILE [-C TEMPORARY_WORKING_DIRECTORY] [-E EXPANDED_TEX_FILENAME] [--embed-bbl | --no-embed-bbl]
Python wrapper for latexpand and bibtex
options:
-h, --help show this help message and exit
-i INPUT_MAIN_TEX_FILE, --input-main-tex-file INPUT_MAIN_TEX_FILE
name of the input tex file. File extension is optional
-C TEMPORARY_WORKING_DIRECTORY, --temporary-working-directory TEMPORARY_WORKING_DIRECTORY
temporarily change to your desired working directory
-E EXPANDED_TEX_FILENAME, --expanded-tex-filename EXPANDED_TEX_FILENAME
expanded tex filename
--embed-bbl, --no-embed-bbl
whether to embed `.bbl` file within the expanded `.tex` file or not (default=False). Note that the generation of `.bbl` is always automated.
This option is ignored if no `\bibliography{...}` is found within the input main `.tex` file.
Written by Wo
Clone the repository
git clone https://github.com/bernwo/pylatexpand.git
cd
into the root directory of the cloned repository, and then you can run the following examples. If successful, you should see mainExpanded.tex
file being created.
pylatexpand -C tests/tex_project_revtex4-2 -i main.tex --embed--bbl
pylatexpand -C tests/tex_project_revtex4-2 -i main.tex --no-embed--bbl
pylatexpand -C tests/tex_project_assignment -i main.tex
After cloning the repository as detailed above, you can run the tests via the command
pytest tests
If the installation is successful, you should see all test cases passing. Note that you need to install pytest
first to run this command. You can install it via pip install pytest
.