Closed bersbersbers closed 3 years ago
patch/caption
only applies to the caption
package. What it does adding \acswitchoff
to caption
's \caption@prepareslc
. It cannot have any effects if the package is not loaded.
I've decided not to check other definitions of \caption
as they depend on the document class.
For standard classes \@makecaption
is defined as follows:
\long\def\@makecaption#1#2{%
\vskip\abovecaptionskip
\sbox\@tempboxa{#1: #2}%
\ifdim \wd\@tempboxa >\hsize
#1: #2\par
\else
\global \@minipagefalse
\hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
\fi
\vskip\belowcaptionskip}
This shows exactly what you observe: long captions are typeset twice, once for measuring in the box and once for real. For short captions the box is just reinserted. With a standard class (article
, report
, or book
) one could do
\makeatletter
\renewcommand\@makecaption[2]{%
\vskip\abovecaptionskip
\sbox\@tempboxa{\acswitchoff#1: #2}%
\ifdim \wd\@tempboxa >\hsize
#1: #2\par
\else
\global \@minipagefalse
\hb@xt@\hsize{\hfil#1: #2\hfil}%
\fi
\vskip\belowcaptionskip}
\makeatother
but this relies very much in the implementation which is why I'm hesitant to do so in acro
. The above would not work with the classes from tufte-latex
or with memoir
or the koma-script
classes. Or. It might work but at the same time destroy how these classes make their captions. At the very least it would disable their options and modifications around captions.
Thanks! For now, in my document, I use this workaround:
\usepackage{regexpatch}
\makeatletter
\newcommand{\mlcaption}[1]{
\makeatletter
\regexpatchcmd{\@makecaption}{
(\c{@tempboxa} \cB\{) \#1:\ \#2 (\cE\})
}{
\1 \c{hspace} \cB\{ 2 \c{hsize} \cE\} \2
}{}{Error.}
\caption{#1}
\makeatother
}
\makeatother
This forces the single-line-check to see a wide line regardless of the content.
And then I use \mlcaption
for multi-line captions (which they almost always are).
And as I had to notice, this workaround had to be adapted for ieeecolor.cls
as you rightly explain. [Fortunately, that document class has some \ifcenterfigcaptions
which is false for me, so I can simply patch its \@makecaption
globally.] Thanks again!
Regardless of the value of
patch/floats
, I do not see a difference betweenpatch/caption=true
andpatch/caption=false
, although for the long caption, the behavior withoutpatch/caption
is the same with and without\usepackage{caption}
, respectively. What I am saying is:patch/caption
should apply also to regular captions, at least the long ones.What I am looking for is
without loading the
caption
package, if possible - but I get either "short and short" (patch/floats=false
) or "long and long" (patch/floats=true
).By the way: the manual says
Isn't this true for all captions with the
caption
package? See this example:The problem ("short and short") appears with both captions, and is fixed for both with
patch/caption=true
. My understanding is thatcaption
'ssinglelinecheck
is done for all captions to see if they are single-line. Confirmed (by yourself, I think):https://tex.stackexchange.com/a/431633/30810
Maybe you could write: