This question already has an answer here:

In beamer class, when i compile using LaTeX, the output pdf results perfectly the way i expect it to. But when i change it to XeLaTeX, in the lstlisting environment, every tab in the code results in a "^^I"-Placeholder (See output-pdf below). How do I fix this?

 if( Bedingung ) {
 ^^I//Code, der nur ausgefuehrt wird, wenn die Bedingung wahr ist 

LaTeX-Code (Reduced to the minimum, one frame as an example):

if( Bedingung ) {
    //Code, der nur ausgefuehrt wird, wenn die Bedingung wahr ist
                 \item Alles innerhalb eines if-Blocks wird nur ausgeführt, wenn die Bedingung (in Klammern) wahr ist.

screenshot of the described frame

marked as duplicate by egreg xetex Feb 4 '17 at 22:00

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – DG' Feb 4 '17 at 21:09
  • @DG' This is my first question on stackexchange, so i'll have to learn the art of asking questions efficiently. Thank you for your review. – Alexander Schoch Feb 4 '17 at 21:48
  • The fourth line can be avoided by putting \end{lstlisting} at the begin of the line. The same I had to apply to \end{frame} with my version of beamer to get the example compiled (after adding a preamble). – Heiko Oberdiek Feb 4 '17 at 21:58
  • This is essentially the same problem as in tex.stackexchange.com/questions/14771/… because the issue is caused by writing the temporary file for the fragile frame. – egreg Feb 4 '17 at 21:59
  • @HeikoOberdiek I also noticed this, but it would've been painful to move the $\end{lstlisting}$ every time at the beginning of the line. Additionally, the preamble would have been added if it wasn't a template file with over 200 lines and you didn't answer that fast. – Alexander Schoch Feb 4 '17 at 22:03

A small test file for the effect can already achieved with verbatim text:

\verb|a b|


If option fragile is given, then beamer writes the frame to an auxiliary file \jobname.vrb. The problem with XeTeX happens at this step, \jobname.vrb contains:


Class beamer reads the frame in a verbatim manner by changing the category codes of many letters to 12 ("other", like digits). Otherwise, with the usual category code, the tabulator would be printed as space character. Then, when the file is written by XeTeX, it sees an "unprintable" ASCII character (a "control" character with ASCII code smaller than the space character) and uses the alternative notation with printable ASCII characters using ^^I. The behavior of pdfTeX is different in this matter.

The problem can be fixed by using XeTeX with option -8bit, from the help screen:

-8bit     make all characters printable, don't use ^^X sequences
  • Thank you for this excellent and extremely fast answer, this solved my problem. – Alexander Schoch Feb 4 '17 at 21:53

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