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

Reply via email to