7

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?

7

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.)

enter image description here

2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.