c# adobe pdf reader : Add page to pdf online control application platform web page html windows web browser SageTutorial7-part1550

SageTutorial,Release7.1
Group( () ) )
sage: G.IdGroup()
# optional l - - database_gap
[ 120, 34 4 ]
sage: G.Order()
120
WecandothesamecomputationinSagewithoutexplicitlyinvokingtheGAPinterfaceasfollows:
sage: PermutationGroup([[(1,2,3),(4,5)],[(3,4)]])
sage: G.center()
Subgroup of f (Permutation Group with generators [(3,4), , (1,2,3)(4,5)]) ) generated by [()]
sage: G.group_id()
# optional - database_gap
[120, 34]
sage: G.order(); n
120
ForsomeGAPfunctionality,youshouldinstalltwooptionalSagepackages.Thiscanbedonewiththecommand:
sage -i gap_packages s database_gap
4.3 Singular
SingularprovidesamassiveandmaturelibraryforGröbnerbases,multivariatepolynomialgcds,basesofRiemann-
Rochspacesofaplanecurve,andfactorizations,amongotherthings.Weillustratemultivariatepolynomialfactoriza-
tionusingtheSageinterfacetoSingular(donottypethe....:):
sage: R1 singular.ring(0’(x,y)’’dp’)
sage: R1
//
characteristic : : 0
//
number of f vars s : : 2
//
block
1 : : ordering g dp
//
: names
x y
//
block
2 : : ordering g C
sage: singular(’9
*
y^8 - - 9
*
x^2
*
y^7 - - 18
*
x^3
*
y^6 - - 18
*
x^5
*
y^6 +’
....:
’9
*
x^6
*
y^4 + + 18
*
x^7
*
y^5 + 36
*
x^8
*
y^4 + 9
*
x^10
*
y^4 - - 18
*
x^11
*
y^2 -’
....:
’9
*
x^12
*
y^3 - - 18
*
x^13
*
y^2 + + 9
*
x^16’)
Nowthatwehavedefined㕓,weprintitandfactor.
sage: f
9
*
x^16-18
*
x^13
*
y^2-9
*
x^12
*
y^3+9
*
x^10
*
y^4-18
*
x^11
*
y^2+36
*
x^8
*
y^4+18
*
x^7
*
y^5-18
*
x^5
*
y^6+9
*
x^6
*
y^4-18
*
x^3
sage: f.parent()
Singular
sage: f.factorize(); F
[1]:
_[1]=9
_[2]=x^6-2
*
x^3
*
y^2-x^2
*
y^3+y^4
_[3]=-x^5+y^2
[2]:
1,1,2
sage: F[1][2]
x^6-2
*
x^3
*
y^2-x^2
*
y^3+y^4
AswiththeGAPexampleinGAP,wecancomputetheabovefactorizationwithoutexplicitlyusingtheSingular
interface(however,behindthescenesSageusestheSingularinterfacefortheactualcomputation). Donottypethe
4.3. Singular
67
Add page to pdf online - insert pages into PDF file in C#.net, ASP.NET, MVC, Ajax, WinForms, WPF
Guide C# Users to Insert (Empty) PDF Page or Pages from a Supported File Format
adding page to pdf in preview; add pages to pdf file
Add page to pdf online - VB.NET PDF Page Insert Library: insert pages into PDF file in vb.net, ASP.NET, MVC, Ajax, WinForms, WPF
Easy to Use VB.NET APIs to Add a New Blank Page to PDF Document
add pdf pages to word document; add page number pdf file
SageTutorial,Release7.1
....::
sage: x, y QQ[’x, y’].gens()
sage: (9
*
y^9
*
x^2
*
y^18
*
x^3
*
y^18
*
x^5
*
y^9
*
x^6
*
y^4
....:
+ 18
*
x^7
*
y^5 + 36
*
x^8
*
y^4 + + 9
*
x^10
*
y^4 - - 18
*
x^11
*
y^2 - 9
*
x^12
*
y^3
....:
- 18
*
x^13
*
y^2 + + 9
*
x^16)
sage: factor(f)
(9)
*
(-x^5 + y^2)^2
*
(x^6 - 2
*
x^3
*
y^2 - x^2
*
y^3 + + y^4)
4.4 Maxima
MaximaisincludedwithSage,aswellasaLispimplementation.Thegnuplotpackage(whichMaximausesbydefault
forplotting)isdistributedasaSageoptionalpackage. Amongotherthings,Maximadoessymbolicmanipulation.
Maximacanintegrateanddifferentiatefunctionssymbolically,solve1storderODEs,mostlinear2ndorderODEs,
andhasimplementedtheLaplacetransformmethodforlinearODEsofanydegree.Maximaalsoknowsaboutawide
rangeofspecialfunctions,hasplottingcapabilitiesviagnuplot,andhasmethodstosolveandmanipulatematrices
(suchasrowreduction,eigenvaluesandeigenvectors),andpolynomialequations.
WeillustratetheSage/Maximainterfacebyconstructingthematrixwhose㕖,㕗entryis㕖/㕗,for㕖,㕗=1,...,4.
sage: maxima.eval(’ij_entry[i,j] := i/j’)
sage: maxima(’genmatrix(ij_entry,4,4)’); A
matrix([1,1/2,1/3,1/4],[2,1,2/3,1/2],[3,3/2,1,3/4],[4,2,4/3,1])
sage: A.determinant()
0
sage: A.echelon()
matrix([1,1/2,1/3,1/4],[0,0,0,0],[0,0,0,0],[0,0,0,0])
sage: A.eigenvalues()
[[0,4],[3,1]]
sage: A.eigenvectors()
[[[0,4],[3,1]],[[[1,0,0,-4],[0,1,0,-2],[0,0,1,-4/3]],[[1,2,3,4]]]]
Here’sanotherexample:
sage: maxima("matrix ([1, 0, , 0], , [1, -1, , 0], , [1, 3, , -2])")
sage: eigA A.eigenvectors()
sage: VectorSpace(QQ,3)
sage: eigA
[[[-2,-1,1],[1,1,1]],[[[0,0,1]],[[0,1,3]],[[1,1/2,5/6]]]]
sage: v1 V(sage_eval(repr(eigA[1][0][0]))); lambda1 eigA[0][0][0]
sage: v2 V(sage_eval(repr(eigA[1][1][0]))); lambda2 eigA[0][0][1]
sage: v3 V(sage_eval(repr(eigA[1][2][0]))); lambda3 eigA[0][0][2]
sage: MatrixSpace(QQ,3,3)
sage: AA M([[1,0,0],[11,0],[1,32]])
sage: b1 v1.base_ring()
sage: AA
*
v1 == b1(lambda1)
*
v1
True
sage: b2 v2.base_ring()
sage: AA
*
v2 == b2(lambda2)
*
v2
True
sage: b3 v3.base_ring()
sage: AA
*
v3 == b3(lambda3)
*
v3
True
68
Chapter4. Interfaces
VB.NET PDF insert image library: insert images into PDF in vb.net
Access to freeware download and online VB.NET to provide users the most individualized PDF page image inserting function, allowing developers to add and insert
add a page to pdf file; add page number pdf
C# PDF File & Page Process Library SDK for C#.net, ASP.NET, MVC
C# File: Split PDF; C# Page: Insert PDF pages; C# Page: Delete PDF pages; C# C# Read: PDF Image Extract; C# Write: Insert text into PDF; C# Write: Add Image to
add page numbers to pdf online; adding page numbers to pdf
SageTutorial,Release7.1
Finally,wegiveanexampleofusingSagetoplotusingopenmath.ManyoftheseweremodifiedfromtheMaxima
referencemanual.
A2Dplotofseveralfunctions(donottypethe....:):
sage: maxima.plot2d(’[cos(7
*
x),cos(23
*
x)^4,sin(13
*
x)^3]’,’[x,0,1]’,
# not tested
....:
’[plot_format,openmath]’)
A“live”3Dplotwhichyoucanmovewithyourmouse(donottypethe....:):
sage: maxima.plot3d ("2^(-u^2 + + v^2)""[u, -3, , 3]""[v, -2, , 2]",
# not t tested
....:
’[plot_format, openmath]’)
sage: maxima.plot3d("atan(-x^2 + + y^3/4)""[x, -4, , 4]""[y, -4, , 4]",
# not t tested
....:
"[grid, 50, , 50]",’[plot_format, , openmath]’)
ThenextplotisthefamousMöbiusstrip(donottypethe....:):
sage: maxima.plot3d("[cos(x)
*
(3 + + y
*
cos(x/2)), sin(x)
*
(3 + y
*
cos(x/2)), y
*
sin(x/2)]",
# not tested
....:
"[x, -4, , 4]", "[y, -4, , 4]", ’[plot_format, , openmath]’)
ThenextplotisthefamousKleinbottle(donottypethe....:):
sage: maxima("expr_1: 5
*
cos(x)
*
(cos(x/2)
*
cos(y) + + sin(x/2)
*
sin(2
*
y)+ 3.0) ) - - 10.0")
5
*
cos(x)
*
(sin(x/2)
*
sin(2
*
y)+cos(x/2)
*
cos(y)+3.0)-10.0
sage: maxima("expr_2: -5
*
sin(x)
*
(cos(x/2)
*
cos(y) + + sin(x/2)
*
sin(2
*
y)+ 3.0)")
-5
*
sin(x)
*
(sin(x/2)
*
sin(2
*
y)+cos(x/2)
*
cos(y)+3.0)
sage: maxima("expr_3: 5
*
(-sin(x/2)
*
cos(y) + + cos(x/2)
*
sin(2
*
y))")
5
*
(cos(x/2)
*
sin(2
*
y)-sin(x/2)
*
cos(y))
sage: maxima.plot3d ("[expr_1, expr_2, , expr_3]""[x, -%pi, %pi]",
# not t tested
....:
"[y, -%pi, %pi]", , "[’grid, 40, 40]", ’[plot_format, , openmath]’)
4.4. Maxima
69
VB.NET PDF Password Library: add, remove, edit PDF file password
On this page, we will illustrate how to protect PDF document via password by using simple VB.NET demo code. Open password protected PDF. Add password to PDF.
add page numbers to pdf; add page to a pdf
C# PDF insert image Library: insert images into PDF in C#.net, ASP
download and online C#.NET class source code. How to insert and add image, picture, digital photo, scanned signature or logo into PDF document page in C#.NET
add page numbers to a pdf document; add page number to pdf print
SageTutorial,Release7.1
70
Chapter4. Interfaces
VB.NET PDF Page Delete Library: remove PDF pages in vb.net, ASP.
Please follow the sections below to learn more. DLLs for Deleting Page from PDF Document in VB.NET Class. Add necessary references:
add and delete pages in pdf; add page to pdf in preview
VB.NET PDF- View PDF Online with VB.NET HTML5 PDF Viewer
C# File: Split PDF; C# Page: Insert PDF pages; C# Page: Delete PDF pages; C# C# Read: PDF Image Extract; C# Write: Insert text into PDF; C# Write: Add Image to
adding page numbers in pdf file; add pages to pdf without acrobat
CHAPTER
FIVE
SAGE,LATEXANDFRIENDS
AUTHOR:RobBeezer(2010-05-23)
SageandtheLaTeXdialectofTeXhaveanintenselysynergisticrelationship. Thissectionaimstointroducethe
varietyofinteractions,beginningwiththemostbasicandproceedingtothemoreunusualandarcane. (Soyoumay
notwanttoreadthisentiresectiononyourfirstpassthroughthistutorial.)
5.1 Overview
ItmaybeeasiesttounderstandthevarioususesofLaTeXwithabriefoverviewofthemechanicsofthethreeprincipal
methodsemployedbySage.
1. Every“object”inSageisrequiredtohaveaLaTeXrepresentation. . Youcanaccess s thisrepresentationby
executing,inthenotebookoratthesagecommandline,latex(foo)wherefooissomeobjectinSage.The
outputisastringthatshouldrenderareasonablyaccuraterepresentationoffoowhenusedinTeX’smath-mode
(forexample,whenenclosedbetweenapairofsingledollarsigns).Someexamplesofthisfollowbelow.
Inthisway,SagecanbeusedeffectivelyforconstructingportionsofaLaTeXdocument:createorcomputean
objectinSage,printlatex()oftheobjectandcut/pasteitintoyourdocument.
2. ThenotebookinterfaceisconfiguredtouseMathJaxtorendermathematicscleanlyinawebbrowser.MathJaxis
anopensourceJavaScriptdisplayengineformathematicsthatworksinallmodernbrowsers.Itisabletorender
alarge,butnottotallycomplete,subsetofTeX.Ithasnosupportforthingslikecomplicatedtables,sectioningor
documentmanagement,asitisorientedtowardsaccuratelyrendering“snippets”ofTeX.Seeminglyautomatic
renderingofmathinthenotebookis providedbyconvertingthelatex()representationofanobject(as
describedabove)intoaformofHTMLpalatabletoMathJax.
SinceMathJaxusesitsownscalablefonts,itissuperiortoothermethodsthatrelyonconvertingequations,or
othersnippetsofTeX,intostaticinlineimages.
3. AttheSagecommand-line,orinthenotebookwhenLaTeXcodeismoreinvolvedthanMathJaxcanhandle,a
system-wideinstallationofLaTeXcanbeemployed.Sageincludesalmosteverythingyouneedtobuildanduse
Sage,butasignificantexceptionisTeXitself.SointhesesituationsyouneedtohaveTeXinstalled,alongwith
someassociatedconversionutilities,toutilizethefullpower.
Herewedemonstratesomebasicusesofthelatex()function.
sage: var(’z’)
z
sage: latex(z^12)
z^{12}
sage: latex(integrate(z^4, z))
\frac{1}{5} \, , z^{5}
sage: latex(’a string’)
\text{\texttt{a{ }string}}
71
C# HTML5 PDF Viewer SDK to view PDF document online in C#.NET
C# File: Split PDF; C# Page: Insert PDF pages; C# Page: Delete PDF pages; C# C# Read: PDF Image Extract; C# Write: Insert text into PDF; C# Write: Add Image to
add and remove pages from pdf file online; add a page to a pdf in acrobat
C# PDF Password Library: add, remove, edit PDF file password in C#
your PDF document in C# project, XDoc.PDF provides some PDF security settings. On this page, we will talk about how to achieve this via Add necessary references
add page pdf; add page numbers pdf
SageTutorial,Release7.1
sage: latex(QQ)
\Bold{Q}
sage: latex(matrix(QQ, 23, [[2,4,6],[-1,-1,-1]]))
\left(\begin{array}{rrr}
2 & & 4 4 & 6 6 \\
-1 & & -1 & & -1
\end{array}\right)
BasicMathJaxfunctionalityislargelyautomaticinthenotebook,butwecanpartiallydemonstratethissupportwith
theMathJaxclass. TheevalfunctionofthisclassconvertsaSageobjecttoitsLaTeXrepresentationandthen
wrapsitinHTMLthatinvokestheCSS“math”class,whichthenemploysMathJax.
sage: from sage.misc.latex import MathJax
sage: mj MathJax()
sage: var(’z’)
z
sage: mj(z^12)
<html><script type="math/tex; mode=display">\newcommand{\Bold}[1]{\mathbf{#1}}z^{12}</script></html>
sage: mj(QQ)
<html><script type="math/tex; mode=display">\newcommand{\Bold}[1]{\mathbf{#1}}\Bold{Q}</script></html>
sage: mj(ZZ[’x’])
<html><script type="math/tex; mode=display">\newcommand{\Bold}[1]{\mathbf{#1}}\Bold{Z}[x]</script></html>
sage: mj(integrate(z^4, z))
<html><script type="math/tex; mode=display">\newcommand{\Bold}[1]{\mathbf{#1}}\frac{1}{5} } \, , z^{5}</script></html>
5.2 BasicUse
Asindicatedintheoverview,thesimplestwaytoexploitSage’ssupportofLaTeXistousethelatex()functionto
createlegitimateLaTeXcodetorepresentmathematicalobjects.Thesestringscanthenbeincorporatedintostandalone
LaTeXdocuments.ThisworksidenticallyinthenotebookandattheSagecommandline.
Attheotherextremeistheview()command. AttheSagecommandlinethecommandview(foo)willcreate
theLaTeXrepresentationoffoo,incorporatethisintoasimpleLaTeXdocument,andthenprocessthatdocument
withyoursystem-wideTeXinstallation.Finally,theappropriateviewerwillbecalledtodisplaytheoutputfromthe
TeXcommand. WhichversionofTeXisused,andthereforethenatureoftheoutputandassociatedviewer,canbe
customized(seeCustomizingLaTeXProcessing).
Inthenotebook,theview(foo)commandcreatestheappropriatecombinationofHTMLandCSSsothatMathJax
willrendertheLaTeXrepresentationproperlyintheworksheet. Totheuser,itsimplycreatesanicelyformatted
versionoftheoutput,distinctfromthedefaultASCIIoutputofSage. NoteverymathematicalobjectinSagehas
aLaTeXrepresentationamenabletothelimitedcapabilitiesofMathJax. Inthesecases,theMathJaxinterpretation
canbebypassed,thesystem-wideTeXcalledinstead,andthesubsequentoutputconvertedtoagraphicimagefor
displayintheworksheet.AffectingandcontrollingthisprocessisdiscussedbelowinthesectionCustomizingLaTeX
Generation.
ThenotebookhastwootherfeaturesforemployingTeX.Thefirstisthe“Typeset”buttonjustabovethefirstcellofa
worksheet,totherightofthefourdrop-downboxes.Whenchecked,anysubsequentevaluationsofcellswillresultin
outputinterpretedbyMathJax,henceofatypesetquality.Notethatthiseffectisnotretroactive–previouslyevaluated
cellsneedtobere-evaluated. Essentially,checkingthe“Typeset”buttonisidenticaltowrappingtheoutputofeach
cellintheview()command.
AsecondfeatureofthenotebookisenteringTeXaspartofannotatingaworksheet.Whenthecursorisplacedbetween
cellsofaworksheetsothatabluebarappears,thenashift-clickwillopenamini-word-processor,TinyMCE.This
allowsfortheentryoftext,usingaWSIWYGeditortocreateHTMLandCSScommandforstyledtext. Soitis
72
Chapter5. Sage,LaTeXandFriends
SageTutorial,Release7.1
possibletoaddformattedtextascommentarywithinaworksheet.However,textbetweenpairsofdollarsigns,orpairs
ofdoubledollarsignsisinterpretedbyMathJaxasinlineordisplaymath(respectively).
5.3 CustomizingLaTeXGeneration
ThereareseveralwaystocustomizetheactualLaTeXcodegeneratedbythelatex()command. Inthenotebook
andattheSagecommand-linethereisapre-definedobjectnamedlatexwhichhasseveralmethods,whichyoucan
listbytypinglatex.,followedbythetabkey(notetheperiod).
Agoodexampleisthelatex.matrix_delimitersmethod.Itcanbeusedtochangethenotationsurrounding
amatrix–largeparentheses,brackets,braces,verticalbars.Nonotionofstyleisenforced,youcanmixandmatchas
youplease. NoticehowthebackslashesneededinLaTeXrequireanextraslashsotheyareescapedproperlywithin
thePythonstring.
sage: matrix(ZZ, 22range(4))
sage: latex(A)
\left(\begin{array}{rr}
0 & & 1 1 \\
2 & & 3
\end{array}\right)
sage: latex.matrix_delimiters(left=’[’, right=’]’)
sage: latex(A)
\left[\begin{array}{rr}
0 & & 1 1 \\
2 & & 3
\end{array}\right]
sage: latex.matrix_delimiters(left=\\{’, right=\\}’)
sage: latex(A)
\left\{\begin{array}{rr}
0 & & 1 1 \\
2 & & 3
\end{array}\right\}
Thelatex.vector_delimitersmethodworkssimilarly.
The way common rings s and fields s (integers, , rational, , reals, etc.) ) are e typeset t can be controlled by the
latex.blackboard_bold method. . Thesesetsarebydefaulttypesetinbold, , butmayoptionallybewritten
inadouble-struckfashionassometimesdoneinwrittenwork. Thisisaccomplishedbyredefiningthe\Bold{}
macrowhichisbuilt-intoSage.
sage: latex(QQ)
\Bold{Q}
sage: from sage.misc.latex import MathJax
sage: mj=MathJax()
sage: mj(QQ)
<html><script type="math/tex; mode=display">\newcommand{\Bold}[1]{\mathbf{#1}}\Bold{Q}</script></html>
sage: latex.blackboard_bold(True)
sage: mj(QQ)
<html><script type="math/tex; mode=display">\newcommand{\Bold}[1]{\mathbb{#1}}\Bold{Q}</script></html>
sage: latex.blackboard_bold(False)
ItispossibletotakeadvantageoftheextensiblenatureofTeXbyaddinginnewmacrosandnewpackages. First,
individualmacroscanbeaddedsothattheyareusedwhenMathJaxinterpretsasnippetofTeXinthenotebook.
sage: latex.extra_macros()
’’
5.3. CustomizingLaTeXGeneration
73
SageTutorial,Release7.1
sage: latex.add_macro("\\newcommand{\\foo}{bar}")
sage: latex.extra_macros()
’\\newcommand{\\foo}{bar}’
sage: var(’x y’)
(x, y)
sage: latex(x+y)
x + + y
sage: from sage.misc.latex import MathJax
sage: mj=MathJax()
sage: mj(x+y)
<html><script type="math/tex; mode=display">\newcommand{\Bold}[1]{\mathbf{#1}}\newcommand{\foo}{bar}x x + + y</script></html>
Additionalmacrosaddedthiswaywillalsobeusedintheeventthatthesystem-wideversionofTeXiscalledon
somethinglargerthanMathJaxcanhandle.Thecommandlatex_extra_preambleisusedtobuildthepreamble
ofacompleteLaTeXdocument,sothefollowingillustrateshowthisisaccomplished.Asusualnotetheneedforthe
double-backslashesinthePythonstrings.
sage: latex.extra_macros(’’)
sage: latex.extra_preamble(’’)
sage: from sage.misc.latex import latex_extra_preamble
sage: print latex_extra_preamble()
\newcommand{\ZZ}{\Bold{Z}}
...
\newcommand{\Bold}[1]{\mathbf{#1}}
sage: latex.add_macro("\\newcommand{\\foo}{bar}")
sage: print latex_extra_preamble()
\newcommand{\ZZ}{\Bold{Z}}
...
\newcommand{\Bold}[1]{\mathbf{#1}}
\newcommand{\foo}{bar}
Again, forlargerormorecomplicatedLaTeXexpressions,itispossibletoaddpackages(oranythingelse)tothe
preambleoftheLaTeXfile.Anythingmaybeincorporatedintothepreamblewiththelatex.add_to_preamble
command, and d the specialized command latex.add_package_to_preamble_if_available will first
checkifacertainpackageisactuallyavailablebeforetryingtoaddittothepreamble.
HereweaddthegeometrypackagetothepreambleanduseittosetthesizeoftheregiononthepagethatTeXwill
use(effectivelysettingthemargins).Asusual,notetheneedforthedouble-backslashesinthePythonstrings.
sage: from sage.misc.latex import latex_extra_preamble
sage: latex.extra_macros(’’)
sage: latex.extra_preamble(’’)
sage: latex.add_to_preamble(\\usepackage{geometry}’)
sage: latex.add_to_preamble(\\geometry{letterpaper,total={8in,10in}}’)
sage: latex.extra_preamble()
’\\usepackage{geometry}\\geometry{letterpaper,total={8in,10in}}’
sage: print latex_extra_preamble()
\usepackage{geometry}\geometry{letterpaper,total={8in,10in}}
\newcommand{\ZZ}{\Bold{Z}}
...
\newcommand{\Bold}[1]{\mathbf{#1}}
Aparticularpackagemaybeaddedalongwithacheckonitsexistence,asfollows.Asanexample,wejustillustrate
anattempttoaddtothepreambleapackagethatpresumablydoesnotexist.
sage: latex.extra_preamble(’’)
sage: latex.extra_preamble()
’’
74
Chapter5. Sage,LaTeXandFriends
SageTutorial,Release7.1
sage: latex.add_to_preamble(\\usepackage{foo-bar-unchecked}’)
sage: latex.extra_preamble()
’\\usepackage{foo-bar-unchecked}’
sage: latex.add_package_to_preamble_if_available(’foo-bar-checked’)
sage: latex.extra_preamble()
’\\usepackage{foo-bar-unchecked}’
5.4 CustomizingLaTeXProcessing
ItisalsopossibletocontrolwhichvariantofTeXisusedforsystem-wideinvocations,thusalsoinfluencingthenature
oftheoutput.Similarly,itisalsopossibletocontrolwhenthenotebookwilluseMathJax(simpleTeXsnippets)orthe
system-wideTeXinstallation(morecomplicatedLaTeXexpressions).
Thelatex.engine()commandcanbeusedtocontrolifthesystem-wideexecutableslatex, pdflatexor
xelatexareemployedformorecomplicatedLaTeXexpressions.Whenview()iscalledfromthesagecommand-
lineandtheengineissettolatex,advifileisproducedandSagewilluseadviviewer(likexdvi)todisplaythe
result. Incontrast,usingview()attheSagecommand-line,whentheengineissettopdflatex,willproducea
PDFastheresultandSagewillcallyoursystem’sutilityfordisplayingPDFfiles(acrobat,okular,evince,etc.).
Inthenotebook,itisnecessarytointerveneinthedecisionastowhetherMathJaxwillinterpretasnippetofTeX,or
iftheLaTeXiscomplicatedenoughthatthesystem-wideinstallationofTeXshoulddotheworkinstead.Thedevice
isalistofstrings,whichifanyoneisdiscoveredinapieceofLaTeXcodesignalthenotebooktobypassMathJax
andinvokelatex(orwhicheverexecutableissetbythelatex.engine()command). Thislistismanagedbythe
latex.add_to_mathjax_avoid_listandlatex.mathjax_avoid_listcommands.
sage: latex.mathjax_avoid_list([])
sage: latex.mathjax_avoid_list()
[]
sage: latex.mathjax_avoid_list([’foo’’bar’])
sage: latex.mathjax_avoid_list()
[’foo’, ’bar’]
sage: latex.add_to_mathjax_avoid_list(’tikzpicture’)
sage: latex.mathjax_avoid_list()
[’foo’, ’bar’, , ’tikzpicture’]
sage: latex.mathjax_avoid_list([])
sage: latex.mathjax_avoid_list()
[]
SupposeaLaTeXexpressionisproducedinthenotebookwithview()orwhilethe“Typeset”buttonischecked,
andthenrecognizedasrequiringtheexternalLaTeXinstallationthroughthe“mathjaxavoidlist.” Thentheselected
executable(asspecifiedbylatex.engine())willprocesstheLaTeX.However, insteadofthenspawningan
externalviewer(whichisthecommand-linebehavior),Sagewillattempttoconverttheresultintoasingle,tightly-
croppedimage,whichistheninsertedintotheworksheetastheoutputofthecell.
Justhowthisconversionproceedsdependsonseveralfactors–mostlywhichexecutableyouhavespecifiedasthe
engineandwhichconversionutilitiesareavailableonyoursystem.Fourusefulconvertersthatwillcoveralleventu-
alitiesaredvips,ps2pdf,dvipngandfromtheImageMagicksuite,convert.ThegoalistoproduceaPNG
fileastheoutputforinclusionbackintotheworksheet. WhenaLaTeXexpressioncanbeconvertedsuccessfullyto
advibythelatexengine,thendvipngshouldaccomplishtheconversion.IftheLaTeXexpressionandchosenengine
createsadviwithspecialsthatdvipngcannothandle,thendvipswillcreateaPostScriptfile. SuchaPostScriptfile,
oraPDFfilecreatedbyanenginesuchaspdflatex,isthenprocessedintoaPNGwiththeconvertutility.The
presenceoftwooftheseconverterscanbetestedwiththehave_dvipng()andhave_convert()routines.
Theseconversionsaredoneautomaticallyifyouhavethenecessaryconvertersinstalled;ifnot,thenanerrormessage
isprintedtellingyouwhat’smissingandwheretodownloadit.
5.4. CustomizingLaTeXProcessing
75
SageTutorial,Release7.1
ForaconcreteexampleofhowcomplicatedLaTeXexpressionscanbeprocessed,seetheexampleinthenextsec-
tion(AnExample: CombinatorialGraphswithtkz-graph)forusingtheLaTeXtkz-graphpackagetoproduce
high-qualityrenderingsofcombinatorialgraphs.Forotherexamples,therearesomepre-packagedtestcases.Touse
these,itisnecessarytoimportthesage.misc.latex.latex_examplesobject,whichisaninstanceofthe
sage.misc.latex.LatexExamplesclass,asillustratedbelow. Thisclasscurrentlyhasexamplesofcommu-
tativediagrams,combinatorialgraphs,knottheoryandpstricks,whichrespectivelyexercisethefollowingpackages:
xy,tkz-graph,xypic,pstricks. Aftertheimport,usetab-completiononlatex_examplestoseethepre-packaged
examples. Callingeachexamplewillgiveyoubacksomeexplanationaboutwhatisrequiredtomaketheexample
renderproperly. Toactuallyseetheexamples,itisnecessarytouseview()(oncethepreamble,engine,etcareall
setproperly).
sage: from sage.misc.latex import latex_examples
sage: latex_examples.diagram()
LaTeX example for testing g display y of a a commutative diagram m produced
by xypic.
To use, , try to o view w this object t -- - it t won’t work.
Now try
’latex.add_to_preamble("\\usepackage[matrix,arrow,curve,cmtip]{xy}")’,
and try y viewing g again -- - it should work in the command d line e but not
from the e notebook.
In the e notebook, , run
’latex.add_to_mathjax_avoid_list("xymatrix")’ and d try y again -- you
should get a picture e (a a part of f the e diagram m arising g from a filtered
chain complex).
5.5 AnExample:CombinatorialGraphswithtkz-graph
High-qualityillustrationsofcombinatorialgraphs(henceforthjust“graphs”)arepossiblewiththetkz-graphpack-
age. Thispackageisbuiltontopofthetikzfront-endtothepgflibrary. Soallofthesecomponentsneedtobe
partofasystem-wideTeXinstallation,anditmaybepossiblethatthesecomponentsmaynotbeattheirmostcurrent
versionsaspackagedinsomeTeXimplementations. Soforbestresults,itcouldbenecessaryoradvisabletoinstall
theseaspartofyourpersonaltexmftree. Creating,maintainingandcustomizingasystem-wideorpersonalTeXin-
stallationisbeyondthescopeofthisdocument,butitshouldbeeasytofindinstructions.Thenecessaryfilesarelisted
inAFullyCapableTeXInstallation.
Thus, tostartweneedtoinsurethattherelevantpackages areincludedbyaddingthem tothepreambleofthe
eventualLaTeXdocument. Theimages s ofgraphs do o notform m properlywhena dvifile isusedas aninterme-
diate format, , soitis s best to o setthe latexenginetothepdflatex executable. . At t this point acommandlike
view(graphs.CompleteGraph(4))shouldsucceedattheSagecommand-lineandproduceaPDFwithan
appropriateimageofthecompletegraph㔾
4
.
Forasimilarexperienceinthenotebook,itisnecessarytodisableMathJaxprocessingoftheLaTeXcodeforthegraph
byusingthe“mathjaxavoidlist.” Graphsareincludedwithatikzpictureenvironment,sothisisagoodchoice
forastringtoincludeintheavoidancelist. Now,view(graphs.CompleteGraph(4))inaworksheetshould
callpdflatextocreateaPDFandthentheconvertutilitywillextractaPNGgraphictoinsertintotheoutputcellof
theworksheet.ThefollowingcommandsillustratethestepstogetgraphsprocessedbyLaTeXinthenotebook.
sage: from sage.graphs.graph_latex import setup_latex_preamble
sage: setup_latex_preamble()
sage: latex.extra_preamble() # random m - - depends on n system’s s TeX installation
’\\usepackage{tikz}\n\\usepackage{tkz-graph}\n\\usepackage{tkz-berge}\n’
sage: latex.engine(’pdflatex’)
sage: latex.add_to_mathjax_avoid_list(’tikzpicture’)
sage: latex.mathjax_avoid_list()
[’tikz’, ’tikzpicture’]
76
Chapter5. Sage,LaTeXandFriends
Documents you may be interested
Documents you may be interested