# xelatex: Minted code block represents tabs as ^^I

I am producing LaTeX output with org mode. My code snippets wind up being indented with tabs, because of my c-mode settings. Changing these would be inconvenient. Although the snippet I am posting could be compiled with latex, I need to be able to compile Unicode documents, so I am using xelatex -shell-escape to compile the automatically generated latex source.

The generated source looks like this:

Which produces LaTeX like the following (some irrelevant stuff removed, this reproduces the problem):

 \documentclass[11pt]{article}
\tolerance=1000
\usepackage{fontspec}
\usepackage{minted}
\author{Glen Stark}
\date{\today}
\title{sample}
\begin{document}

\section{Foo}

\begin{minted}[]{c++}
void foo()
{
void bar = fb();
std::cout << "fbar" << "\n"
}
\end{minted}
\end{document}


Compiling this with xelatex -shell-escape results in output like:

void foo()

^^Ivoid bar = fb();

^^Istd::cout //etc.

The whitespace in the minted block is a tab. Obviously xelatex is inserting something funny in place of the tabs. I have a workaround where I force generation of spaces instead of tabs, but this is inconvenient.

Anyone know what the fix/problem is?

The problem is pretty similar to the one described in Tabs in output file written by xelatex and pdflatex are different

The solution should be to call xelatex with the -8bit option:

xelatex -8bit -shell-escape test


Here's the test.tex example I used, to show that two byte characters are honored in comments nonetheless.

\documentclass[11pt]{article}
\usepackage{fontspec}
\usepackage{minted}

\begin{document}

\section{Foo}

\begin{minted}[]{c++}
// comment éßàł
void foo()
{
void bar = fb();
std::cout << "fbar" << "\n"
}
\end{minted}

\end{document}


(Note: the interface of StackExchange changes tabs to spaces, so change them back for testing.)

• @ComFreek I get unrecognized option -enable-8bit-chars' on TeX Live. – egreg Jun 12 '19 at 18:03
• It seems you only typed one dash. Does it work with two? – ComFreek Jun 13 '19 at 6:03
• @ComFreek No, it doesn’t. TeX Live programs accept one or two hyphens. I think it’s only a MiKTeX option. – egreg Jun 13 '19 at 8:08
• xelatex -8bit -shell-escape worked for me. – Jason Aug 24 at 2:04

The -8bit option doesn't work for me, it just causes xelatex to throw up a compilation error when processing the .pygtex auxiliary file that I can't resolve. What does work for me is saving my function into its own source code file and using the \inputminted command to import into latex:

\inputminted{c++}{foo.cpp}
`

Whitespace characters are then represented correctly.