8

Since a few days I can't color anymore python code with minted; I don't have any error message in the log file, only the minted output doesn't appear in the pdf file.

On the other hand, everything works strangely well with the command \inputminted. How to fix this?

MWE

\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{minted}
\begin{document}
ABCDE
\begin{minted}{python}
def __init__(self, x, y): 
    self.x=x
    self.y=y
\end{minted}
% \inputminted ... work's 
\end{document}

enter image description here

3
  • Of course your code doesn't produce a black background with white letters. I get the expected result from the code you posted.
    – egreg
    Nov 21, 2021 at 15:00
  • I can produce an output without the dark mode of my editor. The issue is the same.
    – jowe_19
    Nov 21, 2021 at 15:05
  • Oh, well, I updated fancyvrb and I see the issue. Too bad! Time to downgrade.
    – egreg
    Nov 21, 2021 at 15:24

3 Answers 3

9

Update (27 November 2021): This issue is now fixed in fancyvrb 4.1. In version 4.0, fancyvrb changed the handling of the lastline option so that using lastline= hides all lines (nothing is displayed). However, this also caused lastline used with no argument to hide all lines. That is, the lastline default was to hide all lines. minted uses lastline (default argument) as part of the highlighting process for minted environments, so these environments stopped displaying anything with fancyvrb 4.0. Everything works correctly again with fancyvrb 4.1, which switches lastline (default argument) back to the original behavior.


The relevant change seems to be \@ne -> \z@ on fancyvrb.sty line 225. This causes minted to write nothing to the temp file it uses for highlighting code, instead of writing the code.

Everything can be switched back to the original behavior, fixing minted, by adding this to the preamble:

\makeatletter
\def\FV@DefineFindStop{%
  \ifx\FancyVerbStopString\relax
    \ifnum\FancyVerbStopNum<\@ne
      \let\FV@FindStartStop\FV@@PreProcessLine
    \else
      \let\FV@FindStartStop\FV@FindStopNum
    \fi
  \else
    \let\FV@FindStartStop\FV@FindStopString
  \fi}
\makeatother

At this point (22 November 2021), I am still unsure whether this change in fancyvrb was fixing an old bug (in which case minted should adapt), introducing a new bug, or defining new behavior.

6
  • 1
    the change is meant to introduce a new feature, there was a request to be able to suppress a verbatim environment completly, and the update says ` added lastline=0 for no output, but this killed the (documented) lastline` behaviour without argument, to get everything you have to use lastline=-1 now. This should really be reported to fancyvrb. Nov 23, 2021 at 8:47
  • It seems that with fancyvrb 4.1 the autogobble option of minted does not work anymore. (Since the minted library of tcolorbox has autogobble as default, I'm receiving bug reports for listings with tcolorbox caused by this change). I do not know if autogobble or fancyvrb needs to be adapted. Nov 30, 2021 at 15:48
  • Just looking into the minted code, I read \ifx\FancyVerbStartNum\z@ for autogobble which may/should (?) be replaced by \ifx\FancyVerbStartNum\m@ne for fancyvrb 4.1a Nov 30, 2021 at 16:07
  • Not working again in 4.1b Feb 5 at 23:05
  • 1
    @ManuelAlves It's working fine for me. If you can't get it figured out, I'd suggest creating a new question with an example document that reproduces whatever issue you are seeing.
    – G. Poore
    Feb 6 at 2:33
8

It is a bug/a change in the newest fancyvrb. The following prints everything with the older version but suppress the line with the newest:

\documentclass[12pt]{article}
\usepackage{fancyvrb}
\begin{document}
\begin{Verbatim}[lastline=]
blub
\end{Verbatim}

\end{document}

You should report this.

2
  • Haaaaaaa, thanks ! how to waste half a day to find a solution, for nothing :- )
    – jowe_19
    Nov 21, 2021 at 15:16
  • I'm not sure who should adapt, perhaps minted should. But ask the maintainer of fancyvrb first. Nov 21, 2021 at 15:17
4
\documentclass[12pt]{article}
\usepackage{fancyvrb}
\makeatletter
\def\KV@FV@lastline@default{%
  \let\FancyVerbStopNum\m@ne
  \let\FancyVerbStopString\relax}
\fvset{lastline}
\makeatother
\usepackage{minted}
\begin{document}
ABCDE
\begin{minted}{python}
def __init__(self, x, y): 
    self.x=x
    self.y=y
\end{minted}
blub

\begin{Verbatim}
abc
\end{Verbatim}

\end{document}

I'll fix it and upload it to CTAN

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.