pandocker
pandocker copied to clipboard
PDF generation with --listings inserts an extra blank line before code blocks
Describe the bug
When generating PDF output from Markdown with --listings enabled, all code blocks have an extraneous blank line inserted in front of them. This behaviour is inconsistent with running Pandoc locally or using pandoc/latex with the same template and parameters, where the blank line does not appear.
Steps To Reproduce
- Use this example file, mwe.md:
## Minimum Working Example Example of a typical query. ``` sql SELECT column1, column2, column3 AS 'Readable Name' FROM table1 INNER JOIN table2 ON table1.column2 = table2.id WHERE condition1 AND condition2 AND id IN (SELECT id from table3 WHERE condition3) ORDER BY column1 DESC, column2 DESC ``` Done.
- Generate PDF with dalibo/pandocker using:
docker run --rm -u `id -u`:`id -g` -v `pwd`:/pandoc dalibo/pandocker:latest -V papersize:letter -V documentclass:book -V classoption:oneside --standalone --listings -o mwe_dalibo.pdf mwe.md
- Generate PDF with pandoc/latex using:
docker run --rm -u `id -u`:`id -g` -v `pwd`:/data pandoc/latex:latest-ubuntu -V papersize:letter -V documentclass:book -V classoption:oneside --standalone --listings -o mwe_pandoc.pdf mwe.md
- Compare the output; mwe_dalibo.pdf has an extra blank line in front of the listing which mwe_pandoc.pdf does not have.
Expected Behavior
There should be no additional blank line above the code block in mwe_dalibo.pdf.
Additional context
I am trying to set up standardized Pandoc PDF generation using a BitBucket pipeline for documentation repositories. This requires a number of additional features provided by dalibo/pandocker (such as Python filters and XeTeX). However, the extra blank lines in front of all code listings are disrupting the document layout to an unfortunate extent.
I would hazard a guess that something in the LaTeX environment related to listings is configured differently in dalibo/pandocker.
It seems that if I upgrade the listings package to 1.8d to 1.7 (brute force, by manually replacing the contents of /usr/share/texlive/texmf-dist/tex/latex/listings), the extra blank lines disappear. Still trying to figure out which part of which file in particular causes this.
Well, it's definitely something in listings.sty. At any rate, I found a workaround by adding these commands to the image (in the pipeline yaml file before running pandoc):
wget http://mirror.csclub.uwaterloo.ca/CTAN/systems/texlive/tlnet/archive/listings.tar.xz -O /usr/share/texlive/texmf-dist/listings.tar.xz
tar xvJf /usr/share/texlive/texmf-dist/listings.tar.xz -C /usr/share/texlive/texmf-dist
which is a tad clumsy, but gets the job done.
Hi @altsan
Thanks for this report
I just built a new image based on Ubuntu 22.04, pandoc 2.19 and TexLive 2022....
you can fetch it with:
docker pull dalibo/pandocker:latest-ubuntu
@daamien Thanks, this image fixes the issue.
Can I suggest adding the enumitem package, to match the buster image? (One of my style templates uses it.)
@altsan fixed by https://github.com/dalibo/pandocker/pull/246
Out of curiosity what template are you using ? Is it an open source latex template ?
Great, thanks!
The template is a heavily-modified version of Pandoc's default.tex that I made myself. It strips out beamer support, reduces the page margins, adds a fancyhead page header, increases maximum list nesting from 4 to 10 (hence enumitem), and a few other small things. I only use it with the book document class; the page headers probably wouldn't work well with other classes.
FWIW, here's the bit that depends on enumitem.
\usepackage{enumitem}
\usepackage{pifont}
% Increase maximum list nesting to 10
\setlistdepth{10}
\renewlist{itemize}{itemize}{10}
\renewlist{enumerate}{enumerate}{10}
% Turn off tight lists
\def\tightlist{}
% Tweak list margins and spacing
\setlist{itemsep=0pt,parsep=5pt,topsep=0pt}
\setlist[itemize]{leftmargin=1.5em,labelwidth=!,align=parleft}
\setlist[description]{style=nextline,leftmargin=1.5em,labelindent=0em,parsep=1em,topsep=1em}
\setlist[enumerate]{label=\arabic*,leftmargin=1.5em,labelwidth=!,align=parleft}
% Customize each itemize level
\setlist[itemize,1]{label=\textbullet}
\setlist[itemize,2]{label=\textendash}
\setlist[itemize,3]{label=\footnotesize\ding{109},parsep=4pt}
\setlist[itemize,4]{label=\textperiodcentered,parsep=3pt}
\setlist[itemize,5]{label=\footnotesize\ding{71},parsep=2pt}
\setlist[itemize,6]{label=\footnotesize\ding{118},parsep=1pt}
\setlist[itemize,7]{label=\textasteriskcentered,parsep=0pt}
\setlist[itemize,8]{label=-,parsep=0pt}
\setlist[itemize,9]{label=\textperiodcentered,parsep=0pt}
\setlist[itemize,10]{label=-,parsep=0pt}
This is confirmed working with the new image.