LyXhow to dotfill the toc?

Information and discussion about LyX, a WYSIWYM editor, available for Linux, Windows and Mac OS X systems.
Post Reply
drdebian
Posts: 3
Joined: Wed Jan 06, 2010 8:23 am

how to dotfill the toc?

Post by drdebian »

I'm a new user to LaTeX and LyX, as I've only begun writing my thesis in it. It's really awesome, which is why I want to stick with it to the end. ;)

Anyway, I'm having a really hard time figuring out how to make my table of contents look right, more specifically how I can get dots between the chapters and the page numbers instead of just blanks. I'm using the report (KOMA-script) document class without any special modifications in Lyx 1.6.5.

I'm sure it can be done, even with an ERT if need be. :)

Any pointers?

Recommended reading 2024:

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

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

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

how to dotfill the toc?

Post by gmedina »

Hi,

The section and subsection entries will, by default, contain dotted leaders in the scrreprt (or report, or book) document class. To obtain the same result for chapters, for example, you could use the tocloft package. Take a look at the following example:

Code: Select all

\documentclass{scrreprt}
\usepackage{tocloft}

\renewcommand\cftchapdotsep{\cftdotsep}
\renewcommand\cftchapleader{\cftdotfill{\cftchapdotsep}}

\begin{document}
\tableofcontents
\clearpage

\chapter{Test chapter}
\section{Test section}
\subsection{Test subsection}

\end{document}
I just noticed that this is the LyX subforum; unfortunately, I have no idea how to implement my solution in LyX.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
drdebian
Posts: 3
Joined: Wed Jan 06, 2010 8:23 am

how to dotfill the toc?

Post by drdebian »

gmedina wrote: I just noticed that this is the LyX subforum; unfortunately, I have no idea how to implement my solution in LyX.
Thanks for the quick hint, I'll give it a try. :D In LyX, you can insert arbitrary LaTeX code using the ERT feature, so I guess I'll just have to place the renewcommands in the right place. ;)
User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

Re: how to dotfill the toc?

Post by Stefan Kottwitz »

Hi,

place those commands in the document preamble of your LyX document, you will find that point in the LyX menu, like in document settings (I don't have LyX right here).

Stefan
LaTeX.org admin
drdebian
Posts: 3
Joined: Wed Jan 06, 2010 8:23 am

how to dotfill the toc?

Post by drdebian »

Stefan_K wrote:Hi,

place those commands in the document preamble of your LyX document, you will find that point in the LyX menu, like in document settings (I don't have LyX right here).

Stefan
Thanks, I saw that option as well. Now I know what to put in there! ;)
MeganGentry
Posts: 8
Joined: Thu Nov 18, 2010 8:05 pm

how to dotfill the toc?

Post by MeganGentry »

Hi,
I'm also trying to do this same thing with Lyx. My document class is article and this is what the preamble looks like:

Code: Select all

\usepackage{epsfig}
\usepackage[nottoc]{tocbibind}
\usepackage{tocloft}
\usepackage{indentfirst}
\pagenumbering{roman}
\let\myLot\listoftables
\renewcommand\listoftables{%
\myLot
\clearpage
\pagenumbering{arabic}
}
\date{}
\@addtoreset{figure}{section}
\renewcommand{\thefigure}{\thesection.\arabic{figure}}
\@addtoreset{table}{section}
\renewcommand{\thetable}{\thesection.\arabic{table}}
\newcommand{\degree}{\ensuremath{^\circ}}
\newcommand{\thcentsignatureline}[1]{ \begin{center}
                \normalsize
                \vspace{8mm}
                \vrule width 80mm height 0.2mm\\
                \end{center}
                \hspace{1.65in}}
\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}%
                                    {-3.25ex\@plus -1ex \@minus -.2ex}% 
                                    {1.5ex \@plus .2ex}%                 
                                    {\normalfont\normalsize\bfseries}}

%\usepackage{epsfig} 
%\usepackage{multirow}
%\usepackage[nottoc]{tocbibind}
\usepackage{setspace} 

\usepackage{tocloft} 
\renewcommand{\cftfigpresnum}{Figure }
\renewcommand{\cftfignumwidth}{5em}
\renewcommand{\cftfigaftersnum}{       }

\renewcommand{\cfttabpresnum}{Table }
\renewcommand{\cfttabnumwidth}{5em} 
\renewcommand{\cfttabaftersnum}{    }

If I add these two lines to the end of the preamble...

Code: Select all

\renewcommand\cftchapdotsep{\cftdotsep}
\renewcommand\cftchapleader{\cftdotfill{\cftchapdotsep}}


Then I get the following error...
LaTeX Error: \cftchapdotsep undefined
LaTeX Error: \cftchapleader undefined
Is this some kind of syntax error. BTW, notice that I added \usepackage{tocloft} to the beginning of the preamble, so I should be able to use these commands, right??

Thanks for any help you can offer. I'm pretty lost with latex and I'm trying to get my dissertation formatted correctly.
Last edited by Stefan Kottwitz on Tue Aug 09, 2011 6:43 pm, edited 1 time in total.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

how to dotfill the toc?

Post by Stefan Kottwitz »

Hi Megan,

for new questions please open a new thread instead of continuing an older topic. So more readers would notice your question.

You are using the article class. This class doesn't support chapters, and \cftchapdotsep and \cftchapleader are chapter commands, as I see because of the chap in the name.
  • You could use \cftsecdotsep and \cftsecleader instead, which are similar but for sections,
  • or you could use a class which supports chapters, such as report or book, and use chapter headings.
Stefan
LaTeX.org admin
MeganGentry
Posts: 8
Joined: Thu Nov 18, 2010 8:05 pm

Re: how to dotfill the toc?

Post by MeganGentry »

Hi,
Thanks for your help. In the future, I'll just start a new topic.

I tried to use your suggestion by putting these two lines at the end of the preamble...

\renewcommand\cftsecdotsep{\cftdotsep}
\renewcommand\cftsecleader{\cftdotfill{\cftsecdotsep}

Is that the correct syntax? I don't get an error anymore, but I also don't get a change in my TOC. It still has no dots between the list of figures, bibliography, etc and the page number. Did I implement your suggestion correctly?
MeganGentry
Posts: 8
Joined: Thu Nov 18, 2010 8:05 pm

how to dotfill the toc?

Post by MeganGentry »

Nevermind... I got it!

I removed the second line so that the end of my preamble just has...

Code: Select all

\renewcommand{\cftsecdotsep}{\cftdotsep}
Thanks for your help!
Last edited by Stefan Kottwitz on Tue Aug 09, 2011 7:53 pm, edited 1 time in total.
Post Reply