diff options
author | jfbu <jfbu@free.fr> | 2021-03-13 18:51:52 +0300 |
---|---|---|
committer | jfbu <jfbu@free.fr> | 2021-03-13 18:56:50 +0300 |
commit | b6d143118d35c2f138c15349fee707aec14f4349 (patch) | |
tree | e5d6eae07e8c0c19c580d6b736661b20d27f588b /sphinx/texinputs | |
parent | 17bb78997c7fc5f821d0e235188b637b8fe0fb88 (diff) |
LaTeX: modify \pysigline and \pysiglinewithargsret
Fix #7241
Fix #8980
Fix #8995
Diffstat (limited to 'sphinx/texinputs')
-rw-r--r-- | sphinx/texinputs/sphinxlatexobjects.sty | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/sphinx/texinputs/sphinxlatexobjects.sty b/sphinx/texinputs/sphinxlatexobjects.sty index 26e2862c1..810d3f2f8 100644 --- a/sphinx/texinputs/sphinxlatexobjects.sty +++ b/sphinx/texinputs/sphinxlatexobjects.sty @@ -58,11 +58,14 @@ % {fulllineitems} is the main environment for object descriptions. % -\newcommand{\py@itemnewline}[1]{% - \kern\labelsep - \@tempdima\linewidth - \advance\@tempdima \labelwidth\makebox[\@tempdima][l]{#1}% - \kern-\labelsep +% With 4.0.0 \pysigline (and \pysiglinewithargsret), used in a fulllineitems +% environment the #1 will already be of the width which is computed here, i.e. +% the available width on line, so the \makebox becomes a bit superfluous +\newcommand{\py@itemnewline}[1]{% macro used as \makelabel in fulllineitems +% Memo: this presupposes \itemindent is 0pt + \kern\labelsep % because \@labels core latex box does \hskip-\labelsep + \makebox[\dimexpr\linewidth+\labelwidth\relax][l]{#1}% + \kern-\labelsep % because at end of \@labels box there is \hskip\labelsep } \newenvironment{fulllineitems}{% @@ -76,13 +79,27 @@ % \newlength{\py@argswidth} \newcommand{\py@sigparams}[2]{% - \parbox[t]{\py@argswidth}{#1\sphinxcode{)}#2}} -\newcommand{\pysigline}[1]{\item[{#1}]} + % The \py@argswidth has been computed in \pysiglinewithargsret to make this + % occupy full available width on line. + \parbox[t]{\py@argswidth}{\raggedright #1\sphinxcode{)}#2\strut}% + % final strut is to help get correct vertical separation in case of multi-line + % box with the item contents. +} +\newcommand{\pysigline}[1]{% +% the \py@argswidth is available we use it despite its name (no "args" here) +% the \relax\relax is because \py@argswidth is a "skip" variable and the first +% \relax only ends its "dimen" part + \py@argswidth=\dimexpr\linewidth+\labelwidth\relax\relax + \item[{\parbox[t]{\py@argswidth}{\raggedright #1\strut}}] +% this strange incantation is because at its root LaTeX in fact did not +% imagine a multi-line label, it is always wrapped in a horizontal box at core +% LaTeX level and we have to find tricks to get correct interline distances. + \leavevmode\par\nobreak\vskip-\parskip\prevdepth\dp\strutbox} \newcommand{\pysiglinewithargsret}[3]{% \settowidth{\py@argswidth}{#1\sphinxcode{(}}% - \addtolength{\py@argswidth}{-2\py@argswidth}% - \addtolength{\py@argswidth}{\linewidth}% - \item[{#1\sphinxcode{(}\py@sigparams{#2}{#3}}]} + \py@argswidth=\dimexpr\linewidth+\labelwidth-\py@argswidth\relax\relax + \item[{#1\sphinxcode{(}\py@sigparams{#2}{#3}}] + \leavevmode\par\nobreak\vskip-\parskip\prevdepth\dp\strutbox} \newcommand{\pysigstartmultiline}{% \def\pysigstartmultiline{\vskip\smallskipamount\parskip\z@skip\itemsep\z@skip}% \edef\pysigstopmultiline |