![](https://secure.gravatar.com/avatar/c5ae4f9aa0d3a9bd5376e92b322c3e50.jpg?s=120&d=mm&r=g)
On Sun, 14 Feb 2021, Jigé wrote:
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
Most likely because the argument of \inmargin is scanned upfront and at that time \draw etc are undefined. One option is: \startbuffer[picture] \starttikzpicture ... \stoptikzpicture \stopbuffer \inmargin{\getbuffer[picture]} Another option (but better to do that in tikz module) is: \let\draw\relax \let\x\relax \inmargin{\starttikzpicture ... \stoptikzpicture}
Actually the command \startmarginblock ... \stop... described in the ConText reference works with a TikZ picture.
Because the \start ... \stop blocks don't scan the argument. Aditya