Re: [dev-context] Adding before and after keys to setupcaption

2018-11-01 Thread Hans Hagen

On 10/31/2018 10:24 AM, Aditya Mahajan wrote:

Hi Hans,

There have been a few questions on TeX.SX asking essentially for a frame 
around a float that covers both the caption and the content.
it's probably a bit more tricky than that ... (also, before/after are 
sort of taken)


i'll send you/wolfgang a variant for testing

Hans

-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
   tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-
___
dev-context mailing list
dev-context@ntg.nl
https://mailman.ntg.nl/mailman/listinfo/dev-context


[dev-context] Adding before and after keys to setupcaption

2018-10-31 Thread Aditya Mahajan

Hi Hans,

There have been a few questions on TeX.SX asking essentially for a frame 
around a float that covers both the caption and the content.


1. 
https://tex.stackexchange.com/questions/25180/adding-a-frame-and-background-color-to-floats-in-context/37128#37128
2. 
https://tex.stackexchange.com/questions/457412/context-place-rules-above-and-below-floating-figure

I have provided a hacky solutions to both questions (the internals changed 
quite a bit between the two questions), but as I was playing around with 
the code, I thought that the simplest solution will be to add a `before` 
and an `after` key to `\setupcaptions`:


\def\strc_floats_build_box
  {\global\setbox\floatbox\vbox % pack ? probably not
 {\strc_floats_set_local_hsize
  \forgetall
  \ifconditional\c_floats_store_minimal_package
\strc_floats_build_box_separate_make
  \else
  % \let\floatcaptionarrangement\s!default
\let\floatcaptionarrangement\v!bottom % for Alan

\processcommacommand[\floatcaptionparameter\c!location]\strc_floats_build_box_step
\floatcaptionparameter\c!before %AM: Added
\ifcsname\??floatbuilder\floatcaptionarrangement\endcsname
  \lastnamedcs
\else
  \strc_floats_build_box_default
\fi
\floatcaptionparameter\c!after %AM: Added
  \fi}}

A simple usage example is the following:


\setupexternalfigures[location={local,global,default}]

\setupcaption
  [
before={\startframedtext[widht=fit, background=color, 
backgroundcolor=gray, frame=off]},

after=\stopframedtext,
  ]
\starttext

\section{A figure with rules}

\startplacefigure[location={left,high},title={A dutch cow}]
  \externalfigure[cow]
\stopplacefigure
\input knuth

\startplacefigure[title={\input zapf \relax}]
  \externalfigure[cow]
\stopplacefigure

\dorecurse{4}{\input knuth \endgraf}

\stoptext


Does it make sense to add this or something similar?

Thanks,
Aditya
___
dev-context mailing list
dev-context@ntg.nl
https://mailman.ntg.nl/mailman/listinfo/dev-context