# \setcounter{section} numbering not working

Here is what I am working with:

\documentclass{amsart}

\newcounter{mysection}
\let\realsection=\section
\renewcommand\section[1]{\refstepcounter{mysection}%
\subsection*{\themysection.\space #1}
}

\begin{document}

\setcounter{section}{4}
\section{}
abc

\setcounter{section}{7}
\section{}
def

\end{document}


However, the sections still display in proper numerical order, e.g. 1, 2, etc. instead of displaying 4 and then 7.

• Out of the blue: shouldn't you set the mysection counter instead? – Philipp Imhof Sep 13 '15 at 18:16
• Yes. According to your definition you have to change mysection. – Sigur Sep 13 '15 at 18:17
• I find this definition rather strange and it's unclear to me what's the purpose of this all – user31729 Sep 13 '15 at 18:18
• there's a better way to change the \section definition. copy the definition out of the amsart.cls file, wrap it in \makeatletter ... \makeatother, and remove the command \centering from the last argument. – barbara beeton Sep 13 '15 at 18:36
• The redefinition of \section doesn't really do anything useful, other than break the following document by redefining it not to use the section counter. Just delete that definition. – David Carlisle Sep 13 '15 at 22:48

Either follow Barbara Beeton's advice or patch the \centering command out of the definition (see amsart.cls)

\documentclass{amsart}

\usepackage{xpatch}

\xpatchcmd{\section}{%
\normalfont\scshape\centering}{%
\normalfont\scshape}{\typeout{Success}}{\typeout{Failure}}%

\begin{document}

\setcounter{section}{4}
\section{A section}
abc

\setcounter{section}{7}
\section{Another text}
def

\end{document}