3

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

9
  • 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. Commented Jan 11, 2016 at 15:13
  • I can only reproduce the issue if I compile with XeLaTeX. Is this the engine you're using?
    – egreg
    Commented Jan 11, 2016 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
    Commented Jan 11, 2016 at 15:43
  • To egreg, yes, i'm using XeLaTeX for compilation. Is it possible to show tabs correctly in XeLaTeX? Thanks. Commented Jan 11, 2016 at 17:55
  • Hi Johannes_B, can a tab be shown as, say 4 spaces, instead of "^^I" in the final result? Thanks. Commented Jan 11, 2016 at 17:58

0

Browse other questions tagged .