I was wondering about the inverse of this question:

Hiding section titles when the section is empty

Instead of hiding empty sections in LaTeX, can one display only empty sections or somehow indicate that a section is empty in the table of contents?


This comes as first idea:

\newcommand{\emphsection}[2]{% emhasizes empty sections
    \ifstrequal{ #2}{ }{\section[empty: #1]{#1} #2}{\section{#1} #2}%

\emphsection{Section 1}{%
This section won't be emphasized
\emphsection{Section 2}
Neither this one.
  • This works, thank you! (Just to clarify for others reading this: Argument #1 = section title, Argument #2 = section text.) Sep 16 '13 at 15:37
  • @AnthonyPulido This works, but there are some costs to making the section text an argument, notably that verbatim won't work any more, it's also slower although that is less important these days. Sep 16 '13 at 16:18
  • @DavidCarlisle Yes, I think you're right. I spoke too soon. I tried it on a small bit of text at first, which worked. I then tried it on what I wanted to use it on, text with subsections and long paragraphs. I'm now receiving an error: TeX capacity exceeded, sorry [input stack size=5000]. Sep 16 '13 at 16:38
  • @Crowley Would you have any new ideas? Sep 16 '13 at 16:39
  • 1
    @AnthonyPulido you can always omit the {} around a tex parameter, so if you omit the {} in this case the the argument is the first letter or command of the section, although in most cases that will work OK. Sep 17 '13 at 18:59

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.