Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[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

Merged
merged 3 commits into from
Dec 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ latex-build: generate
mkdir -p build/latex build/doctrees
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) build/latex $(FILES)
$(PYTHON) postprocess.py tex build/latex/*.tex
perl -pi -e 's/\t(latex.*|pdflatex) (.*)/\t-$$1 -interaction batchmode $$2/' build/latex/Makefile
perl -pi -e 's/LATEXOPTS =/LATEXOPTS ?= --halt-on-error/' build/latex/Makefile
@echo
@echo "Build finished; the LaTeX files are in build/latex."
@echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
Expand Down
21 changes: 17 additions & 4 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,28 @@ def setup(app):
}

# Additional stuff for the LaTeX preamble.
latex_preamble = r'''
\usepackage{amsmath}
\DeclareUnicodeCharacter{00A0}{\nobreakspace}

latex_elements['preamble'] = r'''
% In the parameters section, place a newline after the Parameters
% header
\usepackage{expdlist}
\let\latexdescription=\description
\def\description{\latexdescription{}{} \breaklabel}
% but expdlist old LaTeX package requires fixes:
% 1) remove extra space
\usepackage{etoolbox}
\makeatletter
\patchcmd\@item{{\@breaklabel} }{{\@breaklabel}}{}{}
\makeatother
% 2) fix bug in expdlist's way of breaking the line after long item label
\makeatletter
\def\breaklabel{%
\def\@breaklabel{%
\leavevmode\par
% now a hack because Sphinx inserts \leavevmode after term node
\def\leavevmode{\def\leavevmode{\unhbox\voidb@x}}%
}%
}
\makeatother

% Make Examples/etc section headers smaller and more compact
\makeatletter
Expand Down
6 changes: 4 additions & 2 deletions doc/source/docs/howto_build_docs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Copy link
Contributor Author

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

Copy link
Member

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


If you only want to get the documentation, note that pre-built
versions can be found at
Expand Down Expand Up @@ -57,7 +57,9 @@ To build the PDF documentation, do instead::
make latex
make -C build/latex all-pdf

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.
Copy link
Contributor Author

@jfbu jfbu Dec 4, 2019

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.

Copy link
Member

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.


Instead of the above, you can also do::

Expand Down