Fifteen
Boxes,verbatimsandfiles
Thetitleofthischapterindicatesthatitdealswiththreedisconnectedtopics,butthereis
methodintheseemingpeculiarity. Bytheendofthechapteryouwillbeabletowrite
LaTeXcodethatletsyouputthingsinyourdocumentsourceatoneplaceandhavethem
typesetatadifferentplace,orplaces. Forexample,ifyouarewritingatextbookthat
includesquestionsandanswersthenyoucouldwriteaquestionandanswertogetheryet
havetheanswertypesetattheendofthebook.
Writinginoneplaceandprintinginanotherisbasedonoutputtingstufftoafileand
theninputtingitforprocessingatanotherplaceortime.ThisisjusthowLaTeXproduces
theToC.ItisoftenimportantwhenwritingtoafilethatLaTeXdoesnoprocessingofany
macros,whichimpliesthatweneedtobeabletowriteverbatim. Oneuseofverbatimin
LaTeXistotypesetcomputercodeorthelike,andtoclearlydistinguishthecodefromthe
maintextitisoftentypesetwithinabox.Hencethechaptertitle.
Theclassextendsthekindsofboxesnormallyprovided,extendsthedefaultverbatims,
andprovidesasimplemeansofwritingandreadingfiles.
Oneproblemwithverbatimsisthattheycannotbeusedaspartofanargumenttoa
command.Forexampletotypesetsomethinginaframed
minipage
theobviouswayisto
usethe
minipage
astheargumenttothe
\fbox
macro:
\fbox{\begin{minipage}{6cm}
Contents of f framed minipage
\end{minipage}}
Thisworksperfectlywelluntilthecontentsincludessomeverbatimmaterial,whereupon
youwillgetnastyerrormessages.Howeverthisparticularconundrumissolvable,evenif
thesolutionisnotparticularlyobvious.Hereitis.
Wecanputthingsintoabox,declaredvia
\newsavebox
,andtypesetthecontentsof
theboxlatervia
\usebox
. Themostcommonwayofputtingthingsintoasaveboxis
bythe
\sbox
or
\savebox
macros,butasthematerialforsavingisoneofthearguments
tothesemacrosthisapproachfails. But,
lrbox
isanenvironmentformof
\sbox
,soit
canhandleverbatimmaterial. Thecodebelow, , aftergettinganewsavebox,definesa
new
framedminipage
environmentwhichisusedjustlikethestandard
minipage
. The
framedminipage
startsan
lrbox
environmentandthenstartsa
minipage
environment,
afterwhichcomesthecontents.Attheenditclosesthetwoenvironmentsandcalls
\fbox
withitsargumentbeingthecontentsofthesavedboxwhichhavealreadybeentypeset.
\newsavebox{\minibox}
\newenvironment{framedminipage}[1]{%
\begin{lrbox}{\minibox}\begin{minipage}{#1}}%
Chapterlastupdated2013/04/24 (revision442)
273
Add pdf files together online - Merge, append PDF files in C#.net, ASP.NET, MVC, Ajax, WinForms, WPF
Provide C# Demo Codes for Merging and Appending PDF Document
pdf mail merge; batch combine pdf
Add pdf files together online - VB.NET PDF File Merge Library: Merge, append PDF files in vb.net, ASP.NET, MVC, Ajax, WinForms, WPF
VB.NET Guide and Sample Codes to Merge PDF Documents in .NET Project
acrobat merge pdf files; combine pdf files
15. B
OXES
,
VERBATIMSANDFILES
{\end{minipage}\end{lrbox}\fbox{\usebox{\minibox}}}
Question1.Canyouthinkofanyimprovementstothedefinitionofthe
framedminipage
environment?
Question2.Ananswertoquestion1isattheendofthischapter.Suggesthowitwasput
there.
15.1 B
OXES
LaTeXprovidessome commandstoput aboxroundsometext. . Theclassextendsthe
availablekindsofboxes.
\begin{framed}
text
\end{framed}
\begin{shaded}
text
\end{shaded}
\begin{snugshade}
text
\end{snugshade}
The
framed
,
shaded
,and
snugshade
environments,whichwerecreatedbyDonaldArse-
neauaspartofhisframedpackage[Ars07],puttheircontentsintoboxesthatbreakacross
pages. The
framed
environmentdelineatestheboxbydrawingarectangularframe. If
thereisapagebreakinthemiddleofthebox,framesaredrawnonbothpages.
The
shaded
environmenttypesetstheboxwithashadedorcoloredbackground.This
requirestheuseofthecolorpackage[Car05],whichisoneoftherequiredLaTeXpackages,
orthexcolorpackage[Ker07].Theshadingcoloris
shadecolor
,whichyouhavetodefine
beforeusingtheenvironment.Forexample,tohavealightgraybackground:
\definecolor{shadecolor}{gray}{0.9}
Forcompleteinformationonthisseethedocumentationforthecolororxcolorpackages,or
oneoftheLaTeXbooksliketheGraphicsCompanion[GM+07].Inthe
snugshaded
environ-
menttheboxclingsmorecloselytoitscontentsthanitdoesinthe
shaded
environment.
Beawarethattheseboxesaresomewhatdelicate;theydonotworkinallcircumstances.
Forexampletheywillnotworkwiththemulticolpackage[Mit98],andanyfloatsorfoot-
notesintheboxeswilldisappear.
\FrameRule\FrameSep\FrameHeightAdjust
The
framed
environmentputsthetextintoan‘
\fbox
’withthesettings:
\setlength{\FrameRule}{\fboxrule}
\setlength{\FrameSep}{3\fboxsep}
Themacro
\FrameHeightAdjust
specifiestheheightofthetopoftheframeabovethe
baselineatthetopofapage;itsinitialdefinitionis:
\providecommand*{\FrameHeightAdjust}{0.6em}
\MakeFramed{
settings
}\endMakeFramed
\FrameCommand\FrameRestore
Internally, the e environments are specified using the
MakeFramed
environment. The
settingshouldcontainanyadjustmentstothetextwidth(appliedto
\hsize
andusing
274
C# Word - Merge Word Documents in C#.NET
empowers C# programmers to easily merge and append Word files with mature input Word documents can be merged and appended together according to Add references:
pdf merge files; add pdf together one file
C# PowerPoint - Merge PowerPoint Documents in C#.NET
together according to its loading sequence, and then saved and output as a single PowerPoint with user-defined location. C# DLLs: Merge PowerPoint Files. Add
break pdf file into multiple files; scan multiple pages into one pdf
15.1. Boxes
the
\width
oftheframeitself)anda‘restore’command,whichisnormallytheprovided
\FrameRestore
macro.Theframeitselfisdrawnviathe
\FrameCommand
,whichcanbe
changedtoobtainotherboxingstyles. Thedefaultdefinitionequatestoan
\fbox
andis:
\newcommand*{\FrameCommand}{%
\setlength{\fboxrule}{\FrameRule}\setlength{\fboxsep}{\FrameSep}%
\fbox}
Forexample,the
framed
,
shaded
and
snugshade
environmentsaredefinedas
\newenvironment{framed}{% % % uses s default t \FrameCommand
\MakeFramed{\advance\hsize -\width h \FrameRestore}}%
{\endMakeFramed}
\newenvironment{shaded}{% % % redefines s \FrameCommand as \colorbox
\def\FrameCommand{\fboxsep=\FrameSep \colorbox{shadecolor}}%
\MakeFramed{\FrameRestore}}%
{\endMakeFramed}
\newenvironment{snugshade}{% A A tight version of f shaded
\def\FrameCommand{\colorbox{shadecolor}}%
\MakeFramed{\FrameRestore\@setminipage}}%
{\par\unskip\endMakeFramed}
Ifyouwantedanarrow,centered,framedenvironmentyoucoulddosomethinglike
this:
\newenvironment{narrowframed}{%
\MakeFramed{\setlength{\hsize}{22pc}\FrameRestore}}%
{\endMakeFramed}
where
22pc
willbethewidthofthenewframedenvironment.
\begin{leftbar}
text
\end{leftbar}
The
leftbar
environmentdrawsathickverticallineattheleftofthetext.Itisdefined
as
\newenvironment{leftbar}{%
\def\FrameCommand{\vrule width 3pt \hspace{10pt}}%
\MakeFramed{\advance\hsize -\width h \FrameRestore}}%
{\endMakeFramed}
Bychangingthesettingfor
\MakeFramed
andthedefinitionof
\FrameCommand
you
canobtainavarietyofframingstyles.Forinstance,tohaveroundedcornerstotheframe
insteadofthenormalsharpones,youcanusethefancyboxpackage[Zan98]andthefol-
lowingcode:
\usepackage{fancybox}
\newenvironment{roundedframe}{%
\def\FrameCommand{%
\cornersize*{20pt}%
\setlength{\fboxsep}{5pt}%
\ovalbox}%
\MakeFramed{\advance\hsize-\width \FrameRestore}}%
{\endMakeFramed}
275
C# PDF Convert to Text SDK: Convert PDF to txt files in C#.net
can be copied and pasted to .txt files by keeping text by a method loses the original PDF document layout and all the paragraphs are joining together, our C#
c# pdf merge; asp.net merge pdf files
VB.NET Word: How to Process MS Word in VB.NET Library in .NET
Imaging.MSWordDocx.dll", which, when used together with other online tutorial on how to add & insert controls, PDF document, image to pdf files and components
reader create pdf multiple files; pdf merger online
15. B
OXES
,
VERBATIMSANDFILES
Aframedenvironmentisnormallyusedtodistinguishitscontentsfromthesurround-
ingtext. Atitlefortheenvironmentmaybeuseful,andiftherewasapagebreakinthe
middle,atitleonthecontinuationcouldbedesireable. Doingthistakesabitmorework
thanIhaveshownsofar.Thisfirstpartwasinspiredbyapostingto
CTT
byDonaldArse-
neau.
1
.
\newcommand{\FrameTitle}[2]{%
\fboxrule=\FrameRule \fboxsep=\FrameSep
\fbox{\vbox{\nobreak \vskip -0.7\FrameSep
\rlap{\strut#1}\nobreak\nointerlineskip% left justified
\vskip 0.7\FrameSep
\hbox{#2}}}}
\newenvironment{framewithtitle}[2][\FrameFirst@Lab\ (cont.)]{%
\def\FrameFirst@Lab{\textbf{#2}}%
\def\FrameCont@Lab{\textbf{#1}}%
\def\FrameCommand##1{%
\FrameTitle{\FrameFirst@Lab}{##1}}%
\def\FirstFrameCommand##1{%
\FrameTitle{\FrameFirst@Lab}{##1}}%
\def\MidFrameCommand##1{%
\FrameTitle{\FrameCont@Lab}{##1}}%
\def\LastFrameCommand##1{%
\FrameTitle{\FrameCont@Lab}{##1}}%
\MakeFramed{\advance\hsize-\width \FrameRestore}}%
{\endMakeFramed}
The
framewithtitle
environment,whichistheendgoalofthisexercise,actslikethe
framed
environmentexceptthatitputsaleft-justifiedtitlejustafterthetopoftheframe
boxandbeforetheregularcontents.
\begin{framewithtitle}[
cont-title
]{
title
}
text
\end{framewithtitle}
Thetitleissetinaboldfont.Iftheoptionalcont-titleargumentisgiventhencont-title
isusedasthetitleonanysuceedingpages,otherwisethephrase‘title(cont.)’isusedfor
thecontinuationtitle.
Ifyouwouldlikethetitlescentered,replacethelinemarked‘leftjustified’inthecode
for
\FrameTitle
withtheline:
\rlap{\centerline{\strut#1}}\nobreak\nointerlineskip% centered
Thecodeforthe
frametitle
environmentisnotobvious.Thedifficultyincreatingthe
environmentwasthattheunderlyingframingcodegoesthroughthe‘stuff’tobeframed
byfirsttryingtofititallontoonepage(
\FrameCommand
). Ifitdoesnotfit,thenittakes
asmuchaswillfitandtypesetsthatusing
\FirstFrameCommand
,thentriestotypesetthe
remainderonthenextpage.Ifitallfitsthenituses
\LastFrameCommand
.Ifitdoesn’tfit,
ittypesetsasmuchasitcanusing
\MidFrameCommand
,andthentriestosettheremainder
onthefollowingpage.Theprocessrepeatsuntilallhasbeenset.
Ifyouwouldprefertohavethetitleatthetopoutsidetheframetheabovecodeneeds
adjusting.
1
On2003/10/24inthethreadframed.styw/heading?.Theparticularsarenolongerapplicableastheframingcode
inquestionthenhassincebeenrevised.
276
C# TIFF: TIFF Editor SDK to Read & Manipulate TIFF File Using C#.
2. How to add and implement Tiff imaging functions in your C# project. 2. Word/Excel/PPT/PDF/Jpeg to Tiff conversion. 2. Merge and append Tiff files using
combine pdf; pdf combine pages
C# Excel - Merge Excel Documents in C#.NET
and appended together according to its loading sequence, and then saved and output as a single Excel with user-defined location. C# DLLs: Merge Excel Files. Add
reader combine pdf pages; batch pdf merger online
15.1. Boxes
\newcommand{\TitleFrame}[2]{%
\fboxrule=\FrameRule \fboxsep=\FrameSep
\vbox{\nobreak \vskip -0.7\FrameSep
\rlap{\strut#1}\nobreak\nointerlineskip% left justified
\vskip 0.7\FrameSep
\noindent\fbox{#2}}}
\newenvironment{titledframe}[2][\FrameFirst@Lab\ (cont.)]{%
\def\FrameFirst@Lab{\textbf{#2}}%
\def\FrameCont@Lab{\textbf{#1}}%
\def\FrameCommand##1{%
\TitleFrame{\FrameFirst@Lab}{##1}}
\def\FirstFrameCommand##1{%
\TitleFrame{\FrameFirst@Lab}{##1}}
\def\MidFrameCommand##1{%
\TitleFrame{\FrameCont@Lab}{##1}}
\def\LastFrameCommand##1{%
\TitleFrame{\FrameCont@Lab}{##1}}
\MakeFramed{\hsize\textwidth
\advance\hsize -2\FrameRule
\advance\hsize -2\FrameSep
\FrameRestore}}%
{\endMakeFramed}
\begin{titledframe}[
cont-title
]{
title
}
text
\end{titledframe}
The
titledframe
environmentisidenticalto
framewithtitle
exceptthatthe titleis
placedjust beforethe frame. . Again, , ifyouwouldlikeacenteredtitle, replacetheline
marked‘leftjustified’in
\TitleFrame
by
\rlap{\centerline{\strut#1}}\nobreak\nointerlineskip% centered
Youcanadjustthecodeforthe
framewithtitle
and
titledframe
environmentsto
suityourownpurposes,especiallyastheyarenotpartoftheclasssoyouwouldhaveto
typetheminyourselfanywayifyouwantedtousethem,usingwhatevernamesyoufelt
suitable.
Theclassprovidestwofurtherenvironmentsinadditiontothosefromtheframedpack-
age.
\begin{qframe}
text
\end{qframe}
\begin{qshade}
text
\end{qshade}
Whenusedwithin,say,a
quotation
environment,the
framed
and
shaded
environ-
mentsdonotcloselyboxtheindentedtext. The
qframe
and
qshade
environmentsdo
providecloseboxing.
2
Thedifferencecanbeseeninthefollowing
quotation
.
Thisisthestartofa
quotation
environment. Itformsthebasisshowing
thedifferencebetweenthe
framed
and
qframe
environments.
2
DonaldArseneauhassaidthathemayputsomethingsimilarinalaterversiontheframedpackage.
277
C# Image: C# Code to Encode & Decode JBIG2 Images in RasterEdge .
Easy to add C# JBIG2 codec controls to your image and codec into PDF documents for a better PDF compression; text to the new project folder, together with .NET
combine pdfs online; add pdf pages together
VB.NET PDF Text Search Library: search text inside PDF file in vb.
and find text content in multiple page adobe PDF files in .NET Our VB.NET PDF Document Add-On enables you to search for text in target PDF document by using
merge pdf files; acrobat combine pdf files
15. B
OXES
,
VERBATIMSANDFILES
Thisisthesecondparagraphinthe
quotation
environmentandinturn
itiswithinthe
qframe
environment.
Thisisthethirdparagraphinthe
quotation
environmentandinturn
itiswithinthe
framed
environment.
Thisisthefourthandfinalparagraphwithinthe
quotation
environment
andisnotwithineithera
qfame
or
framed
environment.
Ifyouwanttoputaframeinsidean
adjustwidth
environmentthenyoumaywellfind
that
qframe
or
qshade
meetyourexpectionsbetterthan
framed
of
shaded
.Ofcourse,it
doesdependonwhatyourexpectationsare.
15.2 L
ONGCOMMENTS
The%commentcharactercanbeusedtocommentout(partof)alineofTeXcode,butthis
getstediousifyouneedtocommentoutlongchunksofcode.
\begin{comment}
texttobeskippedover
\end{comment}
Asanextremeformoffontchanging,althoughitdoesn’tactuallyworkthatway,anything
ina
comment
environmentwillnotappearinthedocument;effectively,LaTeXthrowsitall
away.Thiscanbeusefultotemporarilydiscardchunksofstuffinsteadofhavingtomark
eachlinewiththe%commentcharacter.
\newcomment{
name
}
\commentsoff{
name
}
\commentson{
name
}
The classletsyou define your owncommentenvironmentviathe
\newcomment
com-
mandwhichdefinesacommentenvironmentcalledname. Infacttheclassitselfuses
\newcomment{comment}
todefinethe
comment
environment. Acommentenvironment
namemaybeswitchedoffsothatitscontentsarenotignoredbyusingthe
\commentsoff
declaration. Itmaybeswitchedonlaterbythe
\commentson
declaration. Ineithercase
namemusthavebeenpreviouslydeclaredasacommentenvironmentvia
\newcomment
.
Suppose,forexample,thatyouarepreparingadraftdocumentforreviewbysomeoth-
ersandyouwanttoincludesomenotesforthereviewers.Also,youwanttoincludesome
privatecommentsinthe source foryourself. . Youcouldusethe
comment
environment
foryourprivatecommentsandcreateanotherenvironmentforthenotestothereviewers.
Thesenotesshouldnotappearinthefinaldocument.Yoursourcemightthenlooklike:
\newcomment{review}
\ifdraftdoc\else
\commentsoff{review}
\fi
...
\begin{comment}
Remember to finagle the e wingle!
278
15.3. Verbatims
\end{comment}
...
\begin{review}
\textit{REVIEWERS: Please pay particular r attention n to o this s section.}
\end{review}
...
Commentenvironmentscannotbenested,norcantheyoverlap. Theenvironmentsin
thecodebelowwillnotworkinthemannerthatmightbeexpected:
\newcomment{acomment} \newcomment{mycomment}
\begin{comment}
\begin{acomment} %% % comments s cannot be e nested
...
\end{acomment}
...
\begin{mycomment}
...
\end{comment}
...
\end{mycomment} %% % comments s cannot overlap
Moreencompassing
comment
environmentsareavailableifyouuseVictorEijkhout’s
commentpackage[Eij99].
15.3 V
ERBATIMS
StandardLaTeXdefinesthe
\verb
and
\verb*
commandsfortypesettingshortpiecesof
textverbatim, shortbecausetheycannotincludealinebreak. . Forlongerverbatimtexts
the
verbatim
or
verbatim*
environmentscanbeused.Thestarformsindicatespacesin
theverbatimtextbyoutputinga markforeachspace. . Theclassextendsthestandard
verbatimsinvariousways.
Ifyouhavetowritealotof
\verb
text,asIhavehadtodoforthisbook,itgetste-
dioustokeepontypingthissortofthing:
\verb!verbatim text!
. Rememberthatthe
characterimmediatelyafterthe
\verb
,or
\verb*
,endstheverbatimprocessing.
\MakeShortVerb{
backslash-char
}
\DeleteShortVerb{
backslash-char
}
The
\MakeShortVerb
macrotakesacharacterprecededbyabackslashasitsargument,
say
\!
,andmakesthatcharacterequivalentto
\verb!
.Usingthecharacterasecondtime
willstoptheverbatimprocessing. Doing,forexample
\MakeShortVerb{\!}
,letsyou
thenuse
!verbatim text!
insteadofthelongerwinded
\verb!verbatim text!
.
Youhavetopickastheshortverbcharacteronethatyouareunlikelytouse;agood
choiceisoftenthe
|
barcharacterasthisrarelyusedinnormaltext. Thischoice,though
maybeunfortunateifyouwanttohaveanytabularswithverticallines,asthebarcharacter
isusedtospecifythose.The
\DeleteShortVerb
macroisprovidedforthiscontingency;
giveitthesameargumentasanearlier
\MakeShortVerb
anditwillrestoretheshortverb
charactertoitsnormalstate.
279
15. B
OXES
,
VERBATIMSANDFILES
The
\MakeShortVerb
and
\DeleteShortVerb
macroscomefromtheshortvrbpack-
agewhichispartoftheLaTeXbasesystem,butIhavefoundthemsoconvenientthatI
addedthemtotheclass.
\setverbatimfont{
font-declaration
}
The default fontfor verbatimsisthe normalsizedmonospacedfont. . The e declaration
\setverbatimfont
canbeusedtospecifyadifferentfont.Theclassdefaultis
\setverbatimfont{\normalfont\ttfamily}
Touseasmallerversionsimplysay
\setverbatimfont{\normalfont\ttfamily\small}
Amonospacedfontisnormallychosenasverbatimtextisoftenusedtopresentpro-
gramcodeortypewrittentext.Ifyouwantamoreexoticfont,trythis
\setverbatimfont{\fontencoding{T1}\fontfamily{cmss}\selectfont}
andyourverbatimtextwillthenlooklike
Wearenolongerusingtheboringoldtypewriterfont
forverbatimtext.WeusedtheT1encoding
tomakesurethatcharactersthatareoftenligatures
like‘‘,or’’,or---,or<,or>,printasexpected.
Afterthiswewillswitchbacktothedefaultverbatimfontvia
\setverbatimfont{\normalfont\ttfamily}
Inthe normalwayofthingswithanOT1fontencoding,typesettingthe ligaturesmen-
tionedaboveinthesansfontproduces:ligatureslike\,or",or|,or<,or>,whichisnot
whathappensinthe
\verbatim
environment.
\begin{verbatim}
anything
\end{verbatim}
\begin{verbatim*}
anything
\end{verbatim*}
In the
verbatim
environment
3
you can write e anything you u want t (except
\end{verbatim}
), and it willbe typesetexactlyaswritten. . The
verbatim*
environ-
mentissimilarexcept,likewith
\verb*
,spaceswillbeindicatedwitha mark.
\tabson[
number
]
\tabsoff
Thestandard
verbatim
environmentignoresanyTABcharacters;withtheclass’senviron-
mentaftercallingthe
\tabson
declarationtheenvironmentwillhandleTABcharacters.
Bydefault4spacesareusedtorepresentaTAB;theoptionalnumberargumenttothe
declarationwillsetthenumberofspacesforaTABtobenumber.Somefolkliketouse8
spacesforaTAB,inwhichcasetheywouldneedtodeclare
\tabson[8]
. Unremarkably,
thedeclaration
\tabsoff
switchesoffTABs.Theclassdefaultis
\tabsoff
.
3
Thisversionoftheverbatimenvironmentisheavilybasedontheverbatimpackage[SRR99]butdoesprovide
someextensions.
280
15.3. Verbatims
\wrappingon
\wrappingoff
\verbatimindent
\verbatimbreakchar{
char
}
Asnoted,whateveriswrittenina
verbatim
environmentisoutputjustaswritten,even
iflinesaretoolongtofitonthepage. Thedeclaration
\wrappingon
letstheenviron-
mentbreaklinessothattheydonotoverflow.Thedeclaration
\wrappingoff
restoresthe
normalbehaviour.
Thefollowingisanexampleofhowawrappedverbatimlinelooks. Inthesourcethe
contentsofthe
verbatim
waswrittenasasingleline.
This is an n example e of line wrapping g in n the verbatim environment. It %
is a a single line in the source and the \wrappingon %
declaration has been used.
Thewrappedportionofverbatimlinesareindentedfromtheleftmarginbythelength
\verbatimindent
. Thevaluecanbechangedbytheusuallengthchangingcommands.
Theendofeachlinethathasbeenwrappedismarkedwiththe charcharacterofthe
\verbatimbreakchar
macro. Theclassdefault t is
\verbatimbreakchar{\char‘\%}
,
sothatlinesaremarkedwith
%
.Toputa‘/’markattheendofwrappedlinesyoucando
\setverbatimbreak{\char’\/}
orsimilarlyifyouwouldlikeanothercharacter.Anotherpossibilityis
\setverbatimchar{\char’\/\char’\*}
whichwillmake‘/*’theendmarker.
15.3.1 Boxedverbatims
Verbatimenvironmentsareoftenusedtopresentprogramcodeor,asinthisbook,LaTeX
code.Forsuchapplicationsitcanbeusefultoputthecodeinabox,ortonumberthecode
lines,orperhapsboth.
\begin{fboxverbatim}
anything
\end{fboxverbatim}
The
fboxverbatim
environmenttypesetsitscontentsverbatimandputsatightlyfitting
framearoundtheresult;inasenseitissimilartothe
\fbox
command.
\begin{boxedverbatim}
anything
\end{boxedverbatim}
\begin{boxedverbatim*}
anything
\end{boxedverbatim*}
The
boxedverbatim
and
boxedverbatim*
environments are e like the
verbatim
and
verbatim*
environmentsexceptthatabox, allowingpage breaks, maybeputaround
theverbatimtextandthe linesoftextmaybe numbered. . The e particularformatofthe
outputcanbecontrolledasdescribedbelow.
\bvbox\bvtopandtail\bvsides\nobvbox
\bvboxsep
Fourstylesofboxesareprovidedandyoucanextendthese.Followingthe
\bvbox
decla-
ration,aboxisdrawnroundtheverbatimtext,breakingatpageboundariesifnecessary;
thisisthedefaultstyle. Conversely,noboxesaredrawnafterthe
\nobvbox
declaration.
281
15. B
OXES
,
VERBATIMSANDFILES
Withthe
\bvtopandtail
declarationhorizontallinesaredrawnatthestartandendof
theverbatimtext,andwiththe
\bvsides
declarations,verticallinesaredrawnattheleft
andrightofthetext. Theseparationbetweenthelinesandthetextisgivenbythelength
\bvboxsep
.
Thefollowinghooksareprovidedtosetyourownboxingstyle.
\bvtoprulehook\bvtopmidhook\bvendrulehook
\bvleftsidehook\bvrightsidehook
The macros
\bvtoprulehook
and
\bvendrulehook
are called at the start and end
of the
boxedverbatim
environment, and d before e and d after r page e breaks. . The e macros
\bvleftsidehook
and
\bvrightsidehook
arecalledatthestartandendofeachver-
batimline.Themacro
\bvtopmidhook
iscalledafter
\bvtoprulehook
atthestartofthe
environment.Itcanbeusedtoaddsomespaceif
\bvtoprulehook
isempty.
\bvperpagetrue\bvperpagefalse
\bvtopofpage{
text
}\bvendofpage{
text
}
Thecommand
\bvperpagetrue
indicatesthataboxshouldbevisiblybrokenatapage-
break,whilethereshouldbenovisiblebreakfor
\bvperpagefalse
.Iftheboxcontinues
ontoanotherpagethenitmaybeadvantageoustoplacesomesortofheadingbeforethe
verbatimcontinues. Followingthedeclaration
\bvperpagetrue
thetextargumentto
\bvtopofpage
willbetypesetafteranypagebreak.Forexampleyoucouldset:
\bvtopofpage{continued}
toprint‘continued’inthenormaltextfont.
Bydefault,theclasssets
\bvendofpage{\hrule\kern-.4pt}
whichcausesthe
\hrule
tobedrawnattheendofapageasthevisiblebreak(therule
is0.4ptthickandthekernbacksupthatamountaftertherule,soiteffectivelytakesno
verticalspace). Thisisnotalwayssuitable. . For r instance,iftherewillbe a‘continued’
messageatthetopofthefollowingpageitmayseemoddtodrawalineatthebottomof
thepreviouspage.Inthiscase,setting
\bvendofpage{}
willeliminatetherule.
Asexamplesoftheuseofthesehooks,hereishowsomeoftheboxedverbatimstyles
aredefined.
Thedefaultstyleis
\bvbox
,whichputsseparatefullboxesoneachpage.
\newcommand{\bvbox}{%
\bvperpagetrue
\renewcommand{\bvtoprulehook}{\hrule \nobreak k \vskip-.1pt}%
\renewcommand{\bvleftsidehook}{\vrule}%
\renewcommand{\bvrightsidehook}{\vrule}%
\renewcommand{\bvendrulehook}{\hrule}%
\renewcommand{\bvtopmidhook}{\rule{0pt}{2\fboxsep} \hss}%
}
The
\nobvbox
turnsoffallboxing,andisdefinedas
282
Documents you may be interested
Documents you may be interested