LaTeX printing support¶
In order to support latex formatting, an object should define a
special method _latex_(self) that returns a string, which will be typeset
in a mathematical mode (the exact mode depends on circumstances).
This module focuses on using LaTeX for printing. For the use of LaTeX for
rendering math in HTML by MathJax, see MathJax defined in
sage.misc.html.
AUTHORS:
William Stein: original implementation
Joel B. Mohler: latex_variable_name() drastic rewrite and many doc-tests
- class sage.misc.latex.Latex(debug=False, slide=False, density=150, engine=None)[source]¶
Bases:
LatexCallEnter, e.g.,
%latex The equation $y^2 = x^3 + x$ defines an elliptic curve. We have $2006 = \sage{factor(2006)}$.
in an input cell in the notebook to get a typeset version. Use
%latex_debugto get debugging output.Use
latex(...)to typeset a Sage object. UseLatexExprto typeset LaTeX code that you create by hand.Use
%slideinstead to typeset slides.Warning
You must have dvipng (or dvips and magick/convert) installed on your operating system, or this command will not work.
EXAMPLES:
sage: latex(x^20 + 1) # needs sage.symbolic x^{20} + 1 sage: latex(FiniteField(25,'a')) # needs sage.rings.finite_rings \Bold{F}_{5^{2}} sage: latex("hello") \text{\texttt{hello}} sage: LatexExpr(r"\frac{x^2 - 1}{x + 1} = x - 1") \frac{x^2 - 1}{x + 1} = x - 1
>>> from sage.all import * >>> latex(x**Integer(20) + Integer(1)) # needs sage.symbolic x^{20} + 1 >>> latex(FiniteField(Integer(25),'a')) # needs sage.rings.finite_rings \Bold{F}_{5^{2}} >>> latex("hello") \text{\texttt{hello}} >>> LatexExpr(r"\frac{x^2 - 1}{x + 1} = x - 1") \frac{x^2 - 1}{x + 1} = x - 1
LaTeX expressions can be added; note that a space is automatically inserted:
sage: LatexExpr(r"y \neq") + latex(x^20 + 1) # needs sage.symbolic y \neq x^{20} + 1
>>> from sage.all import * >>> LatexExpr(r"y \neq") + latex(x**Integer(20) + Integer(1)) # needs sage.symbolic y \neq x^{20} + 1
- add_macro(macro)[source]¶
Append to the string of extra LaTeX macros, for use with %latex and %html.
INPUT:
macro– string
EXAMPLES:
sage: latex.extra_macros() '' sage: latex.add_macro("\\newcommand{\\foo}{bar}") sage: latex.extra_macros() '\\newcommand{\\foo}{bar}' sage: latex.extra_macros("") # restore to default
>>> from sage.all import * >>> latex.extra_macros() '' >>> latex.add_macro("\\newcommand{\\foo}{bar}") >>> latex.extra_macros() '\\newcommand{\\foo}{bar}' >>> latex.extra_macros("") # restore to default
- add_package_to_preamble_if_available(package_name)[source]¶
Add a
\usepackage{package_name}instruction to the latex preamble if not yet present there, and ifpackage_name.styis available in the LaTeX installation.INPUT:
package_name– string
See also
- add_to_preamble(s)[source]¶
Append to the string
sof extra LaTeX macros, for use with%latex.EXAMPLES:
sage: latex.extra_preamble() '' sage: latex.add_to_preamble("\\DeclareMathOperator{\\Ext}{Ext}")
>>> from sage.all import * >>> latex.extra_preamble() '' >>> latex.add_to_preamble("\\DeclareMathOperator{\\Ext}{Ext}")
At this point, a notebook cell containing
%latex $\Ext_A^*(\GF{2}, \GF{2}) \Rightarrow \pi_*^s*(S^0)$
will be typeset correctly.
sage: latex.add_to_preamble("\\usepackage{xypic}") sage: latex.extra_preamble() '\\DeclareMathOperator{\\Ext}{Ext}\\usepackage{xypic}'
>>> from sage.all import * >>> latex.add_to_preamble("\\usepackage{xypic}") >>> latex.extra_preamble() '\\DeclareMathOperator{\\Ext}{Ext}\\usepackage{xypic}'
Now one can put various xypic diagrams into a
%latexcell, such as%latex \[ \xymatrix{ \circ \ar `r[d]^{a} `[rr]^{b} `/4pt[rr]^{c} `[rrr]^{d} `_dl[drrr]^{e} [drrr]^{f} & \circ & \circ & \circ \\ \circ & \circ & \circ & \circ } \]
Reset the preamble to its default, the empty string:
sage: latex.extra_preamble('') sage: latex.extra_preamble() ''
>>> from sage.all import * >>> latex.extra_preamble('') >>> latex.extra_preamble() ''
- blackboard_bold(t=None)[source]¶
Controls whether Sage uses blackboard bold or ordinary bold face for typesetting
ZZ,RR, etc.INPUT:
t– boolean orNone
OUTPUT:
If
tisNone, return the current setting (TrueorFalse).If
tisTrue, use blackboard bold (\mathbb); otherwise use boldface (\mathbf).EXAMPLES:
sage: latex.blackboard_bold() False sage: latex.blackboard_bold(True) sage: latex.blackboard_bold() True sage: latex.blackboard_bold(False)
>>> from sage.all import * >>> latex.blackboard_bold() False >>> latex.blackboard_bold(True) >>> latex.blackboard_bold() True >>> latex.blackboard_bold(False)
- check_file(file_name, more_info='')[source]¶
INPUT:
file_name– stringmore_info– string (default:'')
Emit a warning if the local LaTeX installation does not include
file_name. The stringmore_infois appended to the warning message. The warning is only emitted the first time this method is called.EXAMPLES:
sage: latex.check_file("article.cls") # optional - latex sage: latex.check_file("some_inexistent_file.sty") Warning: `some_inexistent_file.sty` is not part of this computer's TeX installation. sage: latex.check_file("some_inexistent_file.sty") sage: latex.check_file("some_inexistent_file.sty", "This file is required for blah. It can be downloaded from: http://blah.org/") Warning: `some_inexistent_file.sty` is not part of this computer's TeX installation. This file is required for blah. It can be downloaded from: http://blah.org/
>>> from sage.all import * >>> latex.check_file("article.cls") # optional - latex >>> latex.check_file("some_inexistent_file.sty") Warning: `some_inexistent_file.sty` is not part of this computer's TeX installation. >>> latex.check_file("some_inexistent_file.sty") >>> latex.check_file("some_inexistent_file.sty", "This file is required for blah. It can be downloaded from: http://blah.org/") Warning: `some_inexistent_file.sty` is not part of this computer's TeX installation. This file is required for blah. It can be downloaded from: http://blah.org/
This test checks that the bug in Issue #9091 is fixed:
sage: latex.check_file("article.cls", "The article class is really critical.") # optional - latex
>>> from sage.all import * >>> latex.check_file("article.cls", "The article class is really critical.") # optional - latex
- engine(e=None)[source]¶
Set Sage to use
eas latex engine when typesetting withview(), in%latexcells, etc.INPUT:
e–'latex','pdflatex','xelatex','lualatex'orNone
If
eisNone, return the current engine.If using the XeLaTeX engine, it will almost always be necessary to set the proper preamble with
extra_preamble()oradd_to_preamble(). For example:latex.extra_preamble(r'''\usepackage{fontspec,xunicode,xltxtra} \setmainfont[Mapping=tex-text]{some font here} \setmonofont[Mapping=tex-text]{another font here}''')
EXAMPLES:
sage: latex.engine() # random 'lualatex' sage: latex.engine("latex") sage: latex.engine() 'latex' sage: latex.engine("pdflatex") sage: latex.engine() 'pdflatex'
>>> from sage.all import * >>> latex.engine() # random 'lualatex' >>> latex.engine("latex") >>> latex.engine() 'latex' >>> latex.engine("pdflatex") >>> latex.engine() 'pdflatex'
- eval(x, globals, strip=False, filename=None, debug=None, density=None, engine=None, locals={})[source]¶
Compile the formatted tex given by
xas a png and writes the output file to the directory given byfilename.INPUT:
globals– a globals dictionaryx– string to evaluatestrip– ignoredfilename– output filenamedebug– whether to print verbose debugging outputdensity– how big output image isengine– latex engine to use. Currently'latex','pdflatex','xelatex'and'lualatex'are supportedlocals– extra local variables used when evaluating Sage code inx
Warning
When using
'latex'(the default), you must havedvipng(ordvipsandmagick/convert) installed on your operating system, or this command will not work. When using'pdflatex','xelatex'or'lualatex', you must havemagick/convertinstalled.OUTPUT:
If it compiled successfully, this returns an empty string
'', otherwise it returnsNone.EXAMPLES:
sage: fn = tmp_filename() sage: latex.eval("$\\ZZ[x]$", locals(), filename=fn) # not tested '' sage: latex.eval(r"\ThisIsAnInvalidCommand", {}) # optional -- latex ImageMagick An error occurred...
>>> from sage.all import * >>> fn = tmp_filename() >>> latex.eval("$\\ZZ[x]$", locals(), filename=fn) # not tested '' >>> latex.eval(r"\ThisIsAnInvalidCommand", {}) # optional -- latex ImageMagick An error occurred...
- extra_macros(macros=None)[source]¶
String containing extra LaTeX macros to use with
%latexand%html.INPUT:
macros– string (default:None)
If
macrosisNone, return the current string. Otherwise, set it tomacros. If you want to append to the string of macros instead of replacing it, uselatex.add_macro.EXAMPLES:
sage: latex.extra_macros("\\newcommand{\\foo}{bar}") sage: latex.extra_macros() '\\newcommand{\\foo}{bar}' sage: latex.extra_macros("") sage: latex.extra_macros() ''
>>> from sage.all import * >>> latex.extra_macros("\\newcommand{\\foo}{bar}") >>> latex.extra_macros() '\\newcommand{\\foo}{bar}' >>> latex.extra_macros("") >>> latex.extra_macros() ''
- extra_preamble(s=None)[source]¶
String containing extra preamble to be used with %latex.
INPUT:
s– string orNone
If
sisNone, return the current preamble. Otherwise, set it tos. If you want to append to the current extra preamble instead of replacing it, uselatex.add_to_preamble.You will almost certainly need to use this when using the XeLaTeX engine; see below or the documentation for
engine()for a suggested preamble.EXAMPLES:
sage: latex.extra_preamble("\\DeclareMathOperator{\\Ext}{Ext}") sage: latex.extra_preamble() '\\DeclareMathOperator{\\Ext}{Ext}' sage: latex.extra_preamble("\\"+r"usepackage{fontspec,xunicode,xltxtra}\setmainfont[Mapping=tex-text]{UnBatang}\setmonofont[Mapping=tex-text]{UnDotum}") sage: latex.extra_preamble() '\\usepackage{fontspec,xunicode,xltxtra}\\setmainfont[Mapping=tex-text]{UnBatang}\\setmonofont[Mapping=tex-text]{UnDotum}' sage: latex.extra_preamble("") sage: latex.extra_preamble() ''
>>> from sage.all import * >>> latex.extra_preamble("\\DeclareMathOperator{\\Ext}{Ext}") >>> latex.extra_preamble() '\\DeclareMathOperator{\\Ext}{Ext}' >>> latex.extra_preamble("\\"+r"usepackage{fontspec,xunicode,xltxtra}\setmainfont[Mapping=tex-text]{UnBatang}\setmonofont[Mapping=tex-text]{UnDotum}") >>> latex.extra_preamble() '\\usepackage{fontspec,xunicode,xltxtra}\\setmainfont[Mapping=tex-text]{UnBatang}\\setmonofont[Mapping=tex-text]{UnDotum}' >>> latex.extra_preamble("") >>> latex.extra_preamble() ''
- has_file(file_name)[source]¶
INPUT:
file_name– string
Tests whether the local LaTeX installation includes
file_name.EXAMPLES:
sage: latex.has_file("article.cls") # optional - latex True sage: latex.has_file("some_inexistent_file.sty") False
>>> from sage.all import * >>> latex.has_file("article.cls") # optional - latex True >>> latex.has_file("some_inexistent_file.sty") False
- matrix_column_alignment(align=None)[source]¶
Changes the column-alignment of the LaTeX representation of matrices.
INPUT:
align– string ('r'for right,'c'for center,'l'for left) orNone
OUTPUT:
If
alignisNone, then returns the current alignment-string. Otherwise, set this alignment.The input
aligncan be any string which the LaTeXarray-environment understands as a parameter for aligning a column.EXAMPLES:
sage: # needs sage.modules sage: a = matrix(1, 1, [42]) sage: latex(a) \left(\begin{array}{r} 42 \end{array}\right) sage: latex.matrix_column_alignment('c') sage: latex(a) \left(\begin{array}{c} 42 \end{array}\right) sage: latex.matrix_column_alignment('l') sage: latex(a) \left(\begin{array}{l} 42 \end{array}\right)
>>> from sage.all import * >>> # needs sage.modules >>> a = matrix(Integer(1), Integer(1), [Integer(42)]) >>> latex(a) \left(\begin{array}{r} 42 \end{array}\right) >>> latex.matrix_column_alignment('c') >>> latex(a) \left(\begin{array}{c} 42 \end{array}\right) >>> latex.matrix_column_alignment('l') >>> latex(a) \left(\begin{array}{l} 42 \end{array}\right)
Restore defaults:
sage: latex.matrix_column_alignment('r')
>>> from sage.all import * >>> latex.matrix_column_alignment('r')
- matrix_delimiters(left=None, right=None)[source]¶
Change the left and right delimiters for the LaTeX representation of matrices
INPUT:
left,right– strings orNone
If both
leftandrightareNone, then return the current delimiters. Otherwise, set the left and/or right delimiters, whichever are specified.Good choices for
leftandrightare any delimiters which LaTeX understands and knows how to resize; some examples are:parentheses:
'(',')'brackets:
'[',']'braces:
'\\{','\\}'vertical lines:
'|'angle brackets:
'\\langle','\\rangle'
Note
Putting aside aesthetics, you may combine these in any way imaginable; for example, you could set
leftto be a right-hand bracket']'andrightto be a right-hand brace'\\}', and it will be typeset correctly.EXAMPLES:
sage: # needs sage.modules sage: a = matrix(1, 1, [17]) sage: latex(a) \left(\begin{array}{r} 17 \end{array}\right) sage: latex.matrix_delimiters('[', ']') sage: latex(a) \left[\begin{array}{r} 17 \end{array}\right] sage: latex.matrix_delimiters(left='\\{') sage: latex(a) \left\{\begin{array}{r} 17 \end{array}\right] sage: latex.matrix_delimiters() ['\\{', ']']
>>> from sage.all import * >>> # needs sage.modules >>> a = matrix(Integer(1), Integer(1), [Integer(17)]) >>> latex(a) \left(\begin{array}{r} 17 \end{array}\right) >>> latex.matrix_delimiters('[', ']') >>> latex(a) \left[\begin{array}{r} 17 \end{array}\right] >>> latex.matrix_delimiters(left='\\{') >>> latex(a) \left\{\begin{array}{r} 17 \end{array}\right] >>> latex.matrix_delimiters() ['\\{', ']']
Restore defaults:
sage: latex.matrix_delimiters('(', ')')
>>> from sage.all import * >>> latex.matrix_delimiters('(', ')')
- vector_delimiters(left=None, right=None)[source]¶
Change the left and right delimiters for the LaTeX representation of vectors
INPUT:
left,right– strings orNone
If both
leftandrightareNone, then return the current delimiters. Otherwise, set the left and/or right delimiters, whichever are specified.Good choices for
leftandrightare any delimiters which LaTeX understands and knows how to resize; some examples are:parentheses:
'(',')'brackets:
'[',']'braces:
'\\{','\\}'vertical lines:
'|'angle brackets:
'\\langle','\\rangle'
Note
Putting aside aesthetics, you may combine these in any way imaginable; for example, you could set
leftto be a right-hand bracket']'andrightto be a right-hand brace'\\}', and it will be typeset correctly.EXAMPLES:
sage: # needs sage.modules sage: a = vector(QQ, [1,2,3]) sage: latex(a) \left(1,\,2,\,3\right) sage: latex.vector_delimiters('[', ']') sage: latex(a) \left[1,\,2,\,3\right] sage: latex.vector_delimiters(right='\\}') sage: latex(a) \left[1,\,2,\,3\right\} sage: latex.vector_delimiters() ['[', '\\}']
>>> from sage.all import * >>> # needs sage.modules >>> a = vector(QQ, [Integer(1),Integer(2),Integer(3)]) >>> latex(a) \left(1,\,2,\,3\right) >>> latex.vector_delimiters('[', ']') >>> latex(a) \left[1,\,2,\,3\right] >>> latex.vector_delimiters(right='\\}') >>> latex(a) \left[1,\,2,\,3\right\} >>> latex.vector_delimiters() ['[', '\\}']
Restore defaults:
sage: latex.vector_delimiters('(', ')')
>>> from sage.all import * >>> latex.vector_delimiters('(', ')')
- class sage.misc.latex.LatexCall[source]¶
Bases:
objectTypeset Sage objects via a
__call__method to this class, typically by calling those objects’_latex_methods. The classLatexinherits from this. This class is used inlatex_macros, while functions fromlatex_macrosare used inLatex, so this is here primarily to avoid circular imports.EXAMPLES:
sage: from sage.misc.latex import LatexCall sage: LatexCall()(ZZ) \Bold{Z} sage: LatexCall().__call__(ZZ) \Bold{Z}
>>> from sage.all import * >>> from sage.misc.latex import LatexCall >>> LatexCall()(ZZ) \Bold{Z} >>> LatexCall().__call__(ZZ) \Bold{Z}
This returns an instance of the class
LatexExpr:sage: type(LatexCall()(ZZ)) <class 'sage.misc.latex.LatexExpr'>
>>> from sage.all import * >>> type(LatexCall()(ZZ)) <class 'sage.misc.latex.LatexExpr'>
- class sage.misc.latex.LatexExamples[source]¶
Bases:
objectA catalogue of Sage objects with complicated
_latex_methods. Use these for testinglatex(),view(), the Typeset button in the notebook, etc.The classes here only have
__init__,_repr_, and_latex_methods.EXAMPLES:
sage: from sage.misc.latex import latex_examples sage: K = latex_examples.knot() sage: K LaTeX example for testing display of a knot produced by xypic... sage: latex(K) \vtop{\vbox{\xygraph{!{0;/r1.5pc/:} [u] !{\vloop<(-.005)\khole||\vcrossneg \vunder- } [] !{\ar @{-}@'{p-(1,0)@+}+(-1,1)} [ul] !{\vcap[3]>\khole} [rrr] !{\ar @{-}@'{p-(0,1)@+}-(1,1)} }}}
>>> from sage.all import * >>> from sage.misc.latex import latex_examples >>> K = latex_examples.knot() >>> K LaTeX example for testing display of a knot produced by xypic... >>> latex(K) \vtop{\vbox{\xygraph{!{0;/r1.5pc/:} [u] !{\vloop<(-.005)\khole||\vcrossneg \vunder- } [] !{\ar @{-}@'{p-(1,0)@+}+(-1,1)} [ul] !{\vcap[3]>\khole} [rrr] !{\ar @{-}@'{p-(0,1)@+}-(1,1)} }}}
- class diagram[source]¶
Bases:
SageObjectLaTeX example for testing display of commutative diagrams. See its string representation for details.
EXAMPLES:
sage: from sage.misc.latex import latex_examples sage: CD = latex_examples.diagram() sage: CD LaTeX example for testing display of a commutative diagram...
>>> from sage.all import * >>> from sage.misc.latex import latex_examples >>> CD = latex_examples.diagram() >>> CD LaTeX example for testing display of a commutative diagram...
- class graph[source]¶
Bases:
SageObjectLaTeX example for testing display of graphs. See its string representation for details.
EXAMPLES:
sage: from sage.misc.latex import latex_examples sage: G = latex_examples.graph() sage: G LaTeX example for testing display of graphs...
>>> from sage.all import * >>> from sage.misc.latex import latex_examples >>> G = latex_examples.graph() >>> G LaTeX example for testing display of graphs...
- class knot[source]¶
Bases:
SageObjectLaTeX example for testing display of knots. See its string representation for details.
EXAMPLES:
sage: from sage.misc.latex import latex_examples sage: K = latex_examples.knot() sage: K LaTeX example for testing display of a knot...
>>> from sage.all import * >>> from sage.misc.latex import latex_examples >>> K = latex_examples.knot() >>> K LaTeX example for testing display of a knot...
- class pstricks[source]¶
Bases:
SageObjectLaTeX example for testing display of pstricks output. See its string representation for details.
EXAMPLES:
sage: from sage.misc.latex import latex_examples sage: PS = latex_examples.pstricks() sage: PS LaTeX example for testing display of pstricks...
>>> from sage.all import * >>> from sage.misc.latex import latex_examples >>> PS = latex_examples.pstricks() >>> PS LaTeX example for testing display of pstricks...
- class sage.misc.latex.LatexExpr[source]¶
Bases:
strA class for LaTeX expressions.
Normally, objects of this class are created by a
latex()call. It is also possible to generateLatexExprdirectly from a string, which must contain valid LaTeX code for typesetting in math mode (without dollar signs). In the Jupyter notebook, usepretty_print()to actually see the typeset LaTeX code; alternatively, from either the command-line or the notebook, use theview()function.INPUT:
str– string with valid math mode LaTeX code (or something which can be converted to such a string)
OUTPUT:
LatexExprwrapping the string representation of the inputEXAMPLES:
sage: latex(x^20 + 1) # needs sage.symbolic x^{20} + 1 sage: LatexExpr(r"\frac{x^2 + 1}{x - 2}") # needs sage.symbolic \frac{x^2 + 1}{x - 2}
>>> from sage.all import * >>> latex(x**Integer(20) + Integer(1)) # needs sage.symbolic x^{20} + 1 >>> LatexExpr(r"\frac{x^2 + 1}{x - 2}") # needs sage.symbolic \frac{x^2 + 1}{x - 2}
LatexExprsimply converts to string without doing anything extra, it does not calllatex():sage: latex(ZZ) \Bold{Z} sage: LatexExpr(ZZ) Integer Ring
>>> from sage.all import * >>> latex(ZZ) \Bold{Z} >>> LatexExpr(ZZ) Integer Ring
The result of
latex()is of typeLatexExpr:sage: L = latex(x^20 + 1) # needs sage.symbolic sage: L # needs sage.symbolic x^{20} + 1 sage: type(L) # needs sage.symbolic <class 'sage.misc.latex.LatexExpr'>
>>> from sage.all import * >>> L = latex(x**Integer(20) + Integer(1)) # needs sage.symbolic >>> L # needs sage.symbolic x^{20} + 1 >>> type(L) # needs sage.symbolic <class 'sage.misc.latex.LatexExpr'>
A
LatexExprcan be converted to a plain string:sage: str(latex(x^20 + 1)) # needs sage.symbolic 'x^{20} + 1'
>>> from sage.all import * >>> str(latex(x**Integer(20) + Integer(1))) # needs sage.symbolic 'x^{20} + 1'
- sage.misc.latex.None_function(x)[source]¶
Return the LaTeX code for
None.INPUT:
x–None
EXAMPLES:
sage: from sage.misc.latex import None_function sage: print(None_function(None)) \mathrm{None}
>>> from sage.all import * >>> from sage.misc.latex import None_function >>> print(None_function(None)) \mathrm{None}
- sage.misc.latex.bool_function(x)[source]¶
Return the LaTeX code for a boolean
x.INPUT:
x– boolean
EXAMPLES:
sage: from sage.misc.latex import bool_function sage: print(bool_function(2==3)) \mathrm{False} sage: print(bool_function(3==(2+1))) \mathrm{True}
>>> from sage.all import * >>> from sage.misc.latex import bool_function >>> print(bool_function(Integer(2)==Integer(3))) \mathrm{False} >>> print(bool_function(Integer(3)==(Integer(2)+Integer(1)))) \mathrm{True}
- sage.misc.latex.builtin_constant_function(x)[source]¶
Return the LaTeX code for a builtin constant
x.INPUT:
x– builtin constant
See also
Python built-in Constants http://docs.python.org/library/constants.html
EXAMPLES:
sage: from sage.misc.latex import builtin_constant_function sage: builtin_constant_function(True) '\\mbox{\\rm True}' sage: builtin_constant_function(None) '\\mbox{\\rm None}' sage: builtin_constant_function(NotImplemented) '\\mbox{\\rm NotImplemented}' sage: builtin_constant_function(Ellipsis) '\\mbox{\\rm Ellipsis}'
>>> from sage.all import * >>> from sage.misc.latex import builtin_constant_function >>> builtin_constant_function(True) '\\mbox{\\rm True}' >>> builtin_constant_function(None) '\\mbox{\\rm None}' >>> builtin_constant_function(NotImplemented) '\\mbox{\\rm NotImplemented}' >>> builtin_constant_function(Ellipsis) '\\mbox{\\rm Ellipsis}'
- sage.misc.latex.coeff_repr(c)[source]¶
LaTeX string representing coefficients in a linear combination.
INPUT:
c– a coefficient (i.e., an element of a ring)
OUTPUT: string
EXAMPLES:
sage: from sage.misc.latex import coeff_repr sage: coeff_repr(QQ(1/2)) '\\frac{1}{2}' sage: coeff_repr(-x^2) # needs sage.symbolic '\\left(-x^{2}\\right)'
>>> from sage.all import * >>> from sage.misc.latex import coeff_repr >>> coeff_repr(QQ(Integer(1)/Integer(2))) '\\frac{1}{2}' >>> coeff_repr(-x**Integer(2)) # needs sage.symbolic '\\left(-x^{2}\\right)'
- sage.misc.latex.default_engine()[source]¶
Return the default latex engine and the official name of the engine. This is determined by availability of the popular engines on the user’s system. It is assumed that at least latex is available.
This function is deprecated as part of the public API. There is instead an internal counterpart
_default_engine(), but no stability promises are made with regards to its interface.EXAMPLES:
sage: from sage.misc.latex import default_engine sage: default_engine() # random ('lualatex', 'LuaLaTeX')
>>> from sage.all import * >>> from sage.misc.latex import default_engine >>> default_engine() # random ('lualatex', 'LuaLaTeX')
- sage.misc.latex.dict_function(x)[source]¶
Return the LaTeX code for a dictionary
x.INPUT:
x– dictionary
EXAMPLES:
sage: # needs sage.symbolic sage: from sage.misc.latex import dict_function sage: x,y,z = var('x,y,z') sage: print(dict_function({x/2: y^2})) \left\{\frac{1}{2} \, x : y^{2}\right\} sage: d = {(1,2,x^2): [sin(z^2), y/2]} sage: latex(d) \left\{\left(1, 2, x^{2}\right) : \left[\sin\left(z^{2}\right), \frac{1}{2} \, y\right]\right\}
>>> from sage.all import * >>> # needs sage.symbolic >>> from sage.misc.latex import dict_function >>> x,y,z = var('x,y,z') >>> print(dict_function({x/Integer(2): y**Integer(2)})) \left\{\frac{1}{2} \, x : y^{2}\right\} >>> d = {(Integer(1),Integer(2),x**Integer(2)): [sin(z**Integer(2)), y/Integer(2)]} >>> latex(d) \left\{\left(1, 2, x^{2}\right) : \left[\sin\left(z^{2}\right), \frac{1}{2} \, y\right]\right\}
- sage.misc.latex.float_function(x)[source]¶
Return the LaTeX code for a python float
x.INPUT:
x– a python float
EXAMPLES:
sage: from sage.misc.latex import float_function sage: float_function(float(3.14)) 3.14 sage: float_function(float(1e-10)) 1 \times 10^{-10} sage: float_function(float(2e10)) 20000000000.0
>>> from sage.all import * >>> from sage.misc.latex import float_function >>> float_function(float(RealNumber('3.14'))) 3.14 >>> float_function(float(RealNumber('1e-10'))) 1 \times 10^{-10} >>> float_function(float(RealNumber('2e10'))) 20000000000.0
- sage.misc.latex.has_latex_attr(x)[source]¶
Return
Trueifxhas a_latex_attribute, except ifxis atype, in which case returnFalse.EXAMPLES:
sage: from sage.misc.latex import has_latex_attr sage: has_latex_attr(identity_matrix(3)) # needs sage.modules True sage: has_latex_attr("abc") # strings have no _latex_ method False
>>> from sage.all import * >>> from sage.misc.latex import has_latex_attr >>> has_latex_attr(identity_matrix(Integer(3))) # needs sage.modules True >>> has_latex_attr("abc") # strings have no _latex_ method False
Types inherit the
_latex_method of the class to which they refer, but calling it is broken:sage: # needs sage.modules sage: T = type(identity_matrix(3)); T <class 'sage.matrix.matrix_integer_dense.Matrix_integer_dense'> sage: hasattr(T, '_latex_') True sage: T._latex_() Traceback (most recent call last): ... TypeError: ..._latex_... needs an argument sage: has_latex_attr(T) False
>>> from sage.all import * >>> # needs sage.modules >>> T = type(identity_matrix(Integer(3))); T <class 'sage.matrix.matrix_integer_dense.Matrix_integer_dense'> >>> hasattr(T, '_latex_') True >>> T._latex_() Traceback (most recent call last): ... TypeError: ..._latex_... needs an argument >>> has_latex_attr(T) False
- sage.misc.latex.latex(x, combine_all=False)[source]¶
Return a
LatexExprbuilt out of the argumentx.INPUT:
x– a Sage objectcombine_all– boolean (default:False); ifcombine_allisTrueand the input is a tuple, then it does not return a tuple and instead returns a string with all the elements separated by a single space
OUTPUT: a
LatexExprbuilt fromxEXAMPLES:
sage: latex(Integer(3)) # indirect doctest 3 sage: latex(1==0) \mathrm{False} sage: print(latex([x, 2])) # needs sage.symbolic \left[x, 2\right]
>>> from sage.all import * >>> latex(Integer(Integer(3))) # indirect doctest 3 >>> latex(Integer(1)==Integer(0)) \mathrm{False} >>> print(latex([x, Integer(2)])) # needs sage.symbolic \left[x, 2\right]
Check that Issue #11775 is fixed:
sage: latex((x,2), combine_all=True) # needs sage.symbolic x 2
>>> from sage.all import * >>> latex((x,Integer(2)), combine_all=True) # needs sage.symbolic x 2
- sage.misc.latex.latex_extra_preamble()[source]¶
Return the string containing the user-configured preamble,
sage_latex_macros, and any user-configured macros. This is used in theeval()method for theLatexclass, and in_latex_file_(); it follows eitherLATEX_HEADERorSLIDE_HEADER(defined at the top of this file) which is a string containing the documentclass and standard usepackage commands.EXAMPLES:
sage: from sage.misc.latex import latex_extra_preamble sage: print(latex_extra_preamble()) \newcommand{\ZZ}{\Bold{Z}} \newcommand{\NN}{\Bold{N}} \newcommand{\RR}{\Bold{R}} \newcommand{\CC}{\Bold{C}} \newcommand{\QQ}{\Bold{Q}} \newcommand{\QQbar}{\overline{\QQ}} \newcommand{\GF}[1]{\Bold{F}_{#1}} \newcommand{\Zp}[1]{\Bold{Z}_{#1}} \newcommand{\Qp}[1]{\Bold{Q}_{#1}} \newcommand{\Zmod}[1]{\ZZ/#1\ZZ} \newcommand{\CDF}{\Bold{C}} \newcommand{\CIF}{\Bold{C}} \newcommand{\CLF}{\Bold{C}} \newcommand{\RDF}{\Bold{R}} \newcommand{\RIF}{\Bold{I} \Bold{R}} \newcommand{\RLF}{\Bold{R}} \newcommand{\SL}{\mathrm{SL}} \newcommand{\PSL}{\mathrm{PSL}} \newcommand{\lcm}{\mathop{\operatorname{lcm}}} \newcommand{\dist}{\mathrm{dist}} \newcommand{\Bold}[1]{\mathbf{#1}}
>>> from sage.all import * >>> from sage.misc.latex import latex_extra_preamble >>> print(latex_extra_preamble()) <BLANKLINE> \newcommand{\ZZ}{\Bold{Z}} \newcommand{\NN}{\Bold{N}} \newcommand{\RR}{\Bold{R}} \newcommand{\CC}{\Bold{C}} \newcommand{\QQ}{\Bold{Q}} \newcommand{\QQbar}{\overline{\QQ}} \newcommand{\GF}[1]{\Bold{F}_{#1}} \newcommand{\Zp}[1]{\Bold{Z}_{#1}} \newcommand{\Qp}[1]{\Bold{Q}_{#1}} \newcommand{\Zmod}[1]{\ZZ/#1\ZZ} \newcommand{\CDF}{\Bold{C}} \newcommand{\CIF}{\Bold{C}} \newcommand{\CLF}{\Bold{C}} \newcommand{\RDF}{\Bold{R}} \newcommand{\RIF}{\Bold{I} \Bold{R}} \newcommand{\RLF}{\Bold{R}} \newcommand{\SL}{\mathrm{SL}} \newcommand{\PSL}{\mathrm{PSL}} \newcommand{\lcm}{\mathop{\operatorname{lcm}}} \newcommand{\dist}{\mathrm{dist}} \newcommand{\Bold}[1]{\mathbf{#1}} <BLANKLINE>
- sage.misc.latex.latex_variable_name(x, is_fname=False)[source]¶
Return latex version of a variable name.
Here are some guiding principles for usage of this function:
If the variable is a single letter, that is the latex version.
If the variable name is suffixed by a number, we put the number in the subscript.
If the variable name contains an
'_'we start the subscript at the underscore. Note that #3 trumps rule #2.If a component of the variable is a Greek letter, escape it properly.
Recurse nicely with subscripts.
Refer to the examples section for how these rules might play out in practice.
EXAMPLES:
sage: from sage.misc.latex import latex_variable_name sage: latex_variable_name('a') 'a' sage: latex_variable_name('abc') '\\mathit{abc}' sage: latex_variable_name('sigma') '\\sigma' sage: latex_variable_name('sigma_k') '\\sigma_{k}' sage: latex_variable_name('sigma389') '\\sigma_{389}' sage: latex_variable_name('beta_00') '\\beta_{00}' sage: latex_variable_name('Omega84') '\\Omega_{84}' sage: latex_variable_name('sigma_alpha') '\\sigma_{\\alpha}' sage: latex_variable_name('nothing1') '\\mathit{nothing}_{1}' sage: latex_variable_name('nothing1', is_fname=True) '{\\rm nothing}_{1}' sage: latex_variable_name('nothing_abc') '\\mathit{nothing}_{\\mathit{abc}}' sage: latex_variable_name('nothing_abc', is_fname=True) '{\\rm nothing}_{{\\rm abc}}' sage: latex_variable_name('alpha_beta_gamma12') '\\alpha_{\\beta_{\\gamma_{12}}}' sage: latex_variable_name('x_ast') 'x_{\\ast}'
>>> from sage.all import * >>> from sage.misc.latex import latex_variable_name >>> latex_variable_name('a') 'a' >>> latex_variable_name('abc') '\\mathit{abc}' >>> latex_variable_name('sigma') '\\sigma' >>> latex_variable_name('sigma_k') '\\sigma_{k}' >>> latex_variable_name('sigma389') '\\sigma_{389}' >>> latex_variable_name('beta_00') '\\beta_{00}' >>> latex_variable_name('Omega84') '\\Omega_{84}' >>> latex_variable_name('sigma_alpha') '\\sigma_{\\alpha}' >>> latex_variable_name('nothing1') '\\mathit{nothing}_{1}' >>> latex_variable_name('nothing1', is_fname=True) '{\\rm nothing}_{1}' >>> latex_variable_name('nothing_abc') '\\mathit{nothing}_{\\mathit{abc}}' >>> latex_variable_name('nothing_abc', is_fname=True) '{\\rm nothing}_{{\\rm abc}}' >>> latex_variable_name('alpha_beta_gamma12') '\\alpha_{\\beta_{\\gamma_{12}}}' >>> latex_variable_name('x_ast') 'x_{\\ast}'
- sage.misc.latex.latex_varify(a, is_fname=False)[source]¶
Convert a string
ato a LaTeX string: if it’s an element ofcommon_varnames, then prepend a backslash. Ifaconsists of a single letter, then return it. Otherwise, return either “{\rm a}” or “\mbox{a}” if “is_fname” flag isTrueorFalse.INPUT:
a– string
OUTPUT: string
EXAMPLES:
sage: from sage.misc.latex import latex_varify sage: latex_varify('w') 'w' sage: latex_varify('aleph') '\\mathit{aleph}' sage: latex_varify('aleph', is_fname=True) '{\\rm aleph}' sage: latex_varify('alpha') '\\alpha' sage: latex_varify('ast') '\\ast'
>>> from sage.all import * >>> from sage.misc.latex import latex_varify >>> latex_varify('w') 'w' >>> latex_varify('aleph') '\\mathit{aleph}' >>> latex_varify('aleph', is_fname=True) '{\\rm aleph}' >>> latex_varify('alpha') '\\alpha' >>> latex_varify('ast') '\\ast'
- sage.misc.latex.list_function(x)[source]¶
Return the LaTeX code for a list
x.INPUT:
x– list
EXAMPLES:
sage: from sage.misc.latex import list_function sage: list_function([1,2,3]) '\\left[1, 2, 3\\right]' sage: latex([1,2,3]) # indirect doctest \left[1, 2, 3\right] sage: latex([Matrix(ZZ, 3, range(9)), # indirect doctest # needs sage.modules ....: Matrix(ZZ, 3, range(9))]) \left[\left(\begin{array}{rrr} 0 & 1 & 2 \\ 3 & 4 & 5 \\ 6 & 7 & 8 \end{array}\right), \left(\begin{array}{rrr} 0 & 1 & 2 \\ 3 & 4 & 5 \\ 6 & 7 & 8 \end{array}\right)\right]
>>> from sage.all import * >>> from sage.misc.latex import list_function >>> list_function([Integer(1),Integer(2),Integer(3)]) '\\left[1, 2, 3\\right]' >>> latex([Integer(1),Integer(2),Integer(3)]) # indirect doctest \left[1, 2, 3\right] >>> latex([Matrix(ZZ, Integer(3), range(Integer(9))), # indirect doctest # needs sage.modules ... Matrix(ZZ, Integer(3), range(Integer(9)))]) \left[\left(\begin{array}{rrr} 0 & 1 & 2 \\ 3 & 4 & 5 \\ 6 & 7 & 8 \end{array}\right), \left(\begin{array}{rrr} 0 & 1 & 2 \\ 3 & 4 & 5 \\ 6 & 7 & 8 \end{array}\right)\right]
- sage.misc.latex.pdf(x, filename, tiny=False, tightpage=True, margin=None, engine=None, debug=False)[source]¶
Create an image from the latex representation of
xand save it as a pdf file with the given filename.INPUT:
x– a Sage objectfilename– the filename with which to save the imagetiny– boolean (default:False); ifTrue, use a tiny fonttightpage– boolean (default:True); use the LaTeX packagepreviewwith the ‘tightpage’ optionmargin– float (default: no margin); width of border, only effective with ‘tight page’engine– (default:None)'latex','pdflatex','xelatex'or'lualatex'; ifNone, the value defined in the LaTeX global preferenceslatex.engine()is useddebug– boolean (default:False); ifTrue, print verbose output
EXAMPLES:
sage: # optional - latex sage: from sage.misc.latex import pdf sage: import tempfile sage: with tempfile.NamedTemporaryFile(suffix=".pdf") as f: # random ....: pdf(ZZ[x], f.name)
>>> from sage.all import * >>> # optional - latex >>> from sage.misc.latex import pdf >>> import tempfile >>> with tempfile.NamedTemporaryFile(suffix=".pdf") as f: # random ... pdf(ZZ[x], f.name)
- sage.misc.latex.png(x, filename, density=150, debug=False, do_in_background=False, tiny=False, engine=None)[source]¶
Create a png image representation of
xand save to the given filename.INPUT:
x– object to be displayedfilename– file in which to save the imagedensity– integer (default: 150)debug– boolean (default:False); print verbose outputdo_in_background– boolean (default:False); unused, kept for backwards compatibilitytiny– boolean (default:False); use tiny fontengine– (default:None)'latex','pdflatex','xelatex'or'lualatex'
EXAMPLES:
sage: # optional - imagemagick latex, needs sage.plot sage: from sage.misc.latex import png sage: import tempfile sage: with tempfile.NamedTemporaryFile(suffix='.png') as f: # random ....: png(ZZ[x], f.name)
>>> from sage.all import * >>> # optional - imagemagick latex, needs sage.plot >>> from sage.misc.latex import png >>> import tempfile >>> with tempfile.NamedTemporaryFile(suffix='.png') as f: # random ... png(ZZ[x], f.name)
- sage.misc.latex.repr_lincomb(symbols, coeffs)[source]¶
Compute a latex representation of a linear combination of some formal symbols.
INPUT:
symbols– list of symbolscoeffs– list of coefficients of the symbols
OUTPUT: string
EXAMPLES:
sage: t = PolynomialRing(QQ, 't').0 sage: from sage.misc.latex import repr_lincomb sage: repr_lincomb(['a', 's', ''], [-t, t - 2, t^12 + 2]) '-t\\text{\\texttt{a}} + \\left(t - 2\\right)\\text{\\texttt{s}} + \\left(t^{12} + 2\\right)' sage: repr_lincomb(['a', 'b'], [1,1]) '\\text{\\texttt{a}} + \\text{\\texttt{b}}'
>>> from sage.all import * >>> t = PolynomialRing(QQ, 't').gen(0) >>> from sage.misc.latex import repr_lincomb >>> repr_lincomb(['a', 's', ''], [-t, t - Integer(2), t**Integer(12) + Integer(2)]) '-t\\text{\\texttt{a}} + \\left(t - 2\\right)\\text{\\texttt{s}} + \\left(t^{12} + 2\\right)' >>> repr_lincomb(['a', 'b'], [Integer(1),Integer(1)]) '\\text{\\texttt{a}} + \\text{\\texttt{b}}'
Verify that a certain corner case works (see Issue #5707 and Issue #5766):
sage: repr_lincomb([1,5,-3],[2,8/9,7]) '2\\cdot 1 + \\frac{8}{9}\\cdot 5 + 7\\cdot -3'
>>> from sage.all import * >>> repr_lincomb([Integer(1),Integer(5),-Integer(3)],[Integer(2),Integer(8)/Integer(9),Integer(7)]) '2\\cdot 1 + \\frac{8}{9}\\cdot 5 + 7\\cdot -3'
Verify that Issue #17299 (latex representation of modular symbols) is fixed:
sage: x = EllipticCurve('64a1').modular_symbol_space(sign=1).basis()[0] # needs sage.schemes sage: from sage.misc.latex import repr_lincomb sage: latex(x.modular_symbol_rep()) # needs sage.schemes \left\{\frac{-3}{11}, \frac{-1}{4}\right\} - \left\{\frac{3}{13}, \frac{1}{4}\right\}
>>> from sage.all import * >>> x = EllipticCurve('64a1').modular_symbol_space(sign=Integer(1)).basis()[Integer(0)] # needs sage.schemes >>> from sage.misc.latex import repr_lincomb >>> latex(x.modular_symbol_rep()) # needs sage.schemes \left\{\frac{-3}{11}, \frac{-1}{4}\right\} - \left\{\frac{3}{13}, \frac{1}{4}\right\}
Verify that it works when the symbols are numbers:
sage: x = FormalSum([(1,2),(3,4)]) sage: latex(x) 2 + 3\cdot 4
>>> from sage.all import * >>> x = FormalSum([(Integer(1),Integer(2)),(Integer(3),Integer(4))]) >>> latex(x) 2 + 3\cdot 4
Verify that it works when
bv in CCraises an error:sage: x = FormalSum([(1,'x'),(2,'y')]) sage: latex(x) \text{\texttt{x}} + 2\text{\texttt{y}}
>>> from sage.all import * >>> x = FormalSum([(Integer(1),'x'),(Integer(2),'y')]) >>> latex(x) \text{\texttt{x}} + 2\text{\texttt{y}}
- sage.misc.latex.str_function(x)[source]¶
Return a LaTeX representation of the string
x.The main purpose of this function is to generate LaTeX representation for classes that do not provide a customized method.
If
xcontains only digits with, possibly, a single decimal point and/or a sign in front, it is considered to be its own representation. Otherwise each line ofxis wrapped in a\textttcommand and these lines are assembled in a left-justified array. This gives to complicated strings the closest look to their “terminal representation”.Warning
Such wrappers cannot be used as arguments of LaTeX commands or in command definitions. If this causes you any problems, they probably can be solved by implementing a suitable
_latex_method for an appropriate class.INPUT:
x– string
OUTPUT: string
EXAMPLES:
sage: from sage.misc.latex import str_function sage: str_function('34') '34' sage: str_function('34.5') '34.5' sage: str_function('-34.5') '-34.5' sage: str_function('+34.5') '+34.5' sage: str_function('hello_world') '\\text{\\texttt{hello{\\char`\\_}world}}' sage: str_function('-1.00000?') # trac 12178 '-1.00000?'
>>> from sage.all import * >>> from sage.misc.latex import str_function >>> str_function('34') '34' >>> str_function('34.5') '34.5' >>> str_function('-34.5') '-34.5' >>> str_function('+34.5') '+34.5' >>> str_function('hello_world') '\\text{\\texttt{hello{\\char`\\_}world}}' >>> str_function('-1.00000?') # trac 12178 '-1.00000?'
- sage.misc.latex.tuple_function(x, combine_all=False)[source]¶
Return the LaTeX code for a tuple
x.INPUT:
x– tuplecombine_all– boolean (default:False); ifcombine_allisTrue, then it does not return a tuple and instead returns a string with all the elements separated by a single space. It does not collapse tuples which are inside tuples.
EXAMPLES:
sage: from sage.misc.latex import tuple_function sage: tuple_function((1,2,3)) '\\left(1, 2, 3\\right)'
>>> from sage.all import * >>> from sage.misc.latex import tuple_function >>> tuple_function((Integer(1),Integer(2),Integer(3))) '\\left(1, 2, 3\\right)'
Check that Issue #11775 is fixed:
sage: tuple_function((1,2,3), combine_all=True) '1 2 3' sage: tuple_function(((1,2),3), combine_all=True) '\\left(1, 2\\right) 3'
>>> from sage.all import * >>> tuple_function((Integer(1),Integer(2),Integer(3)), combine_all=True) '1 2 3' >>> tuple_function(((Integer(1),Integer(2)),Integer(3)), combine_all=True) '\\left(1, 2\\right) 3'
- sage.misc.latex.view(objects, title='Sage', debug=False, sep='', tiny=False, engine=None, viewer=None, tightpage=True, margin=None, mode='inline', combine_all=False, **kwds)[source]¶
Compute a latex representation of each object in objects, compile, and display typeset. If used from the command line, this requires that latex be installed.
INPUT:
objects– list (or object)title– string (default:'Sage'); title for the documentdebug– boolean (default:False); print verbose outputsep– string (default:''); separator between math objectstiny– boolean (default:False); use tiny fontengine– string orNone(default:None); can take the following values:None– the value defined in the LaTeX global preferenceslatex.engine()is used'pdflatex'– compilation doestex->pdf'xelatex'– compilation doestex->pdf'lualatex'– compilation doestex->pdf'latex'– compilation first triestex->dvi->pngand if an error occurs then triesdvi->ps->pdf. This is slower than'pdflatex'and known to be broken when overfull hboxes are detected.
viewer– string orNone(default:None); specify a viewer to use; currently the only options areNoneand'pdf'tightpage– boolean (default:True); use the LaTeX packagepreviewwith the ‘tightpage’ option
margin– float orNone(default:None); adds a margin ofmarginmm. Has no affect if the optiontightpageisFalse.mode– string (default:'inline');'display'for displaymath or'inline'for inline mathcombine_all– boolean (default:False); ifcombine_allisTrueand the input is a tuple, then it does not return a tuple and instead returns a string with all the elements separated by a single space
OUTPUT: display typeset objects
The output is displayed in a separate viewer displaying a dvi (or pdf) file, with the following: the title string is printed, centered, at the top. Beneath that, each object in
objectsis typeset on its own line, with the stringsepinserted between these lines.The value of
sepis inserted between each element of the listobjects; you can, for example, add vertical space between objects withsep='\\vspace{15mm}', whilesep='\\hrule'adds a horizontal line between objects, andsep='\\newpage'inserts a page break between objects.If the
engineis either'pdflatex','xelatex', or'lualatex', it produces a pdf file. Otherwise, it produces a dvi file, and if the programdvipngis installed, it checks the dvi file by trying to convert it to a png file. If this conversion fails, the dvi file probably contains some postscript special commands or it has other issues which might make displaying it a problem; in this case, the file is converted to a pdf file, which is then displayed.Setting
viewerto'pdf'forces the use of a separate viewer, even in notebook mode. This also sets the latex engine to bepdflatexif the current engine islatex.Setting the option
tightpagetoTrue(this is the default setting) tells LaTeX to use the package ‘preview’ with the ‘tightpage’ option. Then, each object is typeset in its own page, and that page is cropped to exactly the size of the object. This is typically useful for very large pictures (like graphs) generated with tikz. This only works when using a separate viewer. Note that the object are currently typeset in plain math mode rather than displaymath, because the latter imposes a limit on the width of the picture. Technically,tightpageadds\\usepackage[tightpage,active]{preview} \\PreviewEnvironment{page}
to the LaTeX preamble, and replaces the
\\[and\\]around each object by\\begin{page}$and$\\end{page}. SettingtightpagetoFalseturns off this behavior and provides the latex output as a full page. Iftightpageis set toTrue, theTitleis ignored.