Wandmalfarbe / pandoc-latex-template

A pandoc LaTeX template to convert markdown files to PDF or LaTeX.
BSD 3-Clause "New" or "Revised" License
6.21k stars 968 forks source link

Issue with indented code block and line-wraps #176

Open Lednerb opened 4 years ago

Lednerb commented 4 years ago

Hey and thanks for the nice template!

I've discovered an issue with line wraps when code-blocks are used within lists: screenshot

As you can see from the screenshot, the chars 20(New- are outside the code block.

I don't understand enough about latex to fix this by myself now.

Any help would be appreciated.

Lednerb commented 4 years ago

This issue does not occur in unordered lists.

Wandmalfarbe commented 4 years ago

Could you post your Markdown and the pandoc command that you used to render the document?

Lednerb commented 4 years ago

Hi, sure:

pandoc command:

pandoc src.md -o out.pdf \
  --from markdown+yaml_metadata_block+raw_html \
  --template eisvogel \
  --table-of-contents \
  --toc-depth 6 \
  --top-level-division=chapter \
  --highlight-style zenburn \
  --pdf-engine xelatex

Markdown Text: bug.txt

Wandmalfarbe commented 4 years ago

It looks like the fix implemented in #2 is not working correctly 😢 A workaround is to use listings for rendering code blocks with the option --listings.

Even with the option breakanywhere there are still overflowing lines:

\usepackage{fvextra}
\DefineVerbatimEnvironment{Highlighting}{Verbatim}{breaklines,breakanywhere,fontsize=$if(code-block-font-size)$$code-block-font-size$$else$\small$endif$,commandchars=\\\{\}}
sfc-gh-kcox commented 3 years ago

I agree with Lednerb and can replicate this issue. I also added the option breakanywhere to my eisvogel.tex file. Inline code that exceeds 4-5 words tends to run past the default column width and is then unreadable.

I created a listings-setup.tex file and added the following text:

\usepackage{xcolor}

\lstset{
    basicstyle=\ttfamily,
    numbers=none,
    keywordstyle=\color[RGB]{0.13,0.29,0.53}\bfseries,
    stringstyle=\color[RGB]{0.31,0.60,0.02},
    commentstyle=\color[RGB]{0.56,0.35,0.01}\itshape,
    numberstyle=\small,
    stepnumber=1,
    numbersep=5pt,
    backgroundcolor=\color[RGB]{248,248,248},
    showspaces=false,
    showstringspaces=false,
    showtabs=false,
    tabsize=2,
    captionpos=b,
    breaklines=true,
    breakatwhitespace=true,
    breakautoindent=true,
    escapeinside={\%*}{*)},
    linewidth=\textwidth,
    basewidth=0.5em,
}

I then reference this file in my pandoc build using the syntax --listings -H listings-setup.tex.

The final result DOES enable word wrapping and things work as anticipated. BUT, the color background of inline code is no longer light gray, but is white.

It also adds line numbers to blockcode even when I set the above variable numbers=none.

If I knew where in the eisvogel.tex file I could find or set similar settings rather than reference the outside --listings file, that might work.