This "flattens" a LaTeX document by replacing all \input{X}
lines with the text actually contained in X. It uses the click
module to create a command line interface.
Two new options are available:
- Specify a .tex subfolder for input files similarly to what the
input@path
command does in the main file - Launch an interactive session to allow the user to select only specific sections to import
It was inspired by this discussion on Stack Overflow. There are C and perl versions of this, but I wanted a pure python version to fit in with my existing paper-creating toolchain.
git clone https://github.com/johnjosephhorton/flatex.git
cd flatex
pip install --editable .
As a stand-alone script:
flatex inputfile.tex outputfile.tex
If you want to include the bbl file as well:
flatex --include_bbl inputfile.tex outputfile.tex
If you want to specify a .tex subfolder:
flatex inputfile.tex outputfile.tex --tex_folder folder_name
If you want to select only specific input files to expand:
flatex inputfile.tex outputfile.tex --interactive
- It does also recognize
\includes
commands, but this has not been tested. - Tested for nested inputs, although not extensively (only two levels deep).
- Tested for file living in subdirectories, only one level deep.
- The test case writes to the /tmp folder - so the test probably wouldn't work on Windows(?).
Copyright, 2015, John J. Horton (john.joseph.horton@gmail.com) Distributed under the terms of the GNU General Public License See http://www.gnu.org/licenses/gpl.txt for details.