创建命令的参考

创建命令的参考

我有一个命令,可以创建一个格式化的迷你页面,其定义大致如下

\newcounter{X}
\setcounter{X}{1}
\newcommand{\assumption}[2]{
   \begin{minipage}%
     Assumption \Roman{X}: #1 \\#2%
   \end{minipage}%
   \addtocounter{X}{1}%
}

我希望能够引用 minipage 命令。最好使用\ref,但这不是必需的。基本上我希望能够做类似的事情

\assumption{flatearth}{The earth is flat!}{It is obvious that this   
assumption is reasonable.}

From assumption \ref{assum:flatearth} it follows that it's \emph{real} 
circumference is $\infty$ and that the Victoria was capable of
superluminal velocities.

或者只是有类似的命令\assref{flatearth}。它们应该产生与计数器相对应的罗马数字X

抱歉,标题有点模糊,我一直在想该搜索什么,但不太清楚。

答案1

\newcounter{X}
\renewcommand\theX{\Roman{X}}

\newcommand{\assumption}[2]{%
\refstepcounter{X}%
\label{assum:#1}%
   \begin{minipage}%
     Assumption \theX: #1 \\#2%
   \end{minipage}%

}

相关内容