[Tex/LaTex] \section* doesn’t work with \renewcommand{\section}

amsmathsectioning

I'd like to modify the \section command and I'd like to sometimes use \section*, but this doesn't work with amsmath package.

The code below works fine without it, but I often need it:

\documentclass[a4paper,french,12pt]{article}  
\usepackage{lipsum}  
\usepackage{amsmath}  

\makeatletter  
\renewcommand{\subsection}{%  
    \@startsection{subsection}{2}{\z@}%  
    {-3.25ex\@plus -1ex \@minus -.2ex}%  
    {1.5ex \@plus .2ex}%  
    {\normalfont\large\bfseries}%  
    }  
\makeatother  

\begin{document}  

\section{Section 1}  

\subsection*{Introduction}  
\lipsum[2]  

\section{subsection 1}  
\lipsum[2]  

\end{document}  

with amsmath,when I use \subsection*{my subsec title}, it prints the subsec number and then a star where the "my subsec title" should be. And this title doesn't show up.

Thanks for any clue to sort it out

Best Answer

The code posted is missing a couple of % but in most uses that won't affect the output (unless you load amsmath which changes the behaviour of white space around \@ifnextchar).

By default it does define the * form to give unnumbered subsections.

enter image description here

\documentclass{article}



\begin{document}



\makeatletter
\subsection*{aaa}
aaa

\renewcommand{\subsection}{
    \@startsection{subsection}{2}{\z@}%
    {-3.25ex\@plus -1ex \@minus -.2ex}%
    {1.5ex \@plus .2ex}%
    {\normalfont\large\bfseries}
    }

\subsection*{bbb}
bbb

\renewcommand{\subsection}{%
    \@startsection{subsection}{2}{\z@}%
    {-3.25ex\@plus -1ex \@minus -.2ex}%
    {1.5ex \@plus .2ex}%
    {\normalfont\large\bfseries}%
    }

\subsection*{bbb}
bbb

\end{document}

As always if you have code that isn't working, post a complete document as here, that shows the problem.

If you add

\usepackage{amsmath}

Then you will see instead

enter image description here

Showing the issue is as mentioned originally your missing % the version in the question doesn't work, but the following redefinition works as intended.

Related Question