I use Lyx 2.1, class document : report.
I created a general introduction as unnumbered chapter, but at the table of Contents, the introduction does not exist.
[Tex/LaTex] Add an unnmbered section to the table of Contents in Lyx
lyxtable of contents
Related Solutions
If the standard setup is applied, no empty second page of the ToC should appear, regardless whether \tableofcontents
, \listoffigures
etc. is used.
I have used a loop to generate dummy chapters, dummy figures and dummy tables just in order to fill up the corresponding list of something
(;-)) and removed the \thispagestyle{empty}
used directly after \tableofcontents
by the OP.
Basically, Torbjorn T. changed already the code sample in the OP to a working one ;-)
**Edited version, with list of figures
and list of tables
also in the toc
\documentclass{report}
\usepackage{setspace}%
\usepackage[demo]{graphicx}%
\usepackage{forloop} % Only for quick chapters ;-)
%\usepackage{hyperref}%
\newcounter{loopcounter}
\begin{document}
\pagenumbering{roman}%
\begin{onehalfspace}%
%\phantomsection% if hyperref is used, then \phantomsection
\addcontentsline{toc}{chapter}{\contentsname}%
\tableofcontents%
\cleardoublepage
%\phantomsection% if hyperref is used, then \phantomsection
\addcontentsline{toc}{chapter}{\listfigurename}%
\listoffigures%
\cleardoublepage
%\phantomsection% if hyperref is used, then \phantomsection
\addcontentsline{toc}{chapter}{\listtablename}%
\listoftables%
\end{onehalfspace}%
\clearpage
% Just a proof that `\pagenumbering{arabic}` resets the page counter
\setcounter{page}{100}
\pagenumbering{arabic}
\forloop{loopcounter}{1}{\number\value{loopcounter} < 21}{%
\chapter{Chapter \number\value{loopcounter}}
\begin{table}
\centering
\begin{tabular}{lll}
\hline
1 & 2 & 3 \tabularnewline
\hline
\end{tabular}
\caption{Dummy table}
\end{table}
\begin{figure}%
\centering
\includegraphics[width=5cm,height=4cm]{somefig}%
\caption{Dummy figure}
\end{figure}%
}
\end{document}
Editorial note I kept the screenshot, since nothing visually changed for that part of the document.
This is a wrong approach. Give to Caesar what belongs to Caesar and to \title
what belongs to \title
(that is, the title of the document and nothig else).
What you show is the ToC of a book, not of an article, with chapters, and a front matter with roman numerals, etc. Force to the article class to behave like a book is against nature.
A better approach is to use the memoir
class and simply add the option article
to format the chapters like the sections, without having to do anything else. Moreover, this class is very customizable, so you can change the ToC exactly as you showed without the help of extra packages. Example:
\documentclass[article,oneside,12pt]{memoir}
\usepackage{lipsum}
\setsecnumdepth{subsubsection}
\settocdepth{subsubsection}
\renewcommand{\contentsname}{Table of contents}
\renewcommand*{\cftchapterdotsep}{\cftdotsep}
\renewcommand*{\cftchaptername}{Chapter\space}
\renewcommand{\cftchapteraftersnum}{.}
\begin{document}
\frontmatter
\tableofcontents* % * = No sense show the ToC in the ToC ...
\clearpage
\listoftables\clearpage
\listoffigures\clearpage
\mainmatter
\chapter{foo}\lipsum[1-10]
\section{abc}\lipsum[11-20]
\section{def}\lipsum[21-30]
\begin{table}\caption{table}\end{table}\newpage
\begin{figure}\caption{figure}\end{figure}\newpage
\subsection{ghi}\lipsum[31-39]
\subsection{jkl}\lipsum[40-49]
\subsubsection{mno}\lipsum[50-52]
\subsubsection{pqr}\lipsum[54]
\chapter{bah}\lipsum[55]
\end{document}
Best Answer
There is no formal LyX way to insert general content into the Table of Contents (ToC) other than using an ERT (the (La)TeX way). As such, you should insert an ERT containing
immediately after you've inserted the chapter. For alignment purposes (of the numbers in the ToC), you could also use
One could modify the LaTeX preamble to always insert an unnumbered chapter into the ToC by adding the following:
However, you may not be interested in this generic redefinition.