amsart でサブセクション番号のみを太字にするにはどうすればよいでしょうか?

amsart でサブセクション番号のみを太字にするにはどうすればよいでしょうか?

コードを使うと

\makeatletter
\renewcommand{\@secnumfont}{\bfseries}
\makeatother

からセクション ヘッダーを太字にするにはどうすればよいでしょうか (タイトルと番号を含む)セクション番号も太字になります。サブセクションの番号のみを太字にするにはどうすればよいでしょうか? amsart.cls を調べてみると、サブセクションや段落用の特定のコマンドはないようです。

答え1

タップすると、\@seccntformat使用されているカウンターの種類に基づいて、セクション カウンターの表示をニーズに合わせてフォーマットできます。

以下に、カウンターを設定するかどうかを確認する条件を追加しましたsubsection。設定する場合は、 を使用します\bfseries。もちろん、条件を追加することで、他のセクションのカウンター設定も変更するように拡張できます。

ここに画像の説明を入力してください

\documentclass{amsart}

\makeatletter
\def\@seccntformat#1{%
  \protect\textup{\protect\@secnumfont
    \ifnum\pdfstrcmp{subsection}{#1}=0 \bfseries\fi% subsection # in \bfseries
    \csname the#1\endcsname
    \protect\@secnumpunct
  }%
}  
\makeatother

\begin{document}
\section{A section}
\subsection{A subsection}
\subsubsection{A subsection}
\end{document}

これには e-TeX が必要です\pdfstrcmp

答え2

を活用するという Werner のアイデアは\@seccntformat良いですが、もっと巧妙な方法があります。 という形式のコマンドを追加します\format<level>。コマンドが定義されていない場合は、 で使用すると と\csname...\endcsname同等になります\relax

\documentclass{amsart}

\makeatletter
\def\@seccntformat#1{%
  \protect\textup{%
    \protect\@secnumfont
    \expandafter\protect\csname format#1\endcsname % <--- added
    \csname the#1\endcsname
    \protect\@secnumpunct
  }%
}

% define what you want for the various levels
\newcommand{\formatsubsection}{\bfseries}
%\newcommand{\formatsubsubsection}{\Huge} %%%% try for experimenting

\makeatother

\begin{document}
\section{A section}
\subsection{A subsection}
\subsubsection{A subsection}
\end{document}

ここに画像の説明を入力してください

実験として、その\formatsubsubsection行のコメントを解除してみてください。

答え3

Amsart には奇妙な動作があります。サブセクションのタイトルが空の場合、その番号は太字になります。これは、\sect定義内の次の行によって実現されます。

\@ifempty{#8}{%
  \ifnum #2=\tw@ \def\@secnumfont{\bfseries}\fi}{}%

#2セクション レベルは次のとおりです (セクションの場合は 1、サブセクションの場合は 2、サブサブセクションの場合は 3 など)。

したがって、タイトル ( ) が空であるかどうかのチェックを削除し#8、サブセクション番号が常に太字になるようにする必要があります。

これはうまくいきます (amsart コードを取得して\@ifemptyチェックを削除しただけです):

\makeatletter
\def\@sect#1#2#3#4#5#6[#7]#8{%
  \edef\@toclevel{\ifnum#2=\@m 0\else\number#2\fi}%
  \ifnum #2>\c@secnumdepth \let\@secnumber\@empty
  \else \@xp\let\@xp\@secnumber\csname the#1\endcsname\fi
  \@tempskipa #5\relax
  \ifnum #2>\c@secnumdepth
    \let\@svsec\@empty
  \else
    \refstepcounter{#1}%
    \edef\@secnumpunct{%
      \ifdim\@tempskipa>\z@ % not a run-in section heading
        \@ifnotempty{#8}{.\@nx\enspace}%
      \else
        \@ifempty{#8}{.}{.\@nx\enspace}%
      \fi
    }%
    \ifnum #2=\tw@ \def\@secnumfont{\bfseries}\fi
    \protected@edef\@svsec{%
      \ifnum#2<\@m
        \@ifundefined{#1name}{}{%
          \ignorespaces\csname #1name\endcsname\space
        }%
      \fi
      \@seccntformat{#1}%
    }%
  \fi
  \ifdim \@tempskipa>\z@ % then this is not a run-in section heading
    \begingroup #6\relax
    \@hangfrom{\hskip #3\relax\@svsec}{\interlinepenalty\@M #8\par}%
    \endgroup
    \ifnum#2>\@m \else \@tocwrite{#1}{#8}\fi
  \else
  \def\@svsechd{#6\hskip #3\@svsec
    \@ifnotempty{#8}{\ignorespaces#8\unskip
       \@addpunct.}%
    \ifnum#2>\@m \else \@tocwrite{#1}{#8}\fi
  }%
  \fi
  \global\@nobreaktrue
  \@xsect{#5}}
\makeatother

関連情報