CTAN has a new package: cprotect
Date: January 1, 2011 6:42:01 AM CET
This should be at your local mirror.
Thanks again,
Jim Hef{}feron
Saint Michael's College
..................................................................................
The following information was provided by our fellow contributor:
Name of contribution: cprotect.zip
Version number: 1.0
Author's name: Bruno Le Floch
Summary description: verbatim in macro arguments (\footnote, \section,...)
License type: lppl
Announcement text:
Introduces the macro \cprotect, which allows the control sequence that follows to take verbatim text among its argument. For instance, \footnote, \section, \chapter, \title... can be made to contain \verb, and \begin{verbatim}...\end{verbatim}, as well as any \catcode change. Moving arguments, \tableofcontents, etc. also work well! A typical use: \cprotect\section{The \verb+|+ symbol.} works as wanted. Similar command for protecting environments.
Note from author:
I am also thinking of writing a package that parses a TeX file for regexp, if people think it might be useful (probably a hard exercise in catcode changes). Let me know.
This package is at http://tug.ctan.org/tex-archive/macros/latex/contrib/cprotect . Information is at http://tug.ctan.org/pkg/cprotect (it may take a day for the information to appear). We are supported by the TeX Users Group http://www.tug.org . For your users group see http://www.tug.org/usergroups.html .
Introduces the macro \cprotect, which allows the control sequence that follows to take verbatim text among its argument. For instance, \footnote, \section, \chapter, \title... can be made to contain \verb, and \begin{verbatim}...\end{verbatim}, as well as any \catcode change. Moving arguments, \tableofcontents, etc. also work well! A typical use: \cprotect\section{The \verb+|+ symbol.} works as wanted. Similar command for protecting environments.
Note from author:
I am also thinking of writing a package that parses a TeX file for regexp, if people think it might be useful (probably a hard exercise in catcode changes). Let me know.
This package is at http://tug.ctan.org/tex-archive/macros/latex/contrib/cprotect . Information is at http://tug.ctan.org/pkg/cprotect (it may take a day for the information to appear). We are supported by the TeX Users Group http://www.tug.org . For your users group see http://www.tug.org/usergroups.html .
cprotect – Allow verbatim, etc., in macro arguments
The package defines the macro \cprotect that makes a following macro proof against verbatim in its argument; as, for example, \cprotect\section{\verb"foo"}
A similar macro \cprotEnv (applied to the \begin of an environment) sanitises the behavior of fragile environments.
Moving arguments, and corresponding “tables of …” work happily.
Package | cprotect |
Version | 1.0e |
Copyright | 2010–2011 Bruno Le Floch |
Maintainer | Bruno Le Floch |