对于某些“定理”环境的情况,我们可以从环境的可选参数中删除括号“(”和“)”吗?

对于某些“定理”环境的情况,我们可以从环境的可选参数中删除括号“(”和“)”吗?

对于某些情况,我们可以从a 的可选参数中删除括号 --()-- 吗?theorem

我准备使用如下命令\nobracket,如下所示:

\documentclass{article}
\usepackage{amsthm}

\begin{document}
\nobrackets
\begin{theorem}[aaa]
For this theorem don't want bracket ()
\end{theorem}

\begin{theorem}[bbb]
For this theorem need bracket ()
\end{theorem}
\end{document}

答案1

当您不想要括号时,需要以某种方式进行标记。

使用您建议的语法:

\documentclass{article}
\usepackage{amsthm}

\usepackage{lipsum} % for mock text

\newtheoremstyle{funny}
  {}{}
  {\itshape}
  {}
  {\bfseries}
  {.}
  { }
  {%
   \thmname{#1}% the label
   \thmnumber{ #2}% the number
   \thmnote{ {\mdseries\iffunny(\fi#3\iffunny)\fi}}% the note
   \global\funnytrue % restore the standard
  }
\newif\iffunny
\newcommand{\nobrackets}{\global\funnyfalse}

\theoremstyle{funny}
\newtheorem{theorem}{Theorem}

\begin{document}

\lipsum[1][1-6]

\nobrackets
\begin{theorem}[aaa]
For this theorem we don't want parentheses.
\end{theorem}

\lipsum[2][1-6]

\begin{theorem}[bbb]
For this theorem we need parentheses.
\end{theorem}

\lipsum[3][1-6]

\end{document}

在此处输入图片描述

使用更好的语法:

\documentclass{article}
\usepackage{amsthm}

\usepackage{lipsum} % for mock text

\newtheoremstyle{funny}
  {}{}
  {\itshape}
  {}
  {\bfseries}
  {.}
  { }
  {%
   \thmname{#1}% the label
   \thmnumber{ #2}% the number
   \thmnote{ {\mdseries\iffunny(\fi#3\iffunny)\fi}}% the note
  }
\newif\iffunny
\funnytrue

\theoremstyle{funny}
\newtheorem{theorem}{Theorem}
\newenvironment{theorem*}{\funnyfalse\theorem}{\endtheorem}

\begin{document}

\lipsum[1][1-6]

\begin{theorem*}[aaa]
For this theorem we don't want parentheses.
\end{theorem*}

\lipsum[2][1-6]

\begin{theorem}[bbb]
For this theorem we need parentheses.
\end{theorem}

\lipsum[3][1-6]

\end{document}

答案2

第 10 页用户指南在该amsthm包中,可以找到有关如何创建定理样式的说明,该定理样式具有默认plain定理样式的大多数属性,只是定理的可选参数周围没有括号。

以下解决方案以此材料为基础。

在此处输入图片描述

\documentclass{article}

\usepackage{amsthm}
\theoremstyle{plain} % the default
\newtheorem{theorem}{Theorem}

\newtheoremstyle{noparens}% cf. p. 10 of user guide of 'amsthm' package
    {}{}{\itshape}{}%
    {\bfseries}{.}{ }%
    {\thmname{#1}\thmnumber{ #2}\thmnote{ {\mdseries #3}}}
\theoremstyle{noparens} % switch to the new theorem style
\newtheorem{theoremnp}[theorem]{Theorem} % 'theoremnp' and 'theorem' share same counter

\begin{document}

\begin{theoremnp}[aaa]
For this theorem we don't want parentheses.
\end{theoremnp}

\begin{theorem}[bbb]
For this theorem we need parentheses.
\end{theorem}

\end{document}

相关内容