| 1 |
\documentclass[a4paper]{article} |
| 2 |
\usepackage[dvips,a4paper]{geometry} |
| 3 |
\usepackage{verbdef} |
| 4 |
\verbdef\verbdefcmd|\verbdef| |
| 5 |
\providecommand\cs[1]{\texttt{\char`\\#1}} |
| 6 |
\begin{document} |
| 7 |
\title{The \textsf{verbdef} package\thanks{This documents version 0.2, of |
| 8 |
2000-10-06}} |
| 9 |
\author{Robin Fairbairns} |
| 10 |
\maketitle |
| 11 |
|
| 12 |
\section{What is it for?} |
| 13 |
|
| 14 |
Verbatim text is notoriously difficult in \TeX{}; in \LaTeX{} it adds |
| 15 |
confusion by being ``more fragile than fragile''. |
| 16 |
|
| 17 |
This package provides one way out of the impasse: the command |
| 18 |
\verbdefcmd, which defines a robust command that expands to verbatim |
| 19 |
text. |
| 20 |
|
| 21 |
\section{Using \verbdefcmd} |
| 22 |
|
| 23 |
The \verbdefcmd{} command can take an its verbatim string between |
| 24 |
matching characters, as \cs{verb} does: |
| 25 |
\begin{quote} |
| 26 |
\verbdefcmd\cs{demo}\texttt{|demonstration text|} |
| 27 |
\end{quote} |
| 28 |
or you may give it a more normal-looking argument: |
| 29 |
\begin{quote} |
| 30 |
\verbdefcmd\cs{demo}\texttt{\char`\{demonstration text\char`\}} |
| 31 |
\end{quote} |
| 32 |
|
| 33 |
The command also respects ``\texttt{*}'', as it's used in \cs{verb} |
| 34 |
and the \texttt{verbatim} environment: |
| 35 |
\begin{quote} |
| 36 |
\verbdefcmd\texttt{*}\cs{stardemo}\texttt{\char`\{with visible spaces\char`\}} |
| 37 |
\end{quote} |
| 38 |
% |
| 39 |
% another self-reference... |
| 40 |
\verbdef*\stardemo{with visible spaces}% |
| 41 |
which will define a verbatim text \stardemo{} (just like that). |
| 42 |
|
| 43 |
\section{Caveat} |
| 44 |
|
| 45 |
If the command you're defining with \verbdefcmd{} is to be used in a |
| 46 |
\cs{section}-type command, or a \cs{caption}, it's going to appear in |
| 47 |
the table of contents (or list of whatever else). In this case you |
| 48 |
\emph{must} define the command before the \cs{tableofcontents} command |
| 49 |
(or whatever). I recommend defining such commands in the preamble of |
| 50 |
the document\footnote{In fact, the source of the present document is |
| 51 |
so structured, since \verbdefcmd{} is used to define a command for |
| 52 |
\verbdefcmd\dots}. |
| 53 |
\end{document} |