Page LayoutProblems in TOC with fancyhdr

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
yago
Posts: 29
Joined: Sat Dec 13, 2008 6:40 pm

Problems in TOC with fancyhdr

Post by yago »

Hello to all.

I have a problem with the TOC of my document (two sides) that's is placed at the end. I use the package fancyhdr and the titlesec/titletoc, among the others. This is my preamble:

Code: Select all

\documentclass[spanish]{book}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{geometry}
\geometry{verbose,paperwidth=170mm,paperheight=250mm,tmargin=2.5cm,bmargin=2.5cm,lmargin=2.5cm,rmargin=2cm}
\pagestyle{plain}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{1}
\usepackage{textcomp}
\usepackage{amsmath}
\usepackage{amssymb}

\makeatletter
\usepackage{fnpos}
\usepackage{endnotes}
\let\footnote=\endnote
\renewcommand{\notesname}{Notas}
\usepackage{ifthen}
\usepackage{graphicx}
\usepackage{colortbl}
\usepackage{lscape}
\usepackage{wrapfig}
\usepackage{pst-math,pstricks-add}
\usepackage{picins}
\usepackage{wasysym}
\usepackage{marvosym}
\usepackage{mathtools}
\newtagform{brackets}{[}{]}
\usetagform{brackets}
\usepackage{txfonts}
\usepackage[a]{esvect}
\usepackage{nccparskip}
\usepackage[lflt]{floatflt}
\usepackage{ccaption}
\usepackage[font=small,labelfont=bf]{caption}
\usepackage[spanish]{babel}
\usepackage{subdepth}
\usepackage{array}
\usepackage{booktabs}
\usepackage{multicol}
\usepackage{multirow}
\usepackage{tocvsec2}
\usepackage{fixltx2e}
\usepackage{arcs}
\usepackage{multicol,ragged2e}
\setlength\columnseprule{0.4pt}
\addtolength\columnsep{10pt}
\usepackage{titletoc,titlesec}

\addto\captionsspanish{\renewcommand{\contentsname}{\centering\bfseries\rm\Huge{\'Indice general}}}
\addto\captionsspanish{\renewcommand{\figurename}{Figura}}
\addto\captionsspanish{\renewcommand{\listfigurename}{Lista de Figuras}}
\addto\captionsspanish{\renewcommand{\tablename}{Tabla}}
\addto\captionsspanish{\renewcommand{\listtablename}{Lista de Tablas}}
\addto\captionsspanish{\renewcommand{\chaptername}{Cap\'itulo}}

\renewcommand{\thechapter}{\Roman{chapter}}
\renewcommand{\thesection}{\arabic{chapter}{.}\arabic{section}}
\renewcommand{\thefigure}{\arabic{chapter}.\arabic{figure}}
\renewcommand{\thetable}{\arabic{chapter}.\arabic{table}}

\usepackage{fancyhdr}
\setlength{\headheight}{15pt}
\pagestyle{fancyplain}
\fancyhf{}
\fancyhead[LE,RO]{\fancyplain{}{\bfseries\thepage}}
\fancyhead[RE,LO]{\fancyplain{}{{\bfseries\chaptername \,\thechapter}-\S\,\itshape\thesection}}

\titleformat{\part}[display]
{\vspace{.4\textheight}\Large\bfseries\fillast}
{\partname\hspace{5pt}\thepart}
{1ex minus .1ex}
{\large}
\titlespacing{\part}{2pc}{*3}{*2}[3pc]

\titleformat{\chapter}[display]
{\Large\bfseries\fillast}
{\scshape\chaptername\hspace{5pt}\thechapter}
{1ex minus .1ex}
{\normalsize}
\titlespacing{\chapter}{2pc}{*3}{*2}[3pc]

\titlecontents{part} [0pt]
{\addvspace{2.2pc}\contentsmargin{0pt}\centering\rightskip 1.5pc plus 1fil\leftskip\rightskip}
{\partname}
{\large\scshape\bfseries}
{}
[\begin{center}\addvspace{-.8pc}\rule{0.2\linewidth}{1pt}\end{center}]

\titlecontents{chapter}[56pt]
{\addvspace{1pc}\normalsize}{\contentsmargin{5pt}\bfseries\makebox[35pt][r]{\normalsize\chaptername\hspace{.3pc}\normalsize\thecontentslabel{.}\hspace{10pt}}\filcenter\normalsize}
{\contentsmargin{0pt}\normalsize}{\titlerule*[0.5pc]{.}\normalsize\bfseries\contentspage}[\addvspace{0.2pc}] 

\titlecontents*{section}[1.5em]
{\makebox{\small}}
{\thecontentslabel. }
{}
{, \itshape\thecontentspage}
[.---][.]

\renewcommand{\theequation}{\arabic{chapter}.\arabic{equation}}
\renewcommand{\sin}{\sen \nolimits}
\renewcommand{\arcsin}{\arcsen \nolimits}
\renewcommand{\sinh}{\senh \nolimits}
\renewcommand{\tan}{\tg \nolimits}
\renewcommand{\arctan}{\arctg \nolimits}
\renewcommand{\tanh}{\tgh \nolimits}
\renewcommand{\csc}{\cosec \nolimits}
\renewcommand{\cot}{\cotg \nolimits}
\renewcommand{\lg}{\log \nolimits}

\DeclareMathOperator{\arccot}{arc\,cotg}
\DeclareMathOperator{\arccosec}{arc\,cosec}
\DeclareMathOperator{\arcsec}{arc\,sec}

\makeatletter
\def\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else
\vspace*{\fill}
\thispagestyle{empty}
\newpage 
\if@twocolumn\hbox{}\newpage\fi\fi\fi}
\makeatother

\usepackage[breaklinks]{hyperref}

\deactivatetilden
So, when I put the command \tableofcontents before the command \end{document}, I have this errors in the log file:

Code: Select all

! Use of \reserved@a doesn't match its definition.
\new@ifnextchar ...served@d = #1\def \reserved@a {
                                                  #2}\def \reserved@b {#3}\f...
l.10691 \tableofcontents
                        {}
If you say, e.g., `\def\a1{...}', then you must always
put `1' after `\a', since control sequence names are
made up of letters only. The macro here has not been
followed by the required stuff, so I'm ignoring it.

! Argument of \ttl@assign@i has an extra }.
<inserted text> 
                \par 
l.10691 \tableofcontents
                        {}
I've run across a `}' that doesn't seem to match anything.
For example, `\def\a#1{...}' and `\a}' would produce
this error. If you simply proceed now, the `\par' that
I've just inserted will cause me to report a runaway
argument that might be the root of the problem. But if
your `}' was spurious, just type `2' and it will go away.

Runaway argument?
{\nobreak \@xcentercr }\reserved@a 
! Paragraph ended before \ttl@assign@i was complete.
<to be read again> 
                   \par 
l.10691 \tableofcontents
                        {}
I suspect you've forgotten a `}', causing me to apply this
control sequence to too much text. How can we recover?
My plan is to forget the whole thing and hope for the best.

! Argument of \ttl@assign@i has an extra }.
<inserted text> 
                \par 
l.10691 \tableofcontents
                        {}
I've run across a `}' that doesn't seem to match anything.
For example, `\def\a#1{...}' and `\a}' would produce
this error. If you simply proceed now, the `\par' that
I've just inserted will cause me to report a runaway
argument that might be the root of the problem. But if
your `}' was spurious, just type `2' and it will go away.

Runaway argument?
{\ttl@assign@i {\@tempskipb }}\reserved@a {\@xcentercr }\futurelet \@let@token 
\ETC.
! Paragraph ended before \ttl@assign@i was complete.
<to be read again> 
                   \par 
l.10691 \tableofcontents
                        {}
I suspect you've forgotten a `}', causing me to apply this
control sequence to too much text. How can we recover?
My plan is to forget the whole thing and hope for the best.

! Extra }, or forgotten \endgroup.
\org@markboth ...otected@xdef \@themark {{#1}{#2}}
                                                  \@temptokena \expandafter ...
l.10691 \tableofcontents
                        {}
I've deleted a group-closing symbol because it seems to be
spurious, as in `$x}$'. But perhaps the } is legitimate and
you forgot something else, as in `\hbox{$x}'. In such cases
the way to recover is to insert both the forgotten and the
deleted material, e.g., by typing `I$}'.
Can you help me? Thanks a lot with regards. Please, see the attached file.
Attachments
NDICE GENERAL.pdf
(11.72 KiB) Downloaded 528 times

Recommended reading 2024:

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

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

User avatar
Stefan Kottwitz
Site Admin
Posts: 10320
Joined: Mon Mar 10, 2008 9:44 pm

Re: Problems in TOC with fancyhdr

Post by Stefan Kottwitz »

Hi Yago,

I guess the problem is caused by \pagestyle{fancyplain}. I would suggest don't use \pagestyle{fancyplain}, don't use \fancyplain{}, have a look at \fancypagestyle{plain} instead.

Stefan
LaTeX.org admin
Post Reply