[NTG-context] tikzpicture in margin

Henning Hraban Ramm texml at fiee.net
Sun Feb 14 16:41:06 CET 2021


> Am 14.02.2021 um 16:11 schrieb Jigé <broumpf-c at yahoo.com>:
> 
> Hi all.
> 
> I'm trying to place a TikZ picture in the margin.
> Here is a small example:
> 
> \usemodule[tikz]
> \setuplayout[backspace=4cm, topspace=2cm, height=middle]
> \starttext
> \input{lorem}
> \margintext{I have discovered a truly
>             marvelous proof ...  but
>             this margin is too narrow
>             to contain it.}
> \input{lorem}
> \inmargin{\externalfigure[cow] [width=\marginwidth]}
> % The above works.
> % The following does not:
> \input{lorem}
> \inmargin{
> \starttikzpicture
>   \draw[gray] (-2,0) grid (2,2) ;
>   \draw plot [domain=-2:2, samples=50, smooth] (\x,{\x * \x});
> \stoptikzpicture
> }
> \stoptext

Does \placefigure[margin]{caption}{... tikzpicture ...} fit your needs?

That generally works, but using LMTX there’s a horizontal shift on left pages (still need to prepare a MWE for that).

Hraban


More information about the ntg-context mailing list