GeneralOwn section numbering

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
Borneq
Posts: 14
Joined: Tue May 24, 2016 9:28 am

Own section numbering

Post by Borneq »

I am translating http://www.antlr.org/papers/allstar-techreport.pdf to Polish.
I have sections:

Code: Select all

%+Contents
\tableofcontents
%-Contents
\section{Wprowadzenie}
\input{1.tex}
\subsection{Dynamiczna analiza gramatyczna}
\input{1_1.tex}
\section{ANTLR 4}
\input{2.tex}
\subsection{Przykładowa gramatyka}
\subsection{Usuwanie lewostronnej rekurencji}
but section names can be B2,B3,B4, C, C1
I change, add asterisk and add numbers :

Code: Select all

%+Contents
\tableofcontents
%-Contents
\section*{1. Wprowadzenie}
\input{1.tex}
\subsection*{1.1 Dynamiczna analiza gramatyczna}
\input{1_1.tex}
\section*{2. ANTLR 4}
\input{2.tex}
\subsection{Przykładowa gramatyka}
\subsection{Usuwanie lewostronnej rekurencji}
but table of contents give me only last two section with numbers start from 0.

Recommended reading 2024:

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

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

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Own section numbering

Post by Johannes_B »

Starred structuring commads do not print a toc entry by default.
Please have a look at the part of the wikibook which deals with that stuff. It is shown how you can change the default numbering, but it also shows how to automatically (and manually) add a toc entry for starred sections.
If you want to number semi-automatically, change the appearance of the counter. If you want to stay with manual numbering, use package unnumberedtotoc.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Own section numbering

Post by Stefan Kottwitz »

You should never put numbering into a sectioning title. Let LaTeX do the numbering. Otherwise you cannot make references and all needs to be done manually. Leave it to LaTeX, it can do all that easily.
  • Use starred commands for unnumbered sections: \section*
  • Use \section and \subsection without number in title, let LaTeX do numbering
  • Switch to A, B, C numbering by \appendix

Code: Select all

\documentclass{article}
\usepackage[utf8]{inputenc}
\begin{document}
\tableofcontents
\section*{Abstract}
\section{Introduction}
\subsection{Dynamic grammar analysis}
\section{ANTLR 4}
\subsection{Sample grammar}
\subsection{Left-recursion removal}
\appendix
\section{Correctness and complexity analysis}
\section{Pragmatics}
\subsection{Reducing warm-up time}
\subsection{Semantic predicate evaluation}
\section{Left-recursion elimination}
\end{document}
numbering.png
numbering.png (24.1 KiB) Viewed 12700 times
Stefan
LaTeX.org admin
Post Reply