1

I am using ntheorem to include theorems in my thesis. Currently, my theorem headers are printed as follows: (x.y) Theorem (Title).

The code I use to achieve this is roughly as follows.

\documentclass{scrreprt}

\usepackage[english]{babel}             
\usepackage[intlimits]{amsmath}         
\usepackage[amsmath,thmmarks,hyperref]{ntheorem}    % Definitionen, Sätze, ...                  

\makeatletter
\newtheoremstyle{nummermitklammern}
{\item[\theorem@headerfont\hskip\labelsep (##2)\ ##1.\theorem@separator]}%
{\item[\theorem@headerfont\hskip\labelsep (##2)\ ##1 (##3).\theorem@separator]}%
\makeatother
\theoremstyle{nummermitklammern}

\newtheorem{x}{}[chapter]
\newtheorem{theorem}[x]{Theorem}

\begin{document}
\begin{theorem}[Title]
This is a theorem.
\end{theorem}
\end{document}

What I would like to do now is to be able to provide a second optional argument when inserting a theorem, for example a source. If a source is provided, I would like to have the theorem header printed as: (x.y) Theorem (Title) [Source].

Is there some way to do this? Note that I have other theorem-like environments like corollary and example defined (that use the same counter as theorem), which I would like to behave the same.

1 Answers1

1

This is a pseudo-dirty hack that seems to work (in this case at least, I don't know if it will fail in another situations)

\documentclass{scrreprt}

\usepackage[english]{babel}             
\usepackage{mathtools}         
\usepackage[amsmath,thmmarks,hyperref]{ntheorem}
\usepackage{xparse}

\makeatletter
\newtheoremstyle{nummermitklammern}
  {\finaslonchasnummermitklammernaux{##1}{##2}}
  {\finaslonchasnummermitklammernaux{##1}{##2}[##3]}
\NewDocumentCommand\finaslonchasnummermitklammernaux{mmou\ignorespaces o}
 {\item[\theorem@headerfont\hskip\labelsep
    (#2)\ #1%
    \IfValueT{#3}{ (#3)}%
    \IfValueT{#5}{ [#5]}%
    .\theorem@separator]#4\ignorespaces}
\makeatother
\theoremstyle{nummermitklammern}

\newtheorem{theorem}{Theorem}[chapter]

\begin{document}

\begin{theorem}[Title][Source]
  This is a theorem.
\end{theorem}

\end{document}
Manuel
  • 27,118