-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
[DOC] LaTeX: fix preamble (closes #15026) #15028
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Memo: latex_preamble got removed from Sphinx at 1.6.1, and old LaTeX package expdlist requires a fix else it breaks LaTeX if a description list is in a table cell, and it causes anyhow many LaTeX complaints about Underfull box (badness 10000). The fix for these complaints is copied over from scipy/scipy@c881fdea7a7ef7c518b789 and it turns out it is also a fix for the crash in case a description list is in a table..
Trying this out, I get an error
Do I have to update something in my latex/tex installation (on Ubuntu 18.04)? |
@mattip The preamble which this PR activates contained the Additionally documentation of (copied from Sphinx doc)
(end of copied text)
Yes, probably... as numpy does not modify Usage of this |
edit: actually the numpy conf.py has
so this does not come from |
ah ok I understand, the error was masked by "batchmode" previously on your system with a missing dependency. I tried with this latex file \documentclass{article}
\usepackage[LGRR,T1]{fontenc}
\begin{document}
coucou
\end{document} then $ pdflatex --interaction batchmode testbatchmode.tex
This is pdfTeX, Version 3.14159265-2.6-1.40.20 (TeX Live 2019) (preloaded format=pdflatex)
restricted \write18 enabled.
entering extended mode has no trace of the missing file error but
|
@mattip I was going to suggest possibly dropping LGR but in fact numpy-ref.pdf needs it because of Lines 52 to 60 in b03fab8
If one drops LGR, then one gets while building numpy-ref.pdf:
With LGR included, the Sphinx 2.0 mechanism triggers in, and package |
Thanks, that solved it. So we should mention that somewhere in our dependencies. I think the how to build docs might be appropriate. |
@mattip The problem with such documentation is that it could be non obvious to cover all various Linux distros. Specific Sphinx LaTeX requirements are enumerated here but only mention Ubuntu. Does it matter between requiring |
I think it is fine to start with Ubuntu. The important thing is have some kind of indication of installation requirements, then users can adapt them to their build systems. Extra points for working |
@mattip ok, before actually pushing a commit to add such user info, one last thing. Is there any potential for Numpy docs becoming populated with Unicode apart from individual Greek or Cyrillic letters? Sphinx since 2.0.0 has built-in automatic support via pdflatex route for those (adding resp. LGR and X2 or T2A to 'fontenc' key) but this does not cover things such as Unicode math glyphs (in plain text). I have submitted a matplotlib PR to help build their PDF docs, and it is mandatory at their project to use |
Let's try to keep it simple and only add the support for mathematical symbols for now, we can always revisit this in the future. |
@@ -5,7 +5,7 @@ Building the NumPy API and reference docs | |||
========================================= | |||
|
|||
We currently use Sphinx_ for generating the API and reference | |||
documentation for NumPy. You will need Sphinx 1.8.3 <= 1.8.5. | |||
documentation for NumPy. You will need Sphinx >= 2.0.0. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I felt bad about doing this only for latex PDF, but it seems testing (I don't know if that includes building docs, and possibly it does it only for html) goes via .circleci/config.yml which has sphinx==2.2.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There were problems with sphinx 2.0.0, we should document what we use in the circle CI html run: 2.2.0
You will need to have Latex installed for this. | ||
You will need to have Latex installed for this, inclusive of support for | ||
Greek letters. For example, on Ubuntu xenial ``texlive-lang-greek`` and | ||
``cm-super`` are needed. Also ``latexmk`` is needed on non-Windows systems. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, the texlive-lang-greek
and cm-super
dependencies could be avoided via this diff
diff --git a/numpy/doc/constants.py b/numpy/doc/constants.py
index 72793e44d..fc3ca4b2c 100644
--- a/numpy/doc/constants.py
+++ b/numpy/doc/constants.py
@@ -51,7 +51,7 @@ add_newdoc('numpy', 'e',
add_newdoc('numpy', 'euler_gamma',
"""
- ``γ = 0.5772156649015328606065120900824024310421...``
+ :math:`\\gamma` ``= 0.5772156649015328606065120900824024310421...``
References
----------
and one must (else Sphinx 2.x mechanism for Greek is triggered and there will be error about missing lgrenc.def
file if texlive-lang-greek
is not installed) remove LGR
from latex_elements['fontenc']
configuration in doc/source/conf.py
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should document what we need to do, so either use gamma and remove LGR
or leave it as-is.
About my comments about |
I can check that it works locally on an Ubuntu machine. So we are almost there: just need to change the sphinx version to 2.2 and decide whether to use |
Is this gamma symbol supposed to be usable by copy-paste or Numpy users use I we use LGR, the PDF will give (at least in my testing with Skim.app on macos x) via copy paste the same as original in source i.e. γ GREEK SMALL LETTER GAMMA. |
Let's just put this in as-is, we can fix up the niggle about the sphinx version and greek rendering in a subsequent PR, since the documentation building directions need some editing cleanup anyway. |
Thanks @jfbu, looking forward to more contributions in the future. |
@mattip thanks now lunch time :-) |
But removing enumitem package reveals a bug in expdlist. Import the fix from the SciPy and NumPy projects. numpy/numpy#15028 scipy/scipy@c881fde
- remove loading of amsmath, amssymb, amsfonts (already done by sphinx.sty) - remove loading of txfonts (not compatible with xetex/fontspec) - patch old obsolete expdlist.sty - resolve "Too deeply nested" error without using enumitem package. This Imports the fix already applied to NumPy and SciPy numpy/numpy#15028 scipy/scipy@c881fde - use XITS and XITS Math for wide enough Unicode coverage. As XITS has all the Unicode mathematical symbols needed for the section of the documentation related to Mathtext. (DejaVu Serif was missing 134 of them, and GNU FreeFont 19 of them) The Ubuntu package texlive-fonts-extra provides these latex dependencies. - better looking general index in PDF documentation - backport sphinx-doc/sphinx/pull/6888 to fix double quote issue
But removing enumitem package reveals a bug in expdlist. Import the fix from the SciPy and NumPy projects. numpy/numpy#15028 scipy/scipy@c881fde
But removing enumitem package reveals a bug in expdlist. Import the fix from the SciPy and NumPy projects. numpy/numpy#15028 scipy/scipy@c881fde
I tried it out only with Python 3.7.5 (CPython), Sphinx 2.2.1.
I feel
--halt-on-error
is better than-interaction = batchmode
(anyhow this was not applied because Sphinx LaTeX Makefile changed at 1.6). In both cases latexmk exists with an error, but the former will have the error crashing the build be the last thing in the LaTeX log file.But I separated this as a second commit so the two commits can be considered separately.