Latex document generator
Latex document generator (or GenTexDoc) is a utility that enables its users to generate PDF documents by inserting Markdown code inside a Latex template.
Installation
- Install fontconfig:
sudo apt install fontconfig - Install pandoc (for the markdown to Latex conversion):
sudo apt install pandoc - Install XeLateX (for the Latex to PDF conversion):
sudo apt install texlive-xetex texlive-lang-french texlive-font-utils - Install GenTexDoc:
pip install gentexdoc
Custom fonts then need to be placed in the /usr/local/share/fonts directory.
How does it work?
GenTexDoc uses Jinja2 formatted Latex templates. The Jinja2 syntax allows named elements to be inserted inside the Latex document.
These named elements are meant to be written in the Markdown format, and are converted from Markdown to Latex using Pandoc.
A named element can be either a block of Markdown code, or simply a one-line variable.
How to use it
Writing a Latex template
First, create a Latex template. It will serve as a base for your documents.
In the template, make references to named elements with the Jinja2 syntax {{ element_name }}, where element_name is the name of the element you'd like to insert in your document.
For this example, we'll consider the template below:
%%%%%%%%%% HEADER %%%%%%%%%%
\documentclass[a4paper]{scrarticle}
{{ builtin.packages }}
\title{Test document}
\date
{
\vspace{-1.5cm}
{{ date }}
}
%%%%%%%%%% DOCUMENT %%%%%%%%%%
\begin{document}
\maketitle
{{ content }}
\end{document}
Note that in the example, we're inserting the named entity builtin.packages. This entity contains a list of packages that are necessary for all markdown features to be used properly.
Writing markdown input files
Then, write a markdown input file that defines the necessary elements.
- To define a variabe, use the syntax
[var]: <varname> (value) - To define a block, use the syntax:
[block]: <blockname>
(Block content)
[endblock]: <blockname>
In the example below, we're defining a variable named date and a block named content.
# My awesome markdown input file
[var]: <date> (10/10/2021)
[block]: <content>
This is the content of my document.
[endblock]: <content>
Generate the PDF
After writing your template and your markdown input files, all that's left to do is to generate the final PDF file.
If your template is named template.tex, and your only markdown input file is named document.md, then you can generate a PDF named document.pdf with the command: gentexdoc -t template.tex document.md -o document.pdf
Note that the output file doesn't need to be specified in that case.
License
This project is licensed under the GNU GPLv3 license.
Metadata
Release files for gentexdoc 0.4.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| gentexdoc-0.4.1.tar.gz | 18.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| gentexdoc-0.4.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 38.9 kB
Release files / gentexdoc-0.4.1.tar.gz
| Download URL | gentexdoc-0.4.1.tar.gz |
|---|---|
| Size | 18.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
58d65bfda33ccefaa9b0bba39bbe3ade4b1f490e891feffdc4eb42d68e7902fd
|
|
BLAKE2b-256 checksum How to use checksums |
89e3a71459d86201c9a76bb3daf28858dbf116e1e424dcb587555d4c70ff4a27
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2
|
Release files / gentexdoc-0.4.1-py3-none-any.whl
| Download URL | gentexdoc-0.4.1-py3-none-any.whl |
|---|---|
| Size | 20.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
87e5b7d97fbbf938ab17e55b034492cabe3f23645c901cbc37f76b1e9ba5ae03
|
|
BLAKE2b-256 checksum How to use checksums |
63ac622961efdf19d3677aca4a8ab71ee7a7fd41ced1410e9f4bb617420dd0bf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2
|