It however completely destroys any heading style definition from
titlesec and resets to the original style (only for TOC)
Therefore I would like to know if there is a workaround, or if there
is an alternative to tocloft.
minimal example:
\documentclass[]{report}
\usepackage{titlesec}
\usepackage{tocloft}
\titleformat{\chapter}[display] % {command}[shape]
{\Large} % format
{\LARGE\MakeUppercase{\chaptertitlename}% % label
\Huge~\thechapter \filright}%
{1pt} % sep (from chapternumber)
{\titlerule \vspace{0.9pc} %
\filright } % (before chaptertitle and after)
[\vspace{0.9pc} \filright {\titlerule}] %
\listfiles
\begin{document}
\tableofcontents
\chapter{abc}
\section{def}
\chapter{kjh}
\section{lks}
\end{document}
That however requires styling of everything, and I have no idea how
the standard
styles are defined and thus how the titletoc definition have to be
defined.
What I basically want to change is the font settings of chapters and
sections in the toc.
this seems to me to be an error in tocloft, most of tocloft was copied
into the memoir class but at least there we use the components of the
\chapter command to typeset the title of the TOC.
tocloft should do the samt or at least make it easy to reconfigure (as
it is in memoir)
it even delays the change to the start of the document. I'm not sure
what the author meant by this. You might want to contact Will Robertson
who maintains tocloft these days (though I think he is quite busy at the
moment)
For now you can use
\makeatletter
\AtBeginDocument{
\renewcommand\@cftmaketoctitle{\chapter*{\contentsname}}
}
\makeatother
after loading tocloft
/daleif
> I would like to be able to style the TOC. The (really old) tocloft
> aims to do that.
>
> It however completely destroys any heading style definition from
> titlesec and resets to the original style (only for TOC)
>
> Therefore I would like to know if there is a workaround, or if there
> is an alternative to tocloft.
The titletoc package (which is by the same author as titlesec, and
therefore plays very nicely with it) should do what you want.
Alan
> For now you can use
>
> \makeatletter
> \AtBeginDocument{
> \renewcommand\@cftmaketoctitle{\chapter*{\contentsname}}}
>
> \makeatother
>
> after loading tocloft
that does not change anything, at least it does not make the titlesec
style show up again. (which is about what I complain)
> The titletoc package (which is by the same author as titlesec, and
> therefore plays very nicely with it) should do what you want.
>
It plains nice together, but since I basically only want to change the
colors and font styles and not the positioning I am lost with titletoc
since it requires to define everything (which I do not know)
Yes, or to keep the settings of tocloft (\cftbeforetitleskip etc.) you
can either say:
\def\cfttoctitlefont{\chapter*}
/ daleif has nice chapter titles !
tocloft is a good package.
Try: \def\cfttoctitlefont{\chapter*}
because tocloft does: \cfttoctitlefont\contentsname
and it will expand into: \chapter*\contentsname
May be your example was very minimal, but this "trick" works well here !
However the tocloft package has several issues. Now loading it looks
like this:
\IfElsePackageLoaded{subfig}
% IF subfig
{\usepackage[subfigure]{tocloft}}{
% ELSE
\IfElsePackageLoaded{subfigure}
% IF subfigure
{\usepackage[subfigure]{tocloft}}
% Else (No subfig nor subfigure)
{\usepackage{tocloft}}
}
\IfPackageLoaded{tocloft}{ % fix bugs
\def\cfttoctitlefont{\chapter*}
}
erh, this works fine for me
\documentclass[]{report}
\usepackage{titlesec}
\usepackage{tocloft}
\makeatletter
\AtBeginDocument{
\renewcommand\@cftmaketoctitle{\chapter*{\contentsname}}}
\makeatother
\titleformat{\chapter}[display] % {command}[shape]
{\Large} % format
{\LARGE\MakeUppercase{\chaptertitlename}% % label
\Huge~\thechapter \filright}%
{1pt} % sep (from chapternumber)
{\titlerule \vspace{0.9pc} %
\filright } % (before chaptertitle and after)
[\vspace{0.9pc} \filright {\titlerule}] %
\listfiles
\begin{document}
\tableofcontents
\chapter{abc}
\section{def}
\chapter{kjh}
\section{lks}
\end{document}
--
/daleif (remove RTFSIGNATURE from email address)
LaTeX FAQ: http://www.tex.ac.uk/faq
LaTeX book: http://www.imf.au.dk/system/latex/bog/ (in Danish)
Remember to post minimal examples, see URL below
http://www.tex.ac.uk/cgi-bin/texfaq2html?label=minxampl
http://www.minimalbeispiel.de/mini-en.html
I don't know where you found this ugly IfElsePAckageLoaded.
\@ifpackageloaded{package}{yes}{no} or \ltx@ifpackageloaded...
\@ifpackage{subfig}
{\PassOptionToPackage{subfigure}{tocloft}}
{}
\RequirePackage{tocloft}
Is far more readable.
Now you can load tocloft with the subfigure option always, even if you
don't need it. It's just an extension (some more macros and control
sequences for subfigures and subtables).
> I would like to be able to style the TOC. The (really old) tocloft
> aims to do that.
>
> It however completely destroys any heading style definition from
> titlesec and resets to the original style (only for TOC)
Well it helps to read the documentation:
titles
The titles option causes the titles of the ToC, LoF, and LoT lists
to be typeset using the default LATEX methods. This can be useful,
for example, when the tocloft and fncychap packages are used
together and the `fancy' chapter styles should be used for the ToC,
etc., titles.
So use \usepackage[titles]{tocloft}
--
Ulrike Fischer
oops
It now looks like this:
\IfPackageLoaded{subfig}{\PassOptionsToPackage{subfigure}{tocloft}}
\IfPackageLoaded{subfigure}{\PassOptionsToPackage{subfigure}{tocloft}}
\PassOptionsToPackage{titles}{tocloft}
\RequirePackage{tocloft}
which seems to solve all problems.
Matthias