6

I'm using the packages

\documentclass{amsart} 
\usepackage{amsmath}

they do not leave a vertical space between the section's title and the following text.

So i'm trying to use the titlespacing command of the titlesec package.

Here, it says

 \titlespacing{<command>}{<left>}{<before-sep>}{<after-sep>}
where:

<left> increases the left margin.
<before-sep> is the vertical space before the title.
<after-sep> is the separation between title and non-sectioning text.

so I try

\usepackage{titlesec}
\titlespacing{\subsection}{0em}{0em}{0.5em}

but I get the error

Undefined control sequence.
<argument> ...on\endcsname \protect \@secnumpunct 

at the lines

\section{main}

and

\subsection{subsection title}

I do not understand what is the error, and why it triggers at \section, when I only intended to modify \subsection

Also, where is the documentation. I spent half an hour searching it, and got nothing.

Here is the complete code

\documentclass{amsart} 
\usepackage{amsmath}
\usepackage{titlesec} % <- This lines try to modify the subsection
\titlespacing{\subsection}{0em}{0em}{0.5em} % <- This lines try to modify the subsection


\begin{document}

\section{Main section}% <- This line triggers the error
text main section is on new line

\subsection{subsection title} % <- This line triggers the error
I want this text separated on a new line

\end{document}
2
  • You should provide a minimal working example that compiles all by itself. Nov 19, 2023 at 7:22
  • 2
    @User23456234 I added the code
    – tutizeri
    Nov 19, 2023 at 7:31

2 Answers 2

8

You get

! Undefined control sequence.
<argument> ...on\endcsname \protect \@secnumpunct

l.9 \section{Main section}
                          % <- This line triggers the error
?
! Undefined control sequence.
<argument> ...on\endcsname \protect \@secnumpunct

l.12 \subsection{subsection title}
                                   % <- This line triggers the error
?

which means just one thing: titlesec is not compatible with amsart.

Why? Because amsart redefines \@startsection whereas titlesec expects the kernel version of the command. And because at AMS they don't want users to tinker with the style.

\documentclass{amsart} 
\usepackage{amsmath}

\makeatletter
% here the original definition
%\def\subsection{\@startsection{subsection}{2}%
%  \z@{.5\linespacing\@plus.7\linespacing}{-.5em}%
%  {\normalfont\bfseries}}
\def\subsection{\@startsection{subsection}{2}%
  \z@{-.5\linespacing\@plus-.7\linespacing}{1sp}%
  {\normalfont\bfseries}}
\makeatother

\begin{document}

\section{Main section}
The text main section is on a new line

\subsection{Subsection title}
I want this text separated on a new line

\end{document}

enter image description here

If you want the first line after the header to be indented change the relevant code into

\def\subsection{\@startsection{subsection}{2}%
  \z@{.5\linespacing\@plus.7\linespacing}{1sp}%
  {\normalfont\bfseries}}

enter image description here

0

I "solved" it by adding "phantom" text at the end of the subsection title, followed by a paragraph jump.

\subsection{subsection title}\phantom{dummy_text}\par\samepage

Edit: after egreg comment, I added \samepage at the end of the line, to prevent the title to be separated from the next line on different pages.

1
  • 3
    Please delete. This is not a solution: you'll have to worry about having the heading at the bottom of the page and the text on the next one.
    – egreg
    Nov 19, 2023 at 15:06

You must log in to answer this question.

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