from multimark import markdown_to_latex
markdown_to_latex("**bold** and *italic*")'\\textbf{bold} and \\emph{italic}\n'
Parse CommonMark/GFM and render as LaTeX.
Usage
Converts Markdown to LaTeX source suitable for inclusion in a .tex document. Inline formatting maps to LaTeX commands (\textbf{}, \emph{}, \texttt{}), headings become sectioning commands (\section{}, \subsection{}, etc.), and links use \href{}{}.
The output is a fragment (not a full document): it does not include \documentclass, \begin{document}, or preamble. You can concatenate it into your own LaTeX document structure.
text: strThe Markdown string to parse and render. Must be a Python str.
hardbreaks: bool = FalseRender soft line breaks as hard breaks (\\). By default, this is False.
smart: bool = FalseConvert straight quotes to curly quotes, -- to en-dashes, --- to em-dashes, and ... to ellipses. By default, this is False.
normalize: bool = FalseConsolidate adjacent text nodes in the parsed AST. By default, this is False.
unsafe: bool = FalseAllow raw HTML to pass through. Since LaTeX is the target format, raw HTML is typically irrelevant. By default, this is False.
footnotes: bool = FalseEnable footnote syntax parsing. By default, this is False.
extensions: Sequence[str] = ()
A sequence of GFM extension names to enable. Valid names are "table", "strikethrough", "autolink", "tagfilter", and "tasklist".
width: int = 0The column at which to wrap output lines. Set to 0 (the default) to disable line wrapping entirely. A value like 80 produces lines of at most 80 characters where possible.
options: int = 0Options.SMART | Options.UNSAFE). Merged via OR with any boolean keyword arguments set to True. Defaults to 0.
The boolean keyword arguments (smart, unsafe, hardbreaks, etc.) are convenience shortcuts for the most common Options flags. When both styles are provided, they are merged via OR. See markdown_to_html() for a detailed explanation.
strRender inline formatting:
'\\textbf{bold} and \\emph{italic}\n'
Render a heading:
Enable line wrapping at 72 columns:
This is a very long paragraph. This is a very long paragraph. This is a
very long paragraph. This is a very long paragraph. This is a very long
paragraph. This is a very long paragraph. This is a very long paragraph.
This is a very long paragraph. This is a very long paragraph. This is a
very long paragraph.
Use smart punctuation for typographic output: