Text Formattingprefix in front of section numbering, all left aligned

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 numbering, all left aligned

Post by gert »

Earlier today I asked how to get a prefix in front of section numbers and got this perfect answer:
http://www.latex-community.org/forum/vi ... =44&t=7815

However I'm trying to get my sections left-aligned. While working on the code I ended up creating a style (see below) but still didn't find out how to have everything left-aligned. I mean how text and sections appear as if no style is used.

Code: Select all

\let\LaTeX@startsection\@startsection
\renewcommand{\@startsection}[6]{\LaTeX@startsection%
{#1}{#2}{#3}{#4}{#5}{Article #6}}
Thanks for any advice,
Gert

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 numbering, all left aligned

Post by gmedina »

Hi, again. The following code incorporates my solution to your previous question and the code needed to fulfill your new requirement:

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}{\noindent Article #6}}}%
}
\def\section{\@startsection{section}{1}%
  \z@{.7\linespacing\@plus\linespacing}{.5\linespacing}%
  {\normalfont\scshape}}
\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

prefix in front of section numbering, all left aligned

Post by gert »

Thank you very much gmedina. This is exactly what I was looking for. Tried a few things myself with

Code: Select all

\noindent
but never achieved the result your proposed solution gives.
Many thanks,
Gert
Post Reply