定理風格個性化

定理風格個性化

我使用這種個人化的定理風格:

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

我得到這個輸出: 但我想要一些不同的東西:

  • 刪除定理名稱末尾的點
  • 將定理解釋放在新行中(我已經嘗試過 \newline 但它不起作用)

答案1

像這樣?

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

結果

答案2

您需要刪除\swapnumber,因為它會造成損壞。

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

在此輸入影像描述

為了統一起見,我將定理註釋全部設定為斜體(但帶有直立括號)並用於\newline所有陳述。

相關內容