* alignment of marginal material
@ 2004-02-22 20:40 Jonathan Nicholl
2004-02-23 9:14 ` Hans Hagen
0 siblings, 1 reply; 2+ messages in thread
From: Jonathan Nicholl @ 2004-02-22 20:40 UTC (permalink / raw)
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{% The argument is the text of the paragraph
\setbox0=\vbox{#1}% I do this to work out the height of the paragraph
\inleft [low] {%
\framed%
[height=\ht0,% This makes the height of the frame equal to the
height of the paragraph
top=\vss,%
bottom=\vss,% These two lines centre the picture in the frame
frame=off]%
{\externalfigure [sharp turn sign]}%
}%
#1}% It goes wrong if you replace #1 with \box0
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?
Best wishes,
Jonathan
-----------------------
Jonathan Nicholl
Department of Philosophy
King's College London
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: alignment of marginal material
2004-02-22 20:40 alignment of marginal material Jonathan Nicholl
@ 2004-02-23 9:14 ` Hans Hagen
0 siblings, 0 replies; 2+ messages in thread
From: Hans Hagen @ 2004-02-23 9:14 UTC (permalink / raw)
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{% The argument is the text of the
>paragraph
> \setbox0=\vbox{#1}% I do this to work out the height
> of the paragraph
> \inleft [low] {%
> \framed%
> [height=\ht0,% This makes the height of the
> frame equal to the height of the paragraph
> top=\vss,%
> bottom=\vss,% These two lines centre the
> picture in the frame
> frame=off]%
> {\externalfigure [sharp turn sign]}%
> }%
> #1}% It goes wrong if
> you replace #1 with \box0
>
>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
\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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-02-23 9:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-02-22 20:40 alignment of marginal material Jonathan Nicholl
2004-02-23 9:14 ` Hans Hagen
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).