我希望有 ntheorem 定理,它们没有数字,但使用名称代替数字。对此类定理的引用已在https://stackoverflow.com/questions/2767389/referencing-a-theorem-like-environment-by-its-name
但我仍然有一个格式问题。(我其实不确定理想的格式是什么样的,也许你也可以帮助我?)MWE:
\documentclass{article}
\usepackage{ntheorem}
\usepackage{thmtools}
%https://stackoverflow.com/questions/2767389/referencing-a-theorem-like-environment-by-its-name
\makeatletter
\def\namedlabel#1#2{\begingroup
\def\@currentlabel{#2}%
\label{#1}\endgroup
}
\makeatother
\theoremstyle{nonumberplain}
\theoremseparator{.}
\newtheorem{goal}{Goal}
\begin{document}
\begin{restatable}{goal}{goalName}{\textbf{Name}}
\namedlabel{thm:name}{Name}
Goal without number, but with name.
\end{restatable}
We refer to the Goal~\ref{thm:name}:
\goalName*
\end{document}
生成:
不知何故,theoremseparator 似乎错了?textbf+italics 是否是名称的正确选择?
谢谢,祝一切顺利,马库斯
答案1
您误解了在环境中使用可选参数的方式restatable
:它必须作为第一个参数给出,放在括号中。我借此机会重新定义了nonumberplain
定理样式,以便自动将可选参数合并到标签中。
我不确定是否需要可选参数的括号,所以我没有改变这个特性,但它们很容易从样式的重新定义中删除。
\documentclass{article}
\usepackage{ntheorem}
\usepackage{thmtools, thm-restate}
%https://stackoverflow.com/questions/2767389/referencing-a-theorem-like-environment-by-its-name
\makeatletter
\def\namedlabel#1#2{\begingroup
\def\@currentlabel{#2}%
\label{#1}\endgroup}
\renewtheoremstyle{nonumberplain}%
{\item[\theorem@headerfont\hskip\labelsep ##1\theorem@separator]}%
{\item[\theorem@headerfont\hskip \labelsep ##1\ (##3)\theorem@separator\namedlabel{thm:name}{##3}]}
\makeatother
\theoremstyle{nonumberplain}
\theoremseparator{.}
\newtheorem{goal}{Goal}
\begin{document}
\begin{restatable}[Name]{goal}{goalName}%
Goal without number, but with name.
\end{restatable}
We refer to the Goals~\ref{thm:name} :
\goalName*
\end{document}