# sliminality/pandoc-theorem

Write LaTeX theorems in Pandoc Markdown
sliminality Merge pull request #2 from Fate6174/add_some_more_tags
add tags and modify README
Latest commit 0b5e402 Nov 8, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information. app Jun 28, 2019 examples Jun 28, 2019 src Jul 25, 2019 test Jun 28, 2019 .gitignore Jun 28, 2019 ChangeLog.md Jun 22, 2019 LICENSE Jun 22, 2019 Makefile Jun 28, 2019 README.md Jul 25, 2019 Setup.hs Jun 22, 2019 native Jun 28, 2019 package.yaml Jun 28, 2019 stack.yaml Jun 22, 2019

# pandoc-theorem

A Pandoc filter to convert definition lists into amsthm theorem environments, for compiling to PDF and LaTeX.

The extension supports the following theorem environments:

Supported environment Supported Markdown identifiers
definition Definition, Def
theorem Theorem, Thm
lemma Lemma
proof Proof, Pf
example Example, Ex
assumption Assumption

Note that compilation targets other than PDF and LaTeX have not been tested. Notably, this includes HTML.

## Example

Given the following Markdown:

Lemma (Pumping Lemming). \label{pumping}

:   Let $L$ be a regular language. Then there exists an integer $p \geq 1$ called the "pumping length" which depends only on $L$, such that every string $w \in L$ of length at least $p$ can be divided into three substrings $w = xyz$ such that the following conditions hold:

- $|y| \geq 1$
- $|xy| \leq p$
- $xy^n z \in L$, for all $n \geq 0$.

That is, the non-empty substring $y$ occurring within the first $p$ characters of $w$ can be "pumped" any number of times, and the resulting string is always in $L$.

we transform it into this PDF output: equivalent to this LaTeX:

\begin{lemma}[Pumping Lemming] \label{lem}

Let $$L$$ be a regular language. Then there exists an integer
$$p \geq 1$$ called the pumping length'' which depends only on $$L$$,
such that every string $$w \in L$$ of length at least $$p$$ can be
divided into three substrings $$w = xyz$$ such that the following
conditions hold:

\begin{itemize}
\tightlist
\item
$$|y| \geq 1$$
\item
$$|xy| \leq p$$
\item
$$xy^n z \in L$$, for all $$n \geq 0$$.
\end{itemize}

That is, the non-empty substring $$y$$ occurring within the first $$p$$
characters of $$w$$ can be pumped'' any number of times, and the
resulting string is always in $$L$$.

\end{lemma}

## Usage

### Installation

You must have Pandoc installed and available in your PATH.

You can either download a prebuilt binary from the Releases page, or clone and stack install this repository, which copies the pandoc-theorem-exe binary to your global Stack install location.

Check that pandoc-theorem-exe is in your PATH:

$which pandoc-theorem-exe /Users/slim/.local/bin/pandoc-theorem-exe # or a different path  ### Syntax pandoc-theorem repurposes the syntax for definition lists, checking for recognized identifiers. Theorem (Fermat's Little). : If$p$is a prime number, then for any integer$a$, the number $$a^p - a$$ is an integer multiple of$p$. In general, the format looks like this: <term> : <body> where <body> is standard Pandoc Markdown (with inline or block formatting), and <term> is one of the following: <term> ::= <identifier>. | <identifier> (<name>). | <identifier> (<name>). <additional text>  That is, a <term> consists of: • A supported environment identifier (required), followed by either • A period (.) if the environment has no name, or • A name in parentheses () which will be passed to the LaTeX environment • Optional additional Pandoc Markdown (e.g. for LaTeX \labels) Supported <identifier> values are documented. Confused about indentation, line spacing, or the : characters? Consult the documentated syntax for Pandoc definition lists. More examples can be found in the Examples section below. ### Compilation To use, pass the pandoc-theorem-exe executable as a filter to Pandoc: # Compile to PDF. pandoc --filter pandoc-theorem-exe input.md -H header.tex -o output.pdf # Output LaTeX. pandoc --filter pandoc-theorem-exe input.md -H header.tex -t latex Note that you will always need to include the following header file using Pandoc's -H flag: % examples/header.tex \usepackage{amsthm} \newtheorem{definition}{Definition} \newtheorem{lemma}{Lemma} \newtheorem{theorem}{Theorem} \newtheorem{example}{Example} \newtheorem{assumption}{Assumption} ## Examples This repository includes an example Markdown file in examples/kitchen-sink.md. You can explore its output using the following command: pandoc --filter pandoc-theorem-exe examples/kitchen-sink.md -H examples/header.tex -o examples/kitchen-sink.pdf ### Simple block-level theorem Theorem (Hedberg). : Any type with decidable equality is a set. ### Complex block-level theorem Lemma (Pumping Lemming). \label{lem} : Let$L$be a regular language. Then there exists an integer$p \geq 1$called the "pumping length" which depends only on$L$, such that every string$w \in L$of length at least$p$can be divided into three substrings$w = xyz$such that the following conditions hold: -$|y| \geq 1$-$|xy| \leq p$-$xy^n z \in L$, for all$n \geq 0$. That is, the non-empty substring$y$occurring within the first$p$characters of$w$can be "pumped" any number of times, and the resulting string is always in$L\$. ### Single inline theorem

Proof.
: By induction on the structure of the typing judgment. ### Multiple inline theorems

Def (Coq).
:   A dependently-typed programming language often used for interactive theorem proving.
:   A video game that doesn't mean you understand the underlying theory, according to Bob. ### Regular definition lists still work

If you do not start a definition list with one of the recognized identifiers, the definition list will compile as usual.

Groceries
: Bananas
: Lenses
: Barbed wire
Programming language checklist

:     *Strictures:* Does the language have sufficiently many restrictions? It is always easier to relax strictures later on.

:     *Affordances:* Actually, these don't really matter. ## Acknowledgements

In addition to John MacFarlane's incredible work on Pandoc itself, this filter benefited from the following prior efforts:

You can’t perform that action at this time.