[dev-context] Add headcommand to floatcaption
Wolfgang Schuster
wolfgang.schuster.lists at gmail.com
Fri Dec 27 09:42:26 CET 2019
Hans Hagen schrieb am 25.12.2019 um 15:21:
> On 12/25/2019 12:01 AM, Henri Menke wrote:
>> Dear Hans,
>>
>> Could you please add the possibility to switch the headcommand to
>> floatcaption? Below you can find a simple patch that implements what I
>> am proposing.
>>
>> Happy holidays,
>> Henri
>>
>> ---
>> [...]
> ok, given an impact approval check by WS
>
> but next time also add an example for the test suite so that we see
> what it's meant for
See attachment, you can use \setupcaption[hang=yes] to achieve the
desired result.
Wolfgang
-------------- next part --------------
\unprotect
\def\strc_floats_make_complete_caption
{\doifsomething{\floatcaptionparameter\c!spacebefore}{\blank[\floatcaptionparameter\c!spacebefore]}%
\strc_floats_make_complete_caption_before
\synchronizedisplaydirection % temp hack, till we have a proper model
\noindent
\gdef\lastcaptiontag{\strut\thecurrentfloatnumber}% was xdef ... needs checking
\begingroup
\usefloatcaptionstyleandcolor\c!style\c!color
\clf_doifelselisthastitle{\currentfloat}\numexpr\currentfloatnumber\relax
\donothing
\emptyfloatcaptiontrue
\ifnofloatnumber
\else
% begin old code
% \hbox{\usefloatcaptionstyleandcolor\c!headstyle\c!headcolor\thecurrentfloatnumber}%
% \ifnofloatcaption \else \ifemptyfloatcaption \else
% \doifelsenothing{\floatcaptionparameter\c!spaceinbetween}
% {\floatcaptionparameter\c!headseparator\relax
% \scratchskip\floatcaptionparameter\c!distance\relax
% \dotfskip\scratchskip\emergencystretch.5\scratchskip}
% {\blank[\floatcaptionparameter\c!spaceinbetween]}%
% \fi \fi
% end old code
% begin new code
\setbox\scratchbox\hbox{\usefloatcaptionstyleandcolor\c!headstyle\c!headcolor\thecurrentfloatnumber}%
\ifnofloatcaption \else \ifemptyfloatcaption
\box\scratchbox
\else
\scratchskip\floatcaptionparameter\c!distance\relax
\setbox\scratchbox\hbox
{\box\scratchbox
\floatcaptionparameter\c!headseparator\relax
\dotfskip\scratchskip}%
\doifelsenothing{\floatcaptionparameter\c!spaceinbetween}
{\doifelse{\floatcaptionparameter\c!hang}\v!yes
{\leftskip\wd\scratchbox
\llap{\box\scratchbox}}
{\unhbox\scratchbox}%
\emergencystretch.5\scratchskip}
{\blank[\floatcaptionparameter\c!spaceinbetween]}%
\fi \fi
% end new code
\fi
\ifnofloatcaption
\global\d_strc_floats_caption_height\zeropoint
\global\d_strc_floats_caption_depth \zeropoint
\else
\usefloatcaptionstyleandcolor\c!textstyle\c!textcolor
\global\d_strc_floats_caption_height\strutheight
\global\d_strc_floats_caption_depth \strutdepth
\thecurrentfloatcaption\endgraf
\fi
\endgroup
\strc_floats_make_complete_caption_after
\doifsomething{\floatcaptionparameter\c!spaceafter}{\blank[\floatcaptionparameter\c!spaceafter]}}
\protect
\setupexternalfigures[location=default]
\setupcaption
[figure]
[align=tolerant]
\starttext
\startplacefigure[title={\samplefile{jojomayer}}]
\externalfigure[hacker][width=.75\textwidth]
\stopplacefigure
\setupcaption
[figure]
[hang=yes]
\startplacefigure[title={\samplefile{jojomayer}}]
\externalfigure[hacker][width=.75\textwidth]
\stopplacefigure
\stoptext
More information about the dev-context
mailing list