0

enter image description hereI have a document with 3 chapters. I would like the chapter 2 - Dolor, to appear as a section 1.1 in the table of contents, instead of chapter 2.

I have separate file for each of the chapter and it must stay as a seperate file. How can call chapter as a section from inside chapter 1?

MWE is :

\documentclass[british]{report}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}
\usepackage{subfiles}
\usepackage[backend=biber, style=numeric-comp, refsection=chapter]{biblatex}
\addbibresource{biblatex-examples.bib}

\begin{document}
\tableofcontents
\include{Lorem}
\include{Dolor}
\include{Sit}
\end{document}

The contents of chapter 1 (Lorem.tex) are:

\chapter{Lorem}
Ipsum \autocite{sigfridsson} dolor \autocite{geer,worman}
\section{Lorem Section 1}
To err is human
\printbibliography[heading=subbibliography]

The contents of chapter 2 (Dolor.tex) are:

\chapter{Dolor}
Lorem ipsum \autocite{sigfridsson} dolor \autocite{knuth:ct:a,pines}
\printbibliography[heading=subbibliography]

The contents of chapter 3 (Sit.tex) are:

\chapter{Sit}
Lorem ipsum \autocite{sigfridsson} dolor 
\autocite{geer,cicero,companion}
\printbibliography[heading=subbibliography]
  • 2
    Write \section{Dolor} instead of \chapter{Dolor}. – moewe Sep 29 '18 at 11:49
  • 1
    But that will only help almost: The \include still causes the contents of Dolor to appear on a new page. If you don't want that you should probably use \input. Note that changing from \chapter to \section will also change the behaviour of the refsection. – moewe Sep 29 '18 at 11:56
  • 1
    Not pretty, but \refstepcounter{section}\addcontentsline{toc}{section}{\protect\numberline{\thesection}Dolor} should do it. – moewe Sep 29 '18 at 12:12
  • 1
    Where did you put the code? It should replace the \chapter{Dolor}. – moewe Sep 29 '18 at 12:22
  • 1
    Aha. That would do to much. Just replace the \chapter{Dolor} in the .tex file for the second chapter with the suggested bit of code. That code just fakes the heading entry for the TOC. It does nothing more. – moewe Sep 29 '18 at 12:24
1

If you only want to have a section heading in the TOC, but not in the actual document you need to use a few more low-level commands.

Replace \chapter{Dolor} with \tocsection{Dolor} where \tocsection is defined as below

\documentclass[british]{report}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}

\newcommand*{\tocsection}[1]{%
  \refstepcounter{section}%
  \addcontentsline{toc}{section}{\protect\numberline{\thesection}#1}}

\begin{document}
\tableofcontents

\chapter{Lorem}
lorem ipsum

\section{Ipsum}
lorem ipsum dolor sit amet

\tocsection{Dolor}
sit amet
\end{document}

TOC of the MWE: 1 Lorem//1.1 Ipsum//1.2 Dolor

Page one of the MWE: there is no heading for "1.2 Dolor", there is just a new paragraph between "lorem ipsum dolor sit amet" and "sit amet"

  • hi @moewe, I have encountered a problem in this answer. I see by using this the page header does not get updated. It sticks to the global name (Lorem). However, I would like the page header to get updated to sub-section name (Dolor). Can you please help? – Rouge Dec 3 '18 at 8:57
  • @Rouge Can you open a new question with a short example document that reproduces the issue along with a description of what you expect to see instead? – moewe Dec 3 '18 at 9:03
  • @Rouge Maybe tex.stackexchange.com/q/35433/35864 can help you already, but the exact details will depend on your class and the setup of your headers/footers. – moewe Dec 3 '18 at 9:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.