I am working on a document in which the numbers of headers are displayed in a left margin, e.g.
1 Main header
some text within the given section.
1.1 A Subheader
Some text within the subheader.
I found on the web somewhere, the following code, which achieves this
\newlength\titleindent
\setlength\titleindent{1.35cm}
\titleformat{\chapter}[block]
{\normalfont\huge\bfseries\center}{}{0pt}{\hspace*{-\titleindent}}
\titleformat{\section}
{\normalfont\Large\bfseries}{\llap{\parbox{\titleindent}{\thesection\hfill}}}{0em}{}
\titleformat{\subsection}
{\normalfont\large}{\llap{\parbox{\titleindent}{\thesubsection\hfill}}}{0em}{\bfseries}
\titleformat{\subsubsection}
{\normalfont\normalsize}{\llap{\parbox{\titleindent}{\thesubsubsection}}}{0em}{\bfseries}
\titleformat{\paragraph}[runin]
{\normalfont\large}{\llap{\parbox{\titleindent}{\theparagraph\hfill}}}{0em}{}
\titleformat{\subparagraph}[runin]
{\normalfont\normalsize}{\llap{\parbox{\titleindent}{\theparagraph\hfill}}}{0em}{}
\titlespacing*{\chapter}{0pt}{0pt}{20pt}
\titlespacing*{\subsubsection}{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
\titlespacing*{\paragraph}{0pt}{3.25ex plus 1ex minus .2ex}{0em}
\titlespacing*{\subparagraph}{0pt}{3.25ex plus 1ex minus .2ex}{0em}
What I need is for there to be some way, that I can add such numbers to text sections too. Imagine something like this
\section{Main header}
some text within the given section.
\subsection{A Subheader}
\subsubsection{} Some text within the subheader
would produce
1 Main header
some text within the given section.
1.1 A Subheader
1.1.1 Some text within the subheader.
That is what I want. This should work no matter what level I do it at. In this case it was a subsubsection, but it might as well have been a paragraph
What I actually get with the current preamble is
1 Main header
some text within the given section.
1.1 A Subheader
1.1.1
Some text within the subheader.
That is, the subsubsection with the empty title still gets its own line, and the paragraph is shown below.
The tex markup need not be exactly like this, with empty headers. The important part is that
- Numbers are shown in a left margin
- Hiearchy is preserved so the TOC looks correct (and respects levels)
\ref{...}Will insert the correct number
EDIT: The issue bears some similarities with Numbering of subsections and paragraphs but I cannot connect the dots myself
