[NTG-context] Position margin text block near previous paragraph

Hans Hagen pragma at wxs.nl
Wed Jul 27 09:50:07 CEST 2005


Eugene Toporov wrote:

> Hello!
>
> This time I have a task like this:
>
> I have margin text blocks (like Note, Tip) that follow some paragraph 
> in my document flow.
> In the produced document I get them in margin, but vertically they are 
> just below the paragraph (as in text flow)
> I really need then to start exactly where the previous paragraph 
> starts (vertically). I.e. I need to move them several (unknown number) 
> lines higher.
>
> My realization:
>
> \setupinmargin[style=\sl\tx\setupinterlinespace,location=left,align=right]
> \def\Note#1{
>   \strut
>   \inmargin{
>     \em{#1}
>   }
>   \strut}
> \starttext
>
> This is the para with unknown length that can be any number of lines 
> high. And I have a note below it that should be located to the left of 
> this paragraph and not just below it. That's the case. \par
>
> \Note{ And here is the note that should be in margin.}
>
> \stoptext
>
> The easiest would to put it above the target paragraph, but that's not 
> the solution for me as the same text is rendered to HTML where no 
> margins exist.
>
> Can I do it plainly in tex code?

well, you need to know a bit of tex an dcontext internals -)

it takes some 10 lines of code to hack a solution that moves the margin note to the beginning of a paragraph (ok, page crossing are a problem, so there it stays in place)

however, the note should be attached to the par! so: 

text text\inmargin{...} 

(i suppose that for html you can insert a break before the note) 

as usual the problem is, how to integrate this 

(btw, context does have mechanisms for auto-stacking marginal notes that clash, which is why this not too complex to implement; we needed that functionality a few years ago for a huge xml->pdf project) 

Hans 

-----------------------------------------------------------------
                                          Hans Hagen | PRAGMA ADE
              Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
                                             | www.pragma-pod.nl
-----------------------------------------------------------------



More information about the ntg-context mailing list