调整 \tcolorbox 内的文本并删除框后的 ident

调整 \tcolorbox 内的文本并删除框后的 ident

我有以下一段文字:

\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}

屏幕截图代表该文本的乳胶输出。

tcolorbox 输出

前 6 行格式正确,但接下来的几行格式不正确,我该如何正确对齐它们(向左对齐)?在文本中,方框后面有缩进,但我不想有缩进。我该如何修复它?

答案1

使用flushleft upper作为选项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}

在此处输入图片描述

对字体大小和边距(左和右)进行如下调整:

\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}

你会得到这个:

在此处输入图片描述

要在框后停止缩进,您可以使用after=\ignorespacesafterend\par\noindent作为选项的tcolorbox

相关内容