summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/verbdef
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/verbdef
Initial commit
Diffstat (limited to 'macros/latex/contrib/verbdef')
-rw-r--r--macros/latex/contrib/verbdef/verbdef.pdfbin0 -> 63232 bytes
-rw-r--r--macros/latex/contrib/verbdef/verbdef.sty68
-rw-r--r--macros/latex/contrib/verbdef/verbdef.tex53
3 files changed, 121 insertions, 0 deletions
diff --git a/macros/latex/contrib/verbdef/verbdef.pdf b/macros/latex/contrib/verbdef/verbdef.pdf
new file mode 100644
index 0000000000..ecfa763a5f
--- /dev/null
+++ b/macros/latex/contrib/verbdef/verbdef.pdf
Binary files differ
diff --git a/macros/latex/contrib/verbdef/verbdef.sty b/macros/latex/contrib/verbdef/verbdef.sty
new file mode 100644
index 0000000000..6842113476
--- /dev/null
+++ b/macros/latex/contrib/verbdef/verbdef.sty
@@ -0,0 +1,68 @@
+% verbdef.sty v0.2 -- Robin Fairbairns 2000/10/06
+\ProvidesPackage{verbdef}[2000/10/06 v0.2 define verbatim csnames]
+
+% This package provides a single command \verbdef
+%
+% Usage: \verbdef\test|verbatim text|
+% \verbdef*\testar{with visible spaces}
+%
+% \test (or \testar) above will be defined as robust commands that
+% expand to typeset their `verbatim text' argument in the usual
+% verbatim font (using the visible space symbol in the * case)
+%
+% The verbatim text argument may be delimited in the same was as the
+% argument of a \verb command (see definition of \test above) or using
+% braces (see definition of \testar command above)
+%
+% Note: if the command you're defining with \verbdef is to be used in
+% a \section-type command, or a \caption, it's going to appear in the
+% table of contents, or list of whatevers; in this case you must
+% define the command *before* the \tableofcontents command (or
+% whatever). I recommend defining the commands in the preamble of
+% your document.
+
+% This program may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either version 1.1
+% of this license or (at your option) any later version.
+% The latest version of this license is in
+% http://www.latex-project.org/lppl.txt
+% and version 1.1 or later is part of all distributions of LaTeX
+% version 1999/06/01 or later.
+%
+% This program consists of the file verbdef.sty
+
+\newif\ifverbdef@nostar
+\def\verbdef{\verbdef@nostarfalse
+ \@ifstar\@sverbdef\@verbdef}
+\def\@verbdef{\verbdef@nostartrue\@sverbdef}
+
+% set up robustness of the command to be defined, set conditions for
+% reading verbatim text
+\def\@sverbdef#1{\edef\verbdef@tempa{\expandafter\@gobble\string#1}%
+ \edef#1{\noexpand\protect
+ \expandafter\noexpand\csname\verbdef@tempa\space\endcsname}%
+ \begingroup
+ \verb@eol@error
+ \let\do\@makeother \dospecials
+ \toks@{\verbatim@font\@noligs}%
+ \ifverbdef@nostar
+ \@vobeyspaces
+ \toks@\expandafter{\the\toks@\frenchspacing}%
+ \fi
+ \@verb@def}
+
+%
+\def\@verb@def#1{%
+ \ifnum`#1=`\{\relax
+ \catcode`\}\active
+ \lccode`\~`\}%
+ \else
+ \catcode`#1\active
+ \lccode`\~`#1%
+ \fi
+ \lowercase{%
+ \def\@tempa##1~{%
+ \expandafter\xdef\csname\verbdef@tempa\space\endcsname{%
+ {\the\toks@##1}}}}%
+ \afterassignment\endgroup
+ \@tempa}
diff --git a/macros/latex/contrib/verbdef/verbdef.tex b/macros/latex/contrib/verbdef/verbdef.tex
new file mode 100644
index 0000000000..e07315059a
--- /dev/null
+++ b/macros/latex/contrib/verbdef/verbdef.tex
@@ -0,0 +1,53 @@
+\documentclass[a4paper]{article}
+\usepackage[dvips,a4paper]{geometry}
+\usepackage{verbdef}
+\verbdef\verbdefcmd|\verbdef|
+\providecommand\cs[1]{\texttt{\char`\\#1}}
+\begin{document}
+\title{The \textsf{verbdef} package\thanks{This documents version 0.2, of
+ 2000-10-06}}
+\author{Robin Fairbairns}
+\maketitle
+
+\section{What is it for?}
+
+Verbatim text is notoriously difficult in \TeX{}; in \LaTeX{} it adds
+confusion by being ``more fragile than fragile''.
+
+This package provides one way out of the impasse: the command
+\verbdefcmd, which defines a robust command that expands to verbatim
+text.
+
+\section{Using \verbdefcmd}
+
+The \verbdefcmd{} command can take an its verbatim string between
+matching characters, as \cs{verb} does:
+\begin{quote}
+\verbdefcmd\cs{demo}\texttt{|demonstration text|}
+\end{quote}
+or you may give it a more normal-looking argument:
+\begin{quote}
+ \verbdefcmd\cs{demo}\texttt{\char`\{demonstration text\char`\}}
+\end{quote}
+
+The command also respects ``\texttt{*}'', as it's used in \cs{verb}
+and the \texttt{verbatim} environment:
+\begin{quote}
+ \verbdefcmd\texttt{*}\cs{stardemo}\texttt{\char`\{with visible spaces\char`\}}
+\end{quote}
+%
+% another self-reference...
+\verbdef*\stardemo{with visible spaces}%
+which will define a verbatim text \stardemo{} (just like that).
+
+\section{Caveat}
+
+If the command you're defining with \verbdefcmd{} is to be used in a
+\cs{section}-type command, or a \cs{caption}, it's going to appear in
+the table of contents (or list of whatever else). In this case you
+\emph{must} define the command before the \cs{tableofcontents} command
+(or whatever). I recommend defining such commands in the preamble of
+the document\footnote{In fact, the source of the present document is
+ so structured, since \verbdefcmd{} is used to define a command for
+ \verbdefcmd\dots}.
+\end{document}