我们可以创建一个编号和依赖的case
/subcase
环境吗?这与 Latex 中通常所做的大不相同case
。我不想在编写函数时使用它来打破定义的范围,相反,它应该像在证明某事时考虑参数的不同情况一样。就像在exam
文档类中一样,我们启动questions
环境并在其中parts
,subparts
等等。我真正想要写的是
\begin{cases}
\case
This is the first case.
\begin{subcases}
\subcase
This is the first subcase of the first case.
\subcase
This is the second subcase of the first case.
\end{subcases}
\case
This is the second case.
\begin{subcases}
\subcase
This is the first subcase of the second case.
\subcase
This is the second subcase of the second case.
\end{subcases}
\end{cases}
...等等。这将产生
请帮忙。
答案1
简单实现:
\documentclass[]{article}
\newcounter{cases}
\newcounter{subcases}
\newenvironment{mycases}
{%
\setcounter{cases}{0}%
\def\case
{%
\par\noindent
\refstepcounter{cases}%
\textbf{Case \thecases.}
}%
}
{%
\par
}
\newenvironment{subcases}
{%
\setcounter{subcases}{0}%
\def\subcase
{%
\par\noindent
\refstepcounter{subcases}%
\textit{Subcase (\thesubcases):}
}%
}
{%
}
\renewcommand*\thecases{\arabic{cases}}
\renewcommand*\thesubcases{\roman{subcases}}
\begin{document}
\begin{mycases}
\case
This is the first case.
\begin{subcases}
\subcase
This is the first subcase of the first case.
\subcase
This is the second subcase of the first case.
\end{subcases}
\case
This is the second case.
\begin{subcases}
\subcase
This is the first subcase of the second case.
\subcase
This is the second subcase of the second case.
\end{subcases}
\end{mycases}
\end{document}
我们可以稍微改变一下以去掉subcases
:
\documentclass[]{article}
\newcounter{cases}
\newcounter{subcases}[cases]
\newenvironment{mycases}
{%
\setcounter{cases}{0}%
\setcounter{subcases}{0}%
\def\case
{%
\par\noindent
\refstepcounter{cases}%
\textbf{Case \thecases.}
}%
\def\subcase
{%
\par\noindent
\refstepcounter{subcases}%
\textit{Subcase (\thesubcases):}
}%
}
{%
\par
}
\renewcommand*\thecases{\arabic{cases}}
\renewcommand*\thesubcases{\roman{subcases}}
\begin{document}
\begin{mycases}
\case
This is the first case.
\subcase
This is the first subcase of the first case.
\subcase
This is the second subcase of the first case.
\case
This is the second case.
\subcase
This is the first subcase of the second case.
\subcase
This is the second subcase of the second case.
\end{mycases}
\end{document}
两者都产生: