2

For some occurrences can we remove the parentheses -- ( and ) -- from a theorem's optional argument?

I'm ready to use a command such as \nobracket, as shown below:

\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
  • Welcome to TeX.SE.
    – Mico
    Aug 15, 2020 at 5:23

2 Answers 2

2

You need to somehow mark when you don't want the brackets.

With your proposed syntax:

\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}

enter image description here

With a better syntax:

\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}
0

On page 10 of the user guide of the amsthm package, one finds instructions for how to create a theorem style that shares most properties of the default plain theorem style except that no parentheses are placed around the optional argument of a theorem.

The following solution builds on this material.

enter image description here

\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}
4
  • can we get in with theorem environment. I don't want add further environment in my TeX
    – Learner
    Aug 15, 2020 at 7:50
  • @Learner - According to your initial posting, you seem to be OK with a macro called \nobrackets and, presumably, a companion macro called, say, \brackets. However, your comment indicates that you're not OK with setting up a companion environment named theoremnp. Please help me understand your resistance.
    – Mico
    Aug 15, 2020 at 8:01
  • without changing the environment can we get the required output. I can use command without changing the environments
    – Learner
    Aug 15, 2020 at 12:55
  • @Learner - I believe the main issue with your request is that for the commands you appear to have in mind to "work", they would have to dynamically alter some of the properties of the existing theorem environment. Unfortunately, the structure of the theorem-like environments provided by the amsthm package is such that it's not exactly straightforward to update or "patch" the environments in a way that would let you achieve your objective. That's why I suggested create a second *environment", called theoremnp, and utilizing both theorem and theoremnp as needed throughout the document.
    – Mico
    Aug 15, 2020 at 18:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .