Pandoc Code block is not aligned using Eisvogel and Markdown

markdownpandoc

Hey it's me again and I am back with something that doesn't let me sleep anymore.

I am using the popular Eisvogel Pandoc template for rendering my markdown files to PDFs. So far everything is working splendid, but I just noticed that blockquotes are not aligned with the rest of the document. I inspected the eisvogel.latex file but I couldn't figure what the issue is.. It is driving me crazy. For some reason these blocks are a few points too wide… See images below, but beware this is triggering.

enter image description here

Zoomed, so it's clearly visible that the code blocks are a few points wider than the rest of the content (left and right are affected).

Left:

enter image description here

Right:

enter image description here

I seek your assistance! I should be able sleep again. 🙁

Best Answer

When using the default Haskell skylighting library for code highlighting, pandoc typesets code listings in an environment called "Shaded" which it defines as the snugshade environment from the framed package.

That environment is defined so that the start of the text is in its usual spot, but there is padding for the shaded area so that it extends outside the usual typeset area.

However, that package also provides a starred version that keeps the padding for the shaded area in the inside of the usual typeset area rather than the outside, so the actual text inside is slightly indented on both sides.

So one thing you could do is redefine pandoc's Shaded environment to use that instead:

\renewenvironment{Shaded}{\begin{snugshade*}}{\end{snugshade*}}

You could put that either in your markdown document, in a yaml header-includes: option, or probably most appropriately, at the end of the ./LaTeX/headers.tex file you're including in the preamble with pandoc's -H option.

Since I don't have your my.theme highlight style, and the kate theme it's based on uses a white background, I couldn't test with that, but here's the result using the breezedark theme:

codeblock with snugshade*