我正在输入一些数学文本,并使用tcbtheorem
命题/定理/定义框。我正在使用一个\Alph
对所有框都通用的。问题是:我现在有超过 26 个框,并且tcbcounter
对于字母数字来说太大了。我发现该包alphalph
允许将更大的计数器转换为字母。例如,\AlphAlph{28}
写为 AB。我尝试在选项中实现这一点,但没有成功tcbtheorem
。这是我的工作:
\documentclass{article}
\usepackage[english]{babel}
\usepackage[most]{tcolorbox}
\usepackage{alphalph}
\newtcbtheorem[auto counter, number freestyle = {\noexpand\alph{\tcbcounter}}]
{mybox}{Theorem}{}{mytheorem}
\newtcbtheorem[auto counter, number freestyle = {\noexpand\AlphAlph{\tcbcounter}}]
{mybox2}{Theorem2}{}{mytheorem2}
\begin{document}
\begin{mybox}{This is my box}{} %This box is working fine
\end{mybox}
\begin{mybox2}{This is my box2}{} %With this box, I got an error
\end{mybox2}
\end{document}
请帮我找到一个解决方案。
答案1
\AlphAlph
\value{foo}
如果计数器名为 foo,foo
则需要
number freestyle={\noexpand\AlphAlph{\noexpand\value{\tcbcounter}}}
作为一种选择(\noexpand
需要这些语句来防止过早扩展,如tcolorbox
手册中所述(有关描述,请参阅当前手册第 110 页number freestyle
)
为了显示效果,我使用了use counter=foo
而不是auto counter
。
\documentclass{article}
\usepackage[english]{babel}
\usepackage[most]{tcolorbox}
\usepackage{alphalph}
\newtcbtheorem[auto counter, number freestyle = {\noexpand\alph{\tcbcounter}}]
{mybox}{Theorem}{}{mytheorem}
\newcounter{foo}
\newtcbtheorem[use counter=foo, number freestyle={\noexpand\AlphAlph{\noexpand\value{\tcbcounter}}}]
{mybox2}{Theorem2}{}{mytheorem2}
\begin{document}
\begin{mybox}{This is my box}{} %This box is working fine
\end{mybox}
\setcounter{foo}{100}
\begin{mybox2}{This is my box2}{} %With this box, I got an error
\end{mybox2}
\end{document}