Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Bugs in tocloft, alternatives ?

497 views
Skip to first unread message

pospiech

unread,
Nov 2, 2010, 6:02:57 PM11/2/10
to
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.

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}

pospiech

unread,
Nov 2, 2010, 6:32:21 PM11/2/10
to
On 2 Nov., 23:02, pospiech <m...@matthiaspospiech.de> wrote:
> 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)
>
I have found out that there is also the titletoc Package.

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.

Lars Madsen

unread,
Nov 2, 2010, 6:44:58 PM11/2/10
to

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

Alan Munn

unread,
Nov 2, 2010, 7:14:38 PM11/2/10
to
In article
<3d37acbb-a2e3-47b7...@32g2000yqz.googlegroups.com>,
pospiech <ma...@matthiaspospiech.de> wrote:

> 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

pospiech

unread,
Nov 2, 2010, 7:54:20 PM11/2/10
to
On 2 Nov., 23:44, Lars Madsen <dal...@imf.au.dk> wrote:

> 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)

pospiech

unread,
Nov 2, 2010, 7:56:15 PM11/2/10
to
On 3 Nov., 00:14, Alan Munn <am...@msu.edu> wrote:

> 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)

GL

unread,
Nov 2, 2010, 8:06:07 PM11/2/10
to
Le 02/11/2010 23:44, Lars Madsen a �crit :

Yes, or to keep the settings of tocloft (\cftbeforetitleskip etc.) you
can either say:
\def\cfttoctitlefont{\chapter*}

/ daleif has nice chapter titles !

GL

unread,
Nov 2, 2010, 8:08:27 PM11/2/10
to

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 !


pospiech

unread,
Nov 3, 2010, 3:14:58 AM11/3/10
to
On 3 Nov., 01:06, GL <gouail...@gmail.com> wrote:
> Le 02/11/2010 23:44, Lars Madsen a crit :
>
> Yes, or to keep the settings of tocloft (\cftbeforetitleskip etc.) you
> can either say:
>         \def\cfttoctitlefont{\chapter*}
>
That works well!

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*}
}


Lars Madsen

unread,
Nov 3, 2010, 7:33:04 AM11/3/10
to

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

GL

unread,
Nov 3, 2010, 8:32:07 AM11/3/10
to
Le 03/11/2010 08:14, pospiech a écrit :
> On 3 Nov., 01:06, GL<gouail...@gmail.com> wrote:
>> Le 02/11/2010 23:44, Lars Madsen a crit :
>>
>> Yes, or to keep the settings of tocloft (\cftbeforetitleskip etc.) you
>> can either say:
>> \def\cfttoctitlefont{\chapter*}
>>
> That works well!
>
> However the tocloft package has several issues. Now loading it looks
> like this:
>

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).

Ulrike Fischer

unread,
Nov 3, 2010, 9:55:54 AM11/3/10
to
Am Tue, 2 Nov 2010 15:02:57 -0700 (PDT) schrieb pospiech:

> 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

Lars Madsen

unread,
Nov 3, 2010, 10:04:35 AM11/3/10
to

oops

Matthias Pospiech

unread,
Nov 3, 2010, 1:52:20 PM11/3/10
to
Am 03.11.2010 13:32, schrieb GL:
> Le 03/11/2010 08:14, pospiech a �crit :

>> On 3 Nov., 01:06, GL<gouail...@gmail.com> wrote:
>>> Le 02/11/2010 23:44, Lars Madsen a crit :
>>>
>>> Yes, or to keep the settings of tocloft (\cftbeforetitleskip etc.) you
>>> can either say:
>>> \def\cfttoctitlefont{\chapter*}
>>>
>> That works well!
>>
>> However the tocloft package has several issues. Now loading it looks
>> like this:
>>
>
> I don't know where you found this ugly IfElsePAckageLoaded.
> \@ifpackageloaded{package}{yes}{no} or \ltx@ifpackageloaded...
>
I can not use @ since I am not inside a package and use it far too
often. Therefore I defined these commands without the @.

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

0 new messages