I need a macro that is executed only in the main document (within a section title) and then disappears (for the table of contents).
A minimal example where this occurs is this:
\documentclass[12pt]{memoir}
\usepackage{fixltx2e}[2006/09/13]
\usepackage{times}
\usepackage[T1]{fontenc}
\usepackage{txfonts}
\begin{document}
\tableofcontents
\section{The only section}
Text.
\section{The only section [\textsl{continued}]}
More text.
\section{The only section [\textsl{continued\hspace{0.13ex}}]}
An attempted fix.
\end{document}
The first section title with "[continued]" in it is badly kerned. The manual adjustment (\hspace{0.13ex}
) does the job, but it unfortunately leads to too much space in the table of contents. I would like the extra space to apply only to the actual section heading in the document's body. (I tried every conceivable combination of \/
, \hspace
, and \protect
; nothing works.)
The culprit (what causes kerning to disappear) is clearly the loading of txfonts
, which I need elsewhere in my document. (Yep, I need txfonts
instead of newtxtext
/newtxmath
for an obscure reason having to do with font loading order I'd rather not get into, and circumventing the issue underlying that would be for another question anyways. And my sample code makes for a useful example.) If I omit txfonts
, the problem disappears, meaning I don't need to insert a manual space in the first place. (This might point to another problem.)
Related:
\section[<stuff for the toc>]{<Actual section heading>}
?{ }
) in addition to[ ]
for the first]
not to terminate the optional argument ... Is this quirk documented anywhere?]
, and this character is not supposed to function as the optional argument terminator but as a matching square bracket/parenthesis. Enclosing this in a group works, but I don't know whether doing this has other side effects. There is no (obvious) way other than writing[{ }]
because[
and]
are not normally escaped. That[
and]
are normal characters and bear syntactic function (as optional argument delimiters) creates this potentially problematic situation.