[Tex/LaTex] Adjustment of text inside \tcolorbox and getting rid of ident after box

formattingtcolorbox

I have following chunk of text:

\begin{tcolorbox}[boxrule=0pt,arc=0pt,colback=gray]
tar: Ignoring unknown extended header keyword 'SCHILY.fflags'\\
tar: Ignoring unknown extended header keyword 'SCHILY.fflags'\\
tar: Ignoring unknown extended header keyword 'SCHILY.fflags'\\
tar: Ignoring unknown extended header keyword 'SCHILY.fflags'\\
tar: Ignoring unknown extended header keyword 'SCHILY.fflags'\\
tar: Ignoring unknown extended header keyword 'LIBARCHIVE.xattr.security.capability'\\
tar: Ignoring unknown extended header keyword 'LIBARCHIVE.xattr.security.capability'\\
tar: Ignoring unknown extended header keyword 'LIBARCHIVE.xattr.security.capability'\\
tar: Ignoring unknown extended header keyword 'LIBARCHIVE.xattr.security.capability'\\
tar: Ignoring unknown extended header keyword 'LIBARCHIVE.xattr.security.capability'
\end{tcolorbox}

And screenshot represents latex output of this text.

tcolorbox output.

First 6 lines are formatted ok, but next lines are not ok, how do I align them properly (to the left)? And after box, in text, I have indent that I do NOT want to have. How do I fix it?

Best Answer

Use flushleft upper as the option to tcolorbox

\documentclass{article}
\usepackage{tcolorbox}
\begin{document}
  \begin{tcolorbox}[flushleft upper,boxrule=0pt,arc=0pt,colback=gray]
tar: Ignoring unknown extended header keyword 'SCHILY.fflags'\\
tar: Ignoring unknown extended header keyword 'SCHILY.fflags'\\
tar: Ignoring unknown extended header keyword 'SCHILY.fflags'\\
tar: Ignoring unknown extended header keyword 'SCHILY.fflags'\\
tar: Ignoring unknown extended header keyword 'SCHILY.fflags'\\
tar: Ignoring unknown extended header keyword 'LIBARCHIVE.xattr.security.capability'\\
tar: Ignoring unknown extended header keyword 'LIBARCHIVE.xattr.security.capability'\\
tar: Ignoring unknown extended header keyword 'LIBARCHIVE.xattr.security.capability'\\
tar: Ignoring unknown extended header keyword 'LIBARCHIVE.xattr.security.capability'\\
tar: Ignoring unknown extended header keyword 'LIBARCHIVE.xattr.security.capability'
\end{tcolorbox}
\end{document}

enter image description here

With some font size and margin (left & right) adjustment like this:

\documentclass{article}
\usepackage{tcolorbox}
\begin{document}
  \noindent
  Some text
  \begin{tcolorbox}[fontupper=\footnotesize,flushleft upper,boxrule=0pt,arc=0pt,left=2pt,right=2pt,colback=gray,after=\ignorespacesafterend\par\noindent]
tar: Ignoring unknown extended header keyword 'SCHILY.fflags'\\
tar: Ignoring unknown extended header keyword 'SCHILY.fflags'\\
tar: Ignoring unknown extended header keyword 'SCHILY.fflags'\\
tar: Ignoring unknown extended header keyword 'SCHILY.fflags'\\
tar: Ignoring unknown extended header keyword 'SCHILY.fflags'\\
tar: Ignoring unknown extended header keyword 'LIBARCHIVE.xattr.security.capability'\\
tar: Ignoring unknown extended header keyword 'LIBARCHIVE.xattr.security.capability'\\
tar: Ignoring unknown extended header keyword 'LIBARCHIVE.xattr.security.capability'\\
tar: Ignoring unknown extended header keyword 'LIBARCHIVE.xattr.security.capability'\\
tar: Ignoring unknown extended header keyword 'LIBARCHIVE.xattr.security.capability'
\end{tcolorbox}
Some text here
\end{document}

you get this:

enter image description here

To stop indenting after the box, you can use after=\ignorespacesafterend\par\noindent as the option to tcolorbox.

Related Question