Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Another question related to my university's odd ToC style requirements. Regular chapters in the ToC need to have all-caps titles, and appendices need regular-case titles. I have a perfectly elegant etoolbox solution

\documentclass{memoir}
\makeatletter
\usepackage{etoolbox}
\patchcmd{\@chapter}%
{\addcontentsline{toc}{chapter}}%
{\let\f@rtocold\f@rtoc%
 \def\f@rtoc{\uppercase\expandafter{\f@rtocold}}%
 \addcontentsline{toc}{chapter}}%
{\typeout{Chapter Patch Succeeded}}%
{\typeout{Chapter Patch Failed}}
\makeatother
\begin{document}
\tableofcontents*
\chapter{One}
This is chapter 1.
\appendix
\chapter{Alpha}
This is appendix A.
\end{document}

but it seems PCTeX 6 doesn't have e-TeX support built in (waiting on registration at the PCTeX forums so I can ask about that directly). I don't use it myself, but some people here do, and I'd like to avoid having them change TeX systems if possible.

I can't use memoir's built-in \patchcommand, since \@chapter has delimited arguments. I've tried using \Substitute* from ted, but no success yet. Replacing the commands between \makeatletter and \makeatother above with the following:

\usepackage{ted}
\Substitute*[\renewcommand{\@chapter}]{\@chapter}%
{\addcontentsline{toc}{chapter}}%
{\let\f@rtocold\f@rtoc%
 \def\f@rtoc{\uppercase\expandafter{\f@rtocold}}%
 \addcontentsline{toc}{chapter}}

I get Use of \@chapter doesn't match its definition. How can I convince \Substitute* to modify a command with arguments?

share|improve this question
    
thank you for making me (re-)discover ted. –  Bruno Le Floch Mar 12 '11 at 17:04

1 Answer 1

up vote 5 down vote accepted

Since \@chapter takes (delimited) arguments, we need to write them explicitly. \Substitute* expands \@chapter[#1]{#2} to the replacement text of \@chapter with the correct arguments. It then replaces \addcontentsline{toc}{chapter} by the thing you want. Finally, we perform the definition. The extra set of braces is to prevent the optional argument from terminating too early (when seeing ##1]). We double hash because somewhere in the middle of all this ted stores the final action into a control sequence.

\documentclass{memoir}
\makeatletter
\usepackage{ted}
\Substitute*[{\gdef\@chapter[##1]##2}]{\@chapter[#1]{#2}}%
{\addcontentsline{toc}{chapter}}%
{\let\f@rtocold\f@rtoc%
 \def\f@rtoc{\uppercase\expandafter{\f@rtocold}}%
 \addcontentsline{toc}{chapter}}
\makeatother
\begin{document}
\tableofcontents*
\chapter{One}
This is chapter 1.
\appendix
\chapter{Alpha}
This is appendix A.
\end{document}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.