ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Vertical alignment of marginal material
       [not found] <20040223110008.18013.96778.Mailman@ref.ntg.nl>
@ 2004-02-24  1:42 ` Jonathan Nicholl
  0 siblings, 0 replies; only message in thread
From: Jonathan Nicholl @ 2004-02-24  1:42 UTC (permalink / raw)


> Message: 12
> Date: Mon, 23 Feb 2004 10:14:38 +0100
> To: ntg-context@ntg.nl
> From: Hans Hagen <pragma@wxs.nl>
> Subject: Re: [NTG-context] alignment of marginal material
> Reply-To: ntg-context@ntg.nl
>
> At 21:40 22/02/2004, Jonathan Nicholl wrote:

>> I am trying to write a macro which places a picture in the margin. I  
>> would
>> like the centre of the picture to be aligned vertically with the  
>> centre of
>> the paragraph in which I call the macro. The following works in  
>> simple cases:
>>
>> \def\hazard#1{%
>>         \setbox0=\vbox{#1}%
>>         \inleft [low] {%
>>                 \framed%
>>                         [height=\ht0,%
>>                         top=\vss,%
>>                         bottom=\vss,%
>>                         frame=off]%
>>                         {\externalfigure [sharp turn sign]}%
>>                 }%
>>         #1}%
>>
>> If I type something like
>>
>> \hazard{…paragraph text…}
>>
>> this produces what I want. But it breaks down with mathematics.
>>
>> \hazard{%
>>         \startformula
>>                 …mathematics…
>>         \stopformula
>> }
>>
>> produces the picture aligned with the bottom of the mathematics.
>>
>> A solution to this problem escapes me. Can anyone suggest an improved  
>> macro?
>
> Here is my 10 minute solution ... if i'm in the mood i can make an  
> option of it

Maybe other people would like some support for this kind of thing.  
Certainly I would find it useful if, when I wrote `\inmargin…'  
somewhere inside a paragraph, I could specify an option to determine  
the vertical alignment of the marginal material. Suppose `top' aligned  
the top of the marginal material with the top of the paragraph, `mid'  
the middle of the marginal material with the midpoint of the paragraph,  
and `bot'  the bottom of the marginal material with the bottom of the  
paragraph. That would be good.

> \newcounter\CurrentFigPar
>
> \def\StartFigPar#1%
>    {\doglobal\increment\CurrentFigPar
>     \placefigure
>       [leftmargin,line,none]{}
>       {\setbox\scratchbox\hbox{#1}%
>   
> \ifnum\MPp{figpar:b:\CurrentFigPar}=\MPp{figpar:e: 
> \CurrentFigPar}\relax
>          \scratchdimen\MPy{figpar:b:\CurrentFigPar}%
>          \advance\scratchdimen-\MPy{figpar:e:\CurrentFigPar}%
>          \advance\scratchdimen-\ht\scratchbox
>          \advance\scratchdimen\lineheight
>        \else
>          \scratchdimen\zeropoint
>        \fi
>        \vbox{\vskip.5\scratchdimen\box\scratchbox}}%
>     \indent\hpos{figpar:b:\CurrentFigPar}{\strut}\ignorespaces}
>
> \def\StopFigPar
>     
> {\removeunwantedspaces\hpos{figpar:e:\CurrentFigPar}{\strut}\endgraf}
>
> \starttext
>
> \input tufte
>
> \StartFigPar{\externalfigure[cow.pdf][width=1cm]} \input tufte  
> \StopFigPar
>
> \input tufte
>
> \stoptext=20

Thank you very much indeed, Hans. This puts cow.pdf in the right place  
in the margin. One problem remains. Surrounding a paragraph by  
\StartFigPar…\StopFigPar often messes up the inter-paragraph vertical  
spacing. In particular, surrounding \startformula…\stopformula by  
\StartFigPar…\StopFigPar introduces big spaces above and below the  
mathematics.

Is there a simple way to stop this? It would be good if introducing a  
few \StartFigPar…\StopFigPar pairs to a document had no effect at all  
on the main body of the document, and just put figures in the margin.

-----------------------

Jonathan Nicholl
Department of Philosophy
King's College London

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2004-02-24  1:42 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20040223110008.18013.96778.Mailman@ref.ntg.nl>
2004-02-24  1:42 ` Vertical alignment of marginal material Jonathan Nicholl

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