pandoc / lua-filters

A collection of lua filters for pandoc
MIT License
603 stars 165 forks source link

Filter table-short-captions produces invalid LaTeX #48

Closed tarleb closed 5 years ago

tarleb commented 5 years ago

Trying to compile the provided sample file into a PDF gives an error due to \undef being an undefined control sequence.

% pandoc -s --lua-filter table-short-captions.lua -F pandoc-crossref sample.md -o sample.pdf
Error producing PDF.
! Undefined control sequence.
l.163 \undef

@blake-riley, can you take a look?

bpj commented 5 years ago

May be a typo for \relax.

Den lör 30 mars 2019 15:32Albert Krewinkel notifications@github.com skrev:

Trying to compile the provided sample file into a PDF gives an error due to \undef being an undefined control sequence.

% pandoc -s --lua-filter table-short-captions.lua -F pandoc-crossref sample.md -o sample.pdf Error producing PDF. ! Undefined control sequence. l.163 \undef

@blake-riley https://github.com/blake-riley, can you take a look?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/pandoc/lua-filters/issues/48, or mute the thread https://github.com/notifications/unsubscribe-auth/ABG3U87533CBjFlGGpvDon1gIJOsuSCZks5vb3VtgaJpZM4cTxQa .

blake-riley commented 5 years ago

Hi @tarleb,

Background to the bug \undef is defined in the etoolbox package. This isn't explicitly loaded in the preamble of a pandoc-generated .tex file. In pandoc .tex files, the parskip package is loaded if possible, and in turn it will load etoolbox.

Why I missed the error I've got a full installation of TeXLive 2018 running on my machine, so parskip gets loaded, which loads etoolbox in turn. This defines \undef, so everything runs smoothly. I'm assuming that you don't have a full install of TeXLive, so it all falls apart because parskip isn't loaded.

Fix options

  1. Just add a \RequirePackage{etoolbox}, and call it a day.
  2. Avoid using etoolbox altogether. With parskip not available on your distribution, I am wary that etoolbox might also not be available.

Because (2) is a more robust solution, I went this way.