Update: a previous version of this question wrongly attributed the problem to use of minitoc
to get section-level tables of contents (\secttoc
).
I've got a complicated document with a tables of content, and which switches between one and two-column mode.
I'd like to remove the subsection headings themselves from the text, but leave them in the TOCs.
I tried the recipe from this answer:
\newcommand{\nosubsection}[1]{%
\refstepcounter{subsection}%
\addcontentsline{toc}{subsection}{\protect\numberline{\thesubsection}#1}%
\markright{#1}}
This almost works, but the TOCs comes out wrong. I.E.,
1 first section
1.1 first sub
1.1.1 first subsub
1.1.2 second subsub
1.2.1 first subsub % <--- WRONG
1.2 second sub
but should really be
1 first section
1.1 first sub
1.1.1 first subsub
1.1.2 second subsub
1.2 second sub
1.2.1 first subsub
I think this is due to a strange interaction with the switching between one- and two-column mode: the first subsubsection in each subsection are put in the subsection above where they belong. This happens even when I just to include the supposedly do-nothing \onecolumn\twocolumn
.
Here's an MWE (or actually, a minimal failing example):
\documentclass[11pt]{article}
\newcommand{\nosubsection}[1]{%
\refstepcounter{subsection}%
\addcontentsline{toc}{subsection}{\protect\numberline{\thesubsection}#1}%
\markright{#1}}
\begin{document}
\tableofcontents
\section{first section---show all subs 1---works}
\subsection{first sub 1.1}
\twocolumn[{\subsubsection{first subsub 1.1.1}}]
\twocolumn[{\subsubsection{second subsub 1.1.2}}]
\subsection{second sub 1.2}
\twocolumn[{\subsubsection{first subsub 1.2.1}}]
\section{second section--don't show subs 2 --- fails}
\nosubsection{first sub 2.1} %\label{sub:2.1}
\twocolumn[{\subsubsection{first subsub 2.1.1}}]
\twocolumn[{\subsubsection{second subsub 2.1.2}}]
\onecolumn %%%% these casuse the problem, I think
\twocolumn
\nosubsection{second sub 2.2}
\twocolumn[{\subsubsection{first subsub 2.2.1 \textbf{WRONG}}}]
\end{document}
(Note that you need both nosubsection
and column-switching to get the failure.)
I have also tried using the multicol
package, and I get the same problem.
Any ideas?
\documentclass{...}
and ending with\end{document}
to help us reproduce your problem.includeonly
andimport
, but I can't trace it very far. Aaargh!\onecolumn
immediately followed by\twocolumn
means nothing.