Q:

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

A:

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}

