有人能告诉我如何在我的 tcolorbox 环境(使用 创建newtcbtheorem
)中获得正确的缩进吗?我从其他问题中了解到我们可以使用before upper
,但显然当使用newtcbtheorem
和plain
样式时这没有帮助,因为before upper
已经包含标签,该标签被添加的代码删除。我在文档中看到有相关选项,例如before upper app
,但我不知道如何正确使用它(并且只为整个文档配置一次)。
梅威瑟:
\documentclass{article}
\usepackage{polyglossia}
\usepackage[most,theorems,skins,listings]{tcolorbox}
\tcbset{
proofstyleone/.style={
theorem style=plain,
coltitle=black,
},
proofstyletwo/.style={
theorem style=plain,
coltitle=black,
before upper=\setlength{\parindent}{1em}\everypar{{\setbox0\lastbox}\everypar{}},
}
}
\newtcbtheorem[]{tcbproofone}{Proof}{proofstyleone}{p}
\newtcbtheorem[]{tcbprooftwo}{Proof}{proofstyletwo}{p}
\begin{document}
\begin{tcbproofone*}{}
This is a paragraph to test.
There should be an indent here.
\end{tcbproofone*}
\begin{tcbprooftwo*}{}
This is a paragraph to test.
There should be an indent here.
\end{tcbprooftwo*}
\end{document}
答案1
从评论中,加载tcolorbox
库hooks
,设置
before upper app={\setlength{\parindent}{1em}}
足够了。