3

This question already has an answer here:

My tabs inside the tcblisting environment are not showing correctly and becomes "^^I". I have tried everything to fix this but not worked. Could anyone please help me so the tabs are displayed correctly in tcblisting? (As illustrated in the sample code, lstlisting seems have no problem with tabs.)

\documentclass{article}
\usepackage[dvipsnames]{xcolor}
\usepackage{tcolorbox}
\tcbuselibrary{listings}
\usepackage{lstautogobble}
\lstset{language=[LaTeX]TeX,
keywordstyle=\color{blue},commentstyle=\color{ForestGreen},stringstyle=\color{Maroon},
basicstyle=\ttfamily\footnotesize, frame=tb, rulesepcolor=\color{Gray},
showspaces=false, showstringspaces=false,
tabsize=4, aboveskip=10pt, belowskip=10pt,
lineskip=2pt, breaklines,
autogobble}
\begin{document}
\begin{tcblisting}{}
\begin{enumerate}
    \item First     % some comment
    \item Second
\end{enumerate}
\end{tcblisting}
\begin{lstlisting}{}
    \begin{enumerate}
        \item First     % some comment
        \item Second
    \end{enumerate}
\end{lstlisting}
\end{document}

enter image description here

marked as duplicate by egreg, user13907, darthbith, Romain Picot, Henri Menke Jan 12 '16 at 14:27

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 Richard! Just a note for anyone testing the MWE: the StackExchange interface converts tabs into spaces, so you'll have to put the tabs back in manually. – Paul Gessler Jan 11 '16 at 15:13
  • I can only reproduce the issue if I compile with XeLaTeX. Is this the engine you're using? – egreg Jan 11 '16 at 15:41
  • Since a tab is in fact ^^I, i would say this is correct. How do you want to distingush between a tab and space? – Johannes_B Jan 11 '16 at 15:43
  • To egreg, yes, i'm using XeLaTeX for compilation. Is it possible to show tabs correctly in XeLaTeX? Thanks. – richard1017 Jan 11 '16 at 17:55
  • Hi Johannes_B, can a tab be shown as, say 4 spaces, instead of "^^I" in the final result? Thanks. – richard1017 Jan 11 '16 at 17:58

Browse other questions tagged or ask your own question.