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

  • 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
  • Hi Paul, could you please tell me how to manually insert a character in code blocks of my post? I've been doing research on this for half an hour and couldn't find a solution. I give up :( – richard1017 Jan 11 '16 at 18:53
  • @richard1017 you can't; that's why I left the note about it. :-) – Paul Gessler Jan 11 '16 at 19:33
  • @richard1017 The problem is exactly like the one described in the question this one I marked as duplicate of. The issue is indeed that tcolorbox writes the environment's content to a file; with XeTeX you need the -8bit command line option in order to write tabs literally. – egreg Jan 12 '16 at 12:51
  • Hi egreg, thank you very much. I'm writing my latex in Sublime Text and my builder settings are: "command": ["texify", "-b", "-p", "--engine=xetex", "--tex-option="--synctex=1""] It seems "-8bit" option doesn't work for texify. Anyway, I changed the engine to pdflatex and tabs are shown correctly. – richard1017 Jan 12 '16 at 20:47

0 Answers0