3

As explained by Pandoc user's guide, "by default, pandoc produces a document fragment". However, LaTeX fragments contain non-standard commands defined only in Pandoc's LaTeX template, a LaTeX preamble used to produce standalone LaTeX documents instead of just LaTeX fragments. Such custom commands (like \tightlist) generate errors when the fragment is inserted in any other LaTeX source (like a fragment is supposed to be).

As an example consider the following MWE mardown source:

# Section title

Markdown for lists

* One
* Two
* Three

It is converted in the following LaTeX fragment:

\hypertarget{section-title}{%
\section{Section title}\label{section-title}}

Markdown for lists

\begin{itemize}
\tightlist
\item
  One
\item
  Two
\item
  Three
\end{itemize}

which does not compile if inserted as input in any LaTeX source not containing the definition of \tightlist.

Is it possible to generate LaTeX fragments containing only standard LaTeX?

Or is it possible to generate LaTeX fragments containing the definitions of Pandoc custom LaTeX commands?

Thanks in advance for your help.

Why this is not a duplicate

This is not a duplicate of tightlist error using Pandoc with Markdown because I'm not looking for a solution to a specific error (I used the tightlist example and a Markdown source just to explain the issue, which may arise with any other non standard command and any other type of source format) I'm looking for a general way (an option, a switch, an add-on) to obtain Pandoc LaTeX fragments free of undefined non-standard commands (i.e. self-contained).

mmj
  • 5,514
  • 2
  • 44
  • 51
  • Nope, if you don't use the default template you'll have to figure out yourself what definitions you need to make it compile... – mb21 Apr 12 '18 at 07:36
  • 1
    @mb21 Can you explain it better? I don't mind about the template cause I need just a LaTeX fragment, that is a piece of code which compiles under standard LaTeX. What I mean is that the fragment should either not contain custom commands like `\tightlist` or provide its definition. – mmj Apr 13 '18 at 00:35
  • @rkta I know that, but this question is more general, not about `\tightlist`. Moreover I like the possibility to choose a short list given by Markdown, I just wish that the LaTeX fragment was self-contained. Ironically, Pandoc has a self-contained option, but it does not affect LaTeX output. – mmj Apr 13 '18 at 09:48
  • 3
    Possible duplicate of [tightlist error using Pandoc with Markdown](https://stackoverflow.com/questions/40438037/tightlist-error-using-pandoc-with-markdown) – jadelord Jul 30 '19 at 19:28
  • 1
    Does https://stackoverflow.com/a/53230215/2777074 help? – samcarter_is_at_topanswers.xyz Jul 31 '19 at 09:13
  • 1
    For a bit more background, see https://tex.stackexchange.com/q/480427/ – tarleb Jul 31 '19 at 10:15
  • 1
    @samcarter Actually no, since my aim is to obtain LaTeX **fragments** to be inserted in a full defined LaTeX document. So I need a **fragment** (i.e. without LaTeX preamble), but free of undefined non-standard LaTeX commands. – mmj Aug 01 '19 at 11:49

0 Answers0