From 451115f2d1bdfd95c176322c0f64a615e393f9e3 Mon Sep 17 00:00:00 2001 From: jfbu Date: Sun, 5 Feb 2017 20:02:19 +0100 Subject: [PATCH] no need to pass truedimen as class option, package option is enough --- doc/config.rst | 28 +++++++++++----------- doc/latex.rst | 48 +++++++++++++++++++++++-------------- sphinx/texinputs/sphinx.sty | 5 ++++ sphinx/writers/latex.py | 5 ---- tests/test_build_latex.py | 2 +- 5 files changed, 50 insertions(+), 38 deletions(-) diff --git a/doc/config.rst b/doc/config.rst index a7707590e..220d6bdb0 100644 --- a/doc/config.rst +++ b/doc/config.rst @@ -1733,11 +1733,15 @@ These options influence LaTeX output. See further :doc:`latex`. ``'geometry'`` "geometry" package inclusion, the default definition is: - ``'\\usepackage{geometry}'`` (with ``[dvipdfm]`` for Japanese documents) + ``'\\usepackage{geometry}'`` - and :file:`sphinx.sty` executes a ``\PassOptionsToPackages`` with - ``hmargin=1in,vmargin=1in,marginparwidth=0.5in``. See :doc:`latex` - for the corresponding ``'sphinxsetup'`` options. + with an additional ``[dvipdfm]`` for Japanese documents. + The Sphinx LaTeX style file executes: + + ``\PassOptionsToPackage{hmargin=1in,vmargin=1in,marginpar=0.5in}{geometry}`` + + which can be customized via corresponding ``'sphinxsetup'`` options. + See :doc:`latex`. .. versionadded:: 1.5 @@ -1745,24 +1749,20 @@ These options influence LaTeX output. See further :doc:`latex`. ``dvipdfm`` option if :confval:`latex_engine` is ``'platex'``. .. versionadded:: 1.5.3 - The ``'sphinxsetup'`` margin keys. See :doc:`latex`. + The ``'sphinxsetup'`` keys for ``hmargin, ...``. .. versionchanged:: 1.5.3 - The key is executed after the ``\sphinxsetup`` which follows + The execution has been moved to after the ``\sphinxsetup`` which follows immediately the loading of :file:`sphinx.sty`. This is in order to handle the paper layout options in a special way for Japanese documents: the text width will be set to an integer multiple of the *zenkaku* width, and the text height to an integer multiple of the baseline. - Further, as the ``jsbook`` Japanese standard document class handles - pointsize other than ``10pt`` in a special manner, Sphinx uses then - as first document class option ``truedimen``: this will be received - by ``geometry`` package and help it interpret correctly further - class options such as ``letterpaper`` or ``a4paper``. - - For ``jreport`` (Japanese ``'howto'`` documents), the situation is - otherwise, and the ``truedimen`` must not be used for ``geometry``. + For Japanese ``'manual'`` documents, Sphinx passes additionally to + ``geometry`` the ``truedimen`` option for compatibility with the way + the ``jsbook`` class handles dimensions when the pointsize is not + ``10pt``. ``'babel'`` "babel" package inclusion, default ``'\\usepackage{babel}'`` (the diff --git a/doc/latex.rst b/doc/latex.rst index 472d5e10b..75707026a 100644 --- a/doc/latex.rst +++ b/doc/latex.rst @@ -14,13 +14,19 @@ The *latex* target does not benefit from pre-prepared themes like the .. raw:: latex \begingroup - \sphinxsetup{verbatimwithframe=false,% - VerbatimColor={named}{OldLace}, TitleColor={named}{DarkGoldenrod},% - hintBorderColor={named}{LightCoral}, attentionBgColor={named}{LightPink},% - attentionborder=3pt, attentionBorderColor={named}{Crimson},% - noteBorderColor={named}{Olive}, noteborder=2pt,% - cautionBorderColor={named}{Cyan}, cautionBgColor={named}{LightCyan},% - cautionborder=3pt} + \sphinxsetup{% + verbatimwithframe=false, + VerbatimColor={named}{OldLace}, + TitleColor={named}{DarkGoldenrod}, + hintBorderColor={named}{LightCoral}, + attentionborder=3pt, + attentionBorderColor={named}{Crimson}, + attentionBgColor={named}{FloralWhite}, + noteborder=2pt, + noteBorderColor={named}{Olive}, + cautionborder=3pt, + cautionBorderColor={named}{Cyan}, + cautionBgColor={named}{LightCyan}} \relax @@ -109,13 +115,19 @@ If non-empty, it will be passed as argument to the ``\sphinxsetup`` command:: dynamically the option values: this is actually what we did for the duration of this chapter for the PDF output, which is styled using:: + \sphinxsetup{% verbatimwithframe=false, - VerbatimColor={named}{OldLace}, TitleColor={named}{DarkGoldenrod}, - hintBorderColor={named}{LightCoral}, attentionBgColor={named}{LightPink}, - attentionborder=3pt, attentionBorderColor={named}{Crimson}, - noteBorderColor={named}{Olive}, noteborder=2pt, - cautionBorderColor={named}{Cyan}, cautionBgColor={named}{LightCyan}, - cautionborder=3pt + VerbatimColor={named}{OldLace}, + TitleColor={named}{DarkGoldenrod}, + hintBorderColor={named}{LightCoral}, + attentionborder=3pt, + attentionBorderColor={named}{Crimson}, + attentionBgColor={named}{FloralWhite}, + noteborder=2pt, + noteBorderColor={named}{Olive}, + cautionborder=3pt, + cautionBorderColor={named}{Cyan}, + cautionBgColor={named}{LightCyan}} and with the ``svgnames`` option having been passed to "xcolor" package:: @@ -155,15 +167,15 @@ Here are the currently available options together with their default values. For a ``'manual'`` type document, which by default uses the ``jsbook`` LaTeX document class, the dimension units must be so-called "true" - units: + units:: - 'sphinxsetup': 'hmargin=1.5truein, vmargin=1.5truein, marginpar=2zw' + 'sphinxsetup': 'hmargin=1.5truein, vmargin=1.5truein, marginpar=5zw', - This is due to ``jsbook`` LaTeX class way of handling the pointsize - when it is not ``10pt``. + This is due to the LaTeX class ``jsbook``'s way of handling the + pointsize when it is not ``10pt``. To the contrary, the ``jreport`` class, which is used for ``'howto'`` - document must be configured with "normal" units. + documents, must be configured with "normal" units. .. versionadded:: 1.5.3 diff --git a/sphinx/texinputs/sphinx.sty b/sphinx/texinputs/sphinx.sty index 17b10d15a..62a1f9873 100644 --- a/sphinx/texinputs/sphinx.sty +++ b/sphinx/texinputs/sphinx.sty @@ -1086,6 +1086,11 @@ \newcommand*\sphinxtextlinesja[1]{% \numexpr\@ne+\dimexpr\paperheight-\topskip-\dimexpr#1+#1\relax\relax/ \baselineskip\relax}% + \ifx\@jsc@uplatextrue\undefined\else + % the way we found in order for the papersize special written by + % geometry in the dvi file to be correct in case of jsbook class + \PassOptionsToPackage{truedimen}{geometry}% + \fi \PassOptionsToPackage{% hmarginratio={1:1},% textwidth=\unexpanded{\sphinxtextwidthja{\spx@opt@hmargin}},% diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index 71dd62300..7a64fd936 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -436,11 +436,6 @@ class LaTeXTranslator(nodes.NodeVisitor): # pTeX (Japanese TeX) for support if builder.config.language == 'ja': - # if document uses Japanese standard document classes, then - # geometry package needs truedimen as initial *class* option - if docclass[:2] == 'js': - self.elements['papersize'] = ('truedimen,' + - self.elements['papersize']) # use dvipdfmx as default class option in Japanese self.elements['classoptions'] = ',dvipdfmx' # disable babel which has not publishing quality in Japanese diff --git a/tests/test_build_latex.py b/tests/test_build_latex.py index fc01fc322..6c8861f1b 100644 --- a/tests/test_build_latex.py +++ b/tests/test_build_latex.py @@ -423,7 +423,7 @@ def test_babel_with_language_ja(app, status, warning): print(result) print(status.getvalue()) print(warning.getvalue()) - assert '\\documentclass[truedimen,letterpaper,10pt,dvipdfmx]{sphinxmanual}' in result + assert '\\documentclass[letterpaper,10pt,dvipdfmx]{sphinxmanual}' in result assert '\\usepackage{babel}' not in result assert '\\usepackage{times}' in result assert '\\usepackage[Sonny]{fncychap}' not in result