Text Formattingprefix in front of section numbers

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
gert
Posts: 4
Joined: Wed Feb 24, 2010 9:51 am

prefix in front of section numbers

Post by gert »

Dear Latex Gurus,

Is it possible to put a prefix in front of section numbers?

Code: Select all

\documentclass[12pt]{amsart}

\begin{document}

\section{Article General Remarks}
\subsection{sub 1. Additional notes}

\end{document}
Should look like:

Article 1. General Remarks
Article 1.1 Additional notes

Thanks for any reply,
Gert

ps
I searched for "prefix section numbering" and other terms like this but couldn't find an answer.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

prefix in front of section numbers

Post by gmedina »

Hi,

perhaps something like the following is what you are trying to achieve?

Code: Select all

\documentclass[12pt]{amsart}

\makeatletter
\def\@startsection#1#2#3#4#5#6{%
 \if@noskipsec \leavevmode \fi
 \par \@tempskipa #4\relax
 \@afterindenttrue
 \ifdim \@tempskipa <\z@ \@tempskipa -\@tempskipa \@afterindentfalse\fi
 \if@nobreak \everypar{}\else
     \addpenalty\@secpenalty\addvspace\@tempskipa\fi
 \@ifstar{\@dblarg{\@sect{#1}{\@m}{#3}{#4}{#5}{#6}}}%
         {\@dblarg{\@sect{#1}{#2}{#3}{#4}{#5}{Article #6}}}%
}
\makeatother

\begin{document}

\section{General Remarks}
\subsection{Additional notes}

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
gert
Posts: 4
Joined: Wed Feb 24, 2010 9:51 am

Re: prefix in front of section numbers

Post by gert »

it certainly does what I'm trying to achieve.
Thank you very much, amazing.

Would it be possible to have the sections, subsections all left aligned. With the set-up as given the sections are centered. I've been trying to work on the code but haven't been successful.

Thanks,
Gert
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

prefix in front of section numbers

Post by gmedina »

gert wrote:it certainly does what I'm trying to achieve.
Thank you very much, amazing.

Would it be possible to have the sections, subsections all left aligned. With the set-up as given the sections are centered. I've been trying to work on the code but haven't been successful...
You're welcome. Regarding the new issue, an answer was given in this other thread.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
Post Reply