From e0c6872cf40896c7be36b11dcc744620f10adf1d Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Mon, 2 Sep 2019 13:46:59 +0900 Subject: Initial commit --- macros/latex/contrib/gmverb/README | 70 ++ macros/latex/contrib/gmverb/gmverb.pdf | Bin 0 -> 216613 bytes macros/latex/contrib/gmverb/gmverb.sty | 1371 ++++++++++++++++++++++++++++++++ 3 files changed, 1441 insertions(+) create mode 100644 macros/latex/contrib/gmverb/README create mode 100644 macros/latex/contrib/gmverb/gmverb.pdf create mode 100644 macros/latex/contrib/gmverb/gmverb.sty (limited to 'macros/latex/contrib/gmverb') diff --git a/macros/latex/contrib/gmverb/README b/macros/latex/contrib/gmverb/README new file mode 100644 index 0000000000..05c87b404d --- /dev/null +++ b/macros/latex/contrib/gmverb/README @@ -0,0 +1,70 @@ +The gmverb package +is a work of Grzegorz `Natror' Murzynowski, + + + +1. Copyright 2006, 2007, 2008, 2009, 2010 by Grzegorz `Natror' Murzynowski + +This program is subject to the LaTeX Project Public License. +See http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html +for the details of that license. + + +2. Introduction + +The gmverb.sty package redefines the \verb command and the {verbatim} +environment so that the verbatim text can break into lines, with % as +a `hyphen'. Moreover, it allows the user to define his/her own +{verbatim}-like environments provided their contents would be not +horribly long (as long as a macro's argument may be at most). + +This package also allows the user to declare a chosen char(s) as +a `short verb' e.g., to write |\a\verbatim\example| instead of +\verb|\a\verbatim\example|. + + +3. Installation + +Unpack the gmverb-tds.zip in a texmf directory or put the gmverb.sty +somewhere in the texmf/tex/latex branch on your own. Creating a +/texmf/tex/latex/gm directory may be advisable if you consider using +other packages written by me. + +Then you should refresh your TeX distribution's files' +database most probably. + + +4. Contents + +The distribution of this package consists of the following three files. + +gmverb.sty +README +gmverb.pdf +gmverb-tds.zip + +5. Documentation + +The last of the above files (the .pdf) is a documentation compiled +from the .sty file by running LaTeX on the gmverb.sty file twice: +xelatex gmverb.sty + in the directory you wish the documentation to be in, +you don't have copy the .sty file there---TeX will find it, +then MakeIndex on the gmverb.idx file, and then LaTeX +on gmverbDoc.tex once more. + +MakeIndex shell command: + makeindex -r gmverbDoc +The -r switch is to forbid MakeIndex make implicit ranges since the +(code line) numbers will be hyperlinks + +Compiling of the documentation requires the packages: gmdoc +(gmdoc.sty and gmdocc.cls), gmverb.sty, gmutils.sty and also some +standard packages: hyperref.sty, xcolor.sty, geometry.sty, +multicol.sty, lmodern.sty, fontenc.sty that should have been installed +on your computer by default. + +If you have not installed the mwart.cls class (available on CTAN in +mwcls package), the result of your compilation may differ a bit from +the .pdf provided in this .zip archive in formattings: If you have not +installed mwart.cls, the standard article.cls will be used. diff --git a/macros/latex/contrib/gmverb/gmverb.pdf b/macros/latex/contrib/gmverb/gmverb.pdf new file mode 100644 index 0000000000..7209be0987 Binary files /dev/null and b/macros/latex/contrib/gmverb/gmverb.pdf differ diff --git a/macros/latex/contrib/gmverb/gmverb.sty b/macros/latex/contrib/gmverb/gmverb.sty new file mode 100644 index 0000000000..16a6465148 --- /dev/null +++ b/macros/latex/contrib/gmverb/gmverb.sty @@ -0,0 +1,1371 @@ +%% +% \skiplines +%<*master> +%% \iffalse ^^A we skip the debug setting +\IfFileExists{\string~/bin/gen_and_xela}{\errorcontextlines=1000 }{} +%% \fi +%% ^^A $Id: TheUltimateMaster.gmd,v 0.352 2011/10/12 15:19:42 natror Exp natror $ +% \endskiplines +% +%% \BundleInfoFromName{gmverb} +%% \title{The \pk {gmverb} Package\thfileinfo } +%% \author{Grzegorz Murzynowski} +%% \maketitle +%% +%% \let\ty\emph \let\df\dekfracc +%% +%% \begin{copyrnote} +%% +%% +%% Copyright ©\, 2005, 2006, 2007, 2008, 2009, 2010, 2011 +%% by Grzegorz ‘Natror’ Murzynowski +%% natror (at) gmail (dot) com +%% +%% This program is subject to the \LaTeX\ Project Public License. +%% See ^^A +%% \url{http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html} ^^A +%% for the details of that license.\rrthis +%% +%% \acro{LPPL} status: "author-maintained". \par +%% +%% +%% +%% +%% +%% For documentation please refer to the file(s) +%% \file{gmverb.{sty,pdf}}. +%% +%% \end{copyrnote} +%% +% +% +% \skiplines +% +% \endskiplines +% +% +%% +%% +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{gmverb} + [2011/10/14 v0.98 After shortvrb (FM) but my way (GM)] + + +%<*master> +% +% (A handful of meta-settings skipped) +% \skiplines +\def\Name#1#2{\expandafter#1\csname#2\endcsname} + +% The »v« letter before version number is obligatory and will be +% passed further. +\def\ProvideDateVersion#1[#2 v#3]{% + \Name\def{#1Date}{#2}% + \Name\def{#1Version}{v#3}% +} + +\def\ProvideInfo#1[#2 v#3 #4]{% + \ProvideDateVersion{#1}[#2 v#3]% + \Name\def{#1Info}{#4}% +} + +\def\ProvideLeafInfo#1[#2 v#3 #4]{% + \ProvideDateVersion{#1}[#2 v#3]% + \Name\def{#1LeafInfo}{#4}% +} + +\def\gmutilsThanks{% + Many thanks to my \TeX\ Guru Marcin Woliński for his \TeX nical + support.% +} + +% \endskiplines +% +%\skiplines we skip the driver +%<*master> +\ifnum\catcode`\@=12 + + +\documentclass[debug, countalllines, codespacesgrey, outeroff, +% +pagella, trebuchet, cursor, fontspec=quiet]{gmdocc} + +\usepackage{eufrak}% for |\continuum| in the commentary. +\twocoltoc + + +% +% +% + +\ifdefined\XeTeXversion % was a switch |\ifgmuXeTeX|, but that caused + % an error when not defined (e.g., package \pk{gmmacros} loaded with a standard class). + +\verbLongDashes +\GMverbatimspecials + +\let\zwr\emph % for foreign phrases (in the narration layer of course) + +\fi % of if \XeTeX + + +\begin{document} + +\addtocontents{toc}{\unexpanded{\let\thfileinfo\relax}} + +\DefaultIndexExclusions + +\def\gmdExt{% + sty% +} + +\addtomacro\IndexParms {\noverbatimspecials} + +\DocInput{\jobname.\gmdExt} + +% ^^A \unless\ifcsname textfont@name\endcsname +% ^^A \Name\def{textfont@name}{\small} +% ^^A \fi +% ^^A \unless\ifcsname scriptfont@name\endcsname +% ^^A \Name\def{scriptfont@name}{\scriptsize} +% ^^A \fi + +\PrintChanges +\let\hyperindexformat\firstofone +\PrintIndex + +\thispagestyle{empty} +\typeout{% + Produce change log with^^J% + makeindex -r -s gmglo.ist -o \jobname.gls \jobname.glo^^J + (gmglo.ist should be put into some texmf/makeindex directory.)^^J} +\typeout{% + Produce index with^^J% + makeindex -r \jobname^^J} +\afterfi{\end{document}} + +\fi% of driver pass +% +%\endskiplines +% +% \enoughpage 18 +% \tableofcontents +% +% +% \ChangesStart{}{1000/00/00} +% +% \chschange{v0.70}{06/8/15}{523} +% \chschange{v0.71}{06/9/04}{596} +% \chschange{v0.72}{06/9/05}{660} +% \chschange{v0.73}{06/9/06}{671} +% \chschange{v0.74}{06/9/7}{678} +% \chschange{v0.76}{06/9/24}{679} +% \chschange{v0.77}{06/9/28}{639} +% \chschange{v0.78}{06/12/1}{648} +% \chschange{v0.80}{07/3/2}{683} +% \chschange{v0.80}{07/3/30}{667} +% \chschange{v0.82}{2007/4/26}{663} +% \chschange{v0.83}{2007/11/9}{666} +% \chschange{v0.84}{2007/11/13}{658} +% \chschange{v0.85}{2008/5/1}{673} +% \chschange{v0.87}{2008/8/6}{661} +% \chschange{v0.88}{2008/8/13}{682} +% \chschange{v0.89}{2008/8/30}{686} +% \chschange{v0.90}{2008/10/8}{684} +% \chschange{v0.91}{2008/11/21}{686} +% \toCTAN{2008/11/21 v0.91} +% \chschange{v0.92}{2008/12/18}{979} +% [\cmd\verbatimspecials, hyphenation in verbatims, low star in +% verbatims, kerning of backslash in shrunk fonts] +% \chschange{v0.93}{2010/3/4}{1035} +% [ a bug fix in \cmd\scanverb\space (halfing the hashes)] +% \toCTAN{2010/03/04 v0.93} +% \chschange{v0.94}{2010/07/07}{979} +% [wrapping the \ac{UTF-8} dashes' setting in a \protect\XeTeX's conditional] +% \toCTAN{2010/07/07 v0.94} +% \chschange{}{2010/10/24}{1040} +% \toCTAN{2011/02/02 v0.95} +% \chschange{}{2011/10/14}{997} +% \toCTAN{2011/10/14 v0.98} +% +% \division{Intro, usage} +% +% This package redefines the |\verb| command and the \env{verbatim} +% environment so that the verbatim text can break into lines, with |%| +% (or another character chosen to be the comment char) as +% a~`hyphen'. Moreover, it allows the user to define \hisher\ own +% \env{verbatim}-like environments provided their contents would be not +% \emph{horribly} long (as long as a macro's argument may be at most). +% +% This package also allows the user to declare a chosen char(s) as +% a `short verb' e.g., to write \verb+|\a\verbatim\example|+ instead of +% \verb+\verb|\a\verbatim\example|+. +% \dekmedskip +% +% The \pk{gmverb} package redefines the |\verb| command and the +% \env{verbatim} environment in such a~way that | |, |{| and |\| are +% breakable, the first with no `hyphen' and the other two with the +% comment char as a~hyphen. I.e., |{|\|}| breaks into +% |{%|\par \|}| ^^A] bal. braces for Emacs +% and \|\mymacro| breaks into \|%|\par +% |\mymacro|. +% +% (If you don't like line breaking at backslash, there's the +% \TextUsage\nobreakbslash\ declaration (observing the common scoping +% rules, hence \acro{OCSR}) and an analogous +% declaration for the left brace: \TextUsage\nobreaklbrace.) +% \dekmedskip +% +% The default `hyphen' is |%| since it's the default comment char. If +% you wish another char to appear at the line break, use the +% \TextUsage\VerbHyphen\ declaration that takes |\|\ as the only +% argument. This declaration is always global. +% +% \stanza +% Another difference is the \TextUsage\verbeolOK\ declaration +% (\acro{OCSR}). Within its scope, |\verb| allows an +% end of a~line in its argument and typesets it just as a~space. +% +% As in the standard version(s), the plain |\verb| typesets the spaces +% blank and |\verb*| makes them visible. +% +% Moreover, \pk{gmverb} provides the \TextUsage\MakeShortVerb\ macro +% that takes a~one-char control sequence as the only argument and +% turns the char used into a~short verbatim delimiter, e.g., after +% \verb+\MakeShortVerb*\|+ (as you guess, the declaration has its +% starred version, which is for visible spaces, and the non-starred for +% the spaces blank) you may type \verb+|\mymacro|+ to get |\mymacro| +% instead of typing |\verb+\mymacro+|. Because the char used in this +% example is my favourite and used just this way by DEK in the +% \TeXbook's format, \pk{gmverb} provides a~macro \TextUsage\dekclubs\ +% as a~shorthand for \verb+\MakeShortVerb(*)\|+. +% +% Be careful because such active chars may interfere with other +% things, e.g.\ \verb+|+ with the \pk{tikz} package. If this +% happens, you can declare \TextUsage\DeleteShortVerb\verb+\|+ +% and the previous meaning of the char used shall be restored. +% +% One more difference between \pk{gmverb} and \pk{shortvrb} is that +% the chars |\active|ated by |\MakeShortVerb| in the math mode behave +% as if they were `other', so you may type e.g., \verb+$2|0$+ to get +% $2|0$ and |+| |\active|ated this way is in the math mode typeset properly +% etc. +% +% However, if you don't like such a~conditional behaviour, you may +% specify some |$$$$|'s (any nonempty seQuence) mixed with star(s) if +% you wish as an optional argument to keep the short-verbatim char +% behave as short-verbatim also in math mode. +% +% For compatibility with \pk{gmdoc} and for convenience there is a +% shorthand for that provided, \TextUsage\OldMakeShortVerb.% +% +% +% There's one more declaration provided by \pk{gmverb}: +% \TextUsage\dekclubs, which is a~shorthand for +% \verb+\MakeShortVerb\|+, \TextUsage*{\dekclubs*}\ for +% \verb+\MakeShortVerb*\|+ and \TextUsage\olddekclubs\ for +% \verb+\OldMakeShortVerb\|+. +% +% There's one more declaration, \TextUsage\edverbs\ that makes +% \cs{[} %^^A] +% checks if the next token is an active char and opens an |\hbox| if +% so. That is done +% so that you can write (in |\edverbs|' and |\dekclubs|' scope) +%\[\verb+\[||\]+\] +% instead of +%\[\verb+\[\hbox{||}\]+\] +% to get a~displayed shortverb. +% +% Both versions of |\dekclubs| \acro{OCSR}. +% +% The \env{verbatim} environment inserts |\topsep| before and after +% itself, just as in standard version (as if it was a~\env{list}). +% +% In August 2008 Will Robertson suggested grey visible spaces for +% \pk{gmdoc}. I~added a~respective option to \pk{gmdoc} but I~find +% them so nice that I~want to make them available for all verbatim +% environments so I~bring here the declaration +% \TextUsage\VisSpacesGrey. It redefines only the visible spaces so +% affects \cs{verb*} and \env{verbatim*} and not the unstarred +% versions. The colour of the visible spaces is named +% \TextUsage*{visspacesgrey} and you can redefine it \pk{xcolor} way. +% +% \stanza +% We also provide the \TextUsage\verbatimspecials\ declaration that +% takes six arguments: +% \begin{enumargs} +% \dc * m a~char for verbatim escape char (for catcode 0), has to be +% unbraced\qfootnote{To be precise, the arguments cannot be wrapped in +% curly braces because those are recatcoded to +% ‘other’. But if you make some other pair of chars category 1 and 2 +% that are not on the \cmd\dospecials\ list, then you can wrap the +% arguments in those chars. But what for?}, +% \dc * m a~char for group starter (for catcode 1), has to be +% unbraced, +% \dc * m a~char for group ender (for catcode 2), has to be +% unbraced, +% \opt (optional) a~char for verbatim math shift (for catcode 3); it has +% to be in square brackets if present. If +% absent, nothing is set for the verbatim math shift, +% \opt (optional) a~char for the shorthand for |\metachar|; it has to be +% in square brackets if present. If provided, e.g., |⁄››| as I suggest +% in |\GMverbatimspecials|, then it itself becomes an active char +% let-equal to |\meta|, and a \CS made of it, |⁄›⁄›| in this example, +% becomes |\string|. +% \dc b optional in curly braces, additional stuff (commands) to be +% executed in a~verbatim. +% \end{enumargs} +% All the specials defined this way, except the meta char, if preceded +% with the escape char, will be typeset verbatim. +% +% For example, after telling \TeX +% \[|\verbatimspecials ⁄⁄ ⁄« ⁄» [ ⁄¿ ] [ ⁄›› ] {\def⁄›⁄|{$\vert$}}|\] (the +% slash is Unicode Fractional Slash, spaces are ignored) you +% can write \[\verb:|\macro⁄⁄arg⁄«arg. ⁄¿n+1⁄¿⁄»\⁄››[No⁄››]Value⁄››(T⁄⁄|F⁄››)|:\] to get +% \[|\macro⁄arg«arg. ¿n+1¿»\›[No›]Value›(T⁄|F›)|\]%^^A| +%% +% +% Note also that \verb+⁄⁄|+ is a~control sequence so it doesn't +% delimit the short verbatim \verb+|+'s argument. +% +% The \cmd\verbatimspecials\ declaration \acro{OCSR}. Subsequent uses +% of it override the previous settings. If you specified the optionals +% at first and then specify |\verbatimspecials| without optionals, the +% previous optional settings are forgotten. +% +% To turn the ‘verbatim specials’ off write +% \TextUsage\noverbatimspecials, which \acro{OCSR} too. +% +% Note that although we don't provide a~‘verbatim superscript’ nor +% ‘verbatim subscript’, you have the \TextUsage\sups\ and +% \TextUsage\subs\ \CS'es defined by \pk{gmutils}. +% +% The 4th argument for the math shift is optional because you can use +% \TextMarginize*{\( \)} \LaTeX's |\(| and |\)|. +% +% The |\verbatimspecials| declaration goes a~step further than +% \LaTeX's \TextUsage*{alltt} and Til Tantau's \pk{beamer}'s +% \TextUsage*{semiverbatim} environments. To get their effect, declare +%\[|\verbatimspecials\{}|\] +% +% \stanza +% There is something for verbatims in arguments of commands: +% \TextUsage\scanverb\arg*{text}. However there are some limitations: +% if |%| is the comment char (which is usual situation), then you +% cannot use |%| in \, or rather, |%| will act as comment char +% anyway. Moreover, spaces are ignored. This last limitation may be +% worked around if you declare |\verbatimspecials|, say |⁄⁄| (fraction +% slash) as the escape char. Then you can use |⁄⁄ | to put a~space +% which will be typeset blank in the unstarred version and visible +% with star. +% +% \stanza Not so long ago I started to use the ‘broken bar’ (U+00A6, +% |¦|) character as a hyphen in hyperlinks, because it seems not to +% occur in hyperlinks at all unlike hyphen. I suggest the same char +% for verbatims, but if you don't like it, there's the +% \TextUsage\verbDiscretionaryHyphen declaration that takes two +% arguments. Broken bar is declared as +% \[|\verbDiscretionaryHyphen{"A6}{¦}|\] +% +% \stanza Since version 0.95 (August 2010) this package also provides +% the |\VerbatimPitch| declaration that modifies the \env{verbatim} +% environments and derivatives so that the environment contents +% (recatcoded, i.e.\ “sanitised”) are wrapped in the macro +% |\VerbatimContents| and therefore available after environment's end +% (after |\endverbatim| to be precise, so also in the end-def of a +% derivative verbatim). +% +% This may be useful for \TeX nical examples: you can rescan the +% contents of a verbatim with |\scantokens| and execute/typeset it. +% Such a thing is done in the \pk{gmdoc} package, see the +% \env{verbatim@p} environment. +% +% +% +% \subdivision{The package options} +% As many good packages, this also does not support any options. +% +% \begin{gmlonely} +% \subdivision{Installation} +% +% Unpack the \file{\jobname-tds.zip} +% archive (this is an archive that conforms the \acro{TDS} standard, +% see \file{CTAN/tds/tds.pdf}) in some texmf directory or just put +% the \pk{gmutils.sty} somewhere in the \file{texmf/\:tex/\:latex} +% branch. Creating a \file{texmf/\:tex/\:latex/\:gm} directory may +% be advisable if you consider using other packages written by me. +% +% Then you should refresh your \TeX\ distribution's files' database +% most probably. +% \end{gmlonely} +% +% \subdivision{Contents of the \pk{\jobname.zip} archive} +% +% The distribution of the \pk{gmutils} package consists of the +% following three files and a \acro{TDS}-compliant archive. +% \begin{verse} +% \pk{\jobname.\gmdExt}\\ +% \pk{README}\\ +% \pk{\jobname.pdf}\\ +% \pk{\jobname.tds.zip} +% \end{verse} +% +% \begin{gmlonely} +% \subdivision{Compiling of the documentation} +% +% The last of the above files (the \pk{.pdf}, i.e., \emph{this +% file}) is a documentation compiled from the \pk{.\gmdExt} file by +% running \LaTeX\ on the \pk{\jobname.\gmdExt} file twice +% (|xelatex ⁄jobname.⁄gmdExt| in the directory you wish the +% documentation to be in^^A +% \ifnum\numexpr\strcmp{\gmdExt}{sty}*\strcmp{cls}{\gmdExt}=0\relax^^A +%, you don't have copy the \file{.\gmdExt} file +% there, \TeX\ will find it\fi), +% then MakeIndex on the \file{\jobname.idx} file, and then \LaTeX\ +% on \file{\jobname.\gmdExt} once more. +% +%MakeIndex shell commands: +%\begin{verbatim} +%makeindex -r ⁄jobname +%makeindex -r -s gmglo.ist -o ⁄jobname.gls ⁄jobname.glo +%\end{verbatim} +% +% The |-r| switch is to forbid MakeIndex to make implicit ranges since +% the (code line) numbers will be hyperlinks. +% +% Compiling the documentation requires the packages: +% \pk{gmdoc} (\pk{gmdoc.sty} and \pk{gmdocc.cls}), \pk{gmverb.sty}, +% the \pk{gmutils} bundle, \pk{gmiflink.sty} +% and also some standard packages: +% \pk{hyperref.sty}, \pk{color.sty}, \pk{geometry.sty}, +% \pk{multicol.sty}, \pk{lmodern.sty}, \pk{fontenc.sty} that should +% be installed on your computer by default. +% +% Moreover, you should put the \file{gmglo.ist} file, a MakeIndex +% style for the changes' history, into some \file{texmf/makeindex} +% (sub)directory. +% +% Then you should refresh your \TeX\ distribution's files' database +% most probably. +% +% If you had not installed the \pk{mwcls} classes (available on +% \acro{CTAN} and present in \TeX\ Live e.g.), the result of your +% compilation might differ a bit from the \pk{.pdf} provided in this +% \pk{.zip} archive in formatting: If you had not installed +% \pk{mwcls}, the standard \pk{article.cls} class would be used. +% \end{gmlonely} +% +% +% +% +% \division{The code} +% +% \DoIndex{\verb \verb*} +% \subdivision{Preliminaries} +% +\RequirePackage{gmcommand}[2011/10/12] +% For |\firstofone|, |\afterfi|, |\gmobeyspaces|, |\@ifnextcat|, |\foone| and +% |\noexpand|'s and |\expandafter|'s shorthands |\@nx| and |\@xa| +% resp. and |\DeclareCommand|.\rrthis +% +% +% +% Someone may want to use another char for comment, but we assume here +% `orthodoxy'. Other assumptions in \pk{gmdoc} are made. The `knowledge' +% what char is the comment char is used to put proper `hyphen' when +% a~\env{verbatim} line is broken. +% \Define\verbhyphen +% \changes{v0.75}{06/9/8}{renamed from a~rather confusing +% \cs{commentchar}} +\let\verbhyphen\xiipercent + +% Provide a~declaration for easy changing it. Its argument should be +% of |\|\ form (a~\\catother\ is also allowed). +% \Define\VerbHyphen +% \changes{v0.78}{06/12/1}{added} +\def\VerbHyphen#1{% + {\escapechar\m@ne + \@xa\gdef\@xa\verbhyphen\@xa{\string#1}}} +% As you see, it's always global. + +% \subdivision{The breakables} +% +% Let's define a~|\discretionary| left brace such that if it breaks, +% it turns |{%| at the end of line. We'll use it in almost Knuthian ^^A} +% |\ttverbatim|---it's part of this `almost'. +\def\breaklbrace{% + \discretionary{\type@lbrace\verbhyphen}{}{\type@lbrace}% + \yeshy} + +\foone{\catcode`\[=1 \catcode`\{=\active \catcode`\]=2 }% +[% + \def\dobreaklbrace[\catcode`\{=\active + \def{%^^A} + [\breaklbrace\gm@lbracehook]]%\label{gm@lbracehook} +] + +% Now we only initialise the hook. Real use of it will be made in +% \pk{gmdoc}. +\relaxen\gm@lbracehook + +% The |\bslash| macro defined below I~use also in more `normal' \TeX ing, e.g., +% to |\typeout| some |\outer| macro's name. +%\Define\bslash \Define\breakbslash +\foone{\catcode`\!=0 \@makeother\\}%\CodeEscapeChar\! +{% + !def!bslash{\}%^^A} + }% of |\foone|. +%\CodeEscapeChar\\ +% +\def\breakbslash{% + \discretionary{\verbhyphen}% + {\type@bslash}{\type@bslash}\yeshy% it seems that we allow + % hyphenation after backslash but hyphenation will be allowed + % iff \inverb|\hyphenchar\font| is nonnegative. +}% of |\breakbslash|. + +% Sometimes line breaking at a~backslash may be unwelcome. The basic +% case, when the first \CS in a~verbatim breaks at the line end leaving +% there |%|, is covered by line \ref{special opening bslash}. For the +% others let's give the user a~counter-crank: +\pdef\nobreakbslash{\def\breakbslash{\type@bslash\yeshy}}% to use due to the +% common scoping rules. But for the special case of a~backslash +% opening a~verbatim scope, we deal specially in the line +% \ref{special opening bslash}. +% \changes{v0.92}{2008/12/11}{renamed from \cmd\fixbslash} +% +% Analogously, let's provide a~possibility of `nobreaking' the left brace: +\pdef\nobreaklbrace{\def\breaklbrace{\type@lbrace\yeshy}} +% \changes{v0.92}{2008/12/11}{renamed from \cmd\fixlbrace} + +\foone{\catcode`\!=0 \catcode`\\=\active}%%\CodeEscapeChar\!^^A% +{%^^A{ + !def!dobreakbslash{!catcode`!\=!active !def\{!breakbslash}}% +} +%\CodeEscapeChar\\ + +% The macros defined below, |\visiblebreakspaces| and |\xiiclub| +% we'll use in the almost Knuthian macro making verbatim. This `almost' +% makes a~difference.% + +\def\breakablevisspace{\discretionary{\visiblespace}{}{\visiblespace}} +%\nostanza The \cs{visiblespace} macro is |\let| in \pk{gmutils} +% to \cs{xiispace} or to \cs{xxt\-@\-⁄yeshy⁄‘visiblespace} of \pk{xltxtra} if available. + +\foone\obeyspaces% it's just re|\catcode|'ing. +{% +\newcommand*\dobreakvisiblespace{\def {\breakablevisspace}\obeyspaces}%^^A +% |\def|ing it caused a~stack overflow disaster with \pk{gmdoc}.\ilrr +\newcommand*\dobreakblankspace{\let =\space\obeyspaces}% +} + +% \Define\xiiclub +\foone{\@makeother\|}{% + \def\xiiclub{|}} + +% \subdivision{Almost-Knuthian \cs{ttverbatim}} +% +% |\ttverbatim| comes from \TeXbook\ too, but I~add into it a~\LaTeX\ +% macro changing the |\catcode|s and make spaces visible and breakable +% and left braces too. +% +% \changes{v0.80}{2007/2/27}{\cs{ttverbatim@hook} added} +\pdef\ttverbatim{% + \let\do=\do@noligs \verbatim@nolig@list + \let\do=\@makeother \dospecials + \dobreaklbrace\dobreakbslash + \dobreakspace + \makeatletter + % \chgs{2008/12/10 v0.92 added \cmd\makeatletter\ to sound with the + % ‘verbatim specials’, namely to allow control sequences containing + % \env @} + \ifhmode + \setspaceskip + \fi + \verbatimfont + \xdef\gmv@storedhyphenchar{\the\hyphenchar\font}% + % Assignment of the hyphenchar is always global so let the above + % edefinition be also such. + \hyphenchar\font=\gmv@hyphenchar + \ttverbatim@hook +}% of |\ttverbatim| + +% \CH{2010/08/14 v0.993 rigid \cmd\tt in \cmd\ttverbatim changed to +% redefinable \cmd\verbatimfont due to absurd problems with bad +% fontifying of \pk{gmdoc}} +% +\def\verbatimfont{\tt} + +% While typesetting stuff in the \acro{QX} fontencoding I~noticed there were +% no spaces in verbatims. That was because the \acro{QX} encoding doesn't +% have any reasonable char at position 32. So we provide a~hook in +% the very core of the verbatim making macros to set proper +% fontencoding for instance. +\@emptify\ttverbatim@hook + +% \Define*{\VerbT1} +\def\VerbT1{\def\ttverbatim@hook{\fontencoding{T1}\selectfont}} + +% We wish the visible spaces to be the default. +% \DefIndex\dobreakspace +\let\dobreakspace=\dobreakvisiblespace +% +%^^A~|\meta| and pals moved to \pk{gmutils} + +% \subdivision{The core: from \pk{shortvrb}} +% +% The below is copied verbatim ;-) from +% \file{doc.pdf} and then is added my slight changes. + +\DeclareCommand \MakeShortVerb{ + #1 Q {*$} %^^A $ + #2 m % the char to be made shortverb. Has to be provided as |\⁄| (backslashed). +}{% + \gmu@ifstrany {*}{#1} + {\def\@shortvrbdef{\verb*}}% + {\def\@shortvrbdef{\verb}} + % + \gmu@ifstrany {$}{#1}% ^^A$ + % + % Depending on whether |$| ^^A $ + % was specified as optional argument to + % |\MakeShortVerb|, we define the \CS\ |\gmV@mm\⁄| as + % either sth.\ special or sth.\ usual in the math mode: + % + {\gmV@MakeShortVerbAlsoInMath #2 }% extracted to a macro because we reassign + % it while typesetting \LaTeXe \ Sources. + {\gmV@MakeShortVerbNotInMath #2}% + % + \@MakeShortVerb #2% +}% of |\MakeShortVerb|. + +\pdef\gmV@MakeShortVerbAlsoInMath #1{% ^^A ( + % If some dollars were specified (paid ;-) ) in |#1|, then we direct the + % shortverb char to behave in the math mode the same as in normal + % text. + \Name\glet {gmV@mm\string#1}\@firstofone +}% + +\pdef\gmV@MakeShortVerbNotInMath #1{% ^^A ( + % If no dollar was paid ;-) in |#1|, we get vicious and define + % shortverb to act in math mode as normal (other) char. + \edef\gmV@tempA {\strip@bslash {#1}}% + % + \@XA {% + \Name\gdef {gmV@mm\string#1}}% + \@xa{\@xa % these two expandafters serve to get “other” version of + % (unbackslashed) |#1|. + \ifmmode \gmV@tempA + % Two subsequent expandafters become part of the definition + % and serve to gobble or execute the short-verbatim macro. + \@xa \@gobble + \else + \@xa \@firstofone + \fi + }% +}% of if to be normal in math mode + +% We store the original catcode of a shortverb char in a \CS +% |\gmV@cc\⁄|. Moreover, if the char is originally active +% (of catcode 13), then we create another \CS to store its original +% meaning, |\gmV@ac\⁄|. +% +% \Define\@MakeShortVerb +\def\@MakeShortVerb#1{% + \@xa\ifx\csname gmV@cc\string#1\endcsname\relax + \@shortvrbinfo{Made }{#1}\@shortvrbdef + \add@special{#1}% + \AddtoPrivateOthers#1% a~macro to be \emph{really} defined in + % \pk{gmdoc}. + \@xa + \xdef\csname gmV@cc\string#1\endcsname{\the\catcode`#1}% + \begingroup + \catcode`\~\active \lccode`\~=`#1% + \lowercase{% + \Name\glet {ac\string#1}~% + \@xa\gdef\@xa~\@xa{% + \csname \strip@bslash{\gmV@mm}\string#1\endcsname + {\@shortvrbdef~}% + }% of active |#1| def + }% of lowercase + \endgroup + \global\catcode`#1\active + \else + \@shortvrbinfo\@empty{#1 already}{\@empty\verb(*)}% + \fi +}% of |\@MakeShortVerb|. + +% \Define\DeleteShortVerb +\def\DeleteShortVerb#1{% + \@xa\ifx\csname gmV@cc\string#1\endcsname\relax + \@shortvrbinfo\@empty{#1 not}{\@empty\verb(*)}% + \else + \@shortvrbinfo{Deleted }{#1 as}{\@empty\verb(*)}% + \rem@special{#1}% + \global\catcode`#1\csname gmV@cc\string#1\endcsname + \global \@xa\let \csname gmV@cc\string#1\endcsname \relax + \ifnum\catcode`#1=\active + \begingroup + \catcode`\~\active \lccode`\~`#1% + \lowercase{% + \global\@xa\let\@xa~% + \csname gmV@ac\string#1\endcsname}% + \endgroup + \fi + \fi +} + +% My little addition +% \DefIndex\gmv@packname +\@ifpackageloaded{gmdoc}{% + \def\gmv@packname{gmdoc}}{% + \def\gmv@packname{gmverb}} + +% \Define\@shortvrbinfo +\def\@shortvrbinfo#1#2#3{% + \PackageInfo{\gmv@packname}{% + ^^J\@empty #1\@xa\@gobble\string#2 a short reference + for \@xa\string#3}} + +% \Define\add@special +\def\add@special#1{% + \rem@special{#1}% + \@xa\gdef\@xa\dospecials\@xa + {\dospecials \do #1}% + \@xa\gdef\@xa\@sanitize\@xa + {\@sanitize \@makeother #1}} + +% For the commentary on the below macro see the \pk{doc} package's +% documentation. Here let's only say it's just amazing: so tricky and +% wicked use of |\do|. The internal macro |\rem@special| defines |\do| +% to expand to nothing if the |\do|'s argument is the one to be +% removed and to unexpandable \CSs\ |\do| and \<\cs{do}'s argument> +% otherwise. With |\do| defined this way the entire list is just +% globally expanded itself. Analogous hack is done to the |\@sanitize| +% list. +% +\def\rem@special#1{% + \def\do##1{% + \ifnum`#1=`##1 \else \@nx\do\@nx##1\fi + }% + \xdef\dospecials{\dospecials}% + \begingroup + \def\@makeother##1{% + \ifnum`#1=`##1 \else \@nx\@makeother\@nx##1\fi}% + \xdef\@sanitize{\@sanitize}% + \endgroup} + +% And now the definition of \env{verbatim} itself. As you'll see +% (I~hope), the internal macros of it look for the name of the current +% environment (i.e., |\@currenvir|'s meaning) to set their expectation +% of the environment's |\end| properly. This is done to allow the user +% to define his/her own environments with |\verbatim| inside +% them. I.e., as with the \pk{verbatim} package, you may write +% |\verbatim| in the begin definition of your environment and then +% necessarily |\endverbatim| in its end definition. Of course (or +% maybe \qemph{surprisingly}), the commands written in the begin +% definition after |\verbatim| will also be executed at +% \cs{begin\arg{environment}}. \Define*{verbatim} +\def\verbatim{% + \edef\gmv@hyphenpe{\the\hyphenpenalty}% + \edef\gmv@exhyphenpe{\the\exhyphenpenalty}% + \@beginparpenalty \predisplaypenalty \@verbatim + \frenchspacing \gmobeyspaces \@xverbatim + \hyphenpenalty=\gmv@hyphenpe\relax + \exhyphenpenalty=\gmv@exhyphenpe + \hyphenchar\font=\m@ne +% +% The line below serves as the delimiter for +% |\verbatim@PitchContents|, to discard the stuff before it (see +% l.~\ref{verbatim@PitchContents:1/2}). +% + \@gobble\verbatim +}% in the \LaTeX\ version +% there's \incs{@vobeyspaces} instead of \incs{gmobeyspaces}. +% \changes{v0.73}{06/09/06}{\cs{@vobeyspaces} changed to +% \cs{obeyspaces} to make the blank \cs{verb›[atim›]} spaces breakable} +% \Define*{verbatim*} +\@namedef{verbatim*}{\@beginparpenalty \predisplaypenalty \@verbatim + \@sxverbatim % it's the same as |\@xverbatim| and defines the + % verbatim end (a~macro delimited with \inverb|\end{⁄}|). +} + +\def\endverbatim{\@@par +% ^^V \hyphenchar\font=\gmv@storedhyphenchar % hyphenchar assignments are +% ^^V % always global. And for an entire paragraph works the one +% last in it so we hide it. + \ifdim\lastskip >\z@ + \@tempskipa\lastskip \vskip -\lastskip + \advance\@tempskipa\parskip \advance\@tempskipa -\@outerparskip + \vskip\@tempskipa + \fi + \addvspace\@topsepadd + \@endparenv +} + +% \Define\endverbatim* +\n@melet{endverbatim*}{endverbatim} + +% \Define\@xverbatim +\begingroup \catcode `!=0 % +\catcode `[= 1 \catcode`]=2 % +\catcode`\{=\active +\@makeother\}% +\catcode`\\=\active%\CodeEscapeChar\! +!gdef!@xverbatim[% + [!endlinechar!m@ne !everyeof[!@nx]% + !edef!verbatim@currenvir[%% + !@xa!scantokens!@xa[!@currenvir]%% + ]% of |\verbatim@currenvir|. This macro is defined as the + % meaning of \incs{@currenvir} rescanned. It's done specially + % for the active star in my verbatims. \incs{@currenvir} is + % fully expanded but my active star is \incmd\protected. + !@xa]% and here a~little trick with groups: + !@xa!def!@xa!verbatim@currenvir + !@xa[!verbatim@currenvir]% + !edef!verbatim@edef[% + !def!@nx!verbatim@end% + ####1!noexpand\end!@nx{% + !@xa!unexpanded!@xa[!verbatim@currenvir]% + }[% + !@nx!verbatim@PitchContents ####1% + !@nx!verbatim@PitchContents@Delim%added 2010/8/16 + ####1!@nx!end[!@currenvir]]]%% + !verbatim@edef + !verbatim@end]% +!endgroup +% \CodeEscapeChar\\ + +% \Define\@sxverbatim +\let\@sxverbatim=\@xverbatim + +\def\verbatim@PitchContents@Left{% + \long\def\verbatim@PitchContents + ##1\@gobble\verbatim ##2\verbatim@PitchContents@Delim +} + +% By default we make |\verbatim@PitchContents| a gobbler. +\verbatim@PitchContents@Left {} + +\pdef\VerbatimPitch{% +% But in this declaration scope we make |\@xverbatim| pitch the contents of +% \env{verbatim}s in a macro. We use that in \pk{gmdoc} not to repeat +% examples' code. +% \label{verbatim@PitchContents:1/2} + \verbatim@PitchContents@Left {% + \gdef\VerbatimContents{##2}% + }% + % +}% of |\VerbatimThrow|. + +% \Define\@verbatim +% F.\,Mittelbach says the below is copied almost verbatim from \LaTeX\ +% source, modulo |\check@percent|.\Define\@verbatim +\def\@verbatim{% + % \changes{v0.71}{06/09/04}{\cs{trivlist} substituted with + % chosen explicit macros. Analogous in \cs{endverbatim}.} + % + % Originally here was just |\trivlist \item[]|, but it worked + % badly in my document(s), so let's take just highlights of if. + \parsep\parskip + % From |\@trivlist|: + \if@noskipsec \leavevmode \fi + \@topsepadd \topsep + \ifvmode + \advance\@topsepadd \partopsep + \else + \unskip \par + \fi + \@topsep \@topsepadd + \advance\@topsep \parskip + \@outerparskip \parskip + % (End of |\trivlistlist| and |\@trivlist| highlights.) + \@@par\addvspace\@topsep + \if@minipage\else\vskip\parskip\fi% + \advance\@totalleftmargin\verbatimleftskip + \parskip\verbatimparskip % added 2010/6/2 + \raggedright + \leftskip\@totalleftmargin% so many assignments to preserve the + % \env{list} thinking for possible future changes. However, we may + % be sure no internal \env{list} shall use |\@totalleftmargin| as + % far as no inner environments are possible in \env{verbatim›[*›]}.% + \@@par% most probably redundant. + \@tempswafalse + \def\par{% but I~don't want the terribly ugly empty lines when + % a~blank line is met. Let's make them \pk{gmdoc}-like + % i.e., let a~vertical space be added as in between stanzas + % of poetry. Originally |\if@tempswa\hbox{}\fi|, in my version will + % be + \ifvmode\if@tempswa\addvspace\stanzaskip\@tempswafalse\fi\fi + \@@par + \penalty\interlinepenalty \check@percent}% + \everypar{\@tempswatrue\hangindent\verbatimhangindent\hangafter\@ne}%^^A + % since several chars are breakable, there's a~possibility of + % breaking some lines. We wish them to be hanging indented.\ilrr + \obeylines + \ttverbatim + \verbatim@specials +} + +\@ifundefined{stanzaskip}{\newlength\stanzaskip}{} +\stanzaskip=\medskipamount + +\newskip\verbatimleftskip +%\changes{v0.91}{2008/11/12}{added} +\verbatimleftskip\leftmargini + +\newskip\verbatimhangindent +% \changes{v0.71}{06/09/04}{added to verbatim parameters.} +\verbatimhangindent=3em + +\newskip\verbatimparskip +\verbatimparskip\z@skip + +\providecommand*\check@percent{} +% In the \pk{gmdoc} package shall it be defined to check if the next +% line begins with a~comment char. +% +% Similarly, the next macro shall in \pk{gmdoc} be defined to update +% a~list useful to that package. For now let it just gobble its +% argument. +\providecommand*\AddtoPrivateOthers[1]{} +% Both of the above are |\provide|d to allow the user to load +% \pk{gmverb} after \pk{gmdoc} (which would be redundant since +% \pk{gmdoc} loads this package on its own, but anyway should be +% harmless). + +% Let's define the `short' verbatim command. +% +% \Define*{\verb*} +\def\verb{% + \relax\ifmmode\hbox\else\leavevmode\null\fi + \bgroup + \ttverbatim + \verbatim@specials + \gm@verb@eol + \gmu@ifstar + {\verb@lasthook\@sverb@chbsl}% + {\gmobeyspaces\frenchspacing\verb@lasthook\@sverb@chbsl}}%\ +% in the \LaTeX\ version there's |\@vobeyspaces| instead of +% |\gmobeyspaces|.\ilrr + +\emptify\verb@lasthook + +\def\@sverb@chbsl#1{\@sverb#1\check@bslash} + +% \DefIndex\@def@breakbslash +\def\@def@breakbslash{\breakbslash}% because |\| is |\def|ined +% as \cs{break\-b\-slash} not \inverb|\let|. + +% For the special case of a~backslash opening a~(short) verbatim, in +% which it shouldn't be breakable, we define the checking macro. + +\DeclareCommand\DefineTypeChar{mmo}{% + % \begin{enumargs} + % \dc m the char as a~\CS, + % \dc m short name of the char. + % \dc o the cs of the char in ‘other’ catcode. + % \end{enumargs} + % \stanza + \@namedef{gmu@#2wd@name}{#2 wd of + \@xa\meaning\the\font\space at \detoken@xa\f@size pt} + % \stanza + \@namedef{gmu@measure#2}{% + \unless\ifcsname\csname gmu@#2wd@name\endcsname\endcsname + \gmu@measurewd{#1}% |\edef|s \incs{gmu@tempa} as the width of + % the char and \incs{gmu@tempb} as the width of + % the char among 20 copies of itself. + \@xa\gn@melet\csname gmu@#2wd@name\endcsname{gmu@tempb}% here we + % let the \CS\ with the name contained in |\gmu@⁄wd@name| to + % the expanded value of width of the char measured among copies of + % it. % + \fi + }% of |\gmu@measure⁄|. + % \stanza + \@nameedef{type@#2}{% + \@nx\leavevmode + \@xanxcs{gmu@measure#2}% + \hbox to \@nx\csname + \@xanxcs{gmu@#2wd@name}\@nx\endcsname + {\gmuIfValueTF{#3}{\@nx#3}{\@xanxcs{#2}}% + \@nx\hss}% + }% of |\type@⁄|, +}% of |\DefineTypeChar|. + +\DefineTypeChar\\{bslash}% this defines |\type@bslash| and its +% aides \incs{gmu@measurebslash} and \incs{gmu@bslashwd@name}. + +\DefineTypeChar\{{lbrace}[\xiilbrace]% this defines \incs{type@lbrace} +% and its auxilia analogous to the above. + +\def\check@bslash{% + \@ifnextchar\@def@breakbslash + {\type@bslash\yeshy\@gobble}% note we allow hyphenation but actually this + % will have effect if \inverb|\hyphenchar\font| allows hyphenation + % (when it's not $>0$ ). + {}} +% \label{special opening bslash} +% \changes{v0.70}{06/09/02}{Opening backslash made unbreakable.} + +\let\verb@balance@group\@empty + +% \Define\verb@egroup +\def\verb@egroup{\global\let\verb@balance@group\@empty +% ^^V \hyphenchar\font=\gmv@storedhyphenchar % |\hyphenchar| behaves +% like |\hyphenpenalty| etc.: the last one in a paragraph is in charge +% for entire. + \egroup +} + +% \Define\gm@verb@eol +%\changes[\verb]{v0.74}{06/09/07}{line end forbidden inside \texttilde} +\let\gm@verb@eol\verb@eol@error +% The latter is a~\LaTeXe\ kernel macro that |\active|ates line end +% and defines it to close the verb group and to issue an error +% message. We use a~separate \CS 'cause we are not quite positive to +% the forbidden line ends idea. (Although the allowed line ends with +% a~forgotten closing shortverb char caused funny disasters at my +% work a~few times.) Another reason is that \pk{gmdoc} wishes to +% redefine it for its own queer purpose. +% +% However, let's leave my former `permissive' definition under the +% |\verb@eol| name. +% +\begingroup +\obeylines\obeyspaces% +\gdef\verb@eolOK{\obeylines% +\def^^M{ \check@percent}% +}% +\endgroup +% The |\check@percent| macro here is |\provide|d to be |\@empty| but in +% \pk{gmdoc} employed shall it be. +% +% Let us leave (give?) a~user freedom of choice: +\def\verbeolOK{\let\gm@verb@eol\verb@eolOK} +% \changes{v0.74}{06/09/07}{added} +% And back to the main matter, +\def\@sverb#1{%% + \catcode`#1\active \lccode`\~=`#1% + \gdef\verb@balance@group{\verb@egroup + \@latex@error{Illegal use of \bslash verb command}\@ehc}% + \aftergroup\verb@balance@group + \lowercase{\let~\verb@egroup}% here we make the delimiter to be the + % macro closing the verbatim group. +} + +\def\verbatim@nolig@list{\do\`\do\<\do\>\do\,\do\'\do\-} + +\def\do@noligs#1{% + \catcode`#1\active + \begingroup + \lccode`\~=`#1\relax + \lowercase{\endgroup\def~{\leavevmode\kern\z@\char`#1}}} + +% And finally, what I~thought to be so smart and clever, now is just +% one of many possible uses of a~general almost Rainer Sch\"opf's +% macro: +\def\dekclubs{\gmu@ifstar{\MakeShortVerb*\|}{\MakeShortVerb\|}} +\def\olddekclubs{\OldMakeShortVerb\|} + +% But even if a~shortverb is unconditional, the spaces in the math +% mode are not printed. So, +%\Define\edverbs +% \changes{v0.79}{2007/01/01}{added} +% \changes{v0.80}{2007/02/27}{debugged, i.e. \cs{hbox} added back and +% redefinition of \cs{[}}%^^A] +\newcommand*\edverbs{% + \let\gmv@dismath\[% + \let\gmv@edismath\]% + \def\[{%^^A\] + \@ifnextac\gmv@disverb\gmv@dismath}% + \relaxen\edverbs}% + +\def\gmv@disverb{% + \gmv@dismath% + \hbox\bgroup\def\]{\egroup\gmv@edismath}% +} + +%\subdivision{\pk{doc}- and \pk{shortvrb}-compatibility} +% +% One of minor errors while \TeX ing \pk{doc.dtx} was caused by my +% understanding of a~`shortverb' char: at my settings, in the math +% mode an active `shortverb' char expands to itself's `other' version +% thanks to |\string|. \pk{doc/shortvrb}'s concept is different, there +% a~`shortverb' char should work as usual in the math mode. So let it +% may be as they wish: +% +% +% \Define\OldMakeShortVerb +\pdef\OldMakeShortVerb{\MakeShortVerb $$}% +% + +% \subdivision{Grey visible spaces} +% In August 2008 Will Robertson suggested grey spaces for +% \pk{gmdoc}. I~added a~respective option to that package but I~like +% the grey spaces so much that I~want provide them for any verbatim +% environments, so I~bring the definition here. The declaration, if +% put in the preamble, postpones redefinition of \cs{visiblespace} +% till |\begin{document}| to recognise possible redefinition of +% it when \pk{xltxtra} is loaded. + +\let\gmd@preambleABD\AtBeginDocument +\AtBeginDocument{\let\gmd@preambleABD\firstofone} + +\RequirePackage{xcolor}% for \cs{providecolor} + +\def\VisSpacesGrey{% \changes{v0.88}{2008/08/11}{added, or rather + % moved here from \pk{gmdoc}} + \providecolor{visspacesgrey}{gray}{0.5}% + \gmd@preambleABD{% + \edef\visiblespace{% + \hbox{\@nx\textcolor{visspacesgrey}% + {\@xa\unexpanded\@xa{\visiblespace}}}}% + }} + +% \subdivision{Verbatim specials---\CSes in verbatims} + +\pdef\verbatimspecials{% This declaration only defines a~bearer\ + % of the ‘verbatim specials’.\ + % \begin{enumargs} + % \dc * m char for verbatim escape char (for catcode 0), has to be unbraced, + % \dc * m char for verbatim group begin (for catcode 1), has to be unbraced, + % \dc * m char for verbatim group end (for catcode 2), has to be unbraced, + % \dc o char for verbatim math shift (for catcode 3), + % \dc o char for a~shorthand for |\metachar|. + % \dc b (optional braced) additional stuff (commands) to be executed + % at the beginning of the verbatims. + % \end{enumargs} + \@bsphack + \begingroup + \let\do\@makeother + \dospecials + \catcode`\ =10 + \verbatim@specials@iii} + +\pdef\verbatim@specials@iii#1#2#3{% as you see, we take only first + % three arguments in a~despecialized group. It's to avoid + % \incs{futurelet} of the optionals' parser to touch (and thus + % spoil) subsequent token. Yes, we could handle the case of a~space + % or single line end but handling the case of a~backslash would be + % somewhat difficult. + \endgroup + \def\verbatim@specials@list{#1#2#3}% + \@ifnextchar[%^^A] + {\begingroup\let\do\@makeother\dospecials + \catcode`\ =9 + \verbatim@specials@iv}% + {\addtomacro\verbatim@specials@list{\NoValue\NoValue}% + \verbatim@specials@vi}% +}% of |\verbatim@specials@iii|. + +\pdef\verbatim@specials@iv[#1]{% + \endgroup + \addtomacro\verbatim@specials@list{#1}% + \@ifnextchar[%^^A] + {\begingroup\let\do\@makeother\dospecials + \catcode`\ =9 + \verbatim@specials@v}% + {\addtomacro\verbatim@specials@list{\NoValue}% + \verbatim@specials@vi}% +}% of |\verbatim@specials@iv|. + +\pdef\verbatim@specials@v[#1]{% + \endgroup + \addtomacro\verbatim@specials@list{#1}% + \verbatim@specials@vi +}% of |\verbatim@specials@v|. + +\DeclareCommand\verbatim@specials@vi\long{b} +{\addtomacro\verbatim@specials@list{{#1}}% +\@esphack} + +\def\verbatim@specials{% this is the macro that actually sets the + % chars given in \incs{verbatim@specials@list} as the escape char, + % group begin and group end. + \ifdefined\verbatim@specials@list + \@xa\verbatim@specials@\verbatim@specials@list + \fi +}% of \cmd\verbatim@specials. + +\long\def\verbatim@specials@#1#2#3#4#5#6{%% + \catcode`#1=0 + \protected\@namedef{#1}{#1}% + \catcode`#2=1 + \protected\@namedef{#2}{#2}% + \catcode`#3=2 + \protected\@namedef{#3}{#3}% + \edef\gmu@tempa{\the\endlinechar}% + \endlinechar\m@ne % we have to suppress adding of a~line end by + % \incs{scantokens} since it would turn into an + % active char |^^M| and raise an error (which actually did happen). + \scantokens{% + #1let#1bgroup=#2% + #1let#1egroup=#3% + #1catcode#1backquote#1h=6#1relax% + #1pdef#1

#2#1meta#2h1#3#3% + #1catcode#1backquote#1h=11#1relax% + }% + \endlinechar\gmu@tempa\relax + \gmuIfValueT{#4}{% + \catcode`#4=3 + \protected\@namedef{#4}{#4}}% + \gmuIfValueT{#5}{% + \begingroup + \lccode`\~=`#5\lowercase{\endgroup\let~\metachar}% + \protected\@namedef{#5}{#5}% + \catcode`#5=\active + }% of if value |#5|. + \gmuPutIfValue{#6}% +} + +\pdef\noverbatimspecials{\let\verbatim@specials@list\@undefined} + +\def\GMverbatimspecials{% + \gmu@ifCSdefined {\XeTeXversion}% ^^A \begingroup \let\do\@makeother + % ^^A \do\⁄ \do\« \do\» \do\¿ \do\› + {\verbatimspecials + ⁄% escape + «»% |\bgroup| and |\egroup| + [¿]% math shift + [›]% meta-char + {\def\|{\metachar{$\vert$}}% + % ^^A \hyphenchar\font=\gmv@hyphenchar + \makestarlow + \relaxen\‘% to provide a~\CS\ separator (space is not \cat 10 in + % verbatims). + \let\›\string + }% of |#6|. + }% + {}% ^^A \endgroup +}% of |\GMverbatimspecials|. + +% \subdivision{Partial \cmd\verb\ in arguments} + +% Now command for partial verbatims in arguments of commands: +\let\gmu@tempa\all@stars +\@xa\addtomacro\@xa\gmu@tempa\@xa{\all@unders} + +\foone{\catcode`#=\active} +{\def\gmv@hashhalfing{% + % \chgs{2010/03/01 v0.93 cut out as separate macro} + \def#{\xiihash\@ifnextchar#\gobble{}}% + \catcode`#\active}% +} + +\foone{\@makeother\^^R}{% + \@xa\DeclareCommand\@xa\scanverb\@xa{% + % \chgs{2010/03/01 v0.93 mandatory argument made long (a bug fix)} + \@xa Q\@xa{\gmu@tempa}>Pm}{%\ + % \begin{enumargs} + % \dc Q{*_} + % \dc m the stuff to be rescanned and typeset verbatim. Note that |%| + % will be executed during first scan so at best will disappear. + % \end{enumargs} Spaces are ignored (because of detokenizers that add + % a~space after a~\CS) but if you declare some + % \incmd\verbatimspecials, then you can use \inverb|⁄⁄ | where |⁄⁄| denotes + % the escape char in verbatim. + \begingroup + \gmu@septify + \endlinechar=\m@ne + \@xa\IfIntersect\@xa{\all@stars}{#1}% + {\def\ {\breakablevisspace}}% + {\let\ =\space}% + \@xa\IfIntersect\@xa{\all@unders}{#1}% + {}{% We make spaces ignored only if there was no underscore in + % \inhash1 and if \inhash2 doesn't contain \inverb|\ |. + \gmu@ifxany\ {#2}% + {}{\addtomacro\verb@lasthook{\catcode`\ =9 }}}% + \addtomacro\verb@lasthook{\gmv@hashhalfing }% + \@makeother\^^R% + \edef\gmu@tempa{% + \@nx\scantokens{% + \bslash verb% + ^^R\detokenize{#2}^^R% we delimit the |\verb|'s argument with + % ‘other’ \inverb|^^R| assuming this char to be used very seldom + % if at all. + }% of |\scantokens|, + }\gmu@tempa + \endgroup + }% of |\scanverb|, +}% of |\foone|. + +\def\verbDiscretionaryHyphen#1#2{% + % \chgs{2010/03/03 v0.93 added to synchronise hyphen chars in + % \pk{gmdoc}'s documentation} + \def\gmv@hyphenchar{\numexpr#1\relax}% + \def\gmv@hyphen{#2}% +} + +\verbDiscretionaryHyphen{"A6}{¦} + +\ifgmuXeTeX +% \CH{2010/06/28 v0.94 due to Will Robertson's remark that +% recatcoding long (no-\acro{ASCII}) dashes works only under \XeTeX\ +% and \LuaTeX, I embrace them in a \XeTeX\ conditional} + +\def\gmu@tempa{% + \DeclareCommand\verbLongDashes{ + >iT{–}% to memorise which dash we set + B{1.41} % expansion of en-dash + >iT{—} % as above + B{2} % expansion of em-dash + }% +} + +\def\gmu@tempb{\catcode`–\active \catcode`—\active} + +\foone{\catcode`–\active\catcode`—\active} +{% + \edef\gmu@tempa{\@xau\gmu@tempa + {% + \@nx\addtomacro\@nx\ttverbatim@hook{% + \@xau\gmu@tempb + \def\@nx–{\@nx\scalebox{##1}[1]{\string–}}% + \def\@nx—{\@nx\scalebox{##2}[1]{\string—}}% + }% + }% + }% +}% +\gmu@tempa + +\fi % of if \XeTeX. +% +% Note that we have two “hyphens”: one for places where a line may be +% broken with a comment char and another, provided as |\hyphenchar|, +% for discretionary hyphens at points where correct \TeX\ code cannot +% be broken, such as \CS names. +% +% +% +% \ChangesGeneral +% +% \changes{v0.81}{2007/04/13}{\cs{afterfi} made two-argument (first +% undelimited, the stuff to be put after \cs{fi}, and the other, +% delimited with \cs{fi}, to be discarded} +% +% \changes{v0.83}{2007/11/09}{added a~hook in the active left brace +% definition intended for \pk{gmdoc} automatic detection of +% definitions (in line \protect\ref{gm@lbracehook})} +% +% \changes{v0.85}{2008/03/29}{added restoring of \cs{hyphenpenalty} +% and \cs{exhyphenpenalty} and setting \cs{hyphenchar!=-1}} +% +% \changes{v0.87}{2008/08/06}{visible space tidied and taken from +% \pk{xltxtra} if available. \pk{gmutils} required. The \cs{xii›…} +% \CSes moved to \pk{gmutils}. The documentation driver moved +% into the \file{.sty} file} +% +% \changes{v0.89}{2008/08/30}{\cs{dekclubs}, \cs{dekclubs*} and +% \cs{olddekclubs} made more consistent, shorthands for +% \cs{MakeShortVerb}\cmd\|, \cs{MakeShortVerb*}\cmd\| and +% \cs{OldMakeShortVerb}\cmd{\|} respectively.} +% +% \changes{v0.90}{2008/10/08}{some \cs{›(b⁄!|e›)group} changed to +% \cs{›(begin⁄!|end›)group}} +% +% +% +% +\endinput +%% +%% End of file `gmverb.sty'. -- cgit v1.2.3