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]
moewe
  • 175,683
Rouge
  • 219
  • 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
  • It works good with me, because I want the contents to go to a new page. I've edited the question now, due to a new problem which came up. – Rouge Sep 29 '18 at 12:06
  • Does that mean you want a 'fake' section heading that appears only in the TOC but not actually in the document body? – moewe Sep 29 '18 at 12:07
  • Yes, this is exactly what I want. – Rouge Sep 29 '18 at 12:08
  • 1
    Not pretty, but \refstepcounter{section}\addcontentsline{toc}{section}{\protect\numberline{\thesection}Dolor} should do it. – moewe Sep 29 '18 at 12:12
  • Hm, this is not working properly. It shows Dolor in TOC but under chapter 3 and in the body of the text, it is showing no contents at all. I want only the heading to be gone, not the content. – Rouge Sep 29 '18 at 12:20
  • 1
    Where did you put the code? It should replace the \chapter{Dolor}. – moewe Sep 29 '18 at 12:22
  • I replaced \include{Dolor} by the code. – Rouge Sep 29 '18 at 12:23
  • 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
  • Thanks, now it works :). I replaced \section{Dolor} by your code. – Rouge Sep 29 '18 at 12:24
  • If you will write your comments as an answer, I can accept it (the green check mark) for the future users. – Rouge Sep 29 '18 at 12:25
  • Previously, my main tex file was MWE.tex and my chapters were lispum.tex, sit.tex, my section file was dolor.tex. I had all these tex files in the same folder. Is there a way I could create a subfolder for dolor.tex and the figures inside it and still be able to call \include{dolor.tex}? – Rouge Sep 29 '18 at 12:32
  • Yes, but you will need a package like https://ctan.org/pkg/import to help LaTeX along if you want to specify the path for graphics relative from dolor.tex and not relative from the main file. – moewe Sep 29 '18 at 12:36

1 Answers1

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"

moewe
  • 175,683
  • 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 03 '18 at 08: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 03 '18 at 09:03
  • @Rouge Maybe https://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 03 '18 at 09:06