mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #8779 from jfbu/latex_hlist_support
Fix #8072: Directive hlist not implemented in LaTeX
This commit is contained in:
commit
be20f17892
4
CHANGES
4
CHANGES
@ -4,6 +4,9 @@ Release 3.5.0 (in development)
|
|||||||
Dependencies
|
Dependencies
|
||||||
------------
|
------------
|
||||||
|
|
||||||
|
* LaTeX: ``multicol`` (it is anyhow a required part of the official latex2e
|
||||||
|
base distribution)
|
||||||
|
|
||||||
Incompatible changes
|
Incompatible changes
|
||||||
--------------------
|
--------------------
|
||||||
|
|
||||||
@ -103,6 +106,7 @@ Bugs fixed
|
|||||||
specified
|
specified
|
||||||
* #7576: LaTeX with French babel and memoir crash: "Illegal parameter number
|
* #7576: LaTeX with French babel and memoir crash: "Illegal parameter number
|
||||||
in definition of ``\FNH@prefntext``"
|
in definition of ``\FNH@prefntext``"
|
||||||
|
* #8072: LaTeX: Directive :rst:dir:`hlist` not implemented in LaTeX
|
||||||
* #8214: LaTeX: The :rst:role:`index` role and the glossary generate duplicate
|
* #8214: LaTeX: The :rst:role:`index` role and the glossary generate duplicate
|
||||||
entries in the LaTeX index (if both used for same term)
|
entries in the LaTeX index (if both used for same term)
|
||||||
* #8735: LaTeX: wrong internal links in pdf to captioned code-blocks when
|
* #8735: LaTeX: wrong internal links in pdf to captioned code-blocks when
|
||||||
|
@ -276,6 +276,7 @@ class HList(SphinxDirective):
|
|||||||
npercol, nmore = divmod(len(fulllist), ncolumns)
|
npercol, nmore = divmod(len(fulllist), ncolumns)
|
||||||
index = 0
|
index = 0
|
||||||
newnode = addnodes.hlist()
|
newnode = addnodes.hlist()
|
||||||
|
newnode['ncolumns'] = str(ncolumns)
|
||||||
for column in range(ncolumns):
|
for column in range(ncolumns):
|
||||||
endindex = index + ((npercol + 1) if column < nmore else npercol)
|
endindex = index + ((npercol + 1) if column < nmore else npercol)
|
||||||
bullet_list = nodes.bullet_list()
|
bullet_list = nodes.bullet_list()
|
||||||
|
@ -239,6 +239,8 @@
|
|||||||
\ltx@ifundefined{@removefromreset}
|
\ltx@ifundefined{@removefromreset}
|
||||||
{\RequirePackage{remreset}}
|
{\RequirePackage{remreset}}
|
||||||
{}% avoid warning
|
{}% avoid warning
|
||||||
|
% To support hlist directive
|
||||||
|
\RequirePackage{multicol}
|
||||||
% to make pdf with correct encoded bookmarks in Japanese
|
% to make pdf with correct encoded bookmarks in Japanese
|
||||||
% this should precede the hyperref package
|
% this should precede the hyperref package
|
||||||
\ifx\kanjiskip\@undefined
|
\ifx\kanjiskip\@undefined
|
||||||
|
@ -1177,9 +1177,11 @@ class LaTeXTranslator(SphinxTranslator):
|
|||||||
self.body.append('\n\\end{center}')
|
self.body.append('\n\\end{center}')
|
||||||
|
|
||||||
def visit_hlist(self, node: Element) -> None:
|
def visit_hlist(self, node: Element) -> None:
|
||||||
# for now, we don't support a more compact list format
|
|
||||||
# don't add individual itemize environments, but one for all columns
|
|
||||||
self.compact_list += 1
|
self.compact_list += 1
|
||||||
|
ncolumns = node['ncolumns']
|
||||||
|
if self.compact_list > 1:
|
||||||
|
self.body.append('\\setlength{\\multicolsep}{0pt}\n')
|
||||||
|
self.body.append('\\begin{multicols}{' + ncolumns + '}\\raggedright\n')
|
||||||
self.body.append('\\begin{itemize}\\setlength{\\itemsep}{0pt}'
|
self.body.append('\\begin{itemize}\\setlength{\\itemsep}{0pt}'
|
||||||
'\\setlength{\\parskip}{0pt}\n')
|
'\\setlength{\\parskip}{0pt}\n')
|
||||||
if self.table:
|
if self.table:
|
||||||
@ -1187,12 +1189,17 @@ class LaTeXTranslator(SphinxTranslator):
|
|||||||
|
|
||||||
def depart_hlist(self, node: Element) -> None:
|
def depart_hlist(self, node: Element) -> None:
|
||||||
self.compact_list -= 1
|
self.compact_list -= 1
|
||||||
self.body.append('\\end{itemize}\n')
|
self.body.append('\\end{itemize}\\raggedcolumns\\end{multicols}\n')
|
||||||
|
|
||||||
def visit_hlistcol(self, node: Element) -> None:
|
def visit_hlistcol(self, node: Element) -> None:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def depart_hlistcol(self, node: Element) -> None:
|
def depart_hlistcol(self, node: Element) -> None:
|
||||||
|
# \columnbreak would guarantee same columns as in html ouput. But
|
||||||
|
# some testing with long items showed that columns may be too uneven.
|
||||||
|
# And in case only of short items, the automatic column breaks should
|
||||||
|
# match the ones pre-computed by the hlist() directive.
|
||||||
|
# self.body.append('\\columnbreak\n')
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def latex_image_length(self, width_str: str, scale: int = 100) -> str:
|
def latex_image_length(self, width_str: str, scale: int = 100) -> str:
|
||||||
|
Loading…
Reference in New Issue
Block a user