
I am in the process of converting a bunch of old TikZ notepaper templates to native ConTeXt and MetaPost. This is a part of a project to generate notebooks with documentation data and then blank pages appended to fill out full sheets, and then collated in a particular order for trimming and binding. As such I rely on Imposition. I am having issues with the various techniques of trying to duplicate a MP graphic across the pages using \[start|stop]MPcode \[start|stop]useMPgraphic, etc. But that is a discussion for another time. The method that I found to work was to use \[start|stop]reusableMPgraphic along with overlays I am still struggling with some MetaPost code that works fine in standalone but not when included in a ConTeXt document. With standalone MP, we get thicker lines on major increments as expected. When the same code is included in a ConTeXt document the thicker lines are only drawn up a certain number and then stop --- presumably the mod function returning a non-zero result when it really shouldn't? Here are the MWEs:
ConTeXt % Paper size and layout {{{2 \definepapersize | [PocketPage] | [width=2.75in,height=4.25in]
\setuppapersize[PocketPage][letter,landscape] % }}}2 % MetaPost template for graph paper for pocket sized notebook (2.75" W x % 4.25in H). {{{2 \startreusableMPgraphic{graph} minor=2mm;| | % Minor lines, each every 2mm major=8mm;| | % Major lines, each every 4mm ┆ ┆ ┆ ┆ % major must be a multiple of minor z1 = (0,0);| % lower left corner % z2 = (2.75in,4.25in)-z1;| % upper right corner z2 = (2.75in,4.25in)-z1;|% upper right corner % Use the very thin pen pickup pencircle scaled 0.1; % Draw the vertical lines for i=minor step minor until (y2-y1): ┆ if (i mod major)=0: ┆ ┆ pickup pencircle scaled 0.3; ┆ fi; ┆ draw (z1 shifted (0,i))--((x2,y1) shifted (0,i)) withcolor .4white; ┆ if (i mod major)=0: ┆ ┆ pickup pencircle scaled 0.1; ┆ fi; endfor; % Draw the horizonal lines for i=minor step minor until (x2-x1): ┆ if (i mod major)=0: ┆ ┆ pickup pencircle scaled 0.3; ┆ fi; ┆ draw ( z1--(x1,y2) ) shifted (i,0) withcolor .4white; ┆ if (i mod major)=0: ┆ ┆ pickup pencircle scaled 0.1; ┆ fi; endfor; \stopreusableMPgraphic \defineoverlay[OLgraph][\useMPgraphic{graph}] \setupbackgrounds[page][background=OLgraph] % }}}2 \starttext hello. \stoptext <<<
Standalone MP beginfig(1)
margin=0mm; % Margin of the graph paper minor=2mm; % Minor lines, each every 1mm major=8mm; % Major lines, each every 10mm % major must be a multiple of minor z1 = (margin,margin); % lower left corner z2 = (2.75in,4.25in)-z1; % upper right corner % % Use the thick pen first % pickup pencircle scaled 0.5; % % Draw the frame % draw z1--(x1,y2)--z2--(x2,y1)--cycle withcolor .5white; % Use the very thin pen pickup pencircle scaled 0.1; % Draw the vertical lines for i=minor step minor until (y2-y1-minor): if (i mod major)=0: pickup pencircle scaled 0.3; fi; draw (z1 shifted (0,i))--((x2,y1) shifted (0,i)) withcolor .4white; if (i mod major)=0: pickup pencircle scaled 0.1; fi; endfor; % Draw the horizonal lines for i=minor step minor until (x2-x1-minor): if (i mod major)=0: pickup pencircle scaled 0.3; fi; draw ( z1--(x1,y2) ) shifted (i,0) withcolor .4white; if (i mod major)=0: pickup pencircle scaled 0.1; fi; endfor; endfig; end; <<< advTHANKance -- Pavneet Arora m: +1 647-406-6843 Waroc Informatik e: pavneet_arora@waroc.com