2

Here's what I want to do, and cannot find a simple way to do it:

image

The important thing is to have the section numbers "hanging" within the left margin, ie. not above the text and not inside the text.

  • And no section title? – Bernard Dec 27 '17 at 22:20
  • 1
    There is a problem in that things like \listoffigures and \appendix use \section*{\listfigurename}. – John Kormylo Dec 27 '17 at 22:26
7

Something like this?

\documentclass[a4paper]{article}
\usepackage{needspace}

\usepackage{lipsum}

\newcommand{\Sec}{%
  \par\nointerlineskip
  \needspace{\dimexpr 5\baselineskip}%
  \sectionseparation
  \stepcounter{section}%
  \noindent
  \raisebox{\dimexpr-\height+\fontcharht\font`A}[0pt][0pt]{%
    \makebox[0pt][r]{{\Huge\bfseries\thesection} }%
  }%
}
\newcommand{\sectionseparation}{%
  \cleaders
  \vbox to\dimexpr 2\baselineskip{%
    \vss
    \hrule width \textwidth height \seprulethickness
    \vss
  }\vskip\dimexpr 2\baselineskip
}
\newcommand{\seprulethickness}{1pt}

\begin{document}

\Sec
\lipsum[2-6]

\Sec
\lipsum[3-4]

\end{document}

enter image description here

The separation rule would disappear if not followed by another section in the same page.


Image added to answer the comment by Barbara Beeton below.

enter image description here

  • please check (i can't) ... is the baseline distance between the first and second text lines in section 2 the same as between lines two and three? it looks a bit tighter. – barbara beeton Dec 27 '17 at 23:24
  • @barbarabeeton That's just an optical effect due to image scaling, I added a magnified image. However, I added \nointerlineskip to get even space around the rule. – egreg Dec 27 '17 at 23:32
  • thanks. i was ready to delete comment, but since you've mentioned the comment in your edit, i guess i can't. (i know my laptop may be suspect, and the first section did look okay. it's not fun being separated from a dependable system.) – barbara beeton Dec 27 '17 at 23:49
6
\RequirePackage{fix-cm}
\documentclass{article}
\usepackage{lipsum}
\newcommand\mysection{%
 \par\noindent\refstepcounter{section}%
 \makebox[0pt][r]{\normalsize
  \smash{\raisebox{-\baselineskip}{\fontsize{2.2\baselineskip}{2.2\baselineskip}\bfseries\thesection}}\quad}\ignorespaces}
\begin{document}
    \mysection \lipsum[1-2]
    \mysection \lipsum[1-2]

\end{document}

enter image description here

  • very nice. i like that the base of the section number sits on the same baseline as the second text line. but the transition between the sections isn't as distinct as it might be. i think the op's idea of a divider rule is sound. – barbara beeton Dec 27 '17 at 23:53
  • @barbarabeeton The question title was about hanging numbers, the question itself also sounded as if the hanging numbers was the main point so I ignored the rule. – Ulrike Fischer Dec 28 '17 at 7:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.