6

If I use the code

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

from How to boldface a section header? (including title and number) it makes the number of sections bold as well. How to get a boldface number only for subsection? Looking into amsart.cls, it seems like there is not a specific command for sub(sub)sections or paragraphs.

2
  • do you want the heading of the subsection bold, or just the number? Dec 23, 2014 at 19:54
  • @barbarabeeton Both, but subsection is already bold.
    – user155002
    Dec 23, 2014 at 20:17

3 Answers 3

4

Tapping into \@seccntformat you can format the section counter display to suit your needs based on the type of counter that is being used.

Below I've added a conditional that checks whether you're setting the subsection counter. If so, use \bfseries. Of course, this can be expanded to change other sectional counter setting as well by adding more conditions:

enter image description here

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

This requires e-TeX due to \pdfstrcmp.

1
  • Splendid, I again learned something new...
    – user155002
    Dec 23, 2014 at 20:18
4

Werner's idea of tapping into \@seccntformat is good, but there's a slicker way to do it: add a command of the form \format<level>; if the command is not defined, being used with \csname...\endcsname will make it equivalent to \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}

enter image description here

Try, just by way of experimenting, to uncomment the \formatsubsubsection line.

1
  • Slick indeed, as undefined \format<level> macros are just "ignored".
    – Werner
    Dec 23, 2014 at 21:48
0

Amsart has a curious behavior: if a subsection title is empty, its number is bold. This is achieved by the following lines inside \sect definition:

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

Here #2 is the section level (1 for section, 2 for subsection, 3 for subsubsection etc).

So what you need is to take out the check whether title (#8) is empty, and subsection number will be always bold.

This does the trick (I just took the amsart code and deleted \@ifempty check):

\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
1
  • This will also format the \subsubsection counter in \bfseries.
    – Werner
    Dec 23, 2014 at 20:01

You must log in to answer this question.

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