summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2013-06-28 22:27:16 +0000
committerKarl Berry <karl@freefriends.org>2013-06-28 22:27:16 +0000
commite1dea85ce1b88e8920d2aebf40a78e1c184225bd (patch)
tree5a5f54fe907f650c3021f54a702e156c6edf50c6
parent8cc5831a7004aa1d5c74d29b5806491fafc27323 (diff)
verbatimbox (7jun13)
git-svn-id: svn://tug.org/texlive/trunk@31022 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Master/texmf-dist/doc/latex/verbatimbox/verbatimbox.pdfbin224555 -> 239248 bytes
-rw-r--r--Master/texmf-dist/doc/latex/verbatimbox/verbatimbox.tex122
-rw-r--r--Master/texmf-dist/tex/latex/verbatimbox/verbatimbox.sty47
3 files changed, 149 insertions, 20 deletions
diff --git a/Master/texmf-dist/doc/latex/verbatimbox/verbatimbox.pdf b/Master/texmf-dist/doc/latex/verbatimbox/verbatimbox.pdf
index 5798d11a436..db4a3fd64a3 100644
--- a/Master/texmf-dist/doc/latex/verbatimbox/verbatimbox.pdf
+++ b/Master/texmf-dist/doc/latex/verbatimbox/verbatimbox.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/verbatimbox/verbatimbox.tex b/Master/texmf-dist/doc/latex/verbatimbox/verbatimbox.tex
index 03e5783ebee..60a97445749 100644
--- a/Master/texmf-dist/doc/latex/verbatimbox/verbatimbox.tex
+++ b/Master/texmf-dist/doc/latex/verbatimbox/verbatimbox.tex
@@ -1,5 +1,5 @@
\documentclass{article}
-\def\version{3.0}
+\def\version{3.1}
% Copyright 2013 Steven B. Segletes
%
% This work may be distributed and/or modified under the
@@ -24,6 +24,7 @@
\parindent 0em
\usepackage{verbatimbox}
\usepackage{etoolbox}
+\usepackage{color}
\makeatletter
\preto{\@verbatim}{\topsep=0pt \partopsep=0pt }
\makeatother
@@ -38,7 +39,10 @@
\newcommand\margenv[1]{\marginpar{\hfill\ttfamily#1}}
\begin{document}
+\begin{myverbbox}{\bgn}\begin\end{myverbbox}
+\begin{myverbbox}{\edng}\end\end{myverbbox}
\begin{myverbbox}{\vrbox}verbbox\end{myverbbox}
+\begin{myverbbox}{\vrnobox}verbnobox\end{myverbbox}
\begin{myverbbox}{\myvrbox}myverbbox\end{myverbbox}
\begin{myverbbox}{\ovrbox}origverbbox\end{myverbbox}
\begin{myverbbox}{\vbenv}\begin{verbbox}\end{myverbbox}
@@ -46,6 +50,7 @@
\begin{myverbbox}{\myvb}\begin{myverbbox}\end{myverbbox}
\begin{myverbbox}{\emyvb}end{myverbbox}\end{myverbbox}
\begin{myverbbox}{\vbfbox}\verbfilebox\end{myverbbox}
+\begin{myverbbox}{\vbfnobox}\verbfilenobox\end{myverbbox}
\begin{myverbbox}{\tvb}\theverbbox\end{myverbbox}
\begin{myverbbox}{\avb}\addvbuffer\end{myverbbox}
\begin{myverbbox}{\bts}\boxtopsep\end{myverbbox}
@@ -63,9 +68,13 @@
\begin{center}
\LARGE The {\vbx} Package\\
\rule{0em}{.7em}\small
-Routines for placing verbatim text into boxes, useful in places where
-the verbatim environment is inaccessible. Secondarily, for adding
-vertical buffer around an object.\\
+{\centering
+\begin{minipage}{.7\textwidth}%
+Routines for placing stylized verbatim text into boxes, useful in
+places where the verbatim environment is inaccessible. Secondarily,
+for adding vertical buffer around an object.
+\end{minipage}
+}\\
\rule{0em}{2.7em}\large Steven B. Segletes\\
steven.b.segletes.civ@mail.mil\\
\rule{0em}{1.7em}\today\\
@@ -81,11 +90,21 @@ inaccessible (for example, in the midst of a tabular environment). It
is also useful if a given verbatim text needs to be recalled multiple
times within a document.
+One very nice feature of this package is the optional argument to both
+environments and macros that allows custom stylization of the verbatim
+text (fontshapes, sizes, numbering lines, \textit{etc.}) through the use
+of pre-commands. For those who prefer this form of optional-argument
+customization, the environments and macros are \textit{also} provided in
+a ``no-box'' form that is output directly, rather than being saved in a
+box. The no-box forms can be used when the verbatim has to span across
+page breaks.
+
While there is application for its use within the {\vbx} application,
this package also offers an independent command for conveniently
providing vertical buffer space above and below an object.
-The commands provided by this package are given as follows:\\\itshape
+The environments and macros provided by this package are given as
+follows:\\\itshape
\rl%
\addvbuffer[1ex 1ex]%
{\parbox{4in}{%
@@ -95,7 +114,9 @@ The commands provided by this package are given as follows:\\\itshape
\tvb\lb\texttt{\upshape t}\rb\\
\bts\eq length\\
\bbs\eq length\\
- \avb\lb length \lb below length\rb\rb\lbr object\rbr
+ \avb\lb length \lb below length\rb\rb\lbr object\rbr\\
+ \bgn\lbr\vrnobox\rbr\lb pre-commands\rb\ldots\edng\lbr\vrnobox\rbr\\
+ \vbfnobox\lb pre-commands\rb\lbr filename\rbr
}}\\\upshape
In addition, there is a counter, \vln\margenv{\vln}, which contains the
current verbatim line number being processed. It's use as part of
@@ -161,6 +182,42 @@ third line
\end{verbbox}
\rl\theverbbox
+The customization can make use of the \verb|VerbboxLineNo| counter in
+ways that make it line specific. Note that the optional argument
+must be contained on a single line.
+
+\begin{verbatim}
+\newcommand*\ifline[3]{%
+ \ifthenelse{\value{VerbboxLineNo} = #1}{#2}{#3}}
+\newcommand*\highlight{%
+ \color{red}\rmfamily\itshape\bfseries\large\(\bullet~\)}
+\newcommand\nohighlight{\arabic{VerbboxLineNo}:\hspace{1ex}}
+\begin{verbbox}[\ifline{2}{\highlight}{\nohighlight}]
+Line 1
+Line 2
+Line 3
+\end{verbbox}
+\theverbbox
+\end{verbatim}
+
+\newcommand*\ifline[3]{%
+ \ifthenelse{\value{VerbboxLineNo} = #1}{#2}{#3}}
+\newcommand*\highlight{%
+ \color{red}\rmfamily\itshape\bfseries\large\(\bullet~\)}
+\newcommand\nohighlight{\arabic{VerbboxLineNo}:\hspace{1ex}}
+\begin{verbbox}[\ifline{2}{\highlight}{\nohighlight}]
+Line 1
+Line 2
+Line 3
+\end{verbbox}
+\rl\theverbbox
+
+\begin{verbbox}[\arabic{VerbboxLineNo}:\hspace{1ex}]
+first line
+second line
+third line
+\end{verbbox}
+
\subsection{The \texttt{myverbbox} Environment}
With the {\vrbox} environment, one is limited to one verbatimbox at a
@@ -263,7 +320,7 @@ below the object. So, for example,
\verb|\fbox{\addvbuffer[5pt]{\theverbbox}}|
will produce
-\fbox{\addvbuffer[5pt]{\theverbbox}}
+\rl\fbox{\addvbuffer[5pt]{\theverbbox}}
On the other hand, the optional argument may comprise two lengths, in
which case the first length is added above the object and the second is
@@ -271,26 +328,56 @@ added below the object. Thus,
\verb|\fbox{\addvbuffer[15pt 5pt]{\theverbbox}}|
will produce
-\fbox{\addvbuffer[15pt 5pt]{\theverbbox}}
+\rl\fbox{\addvbuffer[15pt 5pt]{\theverbbox}}
But {\avb} need not only be used for \tvb. It can be used on other
objects, for example a \verb|\parbox|
-\fbox{\addvbuffer[15pt 5pt]{\parbox{1in}{This is a test of the
+\rl\fbox{\addvbuffer[15pt 5pt]{\parbox{1in}{This is a test of the
emergency broadcast system}}}
or even on just plain text \verb|\fbox{\addvbuffer[15pt 5pt]{A test}}|:
-\fbox{\addvbuffer[15pt 5pt]{A test}}
+\rl\fbox{\addvbuffer[15pt 5pt]{A test}}
It can even be used to remove vertical space from an objects size, by
adding negative buffer \verb|\fbox{\addvbuffer[-5pt -5pt]{A test}}|:
-\fbox{\addvbuffer[-5pt -5pt]{A test}}
+\rl\fbox{\addvbuffer[-5pt -5pt]{A test}}
This ability to work on a variety of objects makes {\avb} a powerful
command in many applications.
+When length variables are being used in the optional argument to
+\verb|\addvbuffer|, one must use the string form of them (prefixed with
+\verb|\the|), as in
+
+\begin{verbatim}
+ \addvbuffer[\the\mysep]{A test}
+\end{verbatim}
+
+Likewise, if two length variables are to be used in the optional
+argument, an explicit space (backslash space) must be used to separate
+the arguments:
+
+\begin{verbatim}
+ \addvbuffer[\the\mytopsep\ \the\mybottomsep]{A test}
+\end{verbatim}
+
+\subsection{The ``nobox'' Alternatives}
+
+Alternatives are provided for the {\vrbox} environment and the {\vbfbox}
+macro, which output the content directly, rather than place it into a
+box. These alternatives are named {\vrnobox}\margenv{\vrnobox} and
+{\vbfnobox}\margenv{\vbfnobox}. Like their boxed counterparts, these
+alternatives make use of the convenient optional pre-commands that allow
+for custom stylization of the verbatim content.
+
+Because they are not placed into a box, but instead output directly,
+their content cannot be recalled at a later time in the document. While
+the boxed versions have a particular use in environments where verbatim is
+inaccessible, the no-boxed alternatives may be used when the content
+must span a page break.
\section{Quirks}\fboxsep=0pt
@@ -322,10 +409,10 @@ would look like:\\
\begin{verbbox}[\LARGE]first line
second line
\end{verbbox}
-\addvbuffer[3pt 0pt]{\fbox{\theverbbox}}
+\rl\addvbuffer[3pt 0pt]{\fbox{\theverbbox}}
The solution, in the presence of an optional argument, is to begin the
-first line of the environment contents on the following line. Thus
+first line of the environment contents on the following line. Thus,
\begin{verbatim}
\begin{verbbox}[\LARGE]
@@ -340,7 +427,7 @@ will yield the expected result:\\
first line
second line
\end{verbbox}
-\addvbuffer[3pt 0pt]{\fbox{\theverbbox}}
+\rl\addvbuffer[3pt 0pt]{\fbox{\theverbbox}}
No such requirement is necessary if there are no optional arguments.
So, for example,
@@ -373,7 +460,7 @@ this following example:
first line
second line
\end{verbbox}
-\fbox{\theverbbox}
+\rl\fbox{\theverbbox}
Note how the box does not extend to the end of the text line. When
placing printing commands before non-printing commands that change the
@@ -390,7 +477,7 @@ interpreted:
first line
second line
\end{myverbbox}
-\fbox{\mybox}
+\rl\fbox{\mybox}
There are differences, however, in how {\vrbox} and {\myvrbox} process
the optional argument, which relate to overcoming the problems
@@ -412,7 +499,7 @@ first line
second line
third line
\end{verbbox}
-\theverbbox
+\rl\theverbbox
\section{Acknowledgements}
@@ -432,7 +519,6 @@ by Prof. Enrico Gregorio, to strip the leading backslash from a
removing-a-backslash-from-a-character-sequence
}}
-\clearpage
\section{Code Listing}
\verbatiminput{verbatimbox.sty}
diff --git a/Master/texmf-dist/tex/latex/verbatimbox/verbatimbox.sty b/Master/texmf-dist/tex/latex/verbatimbox/verbatimbox.sty
index e237b3798e0..66aed9d85fc 100644
--- a/Master/texmf-dist/tex/latex/verbatimbox/verbatimbox.sty
+++ b/Master/texmf-dist/tex/latex/verbatimbox/verbatimbox.sty
@@ -1,5 +1,5 @@
\ProvidesPackage{verbatimbox}
- [2013/04/24 v3.0
+ [2013/06/06 v3.1
Routines for placing verbatim text into boxes, useful in places where
the verbatim environment is inaccessible. Secondarily, for adding
vertical buffer around an object.]
@@ -29,6 +29,13 @@ vertical buffer around an object.]
% -Added optional arguments to \addvbuffer
% -Fixed \verbfilebox so that it restored \verbatim@processline
% -Produced real documentation
+% 3.01 -renamed \macro@name so as not to conflict with (I think) ltxdoc
+% package
+% 3.1 -Corrected default argument to \addvbuffer so that it wouldn't
+% break. Also, gave better guidance in documentation to use
+% of optional argument to \addvbuffer
+% -Added verbnobox environment and \verbfilenobox macro
+% -Improved documentation showing line-specific optional arguments
\NeedsTeXFormat{LaTeX2e}
\@ifundefined{verbatim@processline}{\RequirePackage{verbatim}}{}
\usepackage{stringstrings}
@@ -182,7 +189,7 @@ vertical buffer around an object.]
\global\newlength\boxtop@sep
\global\newlength\boxbottom@sep
-\newcommand\addvbuffer[2][{\the\boxtopsep} \the\boxbottomsep]{%
+\newcommand\addvbuffer[2][\the\boxtopsep\ \the\boxbottomsep]{%
\getargs{#1}%
\setlength\boxtop@sep{\argi}%
\if1\narg\setlength\boxbottom@sep{\argi}\else%
@@ -191,5 +198,41 @@ vertical buffer around an object.]
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% The following two "nobox" commands are basically versions of
+% \verbatiminput and \verbatim that have been adapted to take the
+% optional argument style of this package. No boxes are created,
+% but breaking across page boundaries is not a problem here, as
+% it would be with a box.
+
+\newcommand\verbfilenobox[2][]{%
+ \setcounter{VerbboxLineNo}{0}%
+ \def\verbatim@processline{%
+ {\addtocounter{VerbboxLineNo}{1}%
+ #1\setbox0=\hbox{#1\the\verbatim@line}%
+ \hsize=\wd0 \the\verbatim@line\par}}%
+ \verbatiminput{#2}
+ \let\verbatim@processline\sv@verbatim@processline
+}
+
+\newenvironment{verbnobox}{%
+ \setcounter{VerbboxLineNo}{-1}%
+% FOR SOME REASON, USING \my@par INSTEAD OF \par PREVENTS EXTRA SPACE
+% ABOVE verbbox WHEN USING OPTIONAL ARGUMENTS
+ \let\my@par\par%
+ \def\verbatim@processline{%
+% FIRST \@tmp APPLIES OPTIONAL ARGUMENT TO EACH VERBATIM LINE
+% SECOND \@tmp MAKES SURE ANY PRINTED MATTER OF OPTIONAL ARGUMENT
+% IS ACCOUNTED FOR IN VERBATIM BOX WIDTH
+ {\addtocounter{VerbboxLineNo}{1}%
+ \@tmp\setbox0=\hbox{\@tmp\the\verbatim@line}%
+ \hsize=\wd0 \the\verbatim@line\my@par}}%
+\verbatim\verbbox@inner%
+}
+{%
+ \endverbatim%
+ \global\def\@tmp{}%
+}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\endinput