1

I use this personalization of the theorem style:

\documentclass{article}
\usepackage{amsthm}

\swapnumbers % optional, of course
\newtheorem{thm}{Theorem}[section] % the main one

% for specifying a name
\theoremstyle{plain} % just in case the style had changed
\newcommand{\thistheoremname}{}
\newtheorem{genericthm}[thm]{\thistheoremname \textmd{\textit{ (Theorem)}}}
\newenvironment{nth}[1]
  {\renewcommand{\thistheoremname}{#1}%
   \begin{genericthm}}
  {\end{genericthm}}

\begin{document}
\begin{nth}{The name of the theorem}
    theorem explanation
\end{nth}
\end{document}

and I get this output: but I would like to have something a bit different:

  • Remove the dot at the end of the name of the theorem
  • Put the theorem explanation in a new line (I have tried \newline but it doesn't work)

2 Answers 2

1

Like this?

\documentclass{article}
\usepackage{amsthm}
\newtheoremstyle{mystyle}% 〈name〉
    {3pt}% 〈Space above〉
    {3pt}% 〈Space below〉
    {\itshape}% 〈Body font〉
    {}% 〈Indent amount〉
    {\bfseries}% 〈Theorem head font〉
    {\newline}% 〈Punctuation after theorem head〉
    {.5em}% 〈Space after theorem head〉
    {\thmnumber{#2}\thmnote{ #3}\thmname{ \mdseries\itshape(#1)}}% 〈Theorem head spec (can be left empty, meaning ‘normal’)〉

\theoremstyle{mystyle}
\newtheorem{thm}{Theorem}[section] % the main one

\begin{document}
\section{Test}
\begin{thm}[The name of the theorem]
    theorem explanation
\end{thm}
\begin{thm}[Another Theorem]
    Content.
\end{thm}
\end{document}

Result

2
  • 1
    I would like to also keep my edits though, that is, I get to choose the name of the theorem and (theorem) always appears after the name in italic. Mar 13, 2023 at 17:07
  • @DamunaTaliffato Please see the updated answer. Mar 13, 2023 at 17:45
1

You need to remove \swapnumber, because it does damages.

\documentclass{article}
\usepackage{amsthm}

\newtheoremstyle{swapped}
 {\topsep}
 {\topsep}
 {\itshape}
 {}
 {\bfseries}
 {\newline}
 {0pt}
 {\thmnumber{#2 }\thmname{#1}\thmnote{\textmd{ (\textit{#3})}}}

\theoremstyle{swapped}
\newtheorem{thm}{Theorem}[section] % the main one

% for specifying a name
\newtheoremstyle{named}
 {\topsep}
 {\topsep}
 {\itshape}
 {}
 {\bfseries}
 {\newline}
 {0pt}
 {\thmnumber{#2 \thistheoremname} \textmd{(\textit{\thmname{#1}\thmnote{, #3}})}}

\theoremstyle{named}
\newcommand{\thistheoremname}{}
\newtheorem{genericthm}[thm]{Theorem}
\newenvironment{nth}[1]
  {\renewcommand{\thistheoremname}{#1}%
   \begin{genericthm}}
  {\end{genericthm}}

\begin{document}

\section{Test}

\begin{thm}
Theorem statement
\end{thm}

\begin{thm}[with a note]
Theorem statement
\end{thm}

\begin{nth}{The name of the theorem}
Theorem statement
\end{nth}

\begin{nth}{The name of the theorem}[with a note]
Theorem statement
\end{nth}

\end{document}

enter image description here

For uniformity, I set the theorem notes all in italics (but with upright parentheses) and use \newline for all statements.

You must log in to answer this question.

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