0

I want to create a table of contents for my book. Therefore I put some chapters and sections into the text with \chapter and \section commands. That causes changes the display of the text. Is there a way for no changes into the original form and work ToC as well?

Edit: I'm looking for two things: 1. To have different names of chapters into the text and the contents. 2. The \chapter and \section commands not to change the original form of the text. Just to stay exactly as it appears in the first code that I posted.

\documentclass[a4paper,11pt]{book}
\usepackage{tcolorbox}

\begin{document}
\tableofcontents

\begin{center}
\begin{Large}
\begin{tcolorbox}[colbacktitle=red,colback=white!80!black , text width=10cm, title=\begin{center}
Chapter 1
\end{center}] \begin{LARGE}\begin{center}
\textbf{ Section 1.1 }
\end{center}
\end{LARGE}\end{tcolorbox}
\end{Large}
\end{center}


\begin{center}
\begin{Large}
\begin{tcolorbox}[colbacktitle=red,colback=white!80!black , text width=10cm, title=\begin{center}   
\chapter{Chapter 1}
\end{center}] \begin{LARGE}\begin{center}
\section{\textbf{ Section 1.1 }}
\end{center}
\end{LARGE}\end{tcolorbox}
\end{Large}
\end{center}

\end{document}
7
  • 3
    Welcome, its not fully clear what you want to achieve; what causes which specific changes? You don't need to count chapter and sections manually, Latex takes care of it. And to change the appearance of e.g. the font, you should not use commands like \section{\textbf{ Section 1.1 }}. There are packages which can handle it as well as editing counters etc. like tocloft, tocstyle or titletoc.
    – lukeflo
    Commented Aug 22, 2023 at 11:28
  • @lukeflo I'm looking for two things: 1. To have different names of chapters into the text and the contents. 2. The \chapter and \section commands not to change the original form of the text. Just to stay exactly as the first code that I posted (sorry for my bad english).
    – GSpyros
    Commented Aug 22, 2023 at 12:45
  • No problem. But its still not clear to me. Just edit your post and show, what you want as plain output without any TeX code mixed in.
    – lukeflo
    Commented Aug 22, 2023 at 13:52
  • 1
    I take you are formatting the chapter and section titles directly. You can use \addcontentsline to add titles to the TOC. This is commonly done with \section* and \chapter* (many examples on this site). Chapter and section numbers are handled by \numberline. Commented Aug 22, 2023 at 14:51
  • @lukeflo and John Kormylo thank you both. Actually \addcontentsline was the solution to the main problem and tocloft for the rest!
    – GSpyros
    Commented Aug 23, 2023 at 14:03

1 Answer 1

0

According to the discussion:

Actually \addcontentsline was the solution to the main problem and tocloft for the rest!

You must log in to answer this question.

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