I want to number nested sections, subsections, paragraphs etc manually without using commands like \section{Section}
,\paragraph{Paragraph}
like this:
1 1.1 1.1.1 ...
How can I achieve that?
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this communityI'm not sure why you'd want to do this. Even more, I believe you shouldn't discharge the usual commands: if you don't like the appearance of section headings there's the package titlesec
that allows for changing them.
Here I propose a \DIV
macro that can be called with an optional argument and a mandatory argument for the subdivision level; the optional argument is the number to use (if not specified, just step the normal counter).
\usepackage{xparse}
\NewDocumentCommand{\DIV}{om}{%
\IfValueT{#1}{\setcounter{#2}{\numexpr#1-1\relax}}%
\csname #2\endcsname
}
Now you can call
\DIV[42]{section}{The answer to the fundamental question}
and the section will be numbered 42. If the next section is called with
\DIV{section}{Don't panic!}
it will be numbered 43.
Should you want to remove this manual numbering, just comment the \IfValueT
line.
If it's an ad hoc document and you just want the section numbers to match whatever documents the notes are for, a simple solution is to use the *
form to suppress numbers and add them as part of the title
\section*{1.24.33 my title}
\section*{2.3 my next title}
\section*{1.33 my numbers aren't in order}
\addcontentsline
s.
It can be a bit frustrating if the only answers to "How do I do that?" are "Don't." Especially if it's very easy to do what you want (and I can imagine use cases).
A bit of researching in the internet (https://en.wikibooks.org/wiki/LaTeX/Counters) shows that the command you are looking for is \setcounter{section}{23}
, where 23 is the number you want to set it to.
So you'd have something like
\setcounter{section}{23}
\section{My great section}
And it will output "My great section" with number 24, as \section
further increases the counter. Works the same for subsection
and so on.
LaTeX
is the automated document structure. Could you help us with a full MWE about this document?;)