0

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?

  • The only supported option for breaklines with mintinline is breakbytoken[anywhere], not breakafter. – TeXnician Mar 13 '18 at 9:53
  • @TeXnician Here github.com/gpoore/minted/issues/31#issuecomment-361010857 gpoore claims to have the workaround posted in the question – Arch Linux Tux Mar 13 '18 at 10:07
  • In my experiment, breaklines works; also breakafter=. or breakanywhere. Of course, the line must fit in the case of breakafter=., which could be a problem with a monospaced font. – egreg Mar 13 '18 at 11:46
  • @egreg are you using \mintinline? Because I can get it to work with \begin{minted}, but that's not the question. Maybe I have some wrong setting or I miss something. – Arch Linux Tux Mar 13 '18 at 12:00
  • @ArchLinuxTux Can you tell what version of minted you are running? – egreg Mar 13 '18 at 12:54
0

2018/03/16

This is a well known problem, which is documented (search for bgcolor) (bug report):

bgcolor only works with \begin{minted}, but not with \mintinline. If used with \mintinline, breaklines doesn't work.

Regarding the code, that should allow for breakafter with \mintinline:

It doesn't work, because its "such a long string of text with only a single possible hyphenation point". The solution is to add this code (possibly without the \begingroup):

\begingroup
\setlength{\rightskip}{0pt plus 1 fil}
<paragraph with \mintedinline that won't normally break>
\endgroup

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.