ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: "Jakub Piotr Cłapa" <jpc-ml@zenburn.net>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Float captions with hanging indentation
Date: Fri, 09 Oct 2009 16:32:23 +0200	[thread overview]
Message-ID: <4ACF4977.9060200@zenburn.net> (raw)

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	other threads:[~2009-10-09 14:32 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4ACF4977.9060200@zenburn.net \
    --to=jpc-ml@zenburn.net \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).