我可以扩展\ifcase
到两个级别吗:
\ifcase{1.1} = a
\ifcase{1.2} = b
\ifcase{1.3} = c
\ifcase{2.1} = a
\ifcase{2.2} = b
.
.
.
\ifcase{3.1} = a
\ifcase{3.2} = b
\ifcase{3.3} = c
命名应该遵循上面的第二个参数。
答案1
解释:剥离数字的第二部分并将其转换为字母
\documentclass{article}
\makeatletter
\newcommand*{\SecondAsAlph}[1]{%
\@alph{\StripToDot#1}%
}
\def\StripToDot#1.{}
\makeatother
\begin{document}
\newcommand*{\test}[1]{#1 = \SecondAsAlph{#1}\par}
\test{1.1}
\test{1.2}
\test{1.3}
\test{2.1}
\test{2.2}
\test{3.1}
\test{3.2}
\test{3.3}
\end{document}
解释:(子)部分编号的第二部分是字母
\renewcommand*{\thesection}{\thechapter\alph{section}}
或者
\renewcommand*{\thesubsection}{\arabic{section}\alph{subsection}}
解释:\ifcase
跳过数字的第一部分
\newcommand*{\MyCaseMacro}[1]{% #1 is the number of the form <x>.<y>
\ifcase\StripToDot#1 %
% case <x>.0
\or
% case <x>.1
\or
% case <x>.2
\or
% case <x>.3
\else
% case <x>.<y> with <y> equal to or greater than 4 (or negative)
\fi
}
\def\StripToDot#1.{}