# Minted tango theme indentation

The following mwe shows the problem I am facing:

\documentclass{article}
\usepackage{minted}
\begin{document}
\usemintedstyle{tango}
\begin{minted}{matlab}
function test()
i = 1;
j = 1;
end
\end{minted}

\usemintedstyle{emacs}
\begin{minted}{matlab}
function test()
i = 1;
j = 1;
end
\end{minted}
\end{document}


The above code produces the following output:

It can clearly be seen that the first line in the function using the tango style in incorrectly indented. Im fairly sure that this problem is minted-related and does not directly have to do with pygmentize, since I checked the output to HTML files and it seemed fine. The problem only occurs after the function keyword and only in the tango theme (according to my testing). Adding whitespace (i.e. spaces after the parenthesis or blank lines between the keyword and the first line) does not seem to solve the problem. Further, using spaces instead of tabs for indentation does not change the output (assuming the tabsize is equal to the number of spaces).

Another problem I am facing is this artefact after function definitions with multiple return values. The mwe can easily be extended to produce the following output:

where the red box is completely unwanted. This is however related directly to pygmentize, since the screenshot was taken from an HTML output. Still, help would be appreciated.

What is the problem here?

• I might have to revise my earlier comment. A bit of experimenting shows that the problematic \PYG{+w}{ } comes from pygmentize's -f latex option. The first issue might therefore also be a pygmentize issue and not a minted one. I can reproduce a similar issue with pygmentize's HTML output, where with the default style the issue is not visible. It becomes visible once you change the background-color of .w. – moewe Feb 13 at 19:54
• One more: It is quite likely that the problem is not with pygmentize, but rather with pygments itself as I can reproduce the problematic white space handling even on pygments.org/demo/6783503 (the effect is not really visible, but if you check the HTML source you can see that only the spaces in i line are marked up with w, those in the j line are not marked up). I have not been able to find a lexer that gives a similarly inconsistent output (most others that I randomly tried don't use w for the indentation). – moewe Feb 13 at 20:11
• Well, interesting. Definitely seems like both problems are pygments related, as i can also reproduce this with other examples using it directly. I guess this is largely off topic then, my bad. I should have investigated further. – Martin Zach Feb 13 at 20:28
• I'm pretty sure the space issue is connected to bitbucket.org/birkenfeld/pygments-main/src/… That bit of the lexer is the only place where Whitespace is used, which means that one certain spaces at or around a function declaration get marked up as Whitespace all other space presumably ends up as just Text (i.e. with no special markup). ... – moewe Feb 13 at 20:32
• ... I guess you could re-ask on Stackoverflow, where Python would at least be on topic. But really you should be reporting this as a bug or feature request at bitbucket.org/birkenfeld/pygments-main/issues – moewe Feb 13 at 20:33