[texhax] tabularx and titletoc/titlesec: harmful interaction?

Susan Dittmar Susan.Dittmar at gmx.de
Tue Jul 17 19:46:44 CEST 2012


Hi folks,

I just reallized that, if my guess at what's happening is correct, this has
nothing to do with titletoc and titlesec. I just tested, and the behaviour
stays the same if I use the original \section and \subsection commands.
Here's a new (and more minimal) example.

Thanks for any hints how to solve the problem,

	Susan

\documentclass{article}
\usepackage{tabularx}

\makeatletter

\newcounter{mysecdepth}
\setcounter{mysecdepth}{0}
\newenvironment*{mysection}{%
	\begingroup%
	\advance\value{mysecdepth} by 1 % local assignment
	\ifcase\value{mysecdepth}%
		\immediate\write16{mysection: counter mysecdepth has value 0! This can't happen!}%
		\expandafter\sectionI%
	\or\expandafter\section%
	\or\expandafter\subsection%
	\else%
		\immediate\write16{mysection: No more hierarchy levels!}%
		\expandafter\subsection%
	\fi%
}{%
	\par%
	\endgroup%
}%
\makeatother

\begin{document}

\begin{mysection}{first section}
	text of first section
	\begin{mysection}{first subsection of first section}
	text of first subsection of first section
	\end{mysection}
\end{mysection}

\begin{mysection}{second section}
	text of second section
\end{mysection}

\begin{mysection}{third section}
	text of third section

	\begin{tabularx}{\linewidth}{X}
	This is a tabularx \\
	just to show my problem.\\
	\end{tabularx}
\end{mysection}

\begin{mysection}{fourth section}
	text of fourth section, which falsely was chosen to
	be first subsection of section tree
\end{mysection}

\end{document}



More information about the texhax mailing list