Skip to main content

Markdown to Latex to PDF generator

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gentexdoc-0.4.1.tar.gz (18.9 kB view details)

Uploaded Source

Built Distribution

gentexdoc-0.4.1-py3-none-any.whl (20.0 kB view details)

Uploaded Python 3

File details

Details for the file gentexdoc-0.4.1.tar.gz.

File metadata

  • Download URL: gentexdoc-0.4.1.tar.gz
  • Upload date:
  • Size: 18.9 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for gentexdoc-0.4.1.tar.gz
Algorithm Hash digest
SHA256 58d65bfda33ccefaa9b0bba39bbe3ade4b1f490e891feffdc4eb42d68e7902fd
MD5 0c892cbd98f0a9b7512afeae57cd10f3
BLAKE2b-256 89e3a71459d86201c9a76bb3daf28858dbf116e1e424dcb587555d4c70ff4a27

See more details on using hashes here.

File details

Details for the file gentexdoc-0.4.1-py3-none-any.whl.

File metadata

  • Download URL: gentexdoc-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 20.0 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for gentexdoc-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 87e5b7d97fbbf938ab17e55b034492cabe3f23645c901cbc37f76b1e9ba5ae03
MD5 8cd353d8d1d0b9446009241a39c4cb6b
BLAKE2b-256 63ac622961efdf19d3677aca4a8ab71ee7a7fd41ced1410e9f4bb617420dd0bf

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page