[Tex/LaTex] breaklines doesn’t work with \mintinline

line-breakingminted

I try to get line-wrapping to work with \mintinline, like so:

\documentclass[11pt]{report}
\usepackage{minted}

\setmintedinline{
                bgcolor=lightgray,
                }

\begin{document}

\mintinline[breaklines, bgcolor=lightgray]{java}{test test test test test test test test test test test test test test test test test test test test test test test}

\end{document}

I also tried setting

  • \setmintedinline{breaklines}
  • \newmintinline{java}{breaklines}

But the code won't wrap. I read here (github) and here (docu), that \mintinline should allow for breaklines-option.

Also this

\usepackage{minted}
\makeatletter
\renewcommand{\minted@inputpyg}{%
  \expandafter\let\expandafter\minted@PYGstyle%
    \csname PYG\minted@get@opt{style}{default}\endcsname
  \VerbatimPygments{\PYG}{\minted@PYGstyle}%
  \ifthenelse{\boolean{minted@isinline}}%
   {\ifthenelse{\equal{\minted@get@opt{breaklines}{false}}{true}}%
    {\let\FV@BeginVBox\relax
     \let\FV@EndVBox\relax
     \def\FV@BProcessLine##1{%
       \FancyVerbFormatLine{%
         \FV@BreakByTokenAnywhereHook
         \FancyVerbFormatText{\FancyVerbBreakStart##1\FancyVerbBreakStop}}}%
     \minted@inputpyg@inline}%
    {\minted@inputpyg@inline}}%
   {\minted@inputpyg@block}%
}
\makeatother

was suggested by Geoffrey Poore (gpoore) as a workaround for \mintinline to allow breakafter-option on github.

I tried it, but it didn't work for me. Maybe breaklines dosn't work in the first place.

How can I check the version of minted and whats the current version?

I checked Pygments instelled version, it's 2.2.0. Seems to be the current version.

Any ideas, why the lines won't wrap?

Best Answer

It seems like this has been fixed in the minted package. Using the options breaklines and breakafter causes a line break for the source code.

\mintinline[breaklines, breakafter=_]{python}{very_long_class_name}
Related Question