# Merge TEX Learn how to merge TEX files, combine TeX documents into one file programmatically in Python using GroupDocs.Merger for Python via .NET. 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 1. Create an instance of the `Merger` class and pass the path to the first TEX file. 2. Call `merger.join()` with the path to each TEX file to append. 3. Call `merger.save()` with the path of the merged TEX file. {{< tabs "merge-tex-example" >}} {{< tab "merge_tex_files.py" >}} ```python from groupdocs.merger import Merger def merge_tex_files(): # Load the first TEX file with Merger("./input.tex") as merger: # Append the second TEX file merger.join("./input2.tex") # Save the merged document merger.save("./output.tex") if __name__ == "__main__": merge_tex_files() ``` {{< /tab >}} {{< tab "input.tex" >}} {{< tab-text >}} `input.tex` is a sample file used in this example. Click [here](https://docs.groupdocs.com/merger/python-net/_sample_files/developer-guide/merge/tex/input.tex) to download it. {{< /tab-text >}} {{< /tab >}} {{< tab "input2.tex" >}} {{< tab-text >}} `input2.tex` is a sample file used in this example. Click [here](https://docs.groupdocs.com/merger/python-net/_sample_files/developer-guide/merge/tex/input2.tex) to download it. {{< /tab-text >}} {{< /tab >}} {{< /tabs >}} ### 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**](https://products.groupdocs.app/merger/tex), which allows you to try it and check its quality. ## API reference - [`Merger`](https://reference.groupdocs.com/merger/python-net/groupdocs.merger/merger/) — main class; `join`, `save` methods. ## See also - [Merge text files]({{< ref "merger/python-net/developer-guide/merge/text.md" >}}) - [Supported document formats]({{< ref "merger/python-net/getting-started/supported-document-formats.md" >}}) - [More use-cases and complete Python via .NET sources]({{< ref "merger/python-net/showcases.md" >}})