ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* slithering captions
@ 2006-04-17  3:47 Sanjoy Mahajan
  2006-04-17  8:48 ` Hans Hagen
  0 siblings, 1 reply; 5+ messages in thread
From: Sanjoy Mahajan @ 2006-04-17  3:47 UTC (permalink / raw)


One weekend years ago I studied tex's insertions and learnt enough to
write (i.e. hack) macros to produce a layout that I'm trying to
reproduce using ConTeXt.  I've figured parts of it out, no doubt the
easier parts.

The layout has a 4in text column and a 2.3in right margin for figures
and captions.  Experiments with setuplayout got those blocks working.
But figures are to be placed according to their width.  Three natural
widths appear in the layout:

1. margin (2.3in)
2. text (4in)
3. text + margin (+ gutter) = 6.5in

You can see the results of the plain-TeX implementation in the book
chapters at <http://www.inference.phy.cam.ac.uk/sanjoy/mit/>.  A figure
is then placed in one of three ways:

1. width <= margin: margin float, with caption below it.  One example is
   p.8 of chapter 1.

2. width <= text: float to top of page, with caption in the right
   margin.  One example is p.7 of chapter 1.

3. width <= text + margin + gutter: float to top of page, bleeding into
   the margin, with caption below it in the margin.  One example is
   p. 11 of chapter 1.

So the first step in doing the placement automatically is to get the
width of the figure.  Assuming that I've done

  \useexternalfigure[fig_a][f-1.pdf]

is there an easy way to get fig_a's dimensions?  After using the figure,
e.g. with

  \placefigure[margin][]{some caption}{\externalfigure[fig_a]}

then \wd\floatbox has the dimension I need.  Will another macro fill in
\floatbox without doing the work of using the figure? I tried
\dogetfiguresizetex but probably with wrong arguments.  Another option
was

  \newdimen\a \newdimen\b \newdimen\c \newdimen\d 
  \dogetPDFmediabox{f-1.pdf}{\a}{\b}{\c}{\d}

and then \c has the width, but without any scaling and only for pdf
figures.

Once I have the width, I can define \autofig and use it like so:

\autofig{L}{caption}

and \autofig will look up the width of the figure labeled L and do
roughly:

\placefigure[margin][]{caption}{\externalfigure[L]}   % margin figures
  OR
{\setupcaptions[location=middle]	% for text figures
\placefigure[top][]{caption}{\externalfigure[L]}
}
  OR
{\setupcaptions[width=2.3in,align=right]  % for even wider figures
\placefigure[top][]{caption}{\externalfigure[L]}
}

The next problem after finding the figure width is to find the right
alternative to location=middle (which puts the caption to the left,
whereas I wanted it in the margin and to the right).

And, but this is trying to do too much at once, the next problem is that
margin caption below the widest figures (case 3 above) shouldn't overlap
other floats in the margin and also shouldn't count toward the figure's
height in the text block.  But maybe that's done automatically -- I'll
make some experiments.

Any hints greatly appreciated, and, once I get it working, I'll wikify
the layout if there's interest.

-Sanjoy

`A society of sheep must in time beget a government of wolves.'
   - Bertrand de Jouvenal

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-05-22 13:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-17  3:47 slithering captions Sanjoy Mahajan
2006-04-17  8:48 ` Hans Hagen
2006-05-22  0:37   ` Sanjoy Mahajan
2006-05-22  7:38     ` Hans Hagen
2006-05-22 13:59       ` Sanjoy Mahajan

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).