5

I'm trying to typeset a document in amsart and I wasn't familiar with the counter used for sections, so I just redefined the section environment to try to get the look I'm going for... unfortunately, the way I've defined the environment, the counter doesn't seem to increment.

The MWE is

\documentclass{amsart}

\newcounter{thesection}
\renewenvironment{section}[1]
{{\centering\Huge {\refstepcounter{thesection}\thesection. #1}\par}}{}

\begin{document}
    \section{Text}    
    \section{More Text}
\end{document}

Have I defined something incorrectly? And is there a more efficient way to get the look I'm going for here?

  • you need to type \thethesection. \thesection print the value of section counter that is defined by ams class. But this is not the correct way to redefine \section style. – touhami Sep 23 '15 at 6:23
  • section is not an environment, so using \renewenvironment is perhaps a bit strange. – Torbjørn T. Sep 23 '15 at 6:34
  • @TorbjørnT.: This is what happens when a mathematician is left to tinker on a LaTeX project by his adviser... :/ – Clayton Sep 23 '15 at 6:35
6

The proper way of doing this is the following:

\documentclass{amsart}
\makeatletter
\def\section{\@startsection{section}{1}%
  \z@{.7\linespacing\@plus\linespacing}{.5\linespacing}%
  {\Huge\scshape\centering}}        %%<<<----       Remove \scshape if you want, Originally we have \normalfont which is replaced by `\Huge.
  \makeatother
\begin{document}
    \section{Text}
    \section{More Text}
\end{document}

enter image description here

Same in a surgical way using xpatch package:

\documentclass{amsart}
\usepackage{xpatch}
\xpatchcmd{\section}{\normalfont\scshape}{\Huge}{}{}

\begin{document}
    \section{Text}
    \section{More Text}
\end{document}

enter image description here

  • In the initial response, is there a particular reason one uses the lengthy commands there? I'm not extremely acquainted with this aspect of latex, and it usually takes me a while to understand what each part is doing. (The second response seems to be much easier to understand.) +1 – Clayton Sep 23 '15 at 6:28
  • @Clayton: Search for the \section command in amsart.cls and fiddle with it. This is how amsart defines \section and we have to follow its style. Note that other packages, used for section styling, like sectsty and titlesec are not that friendly with amsart class. – user11232 Sep 23 '15 at 6:30
  • @Clayton apart from the environment error you redefinition removes most of the \section functionality, the * form tables of contents, indentation etc – David Carlisle Sep 23 '15 at 7:06
  • @DavidCarlisle: I appreciate the insight. I'm doing this for a (small?) presentation, so I only need ~15 transparencies. I'm going for fashion over function in this context, but I'll keep in mind what you've said for future reference. – Clayton Sep 23 '15 at 13:53
  • @Clayton -- before xpatch existed (before 2012), the only way to change a command that allows optional arguments was to redefine the whole thing -- the "lengthy command" as you call it. even using xpatch, it's still necessary to understand the "long form" so that the intended adjustment is made properly. – barbara beeton Sep 23 '15 at 16:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.