diff --git a/.github/workflows/doc-build-pdf.yml b/.github/workflows/doc-build-pdf.yml index bfa32760934..7ae675d9e64 100644 --- a/.github/workflows/doc-build-pdf.yml +++ b/.github/workflows/doc-build-pdf.yml @@ -57,7 +57,7 @@ jobs: export PATH="build/bin:$PATH" eval $(sage-print-system-package-command auto update) eval $(sage-print-system-package-command auto --yes --no-install-recommends install zip) - eval $(sage-print-system-package-command auto --spkg --yes --no-install-recommends install git texlive) + eval $(sage-print-system-package-command auto --spkg --yes --no-install-recommends install git texlive texlive_luatex free_fonts xindy) - name: Add prebuilt tree as a worktree id: worktree diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index 0c5200dbe81..9d82909ef5f 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -161,7 +161,7 @@ jobs: export PATH="build/bin:$PATH" eval $(sage-print-system-package-command auto update) eval $(sage-print-system-package-command auto --yes --no-install-recommends install zip) - eval $(sage-print-system-package-command auto --spkg --yes --no-install-recommends install git texlive) + eval $(sage-print-system-package-command auto --spkg --yes --no-install-recommends install git texlive texlive_luatex free_fonts xindy) export SAGE_USE_CDNS=yes export SAGE_LIVE_DOC=yes export SAGE_JUPYTER_SERVER=binder:sagemath/sage-binder-env/dev diff --git a/build/pkgs/_recommended/dependencies b/build/pkgs/_recommended/dependencies index f4baa9b1fb2..6e36fc6d390 100644 --- a/build/pkgs/_recommended/dependencies +++ b/build/pkgs/_recommended/dependencies @@ -1 +1 @@ -pandoc ffmpeg imagemagick texlive git libjpeg +pandoc ffmpeg imagemagick git libjpeg texlive texlive_luatex free_fonts xindy diff --git a/build/pkgs/free_fonts/SPKG.rst b/build/pkgs/free_fonts/SPKG.rst new file mode 100644 index 00000000000..417954179a7 --- /dev/null +++ b/build/pkgs/free_fonts/SPKG.rst @@ -0,0 +1,23 @@ +free_fonts: a free family of scalable outline fonts +=================================================== + +Description +----------- + +This dummy package represents the GNU free fonts: a free family of scalable +outline fonts, suitable for general use on computers and for desktop +publishing. It is Unicode-encoded for compatibility with all modern operating +systems. + +We do not have an SPKG for it. The purpose of this dummy package is to +associate system package lists with it. + +License +------- + +GNU General Public License GPLv3+ + +Upstream Contact +---------------- + +https://www.gnu.org/software/freefont/ diff --git a/build/pkgs/free_fonts/distros/alpine.txt b/build/pkgs/free_fonts/distros/alpine.txt new file mode 100644 index 00000000000..756efd2627c --- /dev/null +++ b/build/pkgs/free_fonts/distros/alpine.txt @@ -0,0 +1 @@ +ttf-freefont diff --git a/build/pkgs/free_fonts/distros/arch.txt b/build/pkgs/free_fonts/distros/arch.txt new file mode 100644 index 00000000000..b03a4525c08 --- /dev/null +++ b/build/pkgs/free_fonts/distros/arch.txt @@ -0,0 +1 @@ +gnu-free-fonts diff --git a/build/pkgs/free_fonts/distros/conda.txt b/build/pkgs/free_fonts/distros/conda.txt new file mode 100644 index 00000000000..bdf05c629cf --- /dev/null +++ b/build/pkgs/free_fonts/distros/conda.txt @@ -0,0 +1 @@ +open-fonts diff --git a/build/pkgs/free_fonts/distros/debian.txt b/build/pkgs/free_fonts/distros/debian.txt new file mode 100644 index 00000000000..9dae6737769 --- /dev/null +++ b/build/pkgs/free_fonts/distros/debian.txt @@ -0,0 +1 @@ +fonts-freefont-otf diff --git a/build/pkgs/free_fonts/distros/fedora.txt b/build/pkgs/free_fonts/distros/fedora.txt new file mode 100644 index 00000000000..b03a4525c08 --- /dev/null +++ b/build/pkgs/free_fonts/distros/fedora.txt @@ -0,0 +1 @@ +gnu-free-fonts diff --git a/build/pkgs/free_fonts/distros/freebsd.txt b/build/pkgs/free_fonts/distros/freebsd.txt new file mode 100644 index 00000000000..34b729ae37f --- /dev/null +++ b/build/pkgs/free_fonts/distros/freebsd.txt @@ -0,0 +1 @@ +x11-fonts/freefont-ttf diff --git a/build/pkgs/free_fonts/distros/gentoo.txt b/build/pkgs/free_fonts/distros/gentoo.txt new file mode 100644 index 00000000000..f9711d7a9f2 --- /dev/null +++ b/build/pkgs/free_fonts/distros/gentoo.txt @@ -0,0 +1 @@ +media-fonts/freefont diff --git a/build/pkgs/free_fonts/distros/macports.txt b/build/pkgs/free_fonts/distros/macports.txt new file mode 100644 index 00000000000..d5a8b479117 --- /dev/null +++ b/build/pkgs/free_fonts/distros/macports.txt @@ -0,0 +1 @@ +freefont-ttf diff --git a/build/pkgs/free_fonts/distros/opensuse.txt b/build/pkgs/free_fonts/distros/opensuse.txt new file mode 100644 index 00000000000..b03a4525c08 --- /dev/null +++ b/build/pkgs/free_fonts/distros/opensuse.txt @@ -0,0 +1 @@ +gnu-free-fonts diff --git a/build/pkgs/free_fonts/distros/repology.txt b/build/pkgs/free_fonts/distros/repology.txt new file mode 100644 index 00000000000..0870af23017 --- /dev/null +++ b/build/pkgs/free_fonts/distros/repology.txt @@ -0,0 +1 @@ +gnu-freefont diff --git a/build/pkgs/free_fonts/distros/void.txt b/build/pkgs/free_fonts/distros/void.txt new file mode 100644 index 00000000000..d5a8b479117 --- /dev/null +++ b/build/pkgs/free_fonts/distros/void.txt @@ -0,0 +1 @@ +freefont-ttf diff --git a/build/pkgs/free_fonts/spkg-configure.m4 b/build/pkgs/free_fonts/spkg-configure.m4 new file mode 100644 index 00000000000..d6864f5b58c --- /dev/null +++ b/build/pkgs/free_fonts/spkg-configure.m4 @@ -0,0 +1,16 @@ +SAGE_SPKG_CONFIGURE([free_fonts], [ + sage_spkg_install_free_fonts=yes + m4_foreach([font], + [FreeSerif.ttf,FreeSerif.otf], + [ + AC_MSG_CHECKING([for ]font) + AS_IF([kpsewhich ]font[ >& AS_MESSAGE_LOG_FD 2>&1], [ + AC_MSG_RESULT([yes]) + sage_spkg_install_free_fonts=no + break + ], [ + AC_MSG_RESULT([no]) + ]) + ]) +]) + diff --git a/build/pkgs/free_fonts/type b/build/pkgs/free_fonts/type new file mode 100644 index 00000000000..134d9bc32d5 --- /dev/null +++ b/build/pkgs/free_fonts/type @@ -0,0 +1 @@ +optional diff --git a/build/pkgs/sagemath_doc_pdf/dependencies b/build/pkgs/sagemath_doc_pdf/dependencies index 21eb5295b36..7e3e7f136d2 100644 --- a/build/pkgs/sagemath_doc_pdf/dependencies +++ b/build/pkgs/sagemath_doc_pdf/dependencies @@ -1 +1 @@ -sagemath_doc_html texlive +sagemath_doc_html texlive texlive_luatex free_fonts xindy diff --git a/build/pkgs/texlive_luatex/SPKG.rst b/build/pkgs/texlive_luatex/SPKG.rst new file mode 100644 index 00000000000..0bb7f65eb8b --- /dev/null +++ b/build/pkgs/texlive_luatex/SPKG.rst @@ -0,0 +1,21 @@ +texlive_luatex: LuaTeX packages +=============================== + +Description +----------- + +Packages for LuaTeX, a TeX engine using Lua as an embedded scripting and +extension language, with native support for Unicode, OpenType/TrueType fonts, +and both PDF and DVI output. + +The purpose of this dummy package is to associate system package lists with it. + +License +------- + +GNU General Public License version 2.0 (GPLv2) + +Upstream Contact +---------------- + +https://www.luatex.org/ diff --git a/build/pkgs/texlive_luatex/dependencies b/build/pkgs/texlive_luatex/dependencies new file mode 100644 index 00000000000..ba0ee3a029f --- /dev/null +++ b/build/pkgs/texlive_luatex/dependencies @@ -0,0 +1 @@ +texlive diff --git a/build/pkgs/texlive_luatex/distros/alpine.txt b/build/pkgs/texlive_luatex/distros/alpine.txt new file mode 100644 index 00000000000..d2b702df88a --- /dev/null +++ b/build/pkgs/texlive_luatex/distros/alpine.txt @@ -0,0 +1 @@ +texlive-luatex diff --git a/build/pkgs/texlive_luatex/distros/arch.txt b/build/pkgs/texlive_luatex/distros/arch.txt new file mode 100644 index 00000000000..2eec092a978 --- /dev/null +++ b/build/pkgs/texlive_luatex/distros/arch.txt @@ -0,0 +1 @@ +texlive-collection-luatex diff --git a/build/pkgs/texlive_luatex/distros/cygwin.txt b/build/pkgs/texlive_luatex/distros/cygwin.txt new file mode 100644 index 00000000000..ba0ee3a029f --- /dev/null +++ b/build/pkgs/texlive_luatex/distros/cygwin.txt @@ -0,0 +1 @@ +texlive diff --git a/build/pkgs/texlive_luatex/distros/debian.txt b/build/pkgs/texlive_luatex/distros/debian.txt new file mode 100644 index 00000000000..d2b702df88a --- /dev/null +++ b/build/pkgs/texlive_luatex/distros/debian.txt @@ -0,0 +1 @@ +texlive-luatex diff --git a/build/pkgs/texlive_luatex/distros/fedora.txt b/build/pkgs/texlive_luatex/distros/fedora.txt new file mode 100644 index 00000000000..d2b702df88a --- /dev/null +++ b/build/pkgs/texlive_luatex/distros/fedora.txt @@ -0,0 +1 @@ +texlive-luatex diff --git a/build/pkgs/texlive_luatex/distros/gentoo.txt b/build/pkgs/texlive_luatex/distros/gentoo.txt new file mode 100644 index 00000000000..6e651aec020 --- /dev/null +++ b/build/pkgs/texlive_luatex/distros/gentoo.txt @@ -0,0 +1 @@ +dev-texlive/texlive-luatex diff --git a/build/pkgs/texlive_luatex/distros/macports.txt b/build/pkgs/texlive_luatex/distros/macports.txt new file mode 100644 index 00000000000..d2b702df88a --- /dev/null +++ b/build/pkgs/texlive_luatex/distros/macports.txt @@ -0,0 +1 @@ +texlive-luatex diff --git a/build/pkgs/texlive_luatex/distros/opensuse.txt b/build/pkgs/texlive_luatex/distros/opensuse.txt new file mode 100644 index 00000000000..d2b702df88a --- /dev/null +++ b/build/pkgs/texlive_luatex/distros/opensuse.txt @@ -0,0 +1 @@ +texlive-luatex diff --git a/build/pkgs/texlive_luatex/distros/repology.txt b/build/pkgs/texlive_luatex/distros/repology.txt new file mode 100644 index 00000000000..d2b702df88a --- /dev/null +++ b/build/pkgs/texlive_luatex/distros/repology.txt @@ -0,0 +1 @@ +texlive-luatex diff --git a/build/pkgs/texlive_luatex/spkg-configure.m4 b/build/pkgs/texlive_luatex/spkg-configure.m4 new file mode 100644 index 00000000000..6fb53bbc171 --- /dev/null +++ b/build/pkgs/texlive_luatex/spkg-configure.m4 @@ -0,0 +1,10 @@ +SAGE_SPKG_CONFIGURE([texlive_luatex], [ + sage_spkg_install_texlive_luatex=no + AC_MSG_CHECKING([for luaotfload-main.lua]) + AS_IF([kpsewhich luaotfload-main.lua >& AS_MESSAGE_LOG_FD 2>&1], [ + AC_MSG_RESULT([yes]) + ], [ + AC_MSG_RESULT([no]) + sage_spkg_install_texlive_luatex=yes + ]) +]) diff --git a/build/pkgs/texlive_luatex/type b/build/pkgs/texlive_luatex/type new file mode 100644 index 00000000000..134d9bc32d5 --- /dev/null +++ b/build/pkgs/texlive_luatex/type @@ -0,0 +1 @@ +optional diff --git a/build/pkgs/xindy/SPKG.rst b/build/pkgs/xindy/SPKG.rst new file mode 100644 index 00000000000..49733639b2f --- /dev/null +++ b/build/pkgs/xindy/SPKG.rst @@ -0,0 +1,20 @@ +xindy: a general-purpose index processor +======================================== + +Description +----------- + +This dummy package represents xindy: xindy was developed after an impasse had been encountered in the attempt to complete internationalisation of makeindex. Xindy can be used to process indexes for documents marked up using (LA)TEX, Nroff family and SGML-based languages. Xindy is highly configurable, both in markup terms and in terms of the collating order of the text being processed. + +We do not have an SPKG for it. The purpose of this dummy package is to +associate system package lists with it. + +License +------- + +GNU General Public License version 2.0 (GPLv2) + +Upstream Contact +---------------- + +http://www.xindy.org/ diff --git a/build/pkgs/xindy/distros/debian.txt b/build/pkgs/xindy/distros/debian.txt new file mode 100644 index 00000000000..aeb5474c700 --- /dev/null +++ b/build/pkgs/xindy/distros/debian.txt @@ -0,0 +1 @@ +xindy diff --git a/build/pkgs/xindy/distros/macports.txt b/build/pkgs/xindy/distros/macports.txt new file mode 100644 index 00000000000..aeb5474c700 --- /dev/null +++ b/build/pkgs/xindy/distros/macports.txt @@ -0,0 +1 @@ +xindy diff --git a/build/pkgs/xindy/distros/opensuse.txt b/build/pkgs/xindy/distros/opensuse.txt new file mode 100644 index 00000000000..aeb5474c700 --- /dev/null +++ b/build/pkgs/xindy/distros/opensuse.txt @@ -0,0 +1 @@ +xindy diff --git a/build/pkgs/xindy/distros/repology.txt b/build/pkgs/xindy/distros/repology.txt new file mode 100644 index 00000000000..aeb5474c700 --- /dev/null +++ b/build/pkgs/xindy/distros/repology.txt @@ -0,0 +1 @@ +xindy diff --git a/build/pkgs/xindy/spkg-configure.m4 b/build/pkgs/xindy/spkg-configure.m4 new file mode 100644 index 00000000000..07fbe71efa8 --- /dev/null +++ b/build/pkgs/xindy/spkg-configure.m4 @@ -0,0 +1,5 @@ +SAGE_SPKG_CONFIGURE([xindy], [ + sage_spkg_install_xindy=no + AC_PATH_PROG([XINDY], [xindy]) + AS_IF([test -z "$XINDY"], [sage_spkg_install_xindy=yes]) +]) diff --git a/build/pkgs/xindy/type b/build/pkgs/xindy/type new file mode 100644 index 00000000000..134d9bc32d5 --- /dev/null +++ b/build/pkgs/xindy/type @@ -0,0 +1 @@ +optional diff --git a/src/doc/fr/tutorial/conf.py b/src/doc/fr/tutorial/conf.py index 7208ddada17..f44315072ff 100644 --- a/src/doc/fr/tutorial/conf.py +++ b/src/doc/fr/tutorial/conf.py @@ -39,9 +39,6 @@ 'The Sage Group', 'manual'), ] -# Additional LaTeX stuff for the French version -#latex_elements['preamble'] += '\\DeclareUnicodeCharacter{00A0}{\\nobreakspace}\n' - # the definition of \\at in the standard preamble of the sphinx doc # conflicts with that in babel/french[b] latex_elements['preamble'] += '\\let\\at\\undefined' diff --git a/src/doc/ja/a_tour_of_sage/conf.py b/src/doc/ja/a_tour_of_sage/conf.py index bf1f84bf962..451d7cc5b58 100644 --- a/src/doc/ja/a_tour_of_sage/conf.py +++ b/src/doc/ja/a_tour_of_sage/conf.py @@ -25,6 +25,10 @@ name = 'a_tour_of_sage' language = "ja" +# The LaTeX engine to build the docs in Japanese. +# https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-latex_engine +latex_engine = 'uplatex' + # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". html_title = project + " v" + release diff --git a/src/doc/ja/tutorial/conf.py b/src/doc/ja/tutorial/conf.py index 9521bc91828..e4b79bd7875 100644 --- a/src/doc/ja/tutorial/conf.py +++ b/src/doc/ja/tutorial/conf.py @@ -25,6 +25,10 @@ name = 'tutorial-jp' language = "ja" +# The LaTeX engine to build the docs in Japanese. +# https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-latex_engine +latex_engine = 'uplatex' + # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". html_title = project + " v" + release diff --git a/src/doc/ru/tutorial/conf.py b/src/doc/ru/tutorial/conf.py index 0b7a8c4e3db..cda4d9762ed 100644 --- a/src/doc/ru/tutorial/conf.py +++ b/src/doc/ru/tutorial/conf.py @@ -38,6 +38,3 @@ ('index', 'SageTutorial_ru.tex', 'Sage Tutorial in Russian', 'The Sage Development Team', 'manual'), ] - -# Additional LaTeX stuff if necessary: -#latex_elements['preamble'] += '\\DeclareUnicodeCharacter{00A0}{\\nobreakspace}\n' diff --git a/src/sage/misc/latex.py b/src/sage/misc/latex.py index df469ca8189..25f19e6f329 100644 --- a/src/sage/misc/latex.py +++ b/src/sage/misc/latex.py @@ -33,10 +33,9 @@ from tempfile import TemporaryDirectory from sage.misc.cachefunc import cached_function, cached_method +from sage.misc.lazy_attribute import lazy_attribute from sage.structure.sage_object import SageObject -from sage.misc.lazy_import import lazy_import -lazy_import('sage.misc.html', ('MathJax', 'MathJaxExpr'), deprecation=31536) COMMON_HEADER = r'''\usepackage{amsmath} \usepackage{amssymb} @@ -66,111 +65,6 @@ ''') -@cached_function -def have_latex() -> bool: - """ - Return ``True`` if this computer has the program ``latex``. - - If this computer does not have LaTeX installed, you may obtain it - from http://ctan.org/. - - EXAMPLES:: - - sage: from sage.misc.latex import have_latex - sage: have_latex() # random - True - """ - from .superseded import deprecation - deprecation(32650, 'the function have_latex() is replaced by: ' - 'from sage.features.latex import latex;latex().is_present()') - from sage.features.latex import latex - return latex().is_present() - - -@cached_function -def have_pdflatex() -> bool: - """ - Return ``True`` if this computer has the program ``pdflatex``. - - If this computer does not have pdflatex installed, you may obtain it - from http://ctan.org/. - - EXAMPLES:: - - sage: from sage.misc.latex import have_pdflatex - sage: have_pdflatex() # random - True - """ - from .superseded import deprecation - deprecation(32650, 'the function have_pdflatex() is replaced by: ' - 'from sage.features.latex import pdflatex;pdflatex().is_present()') - from sage.features.latex import pdflatex - return pdflatex().is_present() - - -@cached_function -def have_xelatex() -> bool: - """ - Return ``True`` if this computer has the program ``xelatex``. - - If this computer does not have xelatex installed, you may obtain it - from http://ctan.org/. - - EXAMPLES:: - - sage: from sage.misc.latex import have_xelatex - sage: have_xelatex() # random - True - """ - from .superseded import deprecation - deprecation(32650, 'the function have_xelatex() is replaced by: ' - 'from sage.features.latex import xelatex;xelatex().is_present()') - from sage.features.latex import xelatex - return xelatex().is_present() - - -@cached_function -def have_dvipng() -> bool: - """ - Return ``True`` if this computer has the program ``dvipng``. - - If this computer does not have dvipng installed, you may obtain it - from http://sourceforge.net/projects/dvipng/ - - EXAMPLES:: - - sage: from sage.misc.latex import have_dvipng - sage: have_dvipng() # random - True - """ - from .superseded import deprecation - deprecation(32650, 'the function have_dvipng() is replaced by: ' - 'from sage.features.dvipng import dvipng;dvipng().is_present()') - from sage.features.dvipng import dvipng - return dvipng().is_present() - -@cached_function -def have_convert() -> bool: - """ - Return ``True`` if this computer has the program ``convert``. - - If this computer does not have convert installed, you may obtain it - (along with the rest of the ImageMagick suite) from - http://www.imagemagick.org - - EXAMPLES:: - - sage: from sage.misc.latex import have_convert - sage: have_convert() # random - True - """ - from .superseded import deprecation - deprecation(32650, 'the function have_convert() is replaced by: ' - 'from sage.features.imagemagick import imagemagick;imagemagick().is_present()') - from sage.features.imagemagick import ImageMagick - return ImageMagick().is_present() - - def list_function(x): r""" Returns the LaTeX code for a list ``x``. @@ -207,7 +101,7 @@ def tuple_function(x, combine_all=False): - ``x`` -- a tuple - - ``combine_all`` -- boolean (Default: ``False``) If ``combine_all`` is + - ``combine_all`` -- boolean (default: ``False``) If ``combine_all`` is ``True``, 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. @@ -315,11 +209,9 @@ def str_function(x): INPUT: - - ``x`` -- a string. + - ``x`` -- a string - OUTPUT: - - A string + OUTPUT: A string EXAMPLES:: @@ -436,10 +328,10 @@ class LatexExpr(str): Normally, objects of this class are created by a :func:`latex` call. It is also possible to generate :class:`LatexExpr` directly from a string, which must contain valid LaTeX code for typesetting in math mode (without dollar - signs). In the Sage notebook, use - :func:`~sage.repl.rich_output.pretty_print.pretty_print` or the "Typeset" - checkbox to actually see the typeset LaTeX code; alternatively, from - either the command-line or the notebook, use the :func:`view` function. + signs). In the Jupyter notebook, use + :func:`~sage.repl.rich_output.pretty_print.pretty_print` to actually see + the typeset LaTeX code; alternatively, from either the command-line or the + notebook, use the :func:`view` function. INPUT: @@ -583,6 +475,30 @@ def has_latex_attr(x) -> bool: return hasattr(x, '_latex_') and not isinstance(x, type) +@cached_function +def default_engine(): + """ + 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. + + EXAMPLES:: + + sage: from sage.misc.latex import default_engine + sage: default_engine() # random + ('lualatex', 'LuaLaTeX') + """ + from sage.features.latex import pdflatex, xelatex, lualatex + if lualatex().is_present(): + return 'lualatex', 'LuaLaTeX' + if xelatex().is_present(): + return 'xelatex', 'XeLaTeX' + if pdflatex().is_present(): + return 'pdflatex', 'pdfLaTeX' + return 'latex', 'LaTeX' + + class _Latex_prefs_object(SageObject): """ An object that holds LaTeX global preferences. @@ -598,23 +514,38 @@ def __init__(self, bb=False, delimiters=["(", ")"], sage: latex_prefs = _Latex_prefs_object() sage: TestSuite(latex_prefs).run(skip ="_test_pickling") """ - self._option = {} - self._option["blackboard_bold"] = bb - self._option["matrix_delimiters"] = list(delimiters) - self._option["vector_delimiters"] = list(delimiters) - self._option["matrix_column_alignment"] = matrix_column_alignment - self._option["macros"] = "" - self._option["preamble"] = "" - self._option["engine"] = "pdflatex" - self._option["engine_name"] = "LaTeX" + self.__option = {} + self.__option["blackboard_bold"] = bb + self.__option["matrix_delimiters"] = list(delimiters) + self.__option["vector_delimiters"] = list(delimiters) + self.__option["matrix_column_alignment"] = matrix_column_alignment + self.__option["macros"] = "" + self.__option["preamble"] = "" + + @lazy_attribute + def _option(self): + """ + This attribute contains the preferences list. + EXAMPLES:: + + sage: from sage.misc.latex import _Latex_prefs_object + sage: _Latex_prefs_object()._option # random + {'blackboard_bold': False, + 'matrix_delimiters': ['(', ')'], + 'vector_delimiters': ['(', ')'], + 'matrix_column_alignment': 'r', + 'macros': '', + 'preamble': '', + 'engine': 'lualatex', + 'engine_name': 'LuaLaTeX'} + """ + self.__option["engine"] = default_engine()[0] + self.__option["engine_name"] = default_engine()[1] + return self.__option -_Latex_prefs = _Latex_prefs_object() -############################################################## -# The Latex class is used to make slides and LaTeX output in -# the Sage Notebook -######################################### +_Latex_prefs = _Latex_prefs_object() def latex_extra_preamble(): @@ -664,25 +595,25 @@ def latex_extra_preamble(): def _run_latex_(filename, debug=False, density=150, engine=None, png=False, do_in_background=False): """ This runs LaTeX on the TeX file "filename.tex". It produces files - "filename.dvi" (or "filename.pdf"` if engine is either ``pdflatex`` - or ``xelatex``) and if ``png`` is ``True``, "filename.png". If ``png`` - is ``True`` and dvipng cannot convert the dvi file to png (because of - postscript specials or other issues), then dvips is called, and the - PS file is converted to a png file. + ``filename.dvi`` (or ``filename.pdf``` if ``engine`` is either ``'pdflatex'``, + ``'xelatex'``, or ``'lualatex'``) and if ``png`` is ``True``, ``filename.png``. + If ``png`` is ``True`` and ``dvipng`` cannot convert the dvi file to png + (because of postscript specials or other issues), then ``dvips`` is called, and + the PS file is converted to a png file. INPUT: - - ``filename`` -- string: file to process, including full path + - ``filename`` -- string; file to process, including full path - - ``debug`` -- bool (optional, default ``False``): whether to print + - ``debug`` -- bool (optional, default ``False``); whether to print verbose debugging output - - ``density`` -- integer (optional, default 150): how big output + - ``density`` -- integer (optional, default 150); how big output image is. - ``engine`` -- string: latex engine to use. - - ``png`` -- bool (optional, default ``False``): whether to produce a + - ``png`` -- bool (optional, default ``False``); whether to produce a png file. - ``do_in_background`` -- bool (optional, default ``False``). Unused, @@ -690,23 +621,23 @@ def _run_latex_(filename, debug=False, density=150, engine=None, png=False, do_i OUTPUT: - A string which could be a string starting with 'Error' (if - there was a problem), or it could be 'pdf' or 'dvi'. If - engine is latex or ``None``, then a dvi file is created, but if there - appear to be problems with it (because of PS special commands, for - example), then a pdf file is created instead. The function - returns 'dvi' or 'pdf' to indicate which type of file is created. - (Detecting problems requires that dvipng be installed; if it is - not, then the dvi file is not checked for problems and 'dvi' is - returned.) If engine is pdflatex or xelatex and there are no errors, then - 'pdf' is returned. + A string which could be a string starting with ``'Error'`` (if there was a + problem), or it could be ``'pdf'`` or ``'dvi'``. If ``engine`` is + ``'latex'`` or ``None``, then a dvi file is created, but if there appear to + be problems with it (because of PS special commands, for example), then a + pdf file is created instead. The function returns ``'dvi'`` or ``'pdf'`` + to indicate which type of file is created. (Detecting problems requires + that ``dvipng`` be installed; if it is not, then the dvi file is not checked + for problems and ``'dvi'`` is returned.) If ``engine`` is ``'pdflatex'``, + ``'xelatex'`` or ``'lualatex'`` and there are no errors, then ``'pdf'`` is + returned. .. WARNING:: If ``png`` is ``True``, then when using latex (the default), you - must have 'dvipng' (or 'dvips' and 'convert') installed on your + must have ``dvipng`` (or ``dvips`` and ``convert``) installed on your operating system, or this command will not work. When using - pdflatex or xelatex, you must have 'convert' installed. + ``pdflatex``, ``xelatex`` or ``lualatex``, you must have ``convert`` installed. EXAMPLES:: @@ -740,6 +671,12 @@ def _run_latex_(filename, debug=False, density=150, engine=None, png=False, do_i command = "xelatex" suffix = "pdf" return_suffix = "pdf" + elif engine == "lualatex": + from sage.features.latex import lualatex + lualatex().require() + command = "lualatex" + suffix = "pdf" + return_suffix = "pdf" else: raise ValueError("Unsupported LaTeX engine.") @@ -758,10 +695,8 @@ def _run_latex_(filename, debug=False, density=150, engine=None, png=False, do_i print("Go to http://sourceforge.net/projects/dvipng/ and") print("http://www.imagemagick.org to download these programs.") return "Error" - # if png output + pdflatex, check to see if convert is installed. - elif engine == "pdflatex": - ImageMagick().require() - elif engine == "xelatex": + # if png output + [pdf|xe|lua]latex, check to see if convert is installed. + elif engine in ["pdflatex", "xelatex", "lualatex"]: ImageMagick().require() # check_validity: check to see if the dvi file is okay by trying # to convert to a png file. if this fails, return_suffix will be @@ -814,7 +749,7 @@ def _run_latex_(filename, debug=False, density=150, engine=None, png=False, do_i def subpcall(x): return not call(x, stdout=redirect, stderr=redirect, cwd=base) - if engine == "pdflatex" or engine == "xelatex": + if engine in ['pdflatex', 'xelatex', 'lualatex']: if debug: print(lt) if png: @@ -877,6 +812,11 @@ def subpcall(x): return return_suffix +# ------------------------------------------------------- +# The Latex class is used to make slides and LaTeX output +# ------------------------------------------------------- + + class LatexCall: r""" Typeset Sage objects via a ``__call__`` method to this class, @@ -981,7 +921,7 @@ class Latex(LatexCall): sage: LatexExpr(r"y \neq") + latex(x^20 + 1) # needs sage.symbolic y \neq x^{20} + 1 """ - def __init__(self, debug=False, slide=False, density=150, pdflatex=None, engine=None): + def __init__(self, debug=False, slide=False, density=150, engine=None): """ Initialize the latex builder. @@ -993,7 +933,6 @@ def __init__(self, debug=False, slide=False, density=150, pdflatex=None, engine= """ self.__debug = debug self.__slide = slide - self.__pdflatex = pdflatex self.__engine = engine self.__density = density @@ -1046,41 +985,36 @@ def _latex_preparse(self, s, locals): s = s[:i] + k + t[j + 1:] def eval(self, x, globals, strip=False, filename=None, debug=None, - density=None, pdflatex=None, engine=None, locals={}): + density=None, engine=None, locals={}): r""" Compile the formatted tex given by ``x`` as a png and writes the output file to the directory given by ``filename``. INPUT: - - ``globals`` -- a globals dictionary + - ``globals`` -- a globals dictionary - - ``x`` -- string to evaluate. + - ``x`` -- string to evaluate - - ``strip`` -- ignored + - ``strip`` -- ignored - - ``filename`` -- output filename + - ``filename`` -- output filename - - ``debug`` -- whether to print verbose debugging - output + - ``debug`` -- whether to print verbose debugging output - - ``density`` -- how big output image is. + - ``density`` -- how big output image is - - ``pdflatex`` -- whether to use pdflatex. This is deprecated. Use - ``engine`` option instead. + - ``engine`` -- latex engine to use. Currently ``'latex'``, + ``'pdflatex'``, ``'xelatex'`` and ``'lualatex'`` are supported - - ``engine`` -- latex engine to use. Currently latex, pdflatex, and - xelatex are supported. - - - ``locals`` - extra local variables used when - evaluating Sage code in ``x``. + - ``locals`` - extra local variables used when evaluating Sage code in ``x`` .. WARNING:: - When using latex (the default), you must have 'dvipng' (or - 'dvips' and 'convert') installed on your operating system, - or this command will not work. When using pdflatex or xelatex, you - must have 'convert' installed. + When using ``'latex'`` (the default), you must have ``dvipng`` (or + ``dvips`` and ``convert``) installed on your operating system, or + this command will not work. When using ``'pdflatex'``, ``'xelatex'`` + or ``'lualatex'``, you must have ``convert`` installed. OUTPUT: @@ -1151,7 +1085,7 @@ def eval(self, x, globals, strip=False, filename=None, debug=None, def blackboard_bold(self, t=None): r"""nodetex Controls whether Sage uses blackboard bold or ordinary bold - face for typesetting ZZ, RR, etc. + face for typesetting ``ZZ``, ``RR``, etc. INPUT: @@ -1207,18 +1141,18 @@ def matrix_delimiters(self, left=None, right=None): Good choices for ``left`` and ``right`` are any delimiters which LaTeX understands and knows how to resize; some examples are: - - parentheses: '(', ')' - - brackets: '[', ']' - - braces: '\\{', '\\}' - - vertical lines: '|' - - angle brackets: '\\langle', '\\rangle' + - 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 ``left`` to be a - right-hand bracket ']' and ``right`` to be a right-hand - brace '\\}', and it will be typeset correctly. + Putting aside aesthetics, you may combine these in any way + imaginable; for example, you could set ``left`` to be a right-hand + bracket ``']'`` and ``right`` to be a right-hand brace ``'\\}'``, + and it will be typeset correctly. EXAMPLES:: @@ -1228,12 +1162,12 @@ def matrix_delimiters(self, left=None, right=None): \left(\begin{array}{r} 17 \end{array}\right) - sage: latex.matrix_delimiters("[", "]") + sage: latex.matrix_delimiters('[', ']') sage: latex(a) \left[\begin{array}{r} 17 \end{array}\right] - sage: latex.matrix_delimiters(left="\\{") + sage: latex.matrix_delimiters(left='\\{') sage: latex(a) \left\{\begin{array}{r} 17 @@ -1243,7 +1177,7 @@ def matrix_delimiters(self, left=None, right=None): Restore defaults:: - sage: latex.matrix_delimiters("(", ")") + sage: latex.matrix_delimiters('(', ')') """ if left is None and right is None: return _Latex_prefs._option['matrix_delimiters'] @@ -1269,18 +1203,18 @@ def vector_delimiters(self, left=None, right=None): Good choices for ``left`` and ``right`` are any delimiters which LaTeX understands and knows how to resize; some examples are: - - parentheses: '(', ')' - - brackets: '[', ']' - - braces: '\\{', '\\}' - - vertical lines: '|' - - angle brackets: '\\langle', '\\rangle' + - 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 ``left`` to be a - right-hand bracket ']' and ``right`` to be a right-hand - brace '\\}', and it will be typeset correctly. + Putting aside aesthetics, you may combine these in any way + imaginable; for example, you could set ``left`` to be a right-hand + bracket ``']'`` and ``right`` to be a right-hand brace ``'\\}'``, and it + will be typeset correctly. EXAMPLES:: @@ -1288,10 +1222,10 @@ def vector_delimiters(self, left=None, right=None): sage: a = vector(QQ, [1,2,3]) sage: latex(a) \left(1,\,2,\,3\right) - sage: latex.vector_delimiters("[", "]") + sage: latex.vector_delimiters('[', ']') sage: latex(a) \left[1,\,2,\,3\right] - sage: latex.vector_delimiters(right="\\}") + sage: latex.vector_delimiters(right='\\}') sage: latex(a) \left[1,\,2,\,3\right\} sage: latex.vector_delimiters() @@ -1299,7 +1233,7 @@ def vector_delimiters(self, left=None, right=None): Restore defaults:: - sage: latex.vector_delimiters("(", ")") + sage: latex.vector_delimiters('(', ')') """ if left is None and right is None: return _Latex_prefs._option['vector_delimiters'] @@ -1387,7 +1321,7 @@ def check_file(self, file_name, more_info=""): - ``file_name`` -- a string - - ``more_info`` -- a string (default: "") + - ``more_info`` -- a string (default: ``""``) Emit a warning if the local LaTeX installation does not include ``file_name``. The string ``more_info`` is appended @@ -1417,7 +1351,7 @@ def check_file(self, file_name, more_info=""): def extra_macros(self, macros=None): r"""nodetex - String containing extra LaTeX macros to use with %latex and %html. + String containing extra LaTeX macros to use with ``%latex`` and ``%html``. INPUT: @@ -1500,7 +1434,7 @@ def extra_preamble(self, s=None): def add_to_preamble(self, s): r"""nodetex Append to the string ``s`` of extra LaTeX macros, for use with - %latex. + ``%latex``. EXAMPLES:: @@ -1523,7 +1457,7 @@ def add_to_preamble(self, s): sage: latex.extra_preamble() '\\DeclareMathOperator{\\Ext}{Ext}\\usepackage{xypic}' - Now one can put various xypic diagrams into a %latex cell, such as + Now one can put various xypic diagrams into a ``%latex`` cell, such as :: @@ -1576,7 +1510,7 @@ def engine(self, e=None): INPUT: - - ``e`` -- 'latex', 'pdflatex', 'xelatex' or ``None`` + - ``e`` -- ``'latex'``, ``'pdflatex'``, ``'xelatex'``, ``'lualatex'`` or ``None`` If ``e`` is ``None``, return the current engine. @@ -1590,14 +1524,14 @@ def engine(self, e=None): EXAMPLES:: - sage: latex.engine() - 'pdflatex' + sage: latex.engine() # random + 'lualatex' sage: latex.engine("latex") sage: latex.engine() 'latex' - sage: latex.engine("xelatex") + sage: latex.engine("pdflatex") sage: latex.engine() - 'xelatex' + 'pdflatex' """ if e is None: return _Latex_prefs._option["engine"] @@ -1611,8 +1545,12 @@ def engine(self, e=None): elif e == "xelatex": _Latex_prefs._option["engine"] = e _Latex_prefs._option["engine_name"] = "XeLaTeX" + elif e == "lualatex": + _Latex_prefs._option["engine"] = e + _Latex_prefs._option["engine_name"] = "LuaLaTeX" else: - raise ValueError("%s is not a supported LaTeX engine. Use latex, pdflatex, or xelatex" % e) + raise ValueError("%s is not a supported LaTeX engine. Use latex, pdflatex, xelatex, or lualatex" % e) + # Note: latex used to be a separate function, which by default was # only loaded in command-line mode: in the old notebook, @@ -1621,13 +1559,10 @@ def engine(self, e=None): # function. This has been changed around so that the contents of the # old latex function are now in Latex.__call__; thus the following # assignment. - - latex = Latex() # Ensure that latex appear in the sphinx doc as a function # so that the link :func:`latex` is correctly set up. latex.__doc__ = Latex.__call__.__doc__ -######################################### def _latex_file_(objects, title='SAGE', debug=False, @@ -1640,22 +1575,22 @@ def _latex_file_(objects, title='SAGE', debug=False, INPUT: - - ``objects`` -- list (or object) + - ``objects`` -- list (or object) - - ``title`` -- string (default: 'Sage'): title for the document + - ``title`` -- string (default: 'Sage'); title for the document - - ``math_left`` -- string (default: '\\['), left delimiter for math mode + - ``math_left`` -- string (default: '\\['), left delimiter for math mode - - ``math_right`` -- string (default: '\\]'), right delimiter for math mode + - ``math_right`` -- string (default: '\\]'), right delimiter for math mode - - ``debug`` -- bool (default: False): print verbose output + - ``debug`` -- bool (default: False); print verbose output - - ``sep`` -- string (default: ''): separator between math objects + - ``sep`` -- string (default: ``''``); separator between math objects - - ``tiny`` -- bool (default: False): use 'tiny' font. + - ``tiny`` -- bool (default: False); use 'tiny' font. - - ``extra_preamble`` -- string (default: ''): extra LaTeX commands, - inserted before "\\begin{document}" + - ``extra_preamble`` -- string (default: ``''``); extra LaTeX commands, + inserted before ``"\\begin{document}"`` This creates a string intended to be a LaTeX file containing the LaTeX representations of objects. It contains the following: @@ -1674,7 +1609,7 @@ def _latex_file_(objects, title='SAGE', debug=False, Then if ``objects`` contains more than one element, for each remaining element: - - the string ``sep``: you can use this, for example, to add + - the string ``sep``; you can use this, for example, to add vertical space between objects with ``sep='\\vspace{15mm}'``, or to add a horizontal line between objects with ``sep='\\hrule'``, or to insert a page break between objects @@ -1682,7 +1617,7 @@ def _latex_file_(objects, title='SAGE', debug=False, - the LaTeX representation of the element - The string ends with '\\end{document}'. + The string ends with ``'\\end{document}'``. EXAMPLES:: @@ -1757,7 +1692,7 @@ def _latex_file_(objects, title='SAGE', debug=False, def view(objects, title='Sage', debug=False, sep='', tiny=False, - pdflatex=None, engine=None, viewer=None, tightpage=True, margin=None, + engine=None, viewer=None, tightpage=True, margin=None, mode='inline', combine_all=False, **kwds): r"""nodetex Compute a latex representation of each object in objects, compile, @@ -1766,50 +1701,49 @@ def view(objects, title='Sage', debug=False, sep='', tiny=False, INPUT: - - ``objects`` -- list (or object) + - ``objects`` -- list (or object) - - ``title`` -- string (default: ``'Sage'``): title for the + - ``title`` -- string (default: ``'Sage'``); title for the document - - ``debug`` -- bool (default: ``False``): print verbose + - ``debug`` -- bool (default: ``False``); print verbose output - - ``sep`` -- string (default: ''): separator between + - ``sep`` -- string (default: ``''``); separator between math objects - - ``tiny`` -- bool (default: ``False``): use tiny font. - - - ``pdflatex`` -- bool (default: ``False``): use pdflatex. This is - deprecated. Use ``'engine'`` option instead. + - ``tiny`` -- bool (default: ``False``); use tiny font. - - ``engine`` -- string or ``None`` (default: ``None``). Can take the + - ``engine`` -- string or ``None`` (default: ``None``); can take the following values: - - ``None`` -- the value defined in the LaTeX global preferences - ``latex.engine()`` is used. + - ``None`` -- the value defined in the LaTeX global preferences + ``latex.engine()`` is used. - - ``'pdflatex'`` -- compilation does tex -> pdf + - ``'pdflatex'`` -- compilation does ``tex`` -> ``pdf`` - - ``'xelatex'`` -- compilation does tex -> pdf + - ``'xelatex'`` -- compilation does ``tex`` -> ``pdf`` - - ``'latex'`` -- compilation first tries tex -> dvi -> png and if an - error occurs then tries dvi -> ps -> pdf. This is slower than - ``'pdflatex'`` and known to be broken when overfull hbox are detected. + - ``'lualatex'`` -- compilation does ``tex`` -> ``pdf`` - - ``viewer`` -- string or ``None`` (default: ``None``): specify a viewer + - ``'latex'`` -- compilation first tries ``tex`` -> ``dvi`` -> ``png`` and if an + error occurs then tries ``dvi`` -> ``ps`` -> ``pdf``. This is slower than + ``'pdflatex'`` and known to be broken when overfull hboxes are detected. + + - ``viewer`` -- string or ``None`` (default: ``None``); specify a viewer to use; currently the only options are ``None`` and ``'pdf'``. - - ``tightpage`` -- bool (default: ``True``): use the LaTeX package - 'preview' with the 'tightpage' option. + - ``tightpage`` -- bool (default: ``True``); use the LaTeX package + ``preview`` with the 'tightpage' option. - - ``margin`` -- float or ``None`` (default: ``None``): adds a margin + - ``margin`` -- float or ``None`` (default: ``None``); adds a margin of ``margin`` mm; has no affect if the option ``tightpage`` is ``False``. - - ``mode`` -- string (default: ``'inline'``): ``'display'`` for + - ``mode`` -- string (default: ``'inline'``); ``'display'`` for displaymath or ``'inline'`` for inline math - - ``combine_all`` -- bool (default: ``False``): If ``combine_all`` is + - ``combine_all`` -- bool (default: ``False``); if ``combine_all`` is ``True`` and 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. @@ -1829,20 +1763,17 @@ def view(objects, title='Sage', debug=False, sep='', tiny=False, adds a horizontal line between objects, and ``sep='\\newpage'`` inserts a page break between objects. - If ``pdflatex`` is ``True``, then the latex engine is set to - pdflatex. - - If the ``engine`` is either ``pdflatex`` or ``xelatex``, it produces - a pdf file. Otherwise, it produces a dvi file, and if the program dvipng is - 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. + If the ``engine`` is either ``'pdflatex'``, ``'xelatex'``, or ``'lualatex'``, + it produces a pdf file. Otherwise, it produces a dvi file, and if the program + ``dvipng`` is 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 ``viewer`` to ``'pdf'`` forces the use of a separate viewer, even in notebook mode. This also sets the latex engine to be - ``pdflatex`` if the current engine is latex. + ``pdflatex`` if the current engine is ``latex``. Setting the option ``tightpage`` to ``True`` (this is the default setting) tells LaTeX to use the package 'preview' with the 'tightpage' option. @@ -1921,7 +1852,7 @@ def view(objects, title='Sage', debug=False, sep='', tiny=False, s = _latex_file_(objects, title=title, sep=sep, tiny=tiny, debug=debug, **latex_options) if engine is None: engine = _Latex_prefs._option["engine"] - if pdflatex or (viewer == "pdf" and engine == "latex"): + if viewer == "pdf" and engine == "latex": engine = "pdflatex" # command line or notebook with viewer @@ -1970,42 +1901,37 @@ def run_viewer(): def png(x, filename, density=150, debug=False, - do_in_background=False, tiny=False, pdflatex=True, engine='pdflatex'): + do_in_background=False, tiny=False, engine=None): """ Create a png image representation of ``x`` and save to the given filename. INPUT: - - ``x`` -- object to be displayed - - - ``filename`` -- file in which to save the image + - ``x`` -- object to be displayed - - ``density`` -- integer (default: 150) + - ``filename`` -- file in which to save the image - - ``debug`` -- bool (default: ``False``): print verbose - output + - ``density`` -- integer (default: 150) - - ``do_in_background`` -- bool (default: ``False``): Unused, - kept for backwards compatibility + - ``debug`` -- bool (default: ``False``); print verbose output - - ``tiny`` -- bool (default: ``False``): use 'tiny' font + - ``do_in_background`` -- bool (default: ``False``); Unused, kept for + backwards compatibility - - ``pdflatex`` -- bool (default: ``True``): use pdflatex. This option is - deprecated. Use ``engine`` option instead. See below. + - ``tiny`` -- bool (default: ``False``); use tiny font - - ``engine`` -- (default: ``'pdflatex'``) ``'latex'``, ``'pdflatex'``, - or ``'xelatex'`` + - ``engine`` -- (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 # optional - imagemagick latex, needs sage.plot + sage: with tempfile.NamedTemporaryFile(suffix=".png") as f: # random ....: png(ZZ[x], f.name) """ - if not pdflatex: - engine = "latex" import sage.plot.all if sage.plot.graphics.is_Graphics(x): x.save(filename) @@ -2014,6 +1940,8 @@ def png(x, filename, density=150, debug=False, s = _latex_file_([x], math_left='$\\displaystyle', math_right='$', title='', debug=debug, tiny=tiny, extra_preamble='\\textheight=2\\textheight') + if engine is None: + engine = _Latex_prefs._option["engine"] # path name for permanent png output abs_path_to_png = os.path.abspath(filename) # temporary directory to store stuff @@ -2076,13 +2004,11 @@ def repr_lincomb(symbols, coeffs): INPUT: - - ``symbols`` -- list of symbols + - ``symbols`` -- list of symbols - - ``coeffs`` -- list of coefficients of the symbols + - ``coeffs`` -- list of coefficients of the symbols - OUTPUT: - - A string + OUTPUT: A string EXAMPLES:: @@ -2213,9 +2139,7 @@ def latex_varify(a, is_fname=False): - ``a`` -- string - OUTPUT: - - A string + OUTPUT: A string EXAMPLES:: @@ -2260,7 +2184,7 @@ def latex_variable_name(x, is_fname=False): 2. If the variable name is suffixed by a number, we put the number in the subscript. - 3. If the variable name contains an '_' we start the subscript at + 3. If the variable name contains an ``'_'`` we start the subscript at the underscore. Note that #3 trumps rule #2. 4. If a component of the variable is a Greek letter, escape it @@ -2467,7 +2391,7 @@ def _repr_(self): make sure that you have the most recent version of the TeX package pstricks installed. Run 'latex.add_to_preamble("\\usepackage{pstricks}")' and try viewing it again. Call 'view' with the option `engine='latex'` --- the default behavior is to use pdflatex, which does not work with +-- the default behavior is to use lualatex, which does not work with pstricks. From the command line, this should pop open a nice window with a picture of forces acting on a mass on a pendulum.""" diff --git a/src/sage_docbuild/conf.py b/src/sage_docbuild/conf.py index 8602016d042..0ab862c7a13 100644 --- a/src/sage_docbuild/conf.py +++ b/src/sage_docbuild/conf.py @@ -198,6 +198,10 @@ def sphinx_plot(graphics, **kwds): # for a list of supported languages. #language = None +# The LaTeX engine to build the docs. +# https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-latex_engine +latex_engine = 'lualatex' + # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: #today = '' @@ -502,182 +506,6 @@ def set_intersphinx_mappings(app, config): \usepackage{mathrsfs} \usepackage{iftex} -% Only declare unicode characters when compiling with pdftex; E.g. japanese -% tutorial does not use pdftex -\ifPDFTeX - \DeclareUnicodeCharacter{01CE}{\capitalcaron a} - \DeclareUnicodeCharacter{0428}{cyrillic Sha} - \DeclareUnicodeCharacter{250C}{+} - \DeclareUnicodeCharacter{2510}{+} - \DeclareUnicodeCharacter{2514}{+} - \DeclareUnicodeCharacter{2518}{+} - \DeclareUnicodeCharacter{253C}{+} - - \DeclareUnicodeCharacter{03B1}{\ensuremath{\alpha}} - \DeclareUnicodeCharacter{03B2}{\ensuremath{\beta}} - \DeclareUnicodeCharacter{03B3}{\ensuremath{\gamma}} - \DeclareUnicodeCharacter{0393}{\ensuremath{\Gamma}} - \DeclareUnicodeCharacter{03B4}{\ensuremath{\delta}} - \DeclareUnicodeCharacter{0394}{\ensuremath{\Delta}} - \DeclareUnicodeCharacter{03B5}{\ensuremath{\varepsilon}} - \DeclareUnicodeCharacter{03B6}{\ensuremath{\zeta}} - \DeclareUnicodeCharacter{03B7}{\ensuremath{\eta}} - \DeclareUnicodeCharacter{03B8}{\ensuremath{\vartheta}} - \DeclareUnicodeCharacter{0398}{\ensuremath{\Theta}} - \DeclareUnicodeCharacter{03BA}{\ensuremath{\kappa}} - \DeclareUnicodeCharacter{03BB}{\ensuremath{\lambda}} - \DeclareUnicodeCharacter{039B}{\ensuremath{\Lambda}} - \DeclareUnicodeCharacter{00B5}{\ensuremath{\mu}} % micron sign - \DeclareUnicodeCharacter{03BC}{\ensuremath{\mu}} - \DeclareUnicodeCharacter{03BD}{\ensuremath{\nu}} - \DeclareUnicodeCharacter{03BE}{\ensuremath{\xi}} - \DeclareUnicodeCharacter{039E}{\ensuremath{\Xi}} - \DeclareUnicodeCharacter{03B9}{\ensuremath{\iota}} - \DeclareUnicodeCharacter{03C0}{\ensuremath{\pi}} - \DeclareUnicodeCharacter{03A0}{\ensuremath{\Pi}} - \DeclareUnicodeCharacter{03C1}{\ensuremath{\rho}} - \DeclareUnicodeCharacter{03C3}{\ensuremath{\sigma}} - \DeclareUnicodeCharacter{03A3}{\ensuremath{\Sigma}} - \DeclareUnicodeCharacter{03C4}{\ensuremath{\tau}} - \DeclareUnicodeCharacter{03C6}{\ensuremath{\varphi}} - \DeclareUnicodeCharacter{03A6}{\ensuremath{\Phi}} - \DeclareUnicodeCharacter{03C7}{\ensuremath{\chi}} - \DeclareUnicodeCharacter{03C8}{\ensuremath{\psi}} - \DeclareUnicodeCharacter{03A8}{\ensuremath{\Psi}} - \DeclareUnicodeCharacter{03C9}{\ensuremath{\omega}} - \DeclareUnicodeCharacter{03A9}{\ensuremath{\Omega}} - \DeclareUnicodeCharacter{03C5}{\ensuremath{\upsilon}} - \DeclareUnicodeCharacter{03A5}{\ensuremath{\Upsilon}} - \DeclareUnicodeCharacter{2113}{\ell} - - \DeclareUnicodeCharacter{2148}{\ensuremath{\id}} - \DeclareUnicodeCharacter{2202}{\ensuremath{\partial}} - \DeclareUnicodeCharacter{2205}{\ensuremath{\emptyset}} - \DeclareUnicodeCharacter{2208}{\ensuremath{\in}} - \DeclareUnicodeCharacter{2209}{\ensuremath{\notin}} - \DeclareUnicodeCharacter{2211}{\ensuremath{\sum}} - \DeclareUnicodeCharacter{221A}{\ensuremath{\sqrt{}}} - \DeclareUnicodeCharacter{221E}{\ensuremath{\infty}} - \DeclareUnicodeCharacter{2227}{\ensuremath{\wedge}} - \DeclareUnicodeCharacter{2228}{\ensuremath{\vee}} - \DeclareUnicodeCharacter{2229}{\ensuremath{\cap}} - \DeclareUnicodeCharacter{222A}{\ensuremath{\cup}} - \DeclareUnicodeCharacter{222B}{\ensuremath{\int}} - \DeclareUnicodeCharacter{2248}{\ensuremath{\approx}} - \DeclareUnicodeCharacter{2260}{\ensuremath{\neq}} - \DeclareUnicodeCharacter{2264}{\ensuremath{\leq}} - \DeclareUnicodeCharacter{2265}{\ensuremath{\geq}} - \DeclareUnicodeCharacter{2293}{\ensuremath{\sqcap}} - \DeclareUnicodeCharacter{2294}{\ensuremath{\sqcup}} - \DeclareUnicodeCharacter{22C0}{\ensuremath{\bigwedge}} - \DeclareUnicodeCharacter{22C1}{\ensuremath{\bigvee}} - \DeclareUnicodeCharacter{22C2}{\ensuremath{\bigcap}} - \DeclareUnicodeCharacter{22C3}{\ensuremath{\bigcup}} - \DeclareUnicodeCharacter{2323}{\ensuremath{\smile}} % cup product - \DeclareUnicodeCharacter{00B1}{\ensuremath{\pm}} - \DeclareUnicodeCharacter{2A02}{\ensuremath{\bigotimes}} - \DeclareUnicodeCharacter{2295}{\ensuremath{\oplus}} - \DeclareUnicodeCharacter{2297}{\ensuremath{\otimes}} - \DeclareUnicodeCharacter{2A01}{\ensuremath{\oplus}} - \DeclareUnicodeCharacter{00BD}{\ensuremath{\nicefrac{1}{2}}} - \DeclareUnicodeCharacter{00D7}{\ensuremath{\times}} - \DeclareUnicodeCharacter{00B7}{\ensuremath{\cdot}} - \DeclareUnicodeCharacter{230A}{\ensuremath{\lfloor}} - \DeclareUnicodeCharacter{230B}{\ensuremath{\rfloor}} - \DeclareUnicodeCharacter{2308}{\ensuremath{\lceil}} - \DeclareUnicodeCharacter{2309}{\ensuremath{\rceil}} - \DeclareUnicodeCharacter{22C5}{\ensuremath{\cdot}} - \DeclareUnicodeCharacter{2227}{\ensuremath{\wedge}} - \DeclareUnicodeCharacter{22C0}{\ensuremath{\bigwedge}} - \DeclareUnicodeCharacter{2192}{\ensuremath{\to}} - \DeclareUnicodeCharacter{21A6}{\ensuremath{\mapsto}} - \DeclareUnicodeCharacter{2102}{\ensuremath{\mathbb{C}}} - \DeclareUnicodeCharacter{211A}{\ensuremath{\mathbb{Q}}} - \DeclareUnicodeCharacter{211D}{\ensuremath{\mathbb{R}}} - \DeclareUnicodeCharacter{2124}{\ensuremath{\mathbb{Z}}} - \DeclareUnicodeCharacter{2202}{\ensuremath{\partial}} - - \DeclareUnicodeCharacter{2070}{\ensuremath{{}^0}} - \DeclareUnicodeCharacter{00B9}{\ensuremath{{}^1}} - \DeclareUnicodeCharacter{00B2}{\ensuremath{{}^2}} - \DeclareUnicodeCharacter{00B3}{\ensuremath{{}^3}} - \DeclareUnicodeCharacter{2074}{\ensuremath{{}^4}} - \DeclareUnicodeCharacter{2075}{\ensuremath{{}^5}} - \DeclareUnicodeCharacter{2076}{\ensuremath{{}^6}} - \DeclareUnicodeCharacter{2077}{\ensuremath{{}^7}} - \DeclareUnicodeCharacter{2078}{\ensuremath{{}^8}} - \DeclareUnicodeCharacter{2079}{\ensuremath{{}^9}} - \DeclareUnicodeCharacter{207A}{\ensuremath{{}^+}} - \DeclareUnicodeCharacter{207B}{\ensuremath{{}^-}} - \DeclareUnicodeCharacter{141F}{\ensuremath{{}^/}} - \DeclareUnicodeCharacter{2080}{\ensuremath{{}_0}} - \DeclareUnicodeCharacter{2081}{\ensuremath{{}_1}} - \DeclareUnicodeCharacter{2082}{\ensuremath{{}_2}} - \DeclareUnicodeCharacter{2083}{\ensuremath{{}_3}} - \DeclareUnicodeCharacter{2084}{\ensuremath{{}_4}} - \DeclareUnicodeCharacter{2085}{\ensuremath{{}_5}} - \DeclareUnicodeCharacter{2086}{\ensuremath{{}_6}} - \DeclareUnicodeCharacter{2087}{\ensuremath{{}_7}} - \DeclareUnicodeCharacter{2088}{\ensuremath{{}_8}} - \DeclareUnicodeCharacter{2089}{\ensuremath{{}_9}} - \DeclareUnicodeCharacter{208A}{\ensuremath{{}_+}} - \DeclareUnicodeCharacter{208B}{\ensuremath{{}_-}} - \DeclareUnicodeCharacter{1D62}{\ensuremath{{}_i}} - \DeclareUnicodeCharacter{2C7C}{\ensuremath{{}_j}} - - \newcommand{\sageMexSymbol}[1] - {{\fontencoding{OMX}\fontfamily{cmex}\selectfont\raisebox{0.75em}{\symbol{#1}}}} - \DeclareUnicodeCharacter{239B}{\sageMexSymbol{"30}} % parenlefttp - \DeclareUnicodeCharacter{239C}{\sageMexSymbol{"42}} % parenleftex - \DeclareUnicodeCharacter{239D}{\sageMexSymbol{"40}} % parenleftbt - \DeclareUnicodeCharacter{239E}{\sageMexSymbol{"31}} % parenrighttp - \DeclareUnicodeCharacter{239F}{\sageMexSymbol{"43}} % parenrightex - \DeclareUnicodeCharacter{23A0}{\sageMexSymbol{"41}} % parenrightbt - \DeclareUnicodeCharacter{23A1}{\sageMexSymbol{"32}} % bracketlefttp - \DeclareUnicodeCharacter{23A2}{\sageMexSymbol{"36}} % bracketleftex - \DeclareUnicodeCharacter{23A3}{\sageMexSymbol{"34}} % bracketleftbt - \DeclareUnicodeCharacter{23A4}{\sageMexSymbol{"33}} % bracketrighttp - \DeclareUnicodeCharacter{23A5}{\sageMexSymbol{"37}} % bracketrightex - \DeclareUnicodeCharacter{23A6}{\sageMexSymbol{"35}} % bracketrightbt - - \DeclareUnicodeCharacter{23A7}{\sageMexSymbol{"38}} % curly brace left top - \DeclareUnicodeCharacter{23A8}{\sageMexSymbol{"3C}} % curly brace left middle - \DeclareUnicodeCharacter{23A9}{\sageMexSymbol{"3A}} % curly brace left bottom - \DeclareUnicodeCharacter{23AA}{\sageMexSymbol{"3E}} % curly brace extension - \DeclareUnicodeCharacter{23AB}{\sageMexSymbol{"39}} % curly brace right top - \DeclareUnicodeCharacter{23AC}{\sageMexSymbol{"3D}} % curly brace right middle - \DeclareUnicodeCharacter{23AD}{\sageMexSymbol{"3B}} % curly brace right bottom - \DeclareUnicodeCharacter{23B0}{\{} % 2-line curly brace left top half (not in cmex) - \DeclareUnicodeCharacter{23B1}{\}} % 2-line curly brace right top half (not in cmex) - - \DeclareUnicodeCharacter{2320}{\ensuremath{\int}} % top half integral - \DeclareUnicodeCharacter{2321}{\ensuremath{\int}} % bottom half integral - \DeclareUnicodeCharacter{23AE}{\ensuremath{\|}} % integral extenison - - % Box drawings light - \DeclareUnicodeCharacter{2500}{-} % h - \DeclareUnicodeCharacter{2502}{|} % v - \DeclareUnicodeCharacter{250C}{+} % dr - \DeclareUnicodeCharacter{2510}{+} % dl - \DeclareUnicodeCharacter{2514}{+} % ur - \DeclareUnicodeCharacter{2518}{+} % ul - \DeclareUnicodeCharacter{251C}{+} % vr - \DeclareUnicodeCharacter{2524}{+} % vl - \DeclareUnicodeCharacter{252C}{+} % dh - \DeclareUnicodeCharacter{2534}{+} % uh - \DeclareUnicodeCharacter{253C}{+} % vh - \DeclareUnicodeCharacter{2571}{/} % upper right to lower left - \DeclareUnicodeCharacter{2572}{\ensuremath{\setminus}} % upper left to lower right - \DeclareUnicodeCharacter{2573}{X} % diagonal cross - - \DeclareUnicodeCharacter{25CF}{\ensuremath{\bullet}} % medium black circle - \DeclareUnicodeCharacter{26AC}{\ensuremath{\circ}} % medium small white circle - \DeclareUnicodeCharacter{256D}{+} - \DeclareUnicodeCharacter{256E}{+} - \DeclareUnicodeCharacter{256F}{+} - \DeclareUnicodeCharacter{2570}{+} -\fi - \let\textLaTeX\LaTeX \AtBeginDocument{\renewcommand*{\LaTeX}{\hbox{\textLaTeX}}}