[Tex/LaTex] minted and tabs

minted

I can get a code block including tab characters in a minted environment to work with the obeytabs option, which results in a tab size of 8. The tabsize option, however, will mess up the tab alignment.

\documentclass{article}

\usepackage{minted}
\usemintedstyle{pastie}
\begin{document}

\begin{minted}[obeytabs,showtabs]{c}
    int foo     //bar
            //ffff
\end{minted}
\begin{minted}[tabsize=4,showtabs]{c}
    int foo     //bar
                //ffff
\end{minted}

\end{document}

The output looks as follows:

output

Is there a solution to this?

Best Answer

I am possibly missing the point because I've set up my editor to automatically expand tabs, but after disabling this (I think) it seems to me that minted does do what it is supposed to here. The problem is that in your second example you have forgotten to include the obeytabs option. If you put this in then minted does what (I think) you want.

For example, I get what seems to me to be the following perfectly reasonable output

enter image description here

from the following latex file:

\documentclass{article}

\usepackage{minted}
\usemintedstyle{pastie}
\begin{document}

\begin{minted}[tabsize=2,obeytabs,showtabs]{c}
    int foo //bar
            //ffff
\end{minted}

\begin{minted}[tabsize=4,obeytabs,showtabs]{c}
    int foo //bar
            //ffff
\end{minted}

\begin{minted}[tabsize=6,obeytabs,showtabs]{c}
    int foo //bar
            //ffff
\end{minted}

\end{document}

If I've misunderstood the issue let me know and I'll delete this.

(Btw, I could have answered this in the comments but I'm trying to start a movement to stop answering questions in the comments because currently there are 4190 questions posted on TeX.SX with no answers...except that I suspect that most of these questions are actually answered in the comments!)