correctdriverforwhatyou’redoing(forexample,adistributionthatprovidesboth
LaTeXandPDFLaTeXwillusuallyprovideaconfigurationfilethatdetermineswhether
PDFLaTeXisrunning,andselectsthedefinitionsforitifso).
Thegraphicspackageprovidesatoolkitofcommands(insertgraphics,scalea
box,rotateabox),whichmaybecomposedtoprovidemostfacilitiesyouneed;the
basiccommand,
\includegraphics
,takesoneoptionalargument,whichspecifiesthe
boundingboxofthegraphicstobeincluded.
Thegraphicxpackageusesthefacilitiesofofgraphicsbehindarathermoresophis-
ticatedcommandsyntaxtoprovideaverypowerfulversionofthe
\includegraphics
command.graphicx’sversioncancombinescalingandrotation,viewportingandclip-
ping,andmanyotherthings.Whilethisisallaconvenience(atsomecostofsyntax),
itisalsocapableofproducingnoticeablymoreefficientPostScript,andsomeofits
combinationsaresimplynotpossiblewiththegraphicspackageversion.
Theepsfigpackageprovidesthesamefacilitiesasgraphicx,butviaa
\psfig
command(alsoknownas
\epsfig
),capableofemulatingthebehaviour(ifnotthe
bugs)theoldpsfigpackage.Epsfigalsosupplieshomelysupportforformerusersofthe
epsfpackage.However,there’sasupportissue:ifyoudeclareyou’reusingepsfig,any
potentialmailinglistorusenethelperhastoclearoutoftheequationthepossibilitythat
you’reusing“old”epsfig,sothatsupportisslowercomingthanitwouldotherwisebe.
Thereisnorationalreasontostickwiththeoldpackages,whichhaveneverbeen
entirelysatisfactoryintheLaTeXcontext.(Oneirrationalreasontoleavethembehindis
thattheirreplacement’snametendsnottoimplythatit’sexclusivelyrelatedtoPostScript
graphics.Thereasoningalsoexcludesepsfig,ofcourse.)
Awidevarietyofdetailedtechniquesandtrickshavebeendevelopedovertheyears,
andKeithReckdahl’sepslatexoutlinesthemincompendiousdetail:thishighlyrecom-
mendabledocumentisavailablefromCTAN.Aninvaluablereviewofthepracticalities
ofexchanginggraphicsbetweensites,“GraphicsforInclusioninElectronicDocuments
hasbeenwrittenbyIanHutchinson;thedocumentisn’tonCTAN,butmayalsobe
browsedontheWeb.
epsf.tex
:
macros/generic/epsf/epsf.tex
epsfig.sty
: Partofthe
macros/latex/required/graphics
bundle
epslatex.pdf
:
info/epslatex
graphics.sty
:
macros/latex/required/graphics
graphicx.sty
: Partofthe
macros/latex/required/graphics
bundle
miniltx.tex
:
macros/plain/graphics
psfig.sty
:
graphics/psfig
153 Importedgraphicsindvips
Dvips,asoriginallyconceived,canonlyimportasinglegraphicsformat:encapsulated
PostScript(
.eps
files,encapsulatedPostScript). Dvipsalsodealswiththeslightly
eccentricEPSthatiscreatedbyMetapost.
Apartfromthefactthatadepressingproportionofdrawingapplicationsproduce
corruptEPSwhenaskedforsuchoutput,thisisprettysatisfactoryforvectorgraphics
work.
Toincludebitmapgraphics,youneedsomemeansofconvertingthemtoPostScript;
infactmanystandardimagemanipulators(suchasImageMagick’sconvert)makea
goodjobofcreatingEPSfiles(butbesuretoaskforoutputatPostScriptlevel2or
higher).(Unixusersshouldbewareofxv’sclaims:ithasatendencytodownsample
yourbitmaptoyourscreenresolution.)
Specialpurposeapplicationsjpeg2ps(whichconvertsJPEGfilesusingPostScript
level2functionality),bmeps(whichconvertsbothJPEGandPNGfiles)anda2ping/sam2p
(whichconvertabewilderingarrayofbitmapformatstoEPSorPDFfiles;sam2pisone
oftheenginesthata2pinguses)arealsoconsidered“goodbets”.
Bmepscomeswithpatchestoproduceyourownversionofdvipsthatcancope
withJPEGandPNGdirect,usingbmeps’sconversionlibrary. Dvips,asdistributed
101
Acrobat combine pdf - Merge, append PDF files in C#.net, ASP.NET, MVC, Ajax, WinForms, WPF
Provide C# Demo Codes for Merging and Appending PDF Document
break a pdf into multiple files; batch merge pdf
Acrobat combine pdf - 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
pdf merge; break pdf file into multiple files
byMiKTeX,comeswiththosepatchesbuilt-in,butassumingthatcapabilitydestroys
portability,andisonlyrecommendableifyouaresureyouwillneverwanttoshareyour
document.
a2ping
:
graphics/a2ping
bmeps
: Distributedaspartof
support/dktools
jpeg2ps
:
support/jpeg2ps
sam2p
:
graphics/sam2p
154 ImportedgraphicsinPDFLaTeX
PDFTeXitselfhasaratherwiderangeofformatsthatitcan“natively”incorporateinto
itsoutputPDFstream:JPEG(
.jpg
files)forphotographsandsimilarimages,PNG
filesforartificialbitmapimages,andPDFforvectordrawings.OldversionsofPDFTeX
(priortoversion1.10a)supportedTIFF(
.tif
files)formatasanalternativetoPNGfiles;
don’trelyonthisfacility,evenifyouarerunninganoldenoughversionofPDFTeX...
Inadditiontothe‘native’formats,thestandardPDFLaTeXgraphicspackagesetup
causesHansHagen’s
supp-pdf
macrostobeloaded: thesemacrosarecapableof
translatingtheoutputofMetaposttoPDF“onthefly”;thusMetapostoutput(
.mps
files)
mayalsobeincludedinPDFLaTeXdocuments.
Thecommonestproblemusersencounter,whenswitchingfromTeX,isthatthere
isnostraightforwardwaytoincludeEPSfiles:sincePDFTeXisitsown“driver”,and
sinceitcontainsnomeansofconvertingPostScripttoPDF,there’snodirectwaythe
jobcanbedone.
ThesimplesolutionistoconverttheEPStoanappropriatePDFfile.Theepstopdf
programwilldothis:it’savailableeitherasaWindowsexecutableorasaPerlscript
torunonUnixandothersimilarsystems.ALaTeXpackage,epstopdf,canbeusedto
generatetherequisitePDFfiles“onthefly”;thisisconvenient,butrequiresthatyou
suppressoneofTeX’ssecuritychecks:don’tallowitsuseinfilesfromsourcesyou
don’tentirelytrust.
Thepackagepst-pdfpermitsotherthingsthan‘mere’graphicsfilesinitsargument.
Pst-pdfoperates(theauthorssuggest)“likeBibTeX”—youprocessyourfileusing
PDFLaTeX,thenuseLaTeX,dvipsandps2pdfinsuccession,toproduceasecondary
filetoinputtoyournextPDFLaTeXrun.(Scriptsareprovidedtoeasetheproductionof
thesecondaryfile.)
Afurtherextensionisauto-pst-pdf,whichgeneratesPDF(essentially)transparently,
byspawningajobtoprocessoutputsuchaspst-pdfuses.IfyourPDFLaTeXinstallation
doesn’tautomaticallyallowit—seespawningaprocess—thenyouneedtostart
PDFLaTeXwith:
pdflatex -shell-escape <file>
forcomplete‘automation’.
Analternativesolutionistousepurifyeps,aPerlscriptwhichusesthegoodoffices
ofpstoeditandofMetaposttoconvertyourEncapsulatedPostScriptto“Somethingthat
looksliketheencapsulatedPostScriptthatcomesoutofMetapost”,andcantherefore
beincludeddirectly.Sadly,purifyepsdoesn’tworkforall
.eps
files.
GoodcoverageoftheproblemistobefoundinHerbertVoß’sPDFsupportpage,
whichistargetedattheuseofpstricksinPDFLaTeX,andalsocoversthepstricks-
specificpackagepdftricks.Arecentalternative(notcoveredinHerbertVoß’spage)is
pdftricks2,whichofferssimilarfacilitiestopdftricks,butwithsomeusefulvariations.
auto-pst-pdf.sty
:
macros/latex/contrib/auto-pst-pdf
epstopdf
: Browse
support/epstopdf
epstopdf.sty
DistributedwithHeikoOberdiek’spackages
macros/latex/
contrib/oberdiek
pdftricks.sty
:
graphics/pdftricks
pdftricks2.sty
:
graphics/pdftricks2
102
VB.NET PDF: How to Create Watermark on PDF Document within
PDF Watermark Creator, users need no external application plugin, like Adobe Acrobat. Easy to combine PDF Watermark Add-on within your VB.NET imaging project;
acrobat combine pdf files; .net merge pdf files
VB.NET PowerPoint: VB Code to Draw and Create Annotation on PPT
limitations (other documents are compatible, including PDF, TIFF, MS no more plug-ins needed like Acrobat or Adobe VB.NET users to burn and combine the added
merge pdf files; reader combine pdf
pst-pdf.sty
:
macros/latex/contrib/pst-pdf
pstoedit
:
support/pstoedit
purifyeps
:
support/purifyeps
155 Importedgraphicsindvipdfm
Dvipdfm(anddvipdfmx)translatesdirectfromDVItoPDF(allotheravailableroutes
producePostScriptoutputusingdvipsandthenconvertthattoPDFwithghostscriptor
Acrobat’sDistiller).
Dvipdfm/Dvipdfmxareparticularlyflexibleapplications.Theypermittheinclusion
ofbitmapandPDFgraphics(asdoesPDFTeX),butarealsocapableofemploying
ghostscript“onthefly”topermittheinclusionofencapsulatedPostScript(
.eps
)files
bytranslatingthemtoPDF.Inthisway,theycombinethegoodqualitiesofdvipsandof
PDFTeXasameansofprocessingillustrateddocuments.
Unfortunately,“ordinary”LaTeXcan’tdeducetheboundingboxofabinarybitmap
file(suchasJPEGorPNG),soyouhavetospecifytheboundingbox.Thismaybedone
explicitly,inthedocument:
\usepackage[dvipdfm]{graphicx}
...
\includegraphics[bb=0 0 0 540 405]{photo.jpg}
It’susuallynotobviouswhatvaluestogivethe“
bb
”key,buttheprogramebbwill
generateafilecontainingtheinformation;theabovenumberscamefromanebboutput
file
photo.bb
:
%%Title: /home/gsm10/photo.jpg
%%Creator: ebb b Version 0.5.2
%%BoundingBox: 0 0 0 0 540 405
%%CreationDate: Mon Mar
8 15:17:47 2004
Ifsuchafileisavailable,youmayabbreviatetheinclusioncode,above,toread:
\usepackage[dvipdfm]{graphicx}
...
\includegraphics{photo}
whichmakestheoperationfeelassimpleasdoesincluding
.eps
imagesinaLaTeX
fileforprocessingwithdvips;thegraphicxpackageknowstolookfora
.bb
fileifno
boundingboxisprovidedinthe
\includegraphics
command.
Theoneplacewhereusageisn’tquitesosimpleistheneedtoquotedvipdfm
explicitly,asanoptionwhenloadingthegraphicxpackage:ifyouareusingdvips,you
don’tordinarilyneedtospecifythefact,sincethedefaultgraphicsconfigurationfile(of
mostdistributions)“guesses”the
dvips
optionifyou’reusingTeX.
dvipdfm
:
dviware/dvipdfm
dvipdfmx
:
dviware/dvipdfmx
ebb
: Distributedaspartof
dviware/dvipdfm
156 “Modern”graphicsfilenames
TeXwasdesignedinaworldwherefilenameswereverysimpleindeed,typicallystrictly
limitedbothincharactersetandlength. Inmodernsystems,suchrestrictionshave
largelydisappeared,whichleavesTeXratheratoddswithitsenvironment.Particular
problemsarisewithspacesinfilenames,butthingslikemultipleperiodcharacterscan
seriouslyconfusethegraphicspackage.
ThespecificationofTeXleavessomeleewayfordistributionstoadoptfileaccess
appropriatetotheiroperatingsystem,butthishasn’tgotusveryfar. Manymodern
distributionsallowyoutospecifyafilenameas
"file name.tex"
(forexample),
whichhelpssomewhat,butwhilethisallowsustosay
\input "foo bar.tex"
103
theanalogoususage
\includegraphics{"gappy graphics.eps"}
using“ordinary”LaTeXcausesconfusioninxdvianddvips,eventhoughitworksatcom-
pilationtime.Sadly,evenwithinsuchquotes,multipledotsgive
\includegraphics
difficulties.Notethat
\includegraphics{"gappy graphics.pdf"}
worksinasimilarversionofPDFTeX.
Ifyou’reusingthegraphicspackage,thegrffilepackagewillhelp.Thepackage
offersseveraloptions,thesimplestofwhichare
multidot
(allowingmorethanonedot
inafilename)and
space
(allowingspaceinafilename).The
space
optionrequires
thatyou’rerunningonasufficientlyrecentversionofPDFTeX,inPDFmode—and
eventhenitwon’tworkforMetapostfiles,whicharereadasTeXinput,andtherefore
usethestandardinputmechanism).
grffile.sty
: Distributedaspartof
macros/latex/contrib/oberdiek
157 Importinggraphicsfrom“somewhereelse”
Bydefault,graphicscommandslike
\includegraphics
look“whereverTeXfilesare
found”forthegraphicfilethey’rebeingaskedtouse.Thiscanreduceyourflexibilityif
youchoosetoholdyourgraphicsfilesinacommondirectory,awayfromyour(La)TeX
sources.
ThesimplestsolutionistopatchTeX’spath,bychangingthedefaultpath. On
mostsystems,thedefaultpathistakenfromtheenvironmentvariable
TEXINPUTS
,ifit’s
present;youcanadaptthattotakeinthepathitalreadyhas,bysettingthevariableto
TEXINPUTS=.:<graphics path(s)>:
onaUnixsystem;onaWindowssystemtheseparatorwillbe“
;
”ratherthan“
:
”.The
.
”istheretoensurethatthecurrentdirectoryissearchedfirst;thetrailing“
:
”says
“patchinthevalueof
TEXINPUTS
fromyourconfigurationfile,here”.
Thismethodhasthemeritofefficiency((La)TeXdoesallofthesearches,whichis
quick),butit’salwaysclumsyandmayproveinconvenienttouseinWindowssetups(at
least).
Thealternativeistousethegraphicspackagecommand
\graphicspath
;this
commandisofcoursealsoavailabletousersofthegraphicxandtheepsfigpackages.
Thesyntaxof
\graphicspath
’soneargumentisslightlyodd:it’sasequenceofpaths
(typicallyrelativepaths),eachofwhichisenclosedinbraces.Aslightlyoddexample
(slightlymodifiedfromonegiveninthegraphicsbundledocumentation)is:
\graphicspath{{eps/}{png/}}
whichwillsearchforgraphicsfilesinsubdirectories
eps
and
png
ofthedirectoryin
whichLaTeXisrunning.(Notethatthetrailing“
/
isrequired.)
(Notethatsome(La)TeXsystemswillonlyallowyoutousefilesinthecurrentdi-
rectoryanditssub-directories,forsecurityreasons.However,
\graphicspath
imposes
nosuchrestriction:asfarasitisconcerned,youcanaccessfilesanywhere.)
Beawarethat
\graphicspath
doesnotaffecttheoperationsofgraphicsmacros
otherthanthosefromthegraphicsbundle—inparticular,thoseoftheoutdatedepsf
andpsfigpackagesareimmune.
Theslightdisadvantageofthe
\graphicspath
methodisinefficiency.Thepackage
willcall(La)TeXonceforeachentryinthelisttolookforafile,whichofcourseslows
things. Further,(La)TeXremembersthenameofanyfileit’saskedtolookup,thus
effectivelylosingmemory,sothatinthelimitadocumentthatusesahugenumberof
graphicalinputscouldbeembarrassedbylackofmemory.(Such“memorystarvation”
isprettyunlikelywithanyordinarydocumentinareasonablymodern(La)TeXsystem,
butitshouldbeborneinmind.)
Ifyourdocumentissplitintoavarietyofdirectories,andeachdirectoryhasits
associatedgraphics,theimportpackagemaywellbethethingforyou;seethediscussion
of“bitsofdocumentinotherdirectories”(bitsofdocumentinotherdirectories).
104
graphics
bundle:
macros/latex/required/graphics
import.sty
:
macros/latex/contrib/import
158 Portableimportedgraphics
Aregularneedisadocumenttobedistributedinmorethanoneformat:commonly
bothPostScriptandPDF.Thefollowingadviceisbasedonapostbyonewithmuch
experienceofdealingwiththeproblemofdealingwithEPSgraphicsinthiscase.
• Don’tspecifyadriverwhenloadingloadingwhicheverversionofthegraphics
packageyouuse.Theschemereliesonthedistribution’sabilitytodecidewhich
driverisgoingtobeused:thechoiceisbetweendvipsandPDFTeX,inthiscase.
Besuretoexcludeoptions
dvips
,
pdftex
and
dvipdfm
(dvipdfmisnotusedin
thisscheme,buttheaspirantPDF-makermaybeusingitforhisoutput,before
switchingtothescheme).
• Use
\includegraphics[...]{filename}
withoutspecifyingtheextension(i.e.,
neither
.eps
nor
.pdf
).
• Forevery
.eps
fileyouwillbeincluding,producea
.pdf
version,asdescribed
inGraphicsinPDFLaTeX.Havingdonethis,youwillhavetwocopiesofeach
graphic(a
.eps
anda
.pdf
file)inyourdirectory.
• UsePDFLaTeX(ratherthanLaTeX–dvips–distillationorLaTeX–dvipdfm)topro-
duceyourPDFoutput.
Dvipdfm’scharmsarelessthanattractivehere:thedocumentitselfneedstobealtered
fromitsdefault(dvips)state,beforedvipdfmwillprocessit.
159 Repeatedgraphicsinadocument
Alogoor“watermark”image,oranyotherimagethatisrepeatedinyourdocument,
hasthepotentialtomaketheprocessedversionofthedocumentunmanageablylarge.
Theproblemis,thatthedefaultmechanismsofgraphicsusageaddtheimageatevery
pointit’stobeused,andwhenprocessed,theimageappearsintheoutputfileateach
suchpoint.
HugePostScriptfilesareembarrassing;explainingwhysuchafileishuge,ismore
embarrassingstill.
The
epslatex
graphicstutorialdescribesatechniqueforavoidingtheproblem:
basically,oneconvertstheimagethat’stoberepeatedintoaPostScriptsubroutine,and
loadthatasadvipsprologuefile.Inplaceoftheimage,youloadafile(withthesame
boundingboxastheimage)containingnomorethananinvocationofthesubroutine
definedintheprologue.
The
epslatex
techniqueistricky,butdoesthejob.Trickierstillistheneatscheme
ofconvertingthefiguretoaone-characterAdobeType3outlinefont. Whilethis
techniqueisforthe“realexperts”only(theauthorofthisanswerhasnevereventried
it),ithaspotentialforthesamesortofspacesavingasthe
epslatex
technique,with
greaterflexibilityinactualuse.
MorepracticalisHendriAdriaens’graphicx-psmin; youloadthisinplaceof
graphicx,soratherthan:
\usepackage[<options>]{graphicx}
youwillwrite:
\usepackage[<options>]{graphicx-psmin}
andatthestartofyourdocument,youwrite:
\loadgraphics[<bb>]{<list of f graphics>}
andeachofthegraphicsinthelistisconvertedtoan“object”forusewithintheresulting
PostScriptoutput.(Thisis,inessence,anautomatedversionofthe
epslatex
technique
describedabove.)
Havingloadedthepackageasabove,wheneveryouuse
\includegraphics
,the
commandchecksifthefileyou’veaskedforisoneofthegraphicsin
\loadgraphics
105
list.Ifso,theoperationisconvertedintoacalltothe“object”ratherthananewcopyof
thefile;theresultingPostScriptcanofcoursebemuchsmaller.
Notethatthepackagerequiresarecentdvips,version5.95b(thisversionisn’t—
yet—widelydistributed).
IfyourPostScriptisdestinedforconversiontoPDF,eitherbyaghostscript-based
mechanismsuchasps2pdf orby(forexample)AcrobatDistiller,theissueisn’tso
pressing,sincethedistillationmechanismwillamalgamategraphicsobjectswhetheror
notthePostScripthasthemamalgamated.PDFTeXdoesthesamejobwithgraphics,
automaticallyconvertingmultipleusesintoreferencestographicsobjects.
graphicx-psmin.sty
:
macros/latex/contrib/graphicx-psmin
160 Limitthewidthofimportedgraphics
Supposeyouhavegraphicswhichmayormaynotbeabletofitwithinthewidthofthe
page;iftheywillfit,youwanttosetthemattheirnaturalsize,butotherwiseyouwant
toscalethewholepicturesothatitfitswithinthepagewidth.
Youdothisbydelvingintotheinnardsofthegraphicspackage(whichofcourse
needsalittleLaTeXinternalsprogramming):
\makeatletter
\def\maxwidth{%
\ifdim\Gin@nat@width>\linewidth
\linewidth
\else
\Gin@nat@width
\fi
}
\makeatother
Thisdefinesa“variable”widthwhichhasthepropertiesyouwant.Replace
\linewidth
ifyouhaveadifferentconstraintonthewidthofthegraphic.
Usethecommandasfollows:
\includegraphics[width=\maxwidth]{figure}
161 Top-aligningimportedgraphics
WhenTeXsetsalineofanything,itensuresthatthebase-lineofeachobjectinthe
lineisatthesamelevelasthebase-lineofthefinalobject. (Apart,ofcourse,from
\raisebox
commands...)
Mostimportedgraphicshavetheirbase-linesetatthebottomofthepicture.When
usingpackagessuchassubfig,oneoftenwantstoalignfiguresbytheirtops. The
followingoddlittlebitofcodedoesthis:
\vtop{%
\vskip0pt
\hbox{%
\includegraphics{figure}%
}%
}
The
\vtop
primitivesetsthebase-lineoftheresultingobjecttothatofthefirst“line”in
it;the
\vskip
createstheillusionofanemptyline,so
\vtop
makestheverytopofthe
boxintothebase-line.
Incaseswherethegraphicsaretobealignedwithtext,thereisacaseformaking
thebase-lineoneex-heightbelowthetopofthebox,asin:
\vtop{%
\vskip-1ex
\hbox{%
\includegraphics{figure}%
}%
}
106
AmoreLaTeX-ywayofdoingthejob(somewhatinefficiently)usesthecalcpackage:
\usepackage{calc}
...
\raisebox{1ex-\height}{\includegraphics{figure}}
(thishasthesameeffectasthetext-alignversion,above).
Thefactis,youmaychoosewherethebase-lineendsup.Thisanswermerelyshows
yousensiblechoicesyoumightmake.
162 DisplayingMetapostoutputinghostscript
Metapostordinarilyexpectsitsoutputtobeincludedinsomecontextwherethe‘stan-
dard’Metafontfonts(thatyou’vespecified)arealreadydefined—forexample,asa
figureinTeXdocument.Ifyou’redebuggingyourMetapostcode,youmaywantto
viewitinaghostscript-based(orsomeotherPostScript)previewer,butnotethatviewers
(evenghostscript)don’tordinarilyhavethefontsloaded,andyou’llexperienceanerror
suchas
Error: /undefined d in n cmmi10
ThereisprovisioninMetapostforavoidingthisproblem:issuethecommand
prologues
:= 2;
atthestartofthe
.mp
file.
Unfortunately,thePostScriptthatMetapostinsertsinitsoutput,followingthis
command,isincompatiblewithordinaryuseofthePostScriptininclusionsinto(La)TeX
documents,soit’sbesttomakethe
prologues
commandoptional.Furthermore,Meta-
posttakesaverysimple-mindedapproachtofontencoding:sinceTeXfontencodings
areanythingbutsimple,encodingoftextindiagramsareanothersourceofproblems.If
you’resufferingsuchproblems(thesymptomisthatcharactersdisappear,orarewrongly
presented)thesolutionistoviewthe‘original’Metapostoutputafterprocessingthrough
LaTeXanddvips.
Conditionalcompilationmaybedoneeitherbyinputting
MyFigure.mp
indirectly
fromasimplewrapper
MyFigureDisplay.mp
:
prologues := = 2;
input MyFigure
orbyissuingashellcommandsuchas
mp ’\prologues:=2; input MyFigure’
(whichwillworkwithoutthequotemarksifyou’renotusingaUnixshell).
AsuitableLaTeXroutewouldinvolveprocessing
MyFigure.tex
,whichcontains:
\documentclass{article}
\usepackage{graphicx}
\begin{document}
\thispagestyle{empty}
\includegraphics{MyFigure.1}
\end{document}
ProcessingtheresultingDVIfilewiththedvipscommand
dvips -E E -o o MyFigure.eps MyFigure
wouldthengiveasatisfactoryEncapsulatedPostScriptfile. Thisproceduremaybe
automatedusingthePerlscriptmps2eps,thussavingacertainamountoftedium.
ThePlainTeXusermayuseanadaptation,byDanLuecking,ofajiffyofKnuth’s.
Dan’sversionmpsproof.texwillworkunderTeXtoproduceaDVIfileforusewith
dvips,orunderPDFTeXtoproduceaPDFfile,direct.Theoutputissetuptolooklikea
proofsheet.
Ascriptapplication,mptopdf,isavailableinrecent(La)TeXdistributions:itseems
fairlyreliablytoproducePDFfromMetapost,somayreasonablybeconsideredan
answertothequestion...
107
mps2eps
:
support/mps2eps
mpsproof.tex
DistributedaspartoftheMetapostdistribution
graphics/
metapost
mptopdf
: Partof
graphics/metapost/contrib/tools/mptopdf
163 DrawingwithTeX
Therearemanypackagestodopicturesin(La)TeXitself(ratherthanimportinggraphics
createdexternally),rangingfromsimpleuseofLaTeX
picture
environment,through
enhancementslikeeepic,tosophisticated(butslow)drawingwithPiCTeX.Depending
onyourtypeofdrawing,andsetup,hereareafewsystemsyoumayconsider:
• The
picture
environmentprovidesratherprimitivedrawingcapabilities(anything
requiringmorethanlinearcalculationsisexcluded,unlessafontcancometoyour
help).Theenvironment’stediousinsistenceonitsown
\unitlength
,asthebasic
measurementinadiagram,maybeavoidedbyuseofthepicturepackage,which
detectswhetheralengthisquotedasanumberorasalength,andactsaccordingly.
• epicwasdesignedtomakeuseoftheLaTeX
picture
environmentsomewhatless
agonising;eepicextendsit,andiscapableofusingtpic
\special
commandsto
improveprintingperformance.(Ifthe
\special
saren’tavailable,theeepicemu
willdothebusiness,farlessefficiently.
• pict2e; thiswasadvertisedintheLaTeXmanual,butdidn’tappearfornearly
tenyearsafterpublicationofthebook! Itremovesallthepettyrestrictionsthat
surroundtheuseofthe
picture
environment.Itthereforesuffersonlyfromthe
rathereccentricdrawinglanguageoftheenvironment,andisafarmoreusefultool
thantheoriginalenvironmenthaseverbeen.(Notethatpict2esupersedesDavid
Carlisle’sstop-gappspicture.)
• PiCTeXisavenerable,andverypowerful,system,thatdrawsbyplacingdotson
thepagetogivetheeffectofalineorcurve.Whilethishasthepotentialofgreat
power,itis(ofcourse)muchslowerthananyoftheotherestablishedpackages.
What’smore,thereareproblemswithitsdocumentation.
• PSTricksgivesyouaccesstothe(considerable)powerofPostScriptviaasetof
TeXmacros,whichtalktoPostScriptusing
\special
commands.SincePostScript
isitselfaprettypowerfulprogramminglanguage,manyastoundingthingscanin
principlebeachievedusingPSTricks(awiderangeofcontributedpackages,ranging
fromworldmappingtolensdesigndiagrams,isavailable).Pstricks
\special
s
arebydefaultspecifictodvips,butthereisaPstricks‘driver’thatallowPstricks
tooperateunderXeTeX.PDFTeXusersmayusepst-pdf,which(likeepstopdf
seePDFLaTeXgraphics)generatesPDFfilesusinganauxiliaryprogram,from
PSTrickscommands(pst-pdf alsorequiresarecentinstallationofthepreview
package).
ThereisaPSTricksmailinglist(
pstricks@tug.org
)whichyoumayjoin,oryou
mayjustbrowsethelistarchives.
• pgf:whilepstricksisverypowerfulandconvenientfrom‘traditional’TeX,usingit
withPDFLaTeXisprettytiresome:ifyousimplywantthegraphicalcapabilities,
pgf,togetherwithits“user-oriented”interfacetikz,maybeagoodbetforyou.
WhilePDFhas(inessence)thesamegraphicalcapabilitiesasPostScript,itisn’t
programmable; pgf providesLaTeXcommandsthatwillutilisethegraphical
capabilitiesofbothPostScriptandPDFequally.Pgfhasextensivemathematical
support,whichallowsittorivalPSTricks’useofthecomputationenginewithin
PostScript.Thepgfmanualisenormous,butasimpleintroductionwhichallows
theusertogetafeelforthecapabilitiesofthesystem,isavailableat
http://
cremeronline.com/LaTeX/minimaltikz.pdf
• Metapost;youlikedMetafont,butnevergottogripswithfontfiles?TryMetapost
allthepowerofMetafont,butitgeneratesPostScriptfigures;Metapostisnowadays
partofmostserious(La)TeXdistributions.Knuthusesitforallhiswork...
Notethatyoucan“embed”Metapostsourceinyourdocument(i.e.,keepitin-line
withyourLaTeXcode).
108
• YoulikedMetafont(orMetapost),butfindthelanguagedifficult?Mfpicmakesup
MetafontorMetapostcodeforyouusingfamiliar-looking(La)TeXmacros.Not
quitethefullpowerofMetafontorMetapost,butafriendlierinterface,andwith
MetapostoutputtheresultscanbeusedequallywellineitherLaTeXorPDFLaTeX.
• YoulikedPiCTeXbutdon’thaveenoughmemoryortime?LookatthelateEitan
Gurari’sdratex:itisjustaspowerful,butisanentirelynewimplementationwhich
isnotashardonmemory,ismuchmorereadableandis(admittedlysparsely)doc-
umented at
http://www.cse.ohio-state.edu/~gurari/tpf/html/README.
html
,aswellasintheauthor’sbook“TeXandLATeX:DrawingandLiterate
Programming”,whichremainsavailablefromon-linebooksellers.
Inaddition,thereareseveralmeansofgeneratingcodeforyourgraphicsapplication
(asymptote,gnuplotandMetapost,atleast)in-lineinyourdocument,andthenhavethem
processedinacommandspawnedfromyour(La)TeXrun.Fordetails,seequestion.
dratex.sty
:
graphics/dratex
epic.sty
:
macros/latex/contrib/epic
eepic.sty
:
macros/latex/contrib/eepic
eepicemu.sty
:
macros/latex/contrib/eepic
mfpic
:
graphics/mfpic
preview.sty
:
macros/latex/contrib/preview
pspicture.sty
:
macros/latex/contrib/pspicture
pst-pdf.sty
:
macros/latex/contrib/pst-pdf
pgf.sty
:
graphics/pgf/base
pict2e.sty
:
macros/latex/contrib/pict2e
pictex.sty
:
graphics/pictex
picture.sty
: Distributedaspartof
macros/latex/contrib/oberdiek
pstricks
:
graphics/pstricks
tikz.sty
: Distributedaspartof
graphics/pgf/base
164 In-linesourceforgraphicsapplications
Someofthefree-standinggraphicsapplicationsmayalsobeused(effectively)in-linein
LaTeXdocuments;examplesare
asymptote Thepackageasymptote(providedintheasymptotedistribution)definesan
environment
asy
whicharrangesthatitscontentsareavailableforprocessing,and
willthereforebetypeset(after“enough”runs,inthe‘usual’LaTeXway).
Basically,youwrite
\begin{asy}
h
asymptote code
i
\end{asy}
andthenexecute
latex document
asy document-
*
.asy
latex document
egplot AllowsyoutoincorporateGNUplotinstructionsinyourdocument,forprocess-
ingoutsideofLaTeX.Thepackageprovidescommandsthatenabletheusertodo
calculationinGNUplot,feedingtheresultsintothediagramtobedrawn.
gmp AllowsyoutoincludethesourceofMetaPostdiagrams,withparametersofthe
diagrampassedfromtheenvironmentcall.
109
emp Anearlierpackageprovidingfacilitiessimilartothoseofgmp(gmp’sauthorhopes
thathispackagewillsupportthefacilitiesemp,whichhebelievesisinneedof
update.)
mpgraphics Again,allowsyoutoprogramparametersofMetapostdiagramsfromyour
LaTeXdocument,includingthepreambledetailsoftheLaTeXcodeinanyrecursive
callfromMetapost.
Inallcases(otherthanasymptote),thesepackagesrequirethatyoucanrunexternal
programsfromwithinyourdocument.
asymptote.sty
:
graphics/asymptote
egplot.sty
:
macros/latex/contrib/egplot
emp.sty
:
macros/latex/contrib/emp
gmp.sty
:
macros/latex/contrib/gmp
mpgraphics.sty
:
macros/latex/contrib/mpgraphics
165 DrawingFeynmandiagramsinLaTeX
MichaelLevine’sfeynmanbundle fordrawingthediagramsinLaTeX2.09isstill
available.
ThorstenOhl’sfeynmfisdesignedforusewithcurrentLaTeX,andworksincom-
binationwithMetafont(or,initsfeynmpincarnation,withMetapost). Thefeynmf
orfeynmppackagereadsadescriptionofthediagramwritteninTeX,andwritesout
code.Metafont(orMetapost)canthenproduceafont(orPostScriptfile)foruseina
subsequentLaTeXrun.Fornewusers,whohaveaccesstoMetapost,thePostScript
versionisprobablythebetterroute,fordocumentportabilityandotherreasons.
JosVermaseren’saxodrawismentionedasanalternativeinthedocumentationof
feynmf,butitiswrittenentirelyintermsofdvips
\special
commands,andisthus
ratherimperfectlyportable.
AnalternativeapproachisimplementedbyNormanGray’sfeynpackage.Rather
thancreatingcompletediagramsaspostscriptimages,feynprovidesafont(inavariety
ofsizes)containingfragments,whichyoucancomposetoproducecompletediagrams.
Itoffersfairlysimplediagramswhichlookgoodinequations,ratherthancomplicated
onesmoresuitablefordisplayinfigures.
axodraw
:
graphics/axodraw
feyn
fontbundle:
fonts/feyn
feynmanbundle
:
macros/latex209/contrib/feynman
feynmf/feynmpbundle
:
macros/latex/contrib/feynmf
166 Labellinggraphics
“Technical”graphics(suchasgraphsanddiagrams)areoftenlabelledwithquitecomplex
mathematicalexpressions:therearefewdrawingorgraphingtoolsthatcandosuch
things(thehonourableexceptionbeingMetapost,whichallowsyoutoprogramthe
labels,in(La)TeX,inthemiddleofspecifyingyourgraphic).
Placing‘labels’ongraphicsproducedbyallthoseothertoolsiswhatwediscuss
here.(Notethattheterm“label”shouldbeliberallyinterpreted;manyofthetechniques
weredesignedforusewhenapplyinglabelstofigures,buttheymaybeusedequally
welltodrawfunnyfacesonafigure... oranything.
Thetime-honouredpsfragpackagecanhelp,ifyourimageisincludedasan(en-
capsulated)PostScriptfile.Placeanuniquetextinyourgraphic,usingthenormaltext
featuresofyourtool,andyoucanaskpsfragtoreplacethetextwitharbitrary(La)TeX
material.Psfrag’s“operative”commandis
\psfrag{Orig text}{Repl l text}
,which
instructsthesystemtoreplacetheoriginal(“unique”)textwiththeTeX-typesetreplace-
menttext.Optionalargumentspermitadjustmentofposition,scaleandrotation;full
detailsmaybefoundin
pfgguide
inthedistribution.
110
Documents you may be interested
Documents you may be interested