[Tex/LaTex] Hide some text without hiding it from the table of contents

sectioningtable of contents

I know what I am trying to do could sound contrived. However, I am just writing my thesis. I am the beginning of the work, so I started writing down my table of contents, so as to provide a scaffolding for my work.

Now, while I would like to have my table of contents fully displayed, there are tons of titles and subtitles under it without any content, and that's irritating indeed.

Can I make that huge bunch of titles and subtitles disappear, without deleting those from the table of contents? I tried wrapping them inside an \iffalse\fi couple, but while indeed they were no longer displayed, they also disappeared from my table of contents.

What should I do? I don't care if the trick is dirty, it's just to have everything more tidy while I am still developing my contents.

Best Answer

I propose a \TODO prefix to the command for a chapter/section/subsection that has no contents yet:

\documentclass[a4paper]{book}

\usepackage{xparse}% for easier management of optional arguments

\ExplSyntaxOn
\NewDocumentCommand{\TODO}{msom}
 {
  \IfBooleanF{#1}% do nothing if it's starred
   {
    \cs_if_eq:NNT #1 \chapter { \cleardoublepage\mbox{} }
    \refstepcounter{\cs_to_str:N #1}
    \IfNoValueTF{#3}
     {
      \addcontentsline{toc}{\cs_to_str:N #1}{\protect\numberline{\use:c{the\cs_to_str:N #1}}#4}
     }
     {
      \addcontentsline{toc}{\cs_to_str:N #1}{\protect\numberline{\use:c{the\cs_to_str:N #1}}#3}
     }
   }
  \cs_if_eq:NNF #1 \chapter { \mbox{} }% allow page breaks after sections
 }
\ExplSyntaxOff

\begin{document}

\frontmatter

\tableofcontents

\mainmatter

\chapter{Introduction}

This has contents, which will be completed according
to the results in section~\ref{sec:procr}.

\chapter{Main thing}

\section{Whatever}

This has contents.

\TODO\section{Procrastination}\label{sec:procr}

\TODO\section[Short title for this one]
  {This section has a very very long title}

\TODO\chapter{Developments}

\end{document}

When you start writing contents, just remove the \TODO prefix.

enter image description here