1

I'm using book style, but it happens with a report style, too. I'm using the \chapter* command and I want that the chapter section appears in the table of contents, but it doesn't appear. This is the code:

\documentclass[14pt,a4paper,twoside,spanish,openany]{book}
\usepackage[spanish,activeacute]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amssymb,amsmath,amsthm, mathtools}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\usepackage{fancyhdr}

\renewcommand{\baselinestretch }{1.3}

\renewcommand{\thesection}{\arabic{section}}

\newtheorem{theorem}{Teorema}[section]
\newtheorem{lemma}{Lema}[section]
\newtheorem{proposition}{Proposición}[section]
\newtheorem{corollary}{Corolario}[section]

\theoremstyle{definition}
\newtheorem{definition}{Definición}[section]
\theoremstyle{example}
\newtheorem{example}{Ejemplo}[section]
\theoremstyle{remark}
\newtheorem{remark}{Nota}


\pagestyle{fancy}
\lhead{TEMA 3}
\rhead{\thepage }
\chead{Combinatoria}
\rfoot{Oposiciones}
\rhead{\thepage }
\renewcommand{\footrulewidth}{0.4pt} 
\renewcommand{\headrulewidth}{0.4pt}

\begin{document}
\author{Cristobal López Silla}
\title{Tema 3 - Técnicas De Recuento.Combinatoria.}
\date{}
\tableofcontents

\pagebreak

\chapter*{TEMA 3.\\Técnicas De Recuento.Combinatoria.}
\section{Introducción A Las Técnicas De Recuento.}

\end{document}

Thanks

2

There is a bunch of ways of adding \chapter* like titles to the ToC. I changed the \@makeschapterhead{} command for automatic entries to the ToC.

The \\ has to be protected, but in my opinion, it should not used at all in a chapter title.

\documentclass[14pt,a4paper,twoside,spanish,openany]{book}
\usepackage[spanish,activeacute]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amssymb,amsmath,amsthm, mathtools}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\usepackage{fancyhdr}

\usepackage{xpatch}%

\renewcommand{\baselinestretch }{1.3}

\renewcommand{\thesection}{\arabic{section}}

\newtheorem{theorem}{Teorema}[section]
\newtheorem{lemma}{Lema}[section]
\newtheorem{proposition}{Proposición}[section]
\newtheorem{corollary}{Corolario}[section]

\theoremstyle{definition}
\newtheorem{definition}{Definición}[section]
\theoremstyle{example}
\newtheorem{example}{Ejemplo}[section]
\theoremstyle{remark}
\newtheorem{remark}{Nota}


\pagestyle{fancy}
\lhead{TEMA 3}
\rhead{\thepage }
\chead{Combinatoria}
\rfoot{Oposiciones}
\rhead{\thepage }
\renewcommand{\footrulewidth}{0.4pt} 
\renewcommand{\headrulewidth}{0.4pt}

\begin{document}
\author{Cristobal López Silla}
\title{Tema 3 - Técnicas De Recuento.Combinatoria.}
\date{}
\tableofcontents
\clearpage
%\pagebreak

\makeatletter
\xpatchcmd{\@makeschapterhead}{%
  \Huge \bfseries  #1\par\nobreak%
}{%
  \addcontentsline{toc}{chapter}{\protect\numberline{}#1}%
  \Huge \bfseries  #1\par\nobreak%
}{}{}
\makeatother


\chapter*{{TEMA 3.\protect\\ Técnicas De Recuento.Combinatoria.}}
\section{Introducción A Las Técnicas De Recuento.}

\end{document}

enter image description here

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.