Markdown in LaTeX #
After the experiments below, I have decided that this package is not yet fully production-ready, and am now only using it for snippets (e.g. lists). May come back and re-evaluate in the future.
- CTAN: Package markdown
- Repo: Witiko/markdown: :notebook_with_decorative_cover: A package for converting and rendering markdown documents in TeX
- Doc: Markdown Package User Manual
Compile #
lualatex -synctex=1 -interaction=nonstopmode
Quick start template #
tightLists=false
is necessary immediately at\usepackage
to prevent clashing withenumitem
package. See Witiko/markdown Issue #84 for more details.Also, cannot use
fancyLists
because it also loads theparalist
package per Witiko/markdown Pull Request #241.
\documentclass{article}
\usepackage[tightLists=false,strikeThrough]{markdown}
\usepackage{soul}
\markdownSetup{
footnotes = true,
inlineFootnotes = true,
renderers = {
link = {\href{#3}{#1}},
strikeThrough = {\st{#1}},
},
}
\title{Weekly Report}
\author{loikein}
\begin{document}
\maketitle
\begin{markdown}
# Section title
Things ^[Footnotes], [links](#) [^2][^3]
[^2]: More footnotes.
[^3]: Must have line breaks in-between footnotes.
\end{markdown}
\end{document}
Bookmarks with section numbers #
% by default markdown introduces hyperref
\PassOptionsToPackage{bookmarksnumbered}{hyperref}
\documentclass{article}
Hyperlinks #
Render inline hyperlinks #
Ref: 以 Markdown 撰写文稿,以 LaTeX 排版 | 始终
For more details, see Witiko/markdown Discussion #273.
Caution: this setup will bug all relative references within the Markdown environment. I have had no success with the
\renewcommand
solution the author suggested, even with\makeatletter
.
\usepackage{markdown}
\markdownSetup{
renderers = {
link = {\href{#3}{#1}},
}
}
Images #
Ref: 以 Markdown 撰写文稿,以 LaTeX 排版 | 始终
\usepackage{graphicx}
\usepackage{markdown}
\markdownSetup{
relativeReferences = true,
renderers = {
image = {\begin{figure}
\centering
\includegraphics[width = .8\linewidth]{#3}%
\ifx\empty#4\empty\else
\caption{#4}\label{fig:#1}%
\fi
\end{figure}},
},
}
\begin{document}
\begin{markdown}

See <fig:fig-1>.
\end{markdown}
\end{document}
Lists #
Must have 4 spaces between levels (don’t know about tabs):
\begin{document}
\begin{markdown}
- First level
- Second level
\end{markdown}
\end{document}
Can use all 1.
for ordered lists:
\begin{document}
\begin{markdown}
1. First item
1. Second item
1. Third item
\end{markdown}
\end{document}
Maths #
\usepackage{markdown}
\markdownSetup{
hybrid = true,
}
\begin{document}
\begin{markdown}
Inline $x=y$ maths. Note: \& must be escaped.
Numbered display equation. Note: `equation*` does not work.
\begin{equation}
I = \int^a_b x^2 dx
\end{equation}
\end{markdown}
\end{document}