將 \chapter 導入 amsart

將 \chapter 導入 amsart

我想建立一個文檔的外觀amsart,但添加了\chapter命令(樣式與amsbook或不同)。我怎樣才能做到這一點?

我試圖讓 LaTeX 通過 和 的各種組合來加載和,amsbook但這似乎是一個失敗的策略,因為它們都使用 定義了很多東西,導致了無限的錯誤。我還意識到我不能反過來做,因為我想堅持定理的外觀,如 in和 not in 。我也知道,理論上我可以使用 自己設計樣式,但是要獲得 標題的間距需要大量的手動工作,並且我想避免手動執行此操作。amsart\LoadClass\documentclass\newcommandamsartamsbooktitlesecamsart

MWE 如下:

%\documentclass[openany,11pt]{amsbook}
\documentclass[11pt]{amsart}

\newtheorem{lemma}{Lemma}[chapter]
\newtheorem{theorem}[lemma]{Theorem}

\begin{document}

\chapter{My Fair Chapter}

\section{Lovely section}

\begin{theorem} % Should show "Theorem" in bold, unintended.
I love ducks.
\end{theorem}

\end{document}

答案1

amsbook.cls我會改變你不喜歡的部分。僅添加章節的基礎結構所需的程式碼行比 David Carlisle 新增的程式碼行多得多,因為也應考慮目錄和其他清單。

\documentclass{amsbook}
\usepackage{etoolbox}

\makeatletter
\numberwithin{section}{chapter}
\def\@secnumfont{\mdseries}
\def\section{\@startsection{section}{1}%
  \z@{.7\linespacing\@plus\linespacing}{.5\linespacing}%
  {\normalfont\scshape\centering}}
\def\subsection{\@startsection{subsection}{2}%
  \z@{.5\linespacing\@plus.7\linespacing}{-.5em}%
  {\normalfont\bfseries}}

\patchcmd{\@thm}{\let\thm@indent\indent}{\let\thm@indent\noindent}{}{}
\patchcmd{\@thm}{\thm@headfont{\scshape}}{\thm@headfont{\bfseries}}{}{}

\makeatother

\newtheorem{thm}{Theorem}[section]

\begin{document}

\chapter{Chapter title}

\section{Title of this section}
\subsection{Title of this subsection}

\begin{thm}
Whatever the theorem says.
\end{thm}

\begin{thm}[Somebody]
Whatever the theorem says.
\end{thm}

\end{document}

在此輸入影像描述

\chapter{Chapter title}這是如果我刪除、自訂並加載時得到的結果amsart

在此輸入影像描述

答案2

\chapter只需複製與from amsbook相關的行

%\documentclass[openany,11pt]{amsbook}
\documentclass[11pt]{amsart}

\makeatletter

\def\chaptermark#1{}%whatever


\let\chapterrunhead\partrunhead

\def\chapter{%
  \if@openright\cleardoublepage\else\clearpage\fi
  \thispagestyle{plain}\global\@topnum\z@
  \@afterindenttrue \secdef\@chapter\@schapter}

\def\@chapter[#1]#2{\refstepcounter{chapter}%
  \ifnum\c@secnumdepth<\z@ \let\@secnumber\@empty
  \else \let\@secnumber\thechapter \fi
  \typeout{\chaptername\space\@secnumber}%
  \def\@toclevel{0}%
  \ifx\chaptername\appendixname \@tocwriteb\tocappendix{chapter}{#2}%
  \else \@tocwriteb\tocchapter{chapter}{#2}\fi
  \chaptermark{#1}%
  \addtocontents{lof}{\protect\addvspace{10\p@}}%
  \addtocontents{lot}{\protect\addvspace{10\p@}}%
  \@makechapterhead{#2}\@afterheading}
\def\@schapter#1{\typeout{#1}%
  \let\@secnumber\@empty
  \def\@toclevel{0}%
  \ifx\chaptername\appendixname \@tocwriteb\tocappendix{chapter}{#1}%
  \else \@tocwriteb\tocchapter{chapter}{#1}\fi
  \chaptermark{#1}%
  \addtocontents{lof}{\protect\addvspace{10\p@}}%
  \addtocontents{lot}{\protect\addvspace{10\p@}}%
  \@makeschapterhead{#1}\@afterheading}
\newcommand\chaptername{Chapter}

\def\@makechapterhead#1{\global\topskip 7.5pc\relax
  \begingroup
  \fontsize{\@xivpt}{18}\bfseries\centering
    \ifnum\c@secnumdepth>\m@ne
      \leavevmode \hskip-\leftskip
      \rlap{\vbox to\z@{\vss
          \centerline{\normalsize\mdseries
              \uppercase\@xp{\chaptername}\enspace\thechapter}
          \vskip 3pc}}\hskip\leftskip\fi
     #1\par \endgroup
  \skip@34\p@ \advance\skip@-\normalbaselineskip
  \vskip\skip@ }
\def\@makeschapterhead#1{\global\topskip 7.5pc\relax
  \begingroup
  \fontsize{\@xivpt}{18}\bfseries\centering
  #1\par \endgroup
  \skip@34\p@ \advance\skip@-\normalbaselineskip
  \vskip\skip@ }
\def\appendix{\par
  \c@chapter\z@ \c@section\z@
  \let\chaptername\appendixname
  \def\thechapter{\@Alph\c@chapter}}

\newcounter{chapter}

\newif\if@openright

\makeatother



\newtheorem{lemma}{Lemma}[chapter]
\newtheorem{theorem}[lemma]{Theorem}



\begin{document}

\chapter{My Fair Chapter}

\section{Lovely section}

\begin{theorem} % Should show "Theorem" in bold, unintended.
I love ducks.
\end{theorem}

\end{document}

相關內容