0

I'm using XeLaTeX compiler to create my pdf documents. Recently I had to adjust some lengths in tocloft table of contents, for example I tried changing \cftbeforechapskip using \setlength command -- but I keep getting two errors: Undefined control sequence and Missing \begin{document}.

Please note that I have to have Times font in my document (so I included the way I set it up in code example).

Using \setlength with other (not tocloft) lengths sometimes gives warnings but works nevertheless.

Here is my code example:

%------------------ basic document settings -------------------------------
\documentclass[14pt]{article} % шрифт и формат документа

\usepackage{polyglossia}
\setmainlanguage{russian}
\setmainfont[]{Times New Roman}
%------------------ ToC setup -------------------------------------------------------
\usepackage{tocloft}
\setlength{\cftbeforechapskip}{0cm} %this line gives errors

\author{Мамонтов Иван, Т12О-402Б-20}
%----------------------------------------------------------------------------------------
\begin{document}

\tableofcontents

\section{Part one}
\subsection{Subpart one}

\section{Part two}

\end{document}

This code example produces log file with these errors:

LaTeX Error: Missing \begin{document}. l.9 \setlength{\cftbeforechapskip}{0cm}

Undefined control sequence. \cftbeforechapskip l.9 \setlength{\cftbeforechapskip}{0cm}

LaTeX Warning: Unused global option(s): [14pt].

2
  • 1
    You're using article that has no chapters. Unrelated, there is no 14pt option for article.
    – egreg
    Commented Mar 24 at 10:47
  • Actually, your first error message is Undefined control sequence. \cftbeforechapskip, which has been explained by @egreg. The other message, Missing \begin{document}., is just a consequence of this error. So either use the document class report instead of article, or don't use \cftbeforechapskip, as there will be no chapters.
    – gernot
    Commented Mar 24 at 11:10

1 Answer 1

0

The tocloft package only defines \cftbeforechapskip, together with all other \cftchap[...] commands or parameters, only if the document class provides for \chapter.

\if@cfthaschapter
  \newlength{\cftbeforechapskip}
    \setlength{\cftbeforechapskip}{1.0em \@plus\p@}
  \newlength{\cftchapindent}
    \setlength{\cftchapindent}{0em}
[...]
\fi

Setting \cftbeforechapskip with a class that hasn't chapters would be useless, because it would never be employed.

In your case you probably wanted to set \cftbeforesecskip.

%------------------ basic document settings -------------------------------
\documentclass[12pt]{article} % шрифт и формат документа

\usepackage{polyglossia}
\usepackage{tocloft}

%%%% settings

% languages and fonts
\setmainlanguage{russian}
\setmainfont{Times New Roman}

% toc
\setlength{\cftbeforesecskip}{0cm}

\begin{document}

\author{Мамонтов Иван, Т12О-402Б-20}

\tableofcontents

\section{Part one}
\subsection{Subpart one}

\section{Part two}

\end{document}

I fixed the 14pt option (that doesn't exist) to 12pt.

enter image description here

1
  • Thanks! I totally forgot that I use sections instead of chapters Commented Mar 24 at 12:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .