Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Glossaries with Pandoc (+ LaTeX)

Tags:

latex

pandoc

I'm trying to create a glossary using Pandoc with Markdown in, PDF (/LaTeX) out. I've followed the documentation here which uses the glossaries library. Everything seems to be working, except actually printing out the glossary! And yes, I have \printglossaries in my template.

The documentation there mentions

File processing must now include a call to makeglossaries followed by at least one further invocation of latex or pdflatex.

which...I haven't done, because I don't know how. Is there a canonical or easy way to run latex or pdflatex again, as it says, using pandoc?


What I've done so far:

  1. Made a copy of the default template (using pandoc -D latex) and added this right after $body$, before the bibliography stuff:

    $if(glossary)$
    \printglossaries
    $endif$
    
  2. Updated my main doc YAML metadata to include glossary: true.

  3. My header-includes section looks like this:

    header-includes:
        - \usepackage{glossaries}
        - \makeglossaries
        - \newglossaryentry{foo}{name=bar, description={baz}}
    
  4. In the document I have \gls{foo} in an arbitrary location near the beginning, which does get hyperlinked, just...to nowhere.
  5. Compile using pandoc --standalone --template=aui.latex my_document.md -o my_document.pdf.

I've also tried without the conditional glossary variable stuff, just in case that's what was breaking things, but there's no change.

like image 967
Max Avatar asked Feb 27 '17 01:02

Max


People also ask

Does Pandoc need LaTeX?

By default, pandoc will use LaTeX to create the PDF, which requires that a LaTeX engine be installed (see --pdf-engine below). Alternatively, pandoc can use ConTeXt, roff ms, or HTML as an intermediate format. To do this, specify an output file with a .

How do I use Pandoc markdown PDF?

Generating PDF from Markdown with Pandoc There are actually two steps involved in converting a Markdown file to a PDF file: The Markdown source file is converted to a LaTeX source file. Pandoc invokes the pdflatex or xelatex or other TeX command and converts the . tex source file to a PDF file.


1 Answers

If you use option 1 from section 4 of the glossaries beginners guide to show your glossary, you will not need multiple invocations of pdflatex. It should compile ok with a single run.

Also if you want to use a less latexy syntax in your markdown files you can use the filter I wrote: pandoc-gls. The pandoc-gls repo also has an example meta section setup for the option 1 mentioned above.

like image 89
Tom Cooper Avatar answered Sep 17 '22 09:09

Tom Cooper