Minted red box around greek characters
This seems to be an error in the Python lexer. If you don't need \fcolorbox
inside the minted
environment, here's a hack:
\documentclass[12pt,a4paper]{article}
\usepackage{fontspec}
\setmainfont{XITS}
\setmonofont{Source Code Pro} % I don't have Consolas
\usepackage{minted}
\setminted[python]{
linenos=true,
breaklines=true,
encoding=utf8,
fontsize=\footnotesize,
frame=lines
}
\usepackage{etoolbox}
\makeatletter
\AtBeginEnvironment{minted}{\dontdofcolorbox}
\def\dontdofcolorbox{\renewcommand\fcolorbox[4][]{##4}}
\makeatother
\begin{document}
\section{Some code in this section}
\begin{minted}{python}
def add(α, β):
return α + β
\end{minted}
\end{document}
\end{document}
Here's the patch also for \inputminted
:
\begin{filecontents*}{\jobname.py}
def add(α, β):
return α + β
\end{filecontents*}
\documentclass[12pt,a4paper]{article}
\usepackage{fontspec}
\setmainfont{XITS}
\setmonofont{Source Code Pro} % I don't have Consolas
\usepackage{minted}
\setminted[python]{
linenos=true,
breaklines=true,
encoding=utf8,
fontsize=\footnotesize,
frame=lines
}
\usepackage{etoolbox,xpatch}
\makeatletter
\AtBeginEnvironment{minted}{\dontdofcolorbox}
\def\dontdofcolorbox{\renewcommand\fcolorbox[4][]{##4}}
\xpatchcmd{\inputminted}{\minted@fvset}{\minted@fvset\dontdofcolorbox}{}{}
\xpatchcmd{\mintinline}{\minted@fvset}{\minted@fvset\dontdofcolorbox}{}{} % see https://tex.stackexchange.com/a/401250/
\makeatother
\begin{document}
\section{Some code in this section}
\begin{minted}{python}
def add(α, β):
return α + β
\end{minted}
\inputminted{python}{\jobname.py}
\end{document}
I suggest you try to use a minted style that does not higlight \PYG{err}
\usemintedstyle{xcode}
Of course if your red boxes was generated because of some \PYG{err}
Just for completeness and since I can't comment yet:
The hack in the Answer by egreg can also be applied to the command \mintinline
by
\xpatchcmd{\mintinline}{\minted@fvset}{\minted@fvset\dontdofcolorbox}{}{}
Greetings