假设我想要一个假设标题为Assumption 1-$\mathcal F$.
,Assumption 2-$\mathcal F$.
等等,并在文中用不同于 的符号进一步调用$\mathcal F$
。让我举个例子:
\documentclass[10pt, a4paper]{amsart}
\usepackage{amsmath}
{
\theoremstyle{plain}
\newtheorem{assumption}{Assumption}
}
\begin{document}
\section{The first section}
\subsection{The first subsection}
There are three classes of interest: $\mathcal a$, $\mathcal b$ and $\mathcal c$.
Let $\mathcal f$ be a symbolic variable which takes its values
from the set $\{\mathcal a,\mathcal b,\mathcal c\}$.
\begin{assumption}-$\mathcal f$\label{as:1}
The class $\mathcal f$ is not empty.
\end{assumption}
\begin{assumption}-$\mathcal f$\label{as:2}
The derivative $\mathrm d(\mathcal f)$ is positive.
\end{assumption}
Examples of using the assumptions above are as follows:
\begin{itemize}
\item By saying that Assumption \ref{as:1}-$\mathcal a$ is satisfied,
we mean that the class $\a$ is not empty.
\item By saying that Assumption \ref{as:2}-$\mathcal c$ is satisfied,
we mean that the derivative $\mathrm d(\mathcal c)$ is positive.
\end{itemize}
\end{document}
在这个例子中,除了假设的标题之外,一切都很好。目前它们是Assumption 1. -$\mathcal F$
,而我需要$\mathcal F$
成为标题的一部分。如下所示。但是,每当我\ref
在正文中使用时,引用都是形式Assumption 1.1
而不是Assumption 1
。事实上,编号效果不佳:它似乎仅取决于假设在此处定义的章节/小节的数量。
{
\theoremstyle{plain}
\newtheorem*{assumption1f}{Assumption 1-$\mathcal f$}
\newtheorem*{assumption2f}{Assumption 2-$\mathcal f$}
}
\begin{document}
\section{The first section}
\subsection{The first subsection}
There are three classes of interest: $\mathcal a$, $\mathcal b$ and $\mathcal c$.
Let $\mathcal f$ be a symbolic variable which takes its values
from the set $\{\mathcal a,\mathcal b,\mathcal c\}$.
\begin{assumption1f}\label{as:1}
The class $\mathcal f$ is not empty.
\end{assumption1f}
\begin{assumption2f}\label{as:2}
The derivative $\mathrm d(\mathcal f)$ is positive.
\end{assumption2f}
Examples of using the assumptions above are as follows:
\begin{itemize}
\item By saying that Assumption \ref{as:1}-$\mathcal a$ is satisfied,
we mean that the class $\mathcal a$ is not empty.
\item By saying that Assumption \ref{as:2}-$\mathcal c$ is satisfied,
we mean that the derivative $\mathrm d(\mathcal c)$ is positive.
\end{itemize}
\end{document}
有什么办法可以解决这个问题吗?根据 egreg 的建议,我实现了以下代码。标题现在很好,如上所示 - 但编号仍然不正确:而不是Assumption 1-$\mathcal A$
指第一个假设,我必然在参考文献中得到 $\mathcal F$。
\newtheorem*{assumption*}{\assumptionnumber}
\providecommand{\assumptionnumber}{}
\makeatletter
\newenvironment{assumption}[2]
{%
\renewcommand{\assumptionnumber}{Assumption #1-$\mathcal{#2}$}%
\begin{assumption*}%
\protected@edef\@currentlabel{#1-$\mathcal{#2}$}%
}
{%
\end{assumption*}
}
\makeatother
\begin{document}
\section{The first section}
\subsection{The first subsection}
There are three classes of interest: $\mathcal a$, $\mathcal b$ and $\mathcal c$.
Let $\mathcal f$ be a symbolic variable which takes its values
from the set $\{\mathcal a,\mathcal b,\mathcal c\}$.
\begin{assumption}{1}{F}\label{as:1}
The class $\mathcal f$ is not empty.
\end{assumption}
\begin{assumption}{2}{F}\label{as:2}
The derivative $\mathrm d(\mathcal f)$ is positive.
\end{assumption}
Examples of using the assumptions above are as follows:
\begin{itemize}
\item By saying that Assumption \ref{as:1}-$\mathcal a$ is satisfied,
we mean that the class $\mathcal a$ is not empty.
\item By saying that Assumption \ref{as:2}-$\mathcal c$ is satisfied,
we mean that the derivative $\mathrm d(\mathcal c)$ is positive.
\end{itemize}
\end{document}
总结一下:在第一个版本中,引用符合我的要求,但标题不符合。在另外两个版本中(我自己的尝试,以及 @egreg 建议的代码),标题很好,但引用与第一个版本不同。
答案1
我\newtheorem*
猜你正在使用amsthm
。这里有一种方法可以做到:
\documentclass{article}
\usepackage{amsthm}
\newtheorem*{assumption*}{\assumptionnumber}
\providecommand{\assumptionnumber}{}
\makeatletter
\newenvironment{assumption}[2]
{%
\renewcommand{\assumptionnumber}{Assumption #1-$\mathcal{#2}$}%
\begin{assumption*}%
\protected@edef\@currentlabel{#1-$\mathcal{#2}$}%
}
{%
\end{assumption*}
}
\makeatother
\begin{document}
\begin{assumption}{1}{F}\label{1F}
Something
\end{assumption}
Here's the reference: \ref{1F}
\end{document}
只\newtheorem*
需要一个。assumption
环境将数字和标签作为参数;它还设置当前参考文本。
这是一项修改,似乎可以满足您的要求。也许:规格仍然不明确。
\documentclass{article}
\usepackage{amsthm}
\newtheorem*{assumption*}{\assumptionnumber}
\providecommand{\assumptionnumber}{}
\makeatletter
\newenvironment{assumption}[2]
{%
\renewcommand{\assumptionnumber}{Assumption #1-$\mathcal{#2}$}%
\begin{assumption*}%
\protected@edef\@currentlabel{#1}%
}
{%
\end{assumption*}
}
\makeatother
\newcommand{\asref}[2]{\ref{#1}-$\mathcal{#2}$}
\begin{document}
\section{The first section}
\subsection{The first subsection}
There are three classes of interest: $\mathcal{A}$, $\mathcal{B}$ and $\mathcal{C}$.
Let $\mathcal{F}$ be a symbolic variable which takes its values
from the set $\{\mathcal{A},\mathcal{B},\mathcal{C}\}$.
\begin{assumption}{1}{F}\label{as:1}
The class $\mathcal{F}$ is not empty.
\end{assumption}
\begin{assumption}{2}{F}\label{as:2}
The derivative $\mathrm{d}(\mathcal{F})$ is positive.
\end{assumption}
Examples of using the assumptions above are as follows:
\begin{itemize}
\item By saying that Assumption \asref{as:1}{A} is satisfied,
we mean that the class $\mathcal{A}$ is not empty.
\item By saying that Assumption \asref{as:2}{C} is satisfied,
we mean that the derivative $\mathrm d(\mathcal{C})$ is positive.
\end{itemize}
\end{document}