[NTG-context] tikzpicture in margin

Jigé broumpf-c at yahoo.com
Sun Feb 14 16:11:34 CET 2021


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

-> Undefined control sequence

I tried using \startfigure, \hbox... no success.

Actually the command \startmarginblock ... \stop... described in the ConText reference works with a TikZ picture. But the picture, in the margin, gets near the top of the page. I don't understand the meaning of the options (especially the difference between `location' and `align'). And is it `\setuppagenumbering[alternative=doublesided]'-aware ?
Example:

\usemodule[tikz]
\setuplayout[backspace=4cm, topspace=2cm, height=middle]
\setuppagenumbering[alternative=doublesided]
\starttext
\input{lorem}
\inmargin{\externalfigure[cow] [width=\marginwidth]}
\pagebreak
\input{lorem}
\input{lorem}

\blank
We would like the picture to go the the left of this paragraph.
\setupmarginblocks[location=left,align=inner]
\startmarginblock
\starttikzpicture[scale=0.2]
  \draw[gray] (-2,0) grid (2,2) ;
  \draw plot [domain=-2:2, samples=50, smooth] (\x,{\x * \x});
\stoptikzpicture
\stopmarginblock
\stoptext


Best regards


More information about the ntg-context mailing list