GroupDocs.Merger for Python via .NET merges TeX documents into one file, for example to keep the sections of a report together or to send fewer attachments, without any TeX distribution or other software installed.
How to merge TEX files in Python
Create an instance of the Merger class and pass the path to the first TEX file.
Call merger.join() with the path to each TEX file to append.
Call merger.save() with the path of the merged TEX file.
fromgroupdocs.mergerimportMergerdefmerge_tex_files():# Load the first TEX filewithMerger("./input.tex")asmerger:# Append the second TEX filemerger.join("./input2.tex")# Save the merged documentmerger.save("./output.tex")if__name__=="__main__":merge_tex_files()
input.tex is a sample file used in this example. Click here to download it.
input2.tex is a sample file used in this example. Click here to download it.
Explanation
Load the first file: Merger("./input.tex") opens the first TeX document inside a context manager.
Append another file: merger.join("./input2.tex") appends the second document. Call join again for each additional file.
Save the result: merger.save("./output.tex") writes the merged TeX document to disk.
About the TEX file format
TeX is a typesetting language, with programming as well as markup features, created by Donald Knuth at Stanford University. Authors and publishers around the world use it to produce technical documents, and it is known for typesetting complex mathematical expressions.
Merge TEX Live Demo
GroupDocs.Merger provides a free online TEX Merger App, which allows you to try it and check its quality.