3

I have stumbled upon an indentation problem with \mintinline from the minted-package in combination with the breaklinesoption. Consider the following minimal example:

%!TEX TS-program = pdflatex
%!TEX TS-options = -shell-escape
\documentclass{scrbook}

\usepackage{minted}
\setmintedinline{breaklines=true}
\begin{document}

A sufficently long text, to make breaking meaningful.  
Lets have some really cool code now \mintinline{text}{cool code}.
Some more code \mintinline{sql}{Test} an how about some Java \mintinline{java}{String a = "hello";}
\end{document}

The output (MacTeX 2016, just updated with TeX live Manager):

enter image description here

Without the breaklines option:

enter image description here

As this extra space in front of the verbatim part in the first image looks wrong, I assume this is a bug in minted. Any thoughts on this?

0

2 Answers 2

7

If I use TeX Live 2015, the output is correct, so the problem seems to belong in fvextra.sty (a recent addition). Indeed the package code has unprotected end-of-lines:

   1370 \def\FV@VerbatimPygments#1#2{%
   1371   \edef\FV@PYG@Literal{\expandafter\FV@DetokMacro@StripSpace\detokenize{#1}}%
   1372   \def\FV@BreakBeforePrep@PygmentsHook{%
   1373     \expandafter\FV@BreakBeforePrep@Pygments\expandafter{\FV@PYG@Literal}}
   1374   \def\FV@BreakAfterPrep@PygmentsHook{%
   1375     \expandafter\FV@BreakAfterPrep@Pygments\expandafter{\FV@PYG@Literal}}
   1376   \ifx#2\relax
   1377     \let\FV@PYG#1
   1378   \else
   1379     \let\FV@PYG#2
   1380   \fi
   1381   \ifbool{FV@breakbytoken}%
   1382    {\ifbool{FV@breakbytokenanywhere}%
   1383      {\def\FV@BreakByTokenAnywhereHook{%
   1384         \def\FV@BreakByTokenAnywhereBreak{%
   1385           \let\FV@BreakByTokenAnywhereBreak\FancyVerbBreakByTokenAnywhereBreak}}%
   1386       \def#1##1##2{%
   1387         \FV@BreakByTokenAnywhereBreak
   1388         \leavevmode\hbox{\FV@PYG{##1}{##2}}}}%
   1389      {\def#1##1##2{%
   1390         \leavevmode\hbox{\FV@PYG{##1}{##2}}}}}%
   1391    {\def#1##1##2{%
   1392      \FV@PYG{##1}{\FancyVerbBreakStart##2\FancyVerbBreakStop}}}%
   1393 }

(line numbers added for reference).

If I add % at the end of lines 1373, 1375, 1377 and 1379, the output is correct:

\documentclass{scrbook}

\usepackage{minted}
\setmintedinline{breaklines=true}

\makeatletter
\def\FV@VerbatimPygments#1#2{%
  \edef\FV@PYG@Literal{\expandafter\FV@DetokMacro@StripSpace\detokenize{#1}}%
  \def\FV@BreakBeforePrep@PygmentsHook{%
    \expandafter\FV@BreakBeforePrep@Pygments\expandafter{\FV@PYG@Literal}}% <---
  \def\FV@BreakAfterPrep@PygmentsHook{%
    \expandafter\FV@BreakAfterPrep@Pygments\expandafter{\FV@PYG@Literal}}% <---
  \ifx#2\relax
    \let\FV@PYG#1% <---
  \else
    \let\FV@PYG#2% <---
  \fi
  \ifbool{FV@breakbytoken}%
   {\ifbool{FV@breakbytokenanywhere}%
     {\def\FV@BreakByTokenAnywhereHook{%
        \def\FV@BreakByTokenAnywhereBreak{%
          \let\FV@BreakByTokenAnywhereBreak\FancyVerbBreakByTokenAnywhereBreak}}%
      \def#1##1##2{%
        \FV@BreakByTokenAnywhereBreak
        \leavevmode\hbox{\FV@PYG{##1}{##2}}}}%
     {\def#1##1##2{%
        \leavevmode\hbox{\FV@PYG{##1}{##2}}}}}%
   {\def#1##1##2{%
     \FV@PYG{##1}{\FancyVerbBreakStart##2\FancyVerbBreakStop}}}%
}
\makeatother
\begin{document}

A sufficently long text, to make breaking meaningful.
Lets have some really cool code now \mintinline{text}{cool code}.
Some more code \mintinline{sql}{Test} an how about some Java \mintinline{java}{String a = "hello";}

\end{document}

enter image description here

Update

With version 1.2.1 of fvextra (released 2016/09/02), the issue has been fixed, so the extra code is no longer necessary.

2
  • I've opened an issue for the bug and will fix it in the next fvextra release.
    – G. Poore
    Commented Aug 22, 2016 at 20:23
  • @G.Poore Added to my watch list.
    – egreg
    Commented Aug 22, 2016 at 20:40
1

This is still present at the time of writing on Ubuntu 16.10 with shipped Latex Packages and can be fixed by updating fvextra.sty to version 1.2.1, as egreg said.

fvextra.sty can be found at /usr/share/texlive/texmf-dist/tex/latex/fvextra by default.

The fixed version can be found at Github: fvextra.sty 1.2.1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .