1

Here's an example:

\documentclass{article}

\usepackage[sharp]{easylist} % use # symbol to denote a list
\usepackage{minted}

\begin{document}

\begin{easylist}[enumerate]
# Profile Python
\begin{minted}{python}
import math
\end{minted}
\end{easylist}

\end{document}

To make it work, I could just use other symbols like \usepackage[at]{easylist} instead of sharp. But I am curious because error message cannn't really tell me why is this not working. Do someone know the why I cannot use #?

The error message is:

_./main.out.pyg:2:
Use of \FV@PYG doesn't match its definition.
\PYG #1#2->\FV@PYG {
                #1}{\FancyVerbBreakStart #2\FancyVerbBreakStop }
l.2 \PYG{k+kn}{import} \PYG{n+nn}{math}

Update:

Please see @egreg's answer below (and comments!) for an explanation.

A solution to the above question using \Activate and \Deactivate command provided by easylist.:

\documentclass{article}

\usepackage[sharp]{easylist} % use # symbol to denote a list
\usepackage[cache=false]{minted}
\title{useless}
\begin{document}

\begin{easylist}[enumerate]
# Deactivate it first,
\Deactivate
\begin{minted}{python}
import math
\end{minted}
\Activate
# then activate it again.
# Good!
\end{easylist}

\end{document}
3
  • Does it make sense to use minted inside easylist to begin with?
    – egreg
    Commented Feb 16, 2018 at 18:41
  • I think yes. Because if I use a different symbol, there would be no problem. Also, a vague analogy is that since verbatim works in easylist, why not minted? @egreg
    – taper
    Commented Feb 16, 2018 at 19:03
  • Possibly the answer is that the symbol # is used in minted. And since minted is loaded in easylist, easylist adjust what # means and this clashes with minted. So the choice would only be use another symbol for easylist.
    – taper
    Commented Feb 16, 2018 at 19:14

1 Answer 1

1

The sharp option makes # into an active character. The files that are produced by pygmentize contain macro definitions which in turn use # and, because of being inside easylist, this character is no longer the parameter specifier.

Thus all the auxiliary macros with argument that minted needs to use don't work as expected.

Using other characters can lead to other problems; I tried the at option and @ won't work in minted. For example

\documentclass{article}

\usepackage[at]{easylist} % use # symbol to denote a list
\usepackage{minted}

\begin{document}

\begin{easylist}[enumerate]
@ Profile Python
\begin{minted}{python}
    @classmethod
\end{minted}
\end{easylist}

\end{document}

will not print @.

Besides, minted will not respect the current indentation in the list.

Here's a comparison:

\documentclass{article}

\usepackage{easylist}
\usepackage{minted}

\begin{document}

\begin{enumerate}
\item Profile Python
\begin{minted}{python}
# This program prints Hello, world!
print('Hello, world!')
\end{minted}
\begin{enumerate}
\item Indented
\begin{minted}{python}
# This program prints Hello, world!
print('Hello, world!')
\end{minted}
\end{enumerate}
\end{enumerate}

\begin{easylist}[enumerate]
§ Profile Python
\begin{minted}{python}
# This program prints Hello, world!
print('Hello, world!')
\end{minted}
§§ Indented
\begin{minted}{python}
# This program prints Hello, world!
print('Hello, world!')
\end{minted}
\end{easylist}

\end{document}

enter image description here

9
  • Good explanation! It's strange that @ does not work for you though.
    – taper
    Commented Feb 16, 2018 at 21:45
  • 1
    @taper Try @classmethod in the Python code. The @ will disappear. I added a full example.
    – egreg
    Commented Feb 16, 2018 at 21:58
  • Oh.. Sure. Then I found, among documented keywords, § to be a fairly good choice. Since it is rarely used, could be inputed by \S when needed, and is available on my keyboard (:P).
    – taper
    Commented Feb 16, 2018 at 22:11
  • Hi @egreg, I just found in easylist's documentation there is a way to circumvent this problem. It is updated in my question.
    – taper
    Commented Feb 16, 2018 at 22:25
  • @taper And now, where’s the advantage over using a regular \item?
    – egreg
    Commented Feb 16, 2018 at 22:29

You must log in to answer this question.

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