summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/verbatimbox
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2008-09-08 00:54:18 +0000
committerKarl Berry <karl@freefriends.org>2008-09-08 00:54:18 +0000
commit72e060c8ccab1f801c7f40b5283256f296098de7 (patch)
treebab46b262a3d45b2022e7f0f020845712e1137a5 /Master/texmf-dist/tex/latex/verbatimbox
parent4c1eb5a01d9b26b23bdebd28739b415648adef5a (diff)
new latex package verbatimbox (20aug08)
git-svn-id: svn://tug.org/texlive/trunk@10478 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/verbatimbox')
-rw-r--r--Master/texmf-dist/tex/latex/verbatimbox/verbatimbox.sty90
1 files changed, 90 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/verbatimbox/verbatimbox.sty b/Master/texmf-dist/tex/latex/verbatimbox/verbatimbox.sty
new file mode 100644
index 00000000000..5a4e0a25499
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/verbatimbox/verbatimbox.sty
@@ -0,0 +1,90 @@
+\ProvidesPackage{verbatimbox}
+ [2007/03/16 v1.0]
+% verbatimbox.sty is based on boxedverbatim environment found
+% in moreverb.sty.
+%
+% It adds the verbbox environment and theverbbox command.
+%
+% The verbbox environment is just like boxedverbatim, except:
+%
+% 1) verbbox has no framed place around it; and
+% 2) the verbatim box is not output,
+% but saved in the global box named \savedverbbox.
+%
+% The command \theverbbox will output the verbatim box most recently
+% created within the verbbox environment (that is, \savedverbbox).
+% The [t] option to \theverbbox is made for outputting a verbbox
+% in a tabular environment. Without the [t], insufficient vertical
+% space is allocated above the box.
+%
+% This routine allows the verbatim environment to be stuffed into a
+% LaTeX box, which can then be embedded in other LaTeX constructs.
+%
+% This routine is useful, because there are many LaTeX environments
+% in which a verbatim environment cannot be simply opened, but
+% in which a box can be simply placed (e.g., tabular).
+%
+% An enabling routine \addvbuffer{}, is available for general
+% use. It adds vertical buffer space above and below the argument
+% of the command. The vertical space added above the original box
+% is the length \boxtopsep; below the box, it is \boxbottomsep. It
+% shares some functional similarities to \raisebox, but it is not the
+% same.
+%
+\NeedsTeXFormat{LaTeX2e}
+\@ifundefined{verbatim@processline}{\RequirePackage{verbatim}}{}
+
+\global\newsavebox{\savedverbbox}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% The verbbox environment is based on
+% the boxedverbatim environment found in moreverb.sty
+%
+\def\verbbox{%
+ \def\verbatim@processline{%
+ {\setbox0=\hbox{\the\verbatim@line}%
+ \hsize=\wd0 \the\verbatim@line\par}}%
+ \@minipagetrue%
+ \@tempswatrue%
+ \setbox0=\vbox\bgroup \verbatim
+}
+\def\endverbbox{%
+ \endverbatim
+ \unskip\setbox0=\lastbox %
+ \egroup
+ \global\sbox{\savedverbbox}{\box0}
+}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\newcommand\theverbbox[1][x]{%
+ \if #1t%
+% The t option is for outputting the savedverbbox inside a tabular
+% environment (else insufficent vertical space above box)
+ \boxtopsep = 3pt
+ \boxbottomsep = 0pt
+ \addvbuffer{\usebox{\savedverbbox}}
+ \else%
+ \usebox{\savedverbbox}
+ \fi%
+}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% \addvbuffer is based on \fbox,
+% but without a frame. Empty buffer space
+% is added above and below the object, making a new box.
+% Above the box is added \boxtopsep (initially 3pt) vertical space.
+% Below the box is added \boxbottomsep (initially 0pt) vertical space.
+% This routine is called when a savedverbbox is output in a tabular
+% environment.
+%
+\newdimen\boxtopsep
+\newdimen\boxbottomsep
+\newdimen\ps@tempdima
+\newbox\ps@tempboxa
+\boxtopsep = 3pt
+\boxbottomsep = 0pt
+\long\def\addvbuffer#1{\leavevmode\setbox\ps@tempboxa\hbox{#1}\ps@tempdima
+ 0pt \advance\ps@tempdima \dp\ps@tempboxa \hbox{\lower \ps@tempdima\hbox
+ {\vbox{\hbox{\vbox{\vskip\boxtopsep \box\ps@tempboxa \vskip
+ \boxbottomsep}}}}}}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\endinput
+
+