GeneralCan I add a section to table of contents without a number

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
oltarasenko
Posts: 9
Joined: Thu May 15, 2008 2:02 pm

Can I add a section to table of contents without a number

Post by oltarasenko »

Hi.

I am using eskdx package.

Every new section in my document starts with \section{Name} command.

But according to our formating rules some sections shouldn't have numbers (e.g. Introduction or Conclusions and Recommendations)

But if I will create them with \section*{name} command, they will not appear in my TOC

The question:

How to create sections without numbers and add them to TOC (without numbers too)

Really need your help

Thanks
Oleg

Recommended reading 2024:

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

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

Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Can I add a section to table of contents without a number

Post by Stefan Kottwitz »

Hi Oleg,

welcome to the LaTeX Community board! You could use \addcontentsline, for example:

Code: Select all

\addcontentsline{toc}{section}{Introduction or Conclusions and Recommendations}
or even \addtocontents.

Stefan
LaTeX.org admin
oltarasenko
Posts: 9
Joined: Thu May 15, 2008 2:02 pm

Re: Can I add a section to table of contents without a number

Post by oltarasenko »

Thanks a lot! You answered so quickly!
:)
oltarasenko
Posts: 9
Joined: Thu May 15, 2008 2:02 pm

Can I add a section to table of contents without a number

Post by oltarasenko »

Please help :(

I added the line but no text was added to TOC :(

Code: Select all

  \begin{document}
  \maketitle
  \addcontentsline{toc}{section}{Introductions}
  \tableofcontents
 

 \include{Intro}
 \include{Chap1}
Where the section introductions (it should be without number in TOC) sits in the \include{Intro} file
I only need to add a section without number to TOC (with the page number where it appeared)


Please help
oltarasenko
Posts: 9
Joined: Thu May 15, 2008 2:02 pm

Re: Can I add a section to table of contents without a number

Post by oltarasenko »

Not sure if I am doing it correctly.

Trying to add it this way:
Directly on the file I write
\addtocontents{toc}{section*}{Introduction}
instead of \section*{Introduction}

But get this:

[1{/usr/local/texlive/2007/texmf-var/fonts/map/pdftex/updmap/pdftex.map}]
(./main.toc

! LaTeX Error: Something's wrong--perhaps a missing \item.

See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...

l.3 ...IeC {\cyrn }\IeC {\cyrn }\IeC {\cyrii }}{6}
User avatar
Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Can I add a section to table of contents without a number

Post by Stefan Kottwitz »

Hi Oleg,

try this minimal example, compile it 2 times:

Code: Select all

\documentclass[a4paper,10pt]{article}
\begin{document}
\tableofcontents
\bigskip
\section*{Introduction}
\addcontentsline{toc}{section}{Introduction}
Text
\end{document}
The section Introduction is not numbered and appears without number in the toc.

The error message could mean something else. Could you post your problematic code line? Do you use cyrillic symbols inside the section title? Maybe this has to be protected. Show me the line containing the error.

Stefan
LaTeX.org admin
oltarasenko
Posts: 9
Joined: Thu May 15, 2008 2:02 pm

Can I add a section to table of contents without a number

Post by oltarasenko »

Hi!


People from the CyrTeX-ru@vsu.ru already helped me! Thanks a lot!!!

The solution is:

Code: Select all


\section*{Введение}
\addcontentsline{toc}{section}{Введение}

Directly in the section.

They also recommended me to use this in the preamble of the document

Code: Select all

% Переопределение полужирного шрифта в СОДЕРЖАНИИ и настройка лидеров
\makeatletter
\renewcommand*\l@section[2]{%
   \ifnum \c@tocdepth >\z@
     \addpenalty\@secpenalty
     \addvspace{1.0em \@plus\p@}%
     \setlength\@tempdima{1.5em}%
     \begingroup
       \parindent \z@ \rightskip \@pnumwidth
       \parfillskip -\@pnumwidth
       \leavevmode %\bfseries
       \advance\leftskip\@tempdima
       \hskip -\leftskip
       #1\nobreak
       \leaders\hbox to .82em{\hss.\hss}\hfil  % \hfill
       \nobreak\hb@xt@\@pnumwidth{\hss #2}\par
     \endgroup
   \fi}
\makeatother
%%%%%%
Works cool now!! Thanks!
Post Reply