From cec526458a79de35ecb66e4303e2088615ef7b8b Mon Sep 17 00:00:00 2001 From: jfbu Date: Tue, 2 May 2017 10:54:11 +0200 Subject: [PATCH] Use TeX primitive for efficiency --- sphinx/texinputs/sphinx.sty | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sphinx/texinputs/sphinx.sty b/sphinx/texinputs/sphinx.sty index 2dda42855..ed0473c4d 100644 --- a/sphinx/texinputs/sphinx.sty +++ b/sphinx/texinputs/sphinx.sty @@ -106,16 +106,21 @@ % longtable's wraps captions to a maximal width of \LTcapwidth % so we do the same for all tables \newcommand\sphinxcaptionof[2]{% - \noindent\makebox[\linewidth]{% + \noindent\hb@xt@\linewidth{\hss \vtop{\hsize\LTcapwidth \def\@captype{#1}% \capstart % must be after setting \@captype % longtable ignores \abovecaptionskip/\belowcaptionskip, so do the same here \abovecaptionskip\z@skip \belowcaptionskip\z@skip +% hyperref anchor (and a \write) cause the \vtop to have zero height. Hence if +% the caption is first thing in a list item, the item label (which gets +% inserted indirectly by the \noindent) will have its baseline same as top of +% box which is \ht\strutbox above the caption text baseline. This avoids a +% wide caption overwriting the item label. \caption[{#2}]% {\strut\ignorespaces#2\ifhmode\unskip\@finalstrut\strutbox\fi}% - }}% + }\hss}% \par\prevdepth\dp\strutbox }% \newcommand\sphinxaftercaption