Hello,

I am a new ConTeXt user recently switched from LaTeX (with small amounts of raw TeX macrosity) which I used for several years.

I was searching the internet, this mailing list and finally the ConTeXt sources to find some information about achieving hanging indentation in captions. The 'hang' option for the 'caption' LaTeX package [1] was my inspiration (you can see an example on the 3 page of the linked manual). The only thing I could find was an old reply from Taco Hoekwater [2] but as he mentions this does not work well.

After digging inside the source code of both ConTeXt and caption.sty
I managed to hack the \putcompletecaption macro to do what I need. (see below)

The changes required are minimal (capture the caption head into a box, remember its width and later set \hangindent and \hangafter while typessing the caption body) so maybe this could go into the main ConTeXt tree? Unfortunately I do not know how to make use of the setup macros so this currently hardcodes the hanging indentation.

\unprotect
\newdimen\captionhang
\def\putcompletecaption#1#2%

{\doifsomething{\floatcaptionparameter\c!spacebefore}{\blank[\floatcaptionparameter\c!spacebefore]}%
% \floatcaptionparameter\c!before % test for side effects first
   \noindent
   \xdef\lastcaptiontag{\strut#1}%
   \dostartattributes{\??kj\currentfloat}\c!style\c!color\empty
     \setbox0\hbox{%
       \ifnofloatnumber
       \else

\hbox{\doattributes{\??kj\currentfloat}\c!headstyle\c!headcolor{\strut#1}}%
         \ifnofloatcaption \else \ifemptyfloatcaption \else
           \doifelsenothing{\floatcaptionparameter\c!spaceinbetween}
             {\scratchskip\floatcaptionparameter\c!distance\relax
              \dotfskip\scratchskip\emergencystretch.5\scratchskip}
             {\blank[\floatcaptionparameter\c!spaceinbetween]}%
         \fi \fi
       \fi
     }%
     \captionhang=\wd0\unhbox0%
     \ifnofloatcaption
       \globallet\lastcaptionht\!!zeropoint
       \globallet\lastcaptiondp\!!zeropoint
     \else
       \doattributes{\??kj\currentfloat}\c!textstyle\c!textcolor
         {\hangindent=\captionhang\hangafter=1%
          \xdef\lastcaptionht{\strutheight}%
          \xdef\lastcaptiondp{\strutdepth}%
          \begstrut#2\endstrut\endgraf}%
     \fi
   \dostopattributes
% \floatcaptionparameter\c!after % test for side effects first

\doifsomething{\floatcaptionparameter\c!spaceafter}{\blank[\floatcaptionparameter\c!spaceafter]}}
\protect


[1]: http://www.dd.chalmers.se/latex/Docs/PDF/caption.pdf
[2]: http://thread.gmane.org/gmane.comp.tex.context/21675/focus=21676

--
regards,
Jakub Piotr Cłapa
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

Reply via email to