[NTG-context] \showgrid question
Hans Hagen
pragma at wxs.nl
Mon Oct 16 20:20:46 CEST 2006
Marcus Vinicius Mesquita de So wrote:
> Hi!
>
> Is there an option for the \showgrid command for showing only the line
> numbers (no lines) ?
no, but it's easy to add that option,
put this in cont-new.tex (after \unprotect)
\chardef\gridboxlinenomode\plusone
\chardef\gridboxlinemode \plusone % 0:nothing 1:all 2:lines 3:frame
\def\gridboxvbox {\ifcase\gridboxlinemode\vbox\or\ruledvbox\or\vbox\or\ruledvbox\else\ruledvbox\fi}
\def\gridboxwidth{\ifcase\gridboxlinemode0\or.5\or.5\or0\else.5\fi\testrulewidth}
\def\setgridbox#1#2#3%
{\setbox#1\gridboxvbox to #3 % given size
{\forgetall
\resetteststrut
\offinterlineskip
\hsize#2%
\baselinerulefalse
\gridboxvbox % calculated size
{\getrawnoflines{#3}% \getnoflines{#3}%
\vskip\topskip
\vskip-\strutht
\scratchdimen#2\advance\scratchdimen \lineheight
\dorecurse\noflines
{\strut
\hskip-.5\lineheight
\ifcase\gridboxlinenomode\or
\rlap
{\hskip.2\bodyfontsize\hskip\scratchdimen
\infofont\hbox to 1em{\hss\recurselevel}}%
\or
\llap
{\infofont\hbox to 1em{\hss\recurselevel}%
\hskip.2\bodyfontsize}%
\fi
\vrule
\!!height \gridboxwidth
\!!depth \gridboxwidth
\!!width \scratchdimen
\par}}
\vfill}}
\def\doshowgrid[#1]%
{\chardef\showgridstate \plusone % downward compatible default
\chardef\gridboxlinemode \plusone
\chardef\gridboxlinenomode\plusone
\processallactionsinset
[#1]%
[ \v!reset=>\chardef\showgridstate \zerocount,
\v!bottom=>\chardef\showgridstate \plusone,
\v!top=>\chardef\showgridstate \plustwo,
\v!none=>\chardef\gridboxlinemode \zerocount,
\v!all=>\chardef\gridboxlinemode \plusone,
\v!lines=>\chardef\gridboxlinemode \plustwo,
\v!frame=>\chardef\gridboxlinemode \plusthree,
\v!nonumber=>\chardef\gridboxlinenomode\zerocount,
\v!right=>\chardef\gridboxlinenomode\plusone,
\v!left=>\chardef\gridboxlinenomode\plustwo]}
now you can use keywords, like
\showgrid[lines.left]
\input tufte
-----------------------------------------------------------------
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