summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/newverbs
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-11 03:00:38 +0000
committerNorbert Preining <norbert@preining.info>2019-09-11 03:00:38 +0000
commitef86cc7c003cc95a612e75aea0f78e21db9699fb (patch)
tree74db8841dd06e01b6f056d8c858628fe034ecd07 /macros/latex/contrib/newverbs
parenta1c3d5afa1daf60d772eb18931e05c5397e7404c (diff)
CTAN sync 201909110300
Diffstat (limited to 'macros/latex/contrib/newverbs')
-rw-r--r--macros/latex/contrib/newverbs/README2
-rw-r--r--macros/latex/contrib/newverbs/newverbs.dtx235
-rw-r--r--macros/latex/contrib/newverbs/newverbs.pdfbin181372 -> 220993 bytes
3 files changed, 184 insertions, 53 deletions
diff --git a/macros/latex/contrib/newverbs/README b/macros/latex/contrib/newverbs/README
index 77e2979983..3012c3c67d 100644
--- a/macros/latex/contrib/newverbs/README
+++ b/macros/latex/contrib/newverbs/README
@@ -1,6 +1,6 @@
The 'newverbs' LaTeX package
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Copyright (c) 2010-2012 by Martin Scharrer <martin@scharrer-online.de>
+Copyright (c) 2010-2019 by Martin Scharrer <martin@scharrer-online.de>
Code repository: https://bitbucket.org/martin_scharrer/newverbs
This package allows the definition of \verb variants which add TeX code before
diff --git a/macros/latex/contrib/newverbs/newverbs.dtx b/macros/latex/contrib/newverbs/newverbs.dtx
index f7014ef8d9..f2a79d35fd 100644
--- a/macros/latex/contrib/newverbs/newverbs.dtx
+++ b/macros/latex/contrib/newverbs/newverbs.dtx
@@ -1,6 +1,6 @@
% \iffalse meta-comment
%<=*COPYRIGHT>
-%% Copyright (C) 2012 by Martin Scharrer <martin@scharrer-online.de>
+%% Copyright (C) 2012-2019 by Martin Scharrer <martin@scharrer-online.de>
%% --------------------------------------------------------------------
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
@@ -23,10 +23,10 @@
%<*driver>
\ProvidesFile{newverbs.dtx}[%
%<=*DATE>
- 2012/05/08
+ 2019/09/09
%<=/DATE>
%<=*VERSION>
- v1.3a
+ v1.4
%<=/VERSION>
newverbs DTX file]
\documentclass{ydoc}
@@ -44,7 +44,7 @@
%</driver>
% \fi
%
-% \CheckSum{0}
+% \CheckSum{458}
%
% \CharacterTable
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
@@ -68,6 +68,7 @@
% \changes{v1.2}{2011/02/16}{Added support for 'tabularx' environments.}
% \changes{v1.2a}{2011/03/19}{Removed spurious spaces.}
% \changes{v1.3}{2011/07/24}{Added macros to collect verbatim arguments.}
+% \changes{v1.4}{2019/09/09}{Added several suggested changes.}
%
% \DoNotIndex{\newcommand,\newenvironment,\providecommand}
%
@@ -103,9 +104,9 @@
%
% \DescribeMacro\qverb<char><verbatim material><char>
% This macro adds quote characters around the verbatim material.
-% Two macros are used to insert the quotes: \cs{qverbbeginquote} (`) and \cs{qverbendquote} (').
+% Two macros are used to insert the quotes: \cs{qverbbeginquote} (``) and \cs{qverbendquote} ('').
% They can be redefined by the user if required. If the \pkg{csquotes} package was loaded beforehand
-% the above macros use its macros \cs{openinnerquote} and \cs{closeinnerquote} to take advantage of the language
+% the above macros use its macros \cs{openautoquote} and \cs{closeautoquote} to take advantage of the language
% dependent quotation marks. See the manual of \pkg{csquotes} for more details.
%
% Using \Macro\qverb<char><verbatim material><char> is equal to \\
@@ -133,7 +134,7 @@
%
% The new macro \Macro\MakeSpecialShortVerb*{\textbackslash\meta{verb variant}}{\textbackslash\meta{char}} does the same, but
% instead of \Macro\verb*\relax\relax\ it uses a \MacroArgs'\'<verb variant>*\relax which needs to be defined using \cs{newverbcommand}.
-% The package \pkg{shortvrb} must be loaded by the user in order to make this macro work. It is not loaded automatically by \pkg{newverbs}.
+% The package \pkg{shortvrb} must be installed in order to make this macro work. It is loaded automatically by \pkg{newverbs}.
%
% The special meaning of \meta{char} can be removed using \pkg{shortvrb}'s \cs{DeleteShortVerb}, i.e.\ the same way as for
% characters defined with the normal \cs{MakeShortVerb}.
@@ -170,7 +171,56 @@
% The starred version will make spaces appear as `\Collectverb*{}: :' when typeset but still be written to auxiliary files as normal spaces.
% An exception is if the following \meta{char} is `|{|', then `|}|' is taken as the end \meta{char} to simulate a normal argument to increase user friendliness.
% Afterwards \meta{code} is expanded with \marg{verbatim material} direct behind it. This macro does not add any group around the code.
-% Should the code be typeset after all a proper font (e.g.\ \Macro\ttfamily or \Macro\verbatim@font) must be enabled manually.
+% Should the material be typeset after all a proper font (e.g.\ \Macro\ttfamily or \Macro\newverbsfont) must be enabled manually.
+%
+%
+%
+% \DescribeMacro\collectverbenv{<code>}
+% \DescribeMacro\collectverbenv*{<code>}
+% This macro is supposed to be used with its \marg{code} argument at the end of the begin-code of an user or package environment definition.
+% It then collects the content of the environment as verbatim material and feeds it as an argument to the provided \meta{code} like \Macro\collectverb does
+% (see there for further details which also apply here).
+% This has the following limitations:
+% When used the \Macro\begin of the environment must end with a line break, i.e.\ the source line must not include any other material afterwards.
+% If the environment is defined with arguments, which is supported, the line break must be after the arguments.
+% The \Macro\end of the macro must be at the beginning of an own source code line.
+% If this conditions are not met incorrect results or an error may occur. Currently trailing material on the \Macro\begin line is simply ignored, but this
+% behaviour might change in future versions.
+%
+% The starred version will make the spaces inside the environment appear as `\collectverb*{}: :'.
+%
+% \noindent Example usage:\\
+% \leavevmode\noindent\bgroup\footnotesize
+% |\newenvironment{myenv}{\maybesomeothercode\collectverbenv{\mycmd}}{\someendcode}| \\
+%
+%
+% \DescribeMacro\Collectverbenv{<code>}
+% \DescribeMacro\Collectverbenv*{<code>}
+% This macro works like \Macro\collectverbenv but collects the environment content as plain verbatim material suitable to be
+% written in auxiliary files or log messages.
+% After collecting the environment the \meta{code} is expanded with \marg{verbatim material} direct behind it. This macro does not add any group around the code.
+% Should the material be typeset after all a proper font (e.g.\ \Macro\ttfamily or \Macro\newverbsfont) must be enabled manually.
+%
+% The starred version will make spaces appear as `\Collectverb*{}: :' when typeset but still be written to auxiliary files as normal spaces.
+%
+%
+% \DescribeMacro\newverbsfont
+% Macro which activates the font used by the \pkg{newverbs} package for the verbatim text.
+% This macro can be used manually if verbatim material collected with \Macro\Collectverb or \Macro\Collectverbenv should be typeset afterall.
+%
+% \DescribeMacro\verbdef<\textbackslash macro><char><verbatim material><char>
+% \DescribeMacro\verbdef*<\textbackslash macro><char><verbatim material><char>
+% \DescribeMacro\verbdef<\textbackslash macro>{<verbatim material>}
+% \DescribeMacro\verbdef*<\textbackslash macro>{<verbatim material>}
+% This macro defines the \meta{\textbackslash macro} as a robust macro which typesets the \meta{verbatim material} in the usual verbatim font.
+% For this the material is placed in a brace group with \Macro\newverbsfont. If a different font is wanted, this macro can be redefined locally.
+%
+% If the \meta{\textbackslash macro} existed before it will be overwritten silently. If an error should be raced instead use
+% \Macro\newcommand{\textbackslash macro}{} just before the \Macro\verbdef.
+%
+% Note that this macro is also provided by the \pkg{verbdef} package. If that package is loaded as well it definition of this macro is used,
+% independent on the order of loading the two packages.
+%
%
% \DescribeMacro\Verbdef<\textbackslash macro><char><verbatim material><char>
% \DescribeMacro\Verbdef*<\textbackslash macro><char><verbatim material><char>
@@ -178,7 +228,12 @@
% \DescribeMacro\Verbdef*<\textbackslash macro>{<verbatim material>}
% This macro uses \Macro\Collectverb internally to define \meta{\textbackslash macro} as the plain \meta{verbatim material}.
% This can be used to define macros for special characters, so these can be used in error or warning messages or be written into auxiliary files.
-% A corresponding \Macro\verbdef macro which defines macros with typesetable verbatim material is already provided by the \pkg{verbdef} package.
+%
+% If the \meta{\textbackslash macro} existed before it will be overwritten silently. If an error should be raced instead use
+% \Macro\newcommand{\textbackslash macro}{} just before the \Macro\Verbdef.
+%
+% Note that for maximum flexibility the such defined macros are not defined as robust macros. Therefore using them inside sectioning commands they should
+% be protected using \Macro\protect to avoid syntax issues in the |.aux| file due to verbatim characters.
%
%
% \section{Compatibility with other verbatim packages}
@@ -221,17 +276,37 @@
% \end{macro}
% \end{macro}
%
-% \begin{macro}{\new@verbcommand}[4]{underlying definition macro}{macro to define}{code before}{code after}
+% \begin{macro}{\new@verbcommand}[2]{underlying definition macro}{macro to be defined}
+% Checks for optional argument and calls \cs{new@@verbcommand} accordingly.
+% \begin{macrocode}
+\def\new@verbcommand#1#2{%
+ \@ifnextchar[%
+ {\new@@verbcommand{#1}{#2}}%
+ {\new@@verbcommand{#1}{#2}[\verb]}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\new@verbcommand}[5]{underlying definition macro}{verb macro to be used}{macro to define}{code before}{code after}
% The trailing code is inserted by patching \cs{verb@egroup} which is called by \cs{verb}
% after the verbatim content.
% \begin{macrocode}
-\def\new@verbcommand#1#2#3#4{%
+\let\newverbs@end\@empty
+\def\new@@verbcommand#1#2[#3]#4#5{%
#1*#2{%
- \begingroup
+ \bgroup
\newverbcommand@settings
- \def\verb@egroup{\verb@orig@egroup#4\endgroup}%
- \def\newverbs@txend{#4\endgroup}%
- #3\verb
+ \ifx\newverbs@end\@empty
+ \expandafter\def\expandafter\verb@egroup\expandafter{\verb@egroup\newverbs@end}%
+ \fi
+ \begingroup\def\@tempa{#5}%
+ \expandafter\expandafter\expandafter\endgroup
+ \expandafter\expandafter\expandafter\def
+ \expandafter\expandafter\expandafter\newverbs@end
+ \expandafter\expandafter\expandafter{\expandafter\@tempa\newverbs@end\egroup}%
+ \def\newverbs@txend{#5\egroup}%
+ \verbatim@font\let\verbatim@font\relax
+ #4#3%
}%
}
% \end{macrocode}
@@ -306,11 +381,11 @@
% \changes{v1.1}{2010/04/13}{Added usage of 'csquotes' macros if loaded.}
% \begin{macrocode}
\@ifundefined{openinnerquote}{%
- \def\qverbbeginquote{`}%
- \def\qverbendquote{'}%
+ \def\qverbbeginquote{``}%
+ \def\qverbendquote{''}%
}{%
- \def\qverbbeginquote{\openinnerquote}%
- \def\qverbendquote{\closeinnerquote}%
+ \def\qverbbeginquote{\openautoquote}%
+ \def\qverbendquote{\closeautoquote}%
}
% \end{macrocode}
% \end{macro}
@@ -328,20 +403,66 @@
%
% \subsection{Make Special Short Verbatim Characters}
%
-% \begin{macro}{\MakeSpecialShortVerb}[1]{verbatim macro}
-% Uses the definition of \cs{MakeShortVerb} from \pkg{shortvrb} except with \cs{verb} replaced with the first argument.
-% The second argument is then read by \cs{@MakeShortVerb}.
% \begin{macrocode}
-\newcommand*\MakeSpecialShortVerb[1]{%
+\RequirePackage{shortvrb}
+% \end{macrocode}
+%
+% \begin{macro}{\MakeShortVerb}
+% \begin{macrocode}
+\def\MakeShortVerb{%
\@ifstar
- {\def\@shortvrbdef{#1*}\@MakeShortVerb}%
- {\def\@shortvrbdef{#1}\@MakeShortVerb}%
+ {\newverbs@MakeShortVerb*}%
+ {\newverbs@MakeShortVerb{}}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\newverbs@MakeShortVerb}[1]{star or empty}
+% \begin{macrocode}
+\def\newverbs@MakeShortVerb#1{%
+ \@ifnextchar[%
+ {\newverbs@@MakeShortVerb{#1}}%
+ {\@MakeSpecialShortVerb{#1}{\verb}}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\newverbs@@MakeShortVerb}[2]{star or empty}{verbatim macro}
+% \begin{macrocode}
+\def\newverbs@@MakeShortVerb#1[#2]{%
+ \@MakeSpecialShortVerb{#1}{#2}%
}
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{\@MakeSpecialShortVerb}[3]{star or empty}{verbatim macro}{escaped short verbatim character}
+% Uses the definition of \cs{MakeShortVerb} from \pkg{shortvrb} except with \cs{verb} replaced with the first argument.
+% The last argument is then read by \cs{@MakeShortVerb}.
+% \begin{macrocode}
+\def\@MakeSpecialShortVerb#1#2#3{%
+ %\expandafter\ifx\csname cc\string#3\endcsname\relax
+ %\else
+ % \DeleteShortVerb{#3}%
+ %\fi
+ \def\@shortvrbdef{#2#1}%
+ \@MakeShortVerb{#3}%
+}
+% \end{macrocode}
+% \end{macro}
%
-% \subsection{Collect verbatim argument}
+% \begin{macro}{\MakeSpecialShortVerb}
+% Checks for the starred version and calls \cs{@MakeSpecialShortVerb} appropriately. The star needs to be added again
+% as \cs{@ifstar} removes it.
+% \begin{macrocode}
+\newcommand*\MakeSpecialShortVerb{%
+ \@ifstar
+ {\@MakeSpecialShortVerb{*}}%
+ {\@MakeSpecialShortVerb{}}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+%% \subsection{Collect verbatim argument}
%
% \begin{macro}{\collectverb}
% Collects verbatim text which can be typeset.
@@ -485,7 +606,7 @@
% \end{macro}
%
%
-% \begin{macro}{\@Collectverb}
+% \begin{macro}{\@Collectverb}[1]{<code to be executed afterwards>}
% \begin{macrocode}
\def\@Collectverb#1{%
\verb@eol@error
@@ -498,7 +619,7 @@
% \end{macro}
%
%
-% \begin{macro}{\@sCollectverb}
+% \begin{macro}{\@sCollectverb}[1]{<code to be executed afterwards>}
% \begin{macrocode}
\def\@sCollectverb#1{%
\verb@eol@error
@@ -510,7 +631,7 @@
% \end{macro}
%
%
-% \begin{macro}{\@@Collectverb}
+% \begin{macro}{\@@Collectverb}[2]{<code to be executed afterwards>}{<delimiter character>}
% \begin{macrocode}
\def\@@Collectverb#1#2{%
\ifnum`#2=`\{%
@@ -546,7 +667,7 @@
% \end{macro}
%
%
-% \begin{macro}{\@Collectverbenv}
+% \begin{macro}{\@Collectverbenv}[1]{<code to be executed afterwards>}
% \begin{macrocode}
\def\@Collectverbenv#1{%
\newverb@catcodes
@@ -582,7 +703,7 @@
% \end{macro}
%
%
-% \begin{macro}{\@sCollectverbenv}
+% \begin{macro}{\@sCollectverbenv}[1]{<code to be executed afterwards>}
% \begin{macrocode}
\def\@sCollectverbenv#1{%
\newverb@catcodes
@@ -613,25 +734,6 @@
% \end{macro}
%
%
-% \begin{macro}{\newverbenvironment}
-% \begin{macrocode}
-\newcommand\newverbenvironment{}
-\long\def\newverbenvironment#1#2#{%
- \@newverbenvironment{#1}{#2}%
-}
-\long\def\@newverbenvironment#1#2#3#4{%
- \newenvironment{#1}#2{%
- \begingroup
- \newverb@catcodes
- \obeyspaces
- #3%
- \expandafter\@@Collectverbenv\expandafter{\@currenvir}{\long\def\BODY}%
- }{#4}%
-}
-% \end{macrocode}
-% \end{macro}
-%
-%
% \begin{macro}{\newverbsfont}
% \begin{macrocode}
\newcommand\newverbsfont{%
@@ -653,14 +755,43 @@
% \end{macro}
%
%
-% \begin{macro}{\@Verbdef}
+% \begin{macro}{\@Verbdef}[2]{<star or empty>}{<macro to be defined>}
% \begin{macrocode}
-\newcommand*\@Verbdef[2]{%
+\def\@Verbdef#1#2{%
\Collectverb#1{\def#2}%
}
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{\verbdef}
+% Provides an own definition of \Macro\verbdef which is also defined by the \pkg{verbdef} package.
+% \begin{macrocode}
+\providecommand*\verbdef{%
+ \@ifstar
+ {\newverbs@verbdef*}%
+ {\newverbs@verbdef{}}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\@Verbdef}[2]{<star or empty>}{<macro to be defined>}
+% \begin{macrocode}
+\def\newverbs@verbdef#1#2{%
+ \Collectverb#1{\newverbs@@verbdef{#2}}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\@Verbdef}[2]{<star or empty>}{<macro to be defined>}
+% \begin{macrocode}
+\def\newverbs@@verbdef#1#2{%
+ \DeclareRobustCommand{#1}{{\newverbsfont#2}}%
+}
+% \end{macrocode}
+% \end{macro}
+%
% \iffalse
%</newverbs.sty>
% \fi
diff --git a/macros/latex/contrib/newverbs/newverbs.pdf b/macros/latex/contrib/newverbs/newverbs.pdf
index 389f098093..017a5c7ef6 100644
--- a/macros/latex/contrib/newverbs/newverbs.pdf
+++ b/macros/latex/contrib/newverbs/newverbs.pdf
Binary files differ