diff options
author | Karl Berry <karl@freefriends.org> | 2019-04-05 21:05:06 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2019-04-05 21:05:06 +0000 |
commit | dbdaa8c3ce30ed3514c5b2e0fb227b06152ba7ca (patch) | |
tree | 6d56fc8f737ca2a0437037bbbb6d34e157e079dd /Master/texmf-dist/tex | |
parent | 8453b4092bc269968bd77aa4bf824035718fdec8 (diff) |
knitting (5apr19)
git-svn-id: svn://tug.org/texlive/trunk@50782 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r-- | Master/texmf-dist/tex/latex/knitting/knitting.sty | 428 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/knitting/uknit.fd | 14 | ||||
-rw-r--r-- | Master/texmf-dist/tex/plain/knitting/knitting.tex | 567 |
3 files changed, 700 insertions, 309 deletions
diff --git a/Master/texmf-dist/tex/latex/knitting/knitting.sty b/Master/texmf-dist/tex/latex/knitting/knitting.sty index 7a8410c8791..2a73d0224c5 100644 --- a/Master/texmf-dist/tex/latex/knitting/knitting.sty +++ b/Master/texmf-dist/tex/latex/knitting/knitting.sty @@ -22,31 +22,46 @@ % The complete list of files considered part of this work is in % the file `knitting-doc.pdf' and its source code `knitting-doc.tex'. % -% Version: 2 +% Version: 3 -\ProvidesPackage{knitting}[2010/08/29] +\ProvidesPackage{knitting}[2019/04/03] %\pdfmapfile{+knitfont.map} +% +% Boolean variables +% + \newif \ifchartsonly \chartsonlyfalse \newif \ifgrid +\newif \ifknitsymbol \newif \ifresetrn \resetrntrue \newif \ifleftrn@knit \newif \ifshowrn@knit \showrn@knittrue \newif \ifpdf@knit \newif \ifcountingout@knit +\newif \ifCountStsThisRow@knit \CountStsThisRow@knittrue \pdf@knittrue \ifx \pdfoutput \undefined \pdf@knitfalse \fi \ifx \pdfoutput \relax \pdf@knitfalse \fi +% +% Color commands +% + \RequirePackage{color} \definecolor{purlgray}{gray}{0.65} \definecolor{knitlinecolor}{rgb}{0.7,0,0} \definecolor{gridcolor}{gray}{0.3} +\definecolor{forecolor}{gray}{0} \definecolor{rncolor}{rgb}{0.6,0,0} \definecolor{rnarrowcolor}{rgb}{0.45,0,0} +% +% LaTeX-only material (options and fullpages) +% + \DeclareOption{chartsonly}{\chartsonlytrue} \ProcessOptions @@ -71,7 +86,7 @@ \addtolength{\textheight}{-2in} \setlength{\textwidth}{\paperwidth} \addtolength{\textwidth}{-2in} - % This bit is borrowed from Peter Wilson's chngpage.sty + % This next bit is borrowed from Peter Wilson's chngpage.sty % package. I didn't want to just \usepackage{chngpage} because it % behaves like \addtolength and I wanted \setlength, and loading the % whole package for one eight-line snippet of code just seemed @@ -87,6 +102,10 @@ } {\clearpage} +% +% Dimensions +% + \newlength \leftgap@knit \newlength \bgshift@knit \newlength \chartwidth@knit @@ -98,15 +117,18 @@ \newbox\fgbox@knit \newbox\ggbox@knit -\newcounter{rownumber} +\newcounter{rownumber} \newcounter{tempcount@knit} -\newcounter{rownumberskip} \setcounter{rownumberskip}{1} +\newcounter{rownumberskip} \c@rownumberskip = 1 \newcounter{stitchcountin} \newcounter{stitchcountinprev} \newcounter{stitchcountout} +\newcounter{shortrowstsin@knit} +\newcounter{shortrowstsout@knit} \newcommand \passnum@knit{2} \newcommand \stitchwd{\fontdimen6\csname U/knit/\series@knit/n/\f@size\endcsname} +\newcommand \stitchwd@count@knit{\fontdimen6\csname U/knit/\series@knit/out/\f@size\endcsname} \newcommand \stitchdp{\fontdimen8\csname U/knit/\series@knit/n/\f@size\endcsname} \newcommand \stitchht{\fontdimen9\csname U/knit/\series@knit/n/\f@size\endcsname} \newcommand \gridwidth{\fontdimen10\csname U/knit/\series@knit/n/\f@size\endcsname} @@ -117,36 +139,54 @@ \newcommand \rownumberwd{\fontdimen6\csname U/knit/\series@knit/n/10\endcsname} % The rest of them aren't \the\font because I want them to still work outside of a chart +% +% Fonts +% + \newcommand \ff@knit{\fontencoding{U}\fontfamily{knit}\fontseries{\series@knit}\fontshape{n}\selectfont} \newcommand \gf@knit{\fontencoding{U}\fontfamily{knit}\fontseries{\series@knit}\fontshape{g}\selectfont} \newcommand \pf@knit{\fontencoding{U}\fontfamily{knit}\fontseries{\series@knit}\fontshape{p}\selectfont} +\newcommand \raiseff@knit{\fontencoding{U}\fontfamily{knit}\fontseries{\series@knit}\fontshape{r}\selectfont} +\newcommand \lowerff@knit{\fontencoding{U}\fontfamily{knit}\fontseries{\series@knit}\fontshape{l}\selectfont} \DeclareTextFontCommand {\knitsfsmall@knit}{\dimen0=\f@size pt\fontfamily{cmss}\fontseries{m}\fontshape{n}\fontsize{0.8\dimen0}{\f@baselineskip}\selectfont} \DeclareTextFontCommand {\cablesf@knit}{\dimen0=\f@size pt\fontfamily{cmss}\fontseries{m}\fontshape{n}\fontsize{0.8\dimen0}{\f@baselineskip}\selectfont} \DeclareTextFontCommand{\cablesfsmall@knit}{\dimen0=\f@size pt\fontfamily{cmss}\fontseries{m}\fontshape{n}\fontsize{0.6\dimen0}{\f@baselineskip}\selectfont} +% Some extra effort (the {\ff@knit}) is made to make sure that the fonts actually exist. +% This is done so that the fonts are defined before they are used, +% which is necessary to make \gridwidth work +\newcommand \knitnogrid{\gridfalse\knitsymboltrue \def\series@knit{n}{\ff@knit}} +\newcommand \knitgrid{\gridtrue \knitsymbolfalse\def\series@knit{g}{\ff@knit}} +\newcommand \knitwide{\gridtrue \knitsymbolfalse\def\series@knit{w}{\ff@knit}} +\newcommand \knitmixed{\gridtrue \knitsymboltrue \def\series@knit{m}{\ff@knit}} + +\knitgrid + +% +% Single-pass commands +% + \newcommand \purlpass[2][]{\ifnum\passnum@knit = 0 #2\else #1\fi} \newcommand \gridpass[2][]{\ifnum\passnum@knit = 1 #2\else #1\fi} \newcommand \mainpass[2][]{\ifnum\passnum@knit = 2 #2\else #1\fi} \newcommand \countpass[2][]{\ifnum\passnum@knit = 3 #2\else #1\fi} -% Some extra effort (the {\ff@knit}) is made to make sure that the fonts % actually exist. -% This is done so that the fonts are defined before they are used, -% which is necessary to make \gridwidth work -\newcommand \knitnogrid{\gridfalse\def\series@knit{n}{\ff@knit}} -\newcommand \knitgrid{\gridtrue \def\series@knit{g}{\ff@knit}} -\newcommand \knitwide{\gridtrue \def\series@knit{w}{\ff@knit}} - -\knitgrid +% +% Text knit +% -\newcommand \textknit[1]{\mbox{\ff@knit +\newcommand \textknit[1]{\mbox{\let\|\bar@knit\let\!\barthin@knit + \ff@knit \color{forecolor}% \rlap{\pf@knit \color{purlgray}\def\passnum@knit{0}#1}% \ifgrid\rlap{\gf@knit \color{gridcolor}\def\passnum@knit{1}#1}\fi \def\passnum@knit{2}#1}} \newcommand \do@endofpar@knit[1]{\def\par{#1\endgraf\let\par\endgraf}} +% % Special symbols +% \newcommand \narrowdecrease[1]{\genbobble@knit{#1}{1}{-\narrowincraise@knit}\adjuststitchcount[#1]{0}\adjuststitchcount[-1]{0}} \newcommand \pnarrowdecrease[1]{\genbobble@knit{#1}{2}{-\narrowincraise@knit}\adjuststitchcount[#1]{0}\adjuststitchcount[-1]{0}} @@ -155,24 +195,24 @@ \newcommand \bobble[1]{\genbobble@knit{#1}{0}{0pt}} \newcommand \genbobble@knit[3]{\char#2 \ifnum \passnum@knit = 2 - \llap{\lower\stitchdp\vbox to\stitchht{\vss \vskip\fontvoffset@knit \hbox to \stitchwd{\hfil\knitsfsmall@knit{#1}\hfil}\vskip #3\vss}}\fi} + \llap{\lower \stitchdp \vbox to\stitchht{\vss \vskip\fontvoffset@knit \hbox to \stitchwd{\hfil\knitsfsmall@knit{#1}\hfil}\vskip #3\vss}}\fi} \newcommand \wideincrease[1]{\strut@knit \ifnum\passnum@knit = 3 \narrowincrease{#1}\else \hbox to #1\stitchwd{\char25 - \hskip-0.1pt\leaders\hbox{\char22}\hfil\hskip-0.1pt - \char29 - \hskip-0.1pt\leaders\hbox{\char22}\hfil\hskip-0.1pt - \char26}\fi} + \hskip-0.1pt\leaders\hbox{\char22}\hfil\hskip-0.1pt + \char29 + \hskip-0.1pt\leaders\hbox{\char22}\hfil\hskip-0.1pt + \char26}\fi} \newcommand \widedecrease[1]{\strut@knit \ifnum #1 = 5 \char31 \else \ifnum\passnum@knit = 3 \narrowdecrease{#1}\else - \hbox to #1\stitchwd{\char27 - \hskip-0.1pt\leaders\hbox{\char22}\hfil\hskip-0.1pt - \char30 - \hskip-0.1pt\leaders\hbox{\char22}\hfil\hskip-0.1pt - \char28}\fi\fi} + \hbox to #1\stitchwd{\char27 + \hskip-0.1pt\leaders\hbox{\char22}\hfil\hskip-0.1pt + \char30 + \hskip-0.1pt\leaders\hbox{\char22}\hfil\hskip-0.1pt + \char28}\fi\fi} % Standard chart commands @@ -181,7 +221,7 @@ {\catcode`\^^M = \active \catcode`\| = \active \global\def\commands@knit{% - \setlength{\fboxsep}{0pt}% + \setlength{\fboxsep}{0pt}% \let\[\pnarrowincrease \let\]\pnarrowdecrease \let\<\narrowincrease @@ -190,9 +230,9 @@ \let \! \barthin@knit \let \| \bar@knit \let | \bar@knit - \let \_ \horizline@knit + \let \_ \horizlinenarrow@knit \let \= \horizlinewide@knit - \let \- \horizlinenarrow@knit + \let \- \horizline@knit \let\overline\overline@knit \let\underline\underline@knit \let\rn\rn@knit @@ -215,19 +255,21 @@ % Drawing lines on the chart -\newcommand \horizline@knit{\ifnum\passnum@knit<3 \ifvmode\nonumber\leavevmode\fi \dimen0 = \stitchwd \advance \dimen0 \knitlinewd +\newcommand \horizlinenarrow@knit{\ifnum\passnum@knit<3 \ifvmode\nonumber\leavevmode\fi \dimen0 = \stitchwd \advance \dimen0 \knitlinewd \ifnum\passnum@knit = 2 \hskip -0.5\knitlinewd\smash{{\color{knitlinecolor}\vrule width \dimen0 height 0.5\knitlinewd depth 0.5\knitlinewd}}\hskip -0.5\knitlinewd \else\hskip \stitchwd \fi\fi} -\newcommand \horizlinenarrow@knit[1]{\ifnum\passnum@knit<3 \ifvmode\nonumber\leavevmode\fi \dimen0 = #1\stitchwd \advance \dimen0 \gridwidth - \ifnum\passnum@knit = 2 - \hskip -0.5\gridwidth \smash{{\color{knitlinecolor}\vrule width \dimen0 height 0.5\knitlinewd depth 0.5\knitlinewd}}\hskip -0.5\gridwidth - \else\hskip #1\stitchwd \fi\fi} \newcommand \horizlinewide@knit[1]{\ifnum\passnum@knit<3 \ifvmode\nonumber\leavevmode\fi \dimen0 = #1\stitchwd \advance \dimen0 \knitlinewd \ifnum\passnum@knit = 2 \smash{{\color{knitlinecolor}\vrule width \dimen0 height 0.5\knitlinewd depth 0.5\knitlinewd}} \else\hskip \dimen0 \fi\fi} +\newcommand \horizline@knit{\@ifstar \horizlinestar@knit \horizlinenostar@knit} + +\newcommand \horizlinestar@knit[1]{\nonumber\nostitchcount\overlinestar@knit{\hskip#1\stitchwd}} +\newcommand \horizlinenostar@knit[1]{\nonumber\nostitchcount\overlinenostar@knit{\hskip#1\stitchwd}} + + \newcommand \bar@knit{\ifnum\passnum@knit < 3 \leavevmode \ifgrid \ifnum \passnum@knit = 0 @@ -248,7 +290,8 @@ \newcommand \barthin@knit{\leavevmode\strut@knit \ifnum \passnum@knit = 2 - \dimen2 = \stitchht \advance \dimen2 \barthintop@knit \advance \dimen2 \barthinbot@knit + \dimen2 = \stitchht \advance \dimen2 \barthintop@knit + \advance \dimen2 \barthinbot@knit \dimen3 = \stitchdp \advance \dimen3 \barthinbot@knit \smash{\hbox to 0pt{\hss \color{knitlinecolor}\rule[-\dimen3]{\knitlinewd}{\dimen2}\hss}}% \fi} @@ -273,7 +316,7 @@ \rule[\ht0]{0pt}{\knitlinewd} \fi \fi #1}} - + \newcommand \overlinestar@knit[1]{\leavevmode{\def\barthintop@knit{0.5\knitlinewd}% \setbox0 = \hbox{#1}% \ifnum \passnum@knit = 2 @@ -287,64 +330,73 @@ \setbox0 = \hbox{#1}% \ifgrid \ifnum \passnum@knit = 0 - \dimen1=\wd0 \advance\dimen1 by \gridwidth - \rlap{\raisebox{-\dp0}{\hskip -0.5\gridwidth\color{knitlinecolor}\rule[-\knitlinewd]{\dimen1}{\knitlinewd}\hskip -0.5\gridwidth}}% + \dimen1=\wd0 \advance\dimen1 by \gridwidth + \rlap{\raisebox{-\dp0}{\hskip -0.5\gridwidth\color{knitlinecolor}\rule[-\knitlinewd]{\dimen1}{\knitlinewd}\hskip -0.5\gridwidth}}% \else - \rlap{\raisebox{-\dp0}{\vrule width 0pt height 0pt depth \knitlinewd}}% + \rlap{\raisebox{-\dp0}{\vrule width 0pt height 0pt depth \knitlinewd}}% \fi \else \ifnum \passnum@knit = 2 - \dimen1=\wd0 \advance\dimen1 by \gridwidth - \rlap{\raisebox{-\dp0}{\hskip -0.5\gridwidth\color{knitlinecolor}\rule[-\knitlinewd]{\dimen1}{\knitlinewd}\hskip -0.5\gridwidth}}% + \dimen1=\wd0 \advance\dimen1 by \gridwidth + \rlap{\raisebox{-\dp0}{\hskip -0.5\gridwidth\color{knitlinecolor}\rule[-\knitlinewd]{\dimen1}{\knitlinewd}\hskip -0.5\gridwidth}}% \else - \rlap{\raisebox{-\dp0}{\vrule width 0pt height 0pt depth \knitlinewd}}% + \rlap{\raisebox{-\dp0}{\vrule width 0pt height 0pt depth \knitlinewd}}% \fi \fi #1}} - + \newcommand \underlinestar@knit[1]{\leavevmode{\def\barthinbot@knit{0.5\knitlinewd}% \setbox0 = \hbox{#1}% \ifnum \passnum@knit = 2 - \dimen1=\wd0 \advance\dimen1 by \gridwidth - \smash{\rlap{\raisebox{-\dp0}{\hskip -0.5\gridwidth\color{knitlinecolor}\rule[-0.5\knitlinewd]{\dimen1}{\knitlinewd}}\hskip -0.5\gridwidth}}% + \dimen1=\wd0 \advance\dimen1 by \gridwidth + \smash{\rlap{\raisebox{-\dp0}{\hskip -0.5\gridwidth\color{knitlinecolor}\rule[-0.5\knitlinewd]{\dimen1}{\knitlinewd}}\hskip -0.5\gridwidth}}% \fi #1}} % Fancy cabling -\newcommand \overcableleft@knit[1]{% - \setbox0=\hbox{#1}% - \rlap{#1}% - \hbox to \wd0{\leaders\hbox to \stitchwd{\hfil\char5}\hfil\hskip\stitchwd\char10}} -\newcommand \undercableleft@knit[1]{% - \setbox0=\hbox{#1}% - \rlap{#1}% - \hbox to \wd0{\leaders\hbox to \stitchwd{\hfil\char6}\hfil\hskip\stitchwd\char9}} -\newcommand \undercableright@knit[1]{% - \setbox0=\hbox{#1}% - \rlap{#1}% - \hbox to \wd0{\char13\char12\hskip\stitchwd\leaders\hbox to \stitchwd{\char8\hfil}\hfil}} -\newcommand \overcableright@knit[1]{% - \setbox0=\hbox{#1}% - \rlap{#1}% - \hbox to \wd0{\char14\char11\hskip\stitchwd\leaders\hbox to \stitchwd{\char7\hfil}\hfil}} - -\newcommand \cableleft[2]{\leavevmode{\knitnogrid +% \ifnum \passnum@knit = 3 \leavevmode \fi causes problems +% due to the weird things we do automatically at the start of a paragraph +\def\doifcounting@knit#1{} + +\def\cablebackground#1{\doifcounting@knit{\leavevmode}% + \ifnum \passnum@knit = 0 \leavevmode \hbox to \stitchwd{#1\hss {\raiseff@knit \def\passnum@knit{2}\color{forecolor}#1}}\else \char255 \fi} +\def\cableforeground#1{\doifcounting@knit{\leavevmode}% + \ifnum \passnum@knit = 0 \leavevmode \hbox to \stitchwd{#1\hss {\lowerff@knit \def\passnum@knit{2}\color{forecolor}#1}}\else \char254 \fi} + +\def\orphancablewarning@knit{\typeout{Package knit warning: Orphaned half cable on input line \the\inputlineno.}} + +\newcommand \cableleft[2]{\leavevmode{\ifgrid\knitmixed\fi \ifcase\passnum@knit - \hbox{\pf@knit #1#2} + \hbox{\pf@knit #1#2}% \or - \setbox0=\hbox{\pf@knit #1#2} - \rule{\wd0}{0pt} \vrule width 0pt height \ht0 depth \dp0 + \setbox0=\hbox{\pf@knit #1#2}% + \hbox to \wd0{\char6\leaders\hbox{\char5}\hfil\char6}% \or - \hbox{\let \textsf \cablesf@knit \let \knitsfsmall@knit \cablesfsmall@knit {\ff@knit\fontshape{l}\selectfont \overcableleft@knit{#1}}{\ff@knit\fontshape{r}\selectfont \undercableright@knit{#2}}} + \hbox{\let \textsf \cablesf@knit \let \knitsfsmall@knit \cablesfsmall@knit % + \setbox1=\hbox{#1}% + \setbox2=\hbox{#2}% + \ifdim \wd1 = 0pt \orphancablewarning@knit \fi + \ifdim \wd2 = 0pt \orphancablewarning@knit \fi + {\lowerff@knit \rlap{#1}\hbox to \wd1{\leaders\hbox to \stitchwd{\hfil\char15}\hfil\ifdim\wd1>0pt \hskip\stitchwd\char10\fi}% + \ifdim\wd1>0pt \ifdim \wd2>0pt \char13\fi \fi }% + {\raiseff@knit \rlap{#2}\hbox to \wd2{\ifdim\wd2>0pt \char12\hskip\stitchwd\fi\leaders\hbox to \stitchwd{\char8\hfil}\hfil}}}% \else #1#2\fi}} -\newcommand \cableright[2]{\leavevmode{\knitnogrid +\newcommand \cableright[2]{\leavevmode{\ifgrid\knitmixed\fi \ifcase\passnum@knit - \hbox{\pf@knit #1#2} + \hbox{\pf@knit #1#2}% \or - \setbox0=\hbox{\pf@knit #1#2} \rule{\wd0}{0pt} \vrule width 0pt height \ht0 depth \dp0 + \setbox0=\hbox{\pf@knit #1#2}% + \hbox to \wd0{\char6\leaders\hbox{\char5}\hfil\char6}% \or - \hbox{\let \textsf \cablesf@knit \let \knitsfsmall@knit \cablesfsmall@knit {\ff@knit\fontshape{r}\selectfont \undercableleft@knit{#1}}{\ff@knit\fontshape{l}\selectfont \overcableright@knit{#2}}} + \hbox{\let\textsf \cablesf@knit \let \knitsfsmall@knit \cablesfsmall@knit % + \setbox1=\hbox{#1}% + \setbox2=\hbox{#2}% + \ifdim \wd1 = 0pt \orphancablewarning@knit \fi + \ifdim \wd2 = 0pt \orphancablewarning@knit \fi + {\raiseff@knit \rlap{#1}\hbox to \wd1{\leaders\hbox to \stitchwd{\hfil\char16}\hfil\ifdim\wd1>0pt \hskip\stitchwd\char9\fi}% + \ifdim\wd1>0pt \ifdim \wd2>0pt \char14\fi \fi }% + {\lowerff@knit \rlap{#2}\hbox to \wd2{\ifdim\wd2>0pt \char11\hskip\stitchwd \fi\leaders\hbox to \stitchwd{\char7\hfil}\hfil}}}% \else #1#2\fi}} @@ -366,15 +418,27 @@ \else {\knitboxbackground \purlbackground{\rule[-\stitchdp]{#3\stitchwd}{\stitchht}}}\fi \or - \rlap{\hbox to #3\stitchwd{\leaders\hbox{\char5}\hfil}}% - \hbox to #3\stitchwd{\leaders\hbox to \stitchwd{\char6\hfil\char6}\hskip #1\stitchwd plus 1fil \hskip\wd0\leaders\hbox to \stitchwd{\char6\hfil\char6}\hfil}% + \ifknitsymbol + \hbox to #3\stitchwd{\char6\leaders\hbox{\char5}\hfil\char6}% + \else + \hbox{\hbox to #3\stitchwd{% + \leaders \hbox to \stitchwd{\char6\hfil\char6}\hfil + \hskip \wd0 + \leaders \hbox to \stitchwd{\char6\hfil\char6}\hfil}% + \hskip -#3\stitchwd + \hbox to #3\stitchwd{\char6\leaders\hbox{\char5}\hfil\char6}}% + \fi \or \hbox to #3\stitchwd{% - {\knitboxforeground\leaders\hbox{-}\hskip #1\stitchwd plus 1fil }% - \lower\stitchdp\vbox to\stitchht{\vss\vskip\fontvoffset@knit\hbox{\fontseries{m}\fontshape{n}\textsf{#2}}\vss} - {\knitboxforeground\leaders\hbox{-}\hfil}}% + {\knitboxforeground\leaders\hbox{-}% + \ifnum #1>0 \hskip #1\stitchwd plus 1fil minus #1\stitchwd \else\hfil\fi + }% + \lower\stitchdp\vbox to\stitchht{\vss\vskip\fontvoffset@knit\hbox{\fontseries{m}\fontshape{n}\textsf{#2}}\vss} + {\knitboxforeground \count255 = -#1 \leaders\hbox{-}% + \ifnum #1<0 \hskip \count255\stitchwd plus 1fil minus \count255\stitchwd \else\hfil\fi + }}% \or - \hbox to #3\stitchwd{\hfil} + \hbox to \Knitstitchcount{#2}{#3}\stitchwd{\hfil} \fi} \newcommand \Purl[3][0]{\strut@knit% \setbox0 = \hbox{\fontseries{m}\fontshape{n}\textsf{#2}}% @@ -384,17 +448,34 @@ \else {\purlboxbackground \purlbackground{\rule[-\stitchdp]{#3\stitchwd}{\stitchht}}}\fi \or - \rlap{\hbox to #3\stitchwd{\leaders\hbox{\char5}\hfil}}% - \hbox to #3\stitchwd{\leaders\hbox to \stitchwd{\char6\hfil\char6}\hskip #1\stitchwd plus 1fil \hskip\wd0\leaders\hbox to \stitchwd{\char6\hfil\char6}\hfil}% + \ifknitsymbol + \hbox to #3\stitchwd{\char6\leaders\hbox{\char5}\hfil\char6}% + \else + \hbox{\hbox to #3\stitchwd{% + \leaders \hbox to \stitchwd{\char6\hfil\char6}\hfil + \hskip \wd0 + \leaders \hbox to \stitchwd{\char6\hfil\char6}\hfil}% + \hskip -#3\stitchwd + \hbox to #3\stitchwd{\char6\leaders\hbox{\char5}\hfil\char6}}% + \fi \or \hbox to #3\stitchwd{% - {\purlboxforeground\leaders\hbox{=}\hskip #1\stitchwd plus 1fil }% - \lower\stitchdp\vbox to\stitchht{\vss\vskip\fontvoffset@knit\hbox{\fontseries{m}\fontshape{n}\textsf{#2}}\vss} - {\purlboxforeground\leaders\hbox{=}\hfil}}% + {\purlboxforeground\leaders\hbox{=}% + \ifnum #1>0 \hskip #1\stitchwd plus 1fil minus #1\stitchwd \else\hfil\fi + }% + \lower\stitchdp\vbox to\stitchht{\vss\vskip\fontvoffset@knit\hbox{\fontseries{m}\fontshape{n}\textsf{#2}}\vss} + {\purlboxforeground \count255 = -#1 \leaders\hbox{=}% + \ifnum #1<0 \hskip \count255\stitchwd plus 1fil minus \count255\stitchwd \else\hfil\fi + }}% \or - \hbox to #3\stitchwd{\hfil} + \hbox to \Purlstitchcount{#2}{#3}\stitchwd{\hfil} \fi} +\newcommand \Knitstitchcount[2]{#2} +\newcommand \Purlstitchcount[2]{#2} +\newcommand \knitboxstitchcount[2]{#2} +\newcommand \purlboxstitchcount[2]{#2} + \newcommand \knitbox[3][0]{\strut@knit% \ifcase \passnum@knit \ifx \empty@knit \knitboxbackground @@ -404,9 +485,14 @@ \or \hbox to #3\stitchwd{\char6\leaders\hbox{\char5}\hfil\char6}% \or - \hbox to #3\stitchwd{\hskip #1\stitchwd plus 1fil \lower\stitchdp\vbox to\stitchht{\vss\vskip\fontvoffset@knit\hbox{\fontseries{m}\fontshape{n}\textsf{#2}}\vss}\hfil}% + \lower\stitchdp\vbox to\stitchht{% + \vss\vskip\fontvoffset@knit + \hbox to #3\stitchwd{\ifnum #1>0 \hskip #1\stitchwd plus 1fil minus #1\stitchwd \else\hfil\fi + {\fontseries{m}\fontshape{n}\textsf{#2}}% + \count255 = -#1 \ifnum #1<0 \hskip \count255\stitchwd plus 1fil minus \count255\stitchwd \else\hfil\fi}% + \vss}% \or - \hbox to #3\stitchwd{\hfil} + \hbox to \knitboxstitchcount{#2}{#3}\stitchwd{\hfil} \fi} \newcommand \purlbox[3][0]{\strut@knit% \ifcase \passnum@knit @@ -417,9 +503,14 @@ \or \hbox to #3\stitchwd{\char6\leaders\hbox{\char5}\hfil\char6}% \or - \hbox to #3\stitchwd{\hskip #1\stitchwd plus 1fil \lower\stitchdp\vbox to\stitchht{\vss\vskip\fontvoffset@knit\hbox{\fontseries{m}\fontshape{n}\textsf{#2}}\vss}\hfil}% + \lower\stitchdp\vbox to\stitchht{% + \vss\vskip\fontvoffset@knit + \hbox to #3\stitchwd{\ifnum #1>0 \hskip #1\stitchwd plus 1fil minus #1\stitchwd \else\hfil\fi + {\fontseries{m}\fontshape{n}\textsf{#2}}% + \count255 = -#1 \ifnum #1<0 \hskip \count255\stitchwd plus 1fil minus \count255\stitchwd \else\hfil\fi}% + \vss}% \or - \hbox to #3\stitchwd{\hfil}% + \hbox to \purlboxstitchcount{#2}{#3}\stitchwd{\hfil}% \fi} \newcommand \purlbackground[1]{\leavevmode\setbox0=\hbox{#1}% @@ -432,10 +523,21 @@ \kern-\purlextend@knit \else\box0\fi} +\newcommand \widesymbol[3][0]{\strut@knit + \ifcase \passnum@knit + \knitbox{}{#3}\or + \knitbox{}{#3}\or + \hbox to #3\stitchwd{\ifnum #1>0 \hskip #1\stitchwd plus 1fil minus #1\stitchwd \else\hfil\fi + #2% + \count255 = -#1 \ifnum #1<0 \hskip \count255\stitchwd plus 1fil minus \count255\stitchwd \else\hfil\fi}\else + \widesymbolspacer{#2}{#3}\relax\fi} + +\newcommand \widesymbolspacer[2]{#1} + % Row number commands \newcommand \numberrow[3]{\ifnum\passnum@knit=3 \ifvmode\vskip\stitchht\fi\else - \ifvmode\nonumber\leavevmode\fi + \ifvmode\nonumber\leavevmode\fi \strut@knit \count255=#1 \hbox to \stitchwd{\hss\ifnum \passnum@knit = 2 \color{rncolor}\textnormal{#1}\fi\hss}% @@ -469,15 +571,15 @@ \hbox to \stitchwd{\hss\ifnum \passnum@knit = 2 \color{rncolor}\textnormal{#3}\fi \hss}% \fi} -\newcommand \rnoddonly{\def\rncore@knit##1{\ifshowrn@knit \ifodd\value{rownumber}\csname print##1rownumber\endcsname{\therownumber}\fi\fi}} -\newcommand \rnevenonly{\def\rncore@knit##1{\ifshowrn@knit \ifodd\value{rownumber}\else\csname print##1rownumber\endcsname{\therownumber}\fi\fi}} +\newcommand \rnoddonly{\def\rncore@knit##1{\ifshowrn@knit \ifodd\c@rownumber \csname print##1rownumber\endcsname{\therownumber}\fi\fi}} +\newcommand \rnevenonly{\def\rncore@knit##1{\ifshowrn@knit \ifodd\c@rownumber \else\csname print##1rownumber\endcsname{\therownumber}\fi\fi}} \newcommand \rnnormal{\def\rncore@knit##1{\ifshowrn@knit \csname print##1rownumber\endcsname{\therownumber}\fi}} \newcommand \rncore@knit[1]{\ifshowrn@knit \csname print#1rownumber\endcsname{\therownumber}\fi} \newcommand \rnstep@knit{\ifshowrn@knit - \ifnum \passnum@knit = 2 \addtocounter{rownumber}{-\value{rownumberskip}}\fi - \ifnum \passnum@knit = 0 \addtocounter{rownumber}{-\value{rownumberskip}}\fi - \else\global\showrn@knittrue\fi} + \ifnum \passnum@knit = 2 \global\advance\c@rownumber -\c@rownumberskip \relax\fi + \ifnum \passnum@knit = 0 \global\advance\c@rownumber -\c@rownumberskip \relax\fi + \else\global\showrn@knittrue\fi} \newcommand \printrownumber[1]{{\color{rncolor}\textnormal{#1}}} \newcommand \printrightrownumber[1]{\knitleftarrowhead{\color{rncolor}\textnormal{#1}}} @@ -499,7 +601,7 @@ \newcommand \rnright@knit{\ifnum \passnum@knit < 3 \leavevmode \setbox0 = \hbox{\ifnum \passnum@knit = 2 \rncore@knit{right}\fi\rnstep@knit} \dimen0 = \wd0 %\advance \dimen0 -\rownumberwd - \ifchartsonly\advance \dimen0 1pt\fi + \ifchartsonly\advance \dimen0 1pt\fi \ifdim \dimen0 > \rnrightwd@knit \global\rnrightwd@knit = \dimen0 \fi \hbox to 0pt{\box0\hss}\fi} @@ -520,7 +622,7 @@ % The chart commands -\newcommand \chart[1][]{\smallpage@knit\obeylines \catcode`\|=\active \chart@knit{#1}} +\newcommand \chart[1][]{\smallpage@knit\obeylines \catcode`\|=\active \catcode`\# = 12 \catcode`\& = 12 \chart@knit{#1}} % Some special stuff for chartsonly mode \let\extracommands@knit\relax @@ -530,7 +632,7 @@ % The chart command proper \newcommand \chart@knit[2]{% \global \chartwidth@knit = 0pt - \ifresetrn \setcounter{rownumber}{0}\else \setcounter{tempcount@knit}{\value{rownumber}}\fi + \ifresetrn \c@rownumber = 0 \else \c@tempcount@knit = \c@rownumber \fi \setbox\bgbox@knit=\vbox{\def\passnum@knit{0}\hsize=\maxdimen \ff@knit % This is kind of silly, but to make \stitchht work, we need to be sure that the foreground font exists. \pf@knit @@ -546,7 +648,7 @@ \commands@knit\extracommands@knit \def\nonumber{\global\showrn@knitfalse}% \csname auto#1@knit\endcsname #2\par}% - \ifresetrn \setcounter{tempcount@knit}{-\value{rownumber}}\fi + \ifresetrn \c@tempcount@knit = -\c@rownumber \fi \ifgrid \setbox\ggbox@knit=\vbox{\def\passnum@knit{1}\hsize=\maxdimen \gf@knit @@ -562,11 +664,12 @@ \def\nonumber{\global\showrn@knitfalse}% \csname auto#1@knit\endcsname #2\par}% \fi - \setcounter{rownumber}{\value{tempcount@knit}}% + \c@rownumber = \c@tempcount@knit % \global \rnleftwd@knit = 0pt \global \rnrightwd@knit = 0pt \setbox\fgbox@knit=\vbox{\def\passnum@knit{2}\hsize=\maxdimen \ff@knit + \color{forecolor} \lineskip=0pt \parskip=0pt \baselineskip=0pt @@ -601,7 +704,7 @@ % Special charts only macros \ifchartsonly - \ifpdf@knit\else\errmessage{\chartsonly should only be used with pdfTeX.}\fi% + \ifpdf@knit\else\errmessage{Package knit error: \chartsonly should only be used with pdfTeX.}\fi% \hoffset=-1in \voffset=-1in \oddsidemargin=0pt @@ -611,11 +714,12 @@ \headsep=0pt \footskip=0pt \textheight=120in + \topskip = 0pt % Causes problems in one-row charts if this isn't present \newenvironment{smallpage}{\clearpage - \hsize=\textwidth \columnwidth = \textwidth + \hsize=\textwidth \columnwidth = \textwidth \global\chartwidth@knit=0pt \setbox0 = \vbox\bgroup - \def\smallpage@knit{\let\endsmallpage@knit\egroup \noindent \hbox\bgroup}% + \def\smallpage@knit{\let\endsmallpage@knit\egroup \noindent \hbox\bgroup}% } {\egroup% % @@ -653,15 +757,15 @@ \newcommand \autoleft@knit{\everypar={\everypar@knit\rnleft@knit\do@endofpar@knit{\adjustchartwidth@knit}}} \newcommand \autoright@knit{\everypar={\everypar@knit\do@endofpar@knit{\rnright@knit\adjustchartwidth@knit}}} \newcommand \autooddleft@knit{\everypar={\everypar@knit - \ifodd \value{rownumber}\relax - \rnleft@knit\do@endofpar@knit{\adjustchartwidth@knit}% - \else %\hskip\rownumberwd - \do@endofpar@knit{\rnright@knit\adjustchartwidth@knit}\fi}} + \ifodd \c@rownumber % + \rnleft@knit\do@endofpar@knit{\adjustchartwidth@knit}% + \else %\hskip\rownumberwd + \do@endofpar@knit{\rnright@knit\adjustchartwidth@knit}\fi}} \newcommand \autooddright@knit{\everypar={\everypar@knit - \ifodd \value{rownumber}\relax %\hskip\rownumberwd - \do@endofpar@knit{\rnright@knit\adjustchartwidth@knit}% + \ifodd \c@rownumber %\hskip\rownumberwd + \do@endofpar@knit{\rnright@knit\adjustchartwidth@knit}% \else\rnleft@knit\do@endofpar@knit{\adjustchartwidth@knit}\fi}} -\newcommand \autoboth@knit{\everypar={\everypar@knit\rnleft@knit\global\advance\rownumber 1 \do@endofpar@knit{\rnright@knit\adjustchartwidth@knit}}} +\newcommand \autoboth@knit{\everypar={\everypar@knit\rnleft@knit\global\advance\c@rownumber 1 \do@endofpar@knit{\rnright@knit\adjustchartwidth@knit}}} \let\autoevenleft@knit\autooddright@knit \let\autoevenright@knit\autooddleft@knit @@ -674,31 +778,34 @@ % Stitch-counting macros \newcommand \adjuststitchcount[2][\temp@knit]{\def\temp@knit{#2}% - \leavevmode\ifnum\passnum@knit=3 \null + \leavevmode\ifnum\passnum@knit=3 \null \ifcountingout@knit \kern #2\stitchwd \else \kern #1\stitchwd \fi \null\fi} -\newcommand \stitchcountwarningbar{\ifnum \c@stitchcountinprev = \c@stitchcountout \else \vrule width \overfullrule \fi} +\newcommand \stitchcountwarningbar{% + \ifnum \c@stitchcountinprev = \c@stitchcountout \else + \ifnum \c@stitchcountinprev > -99 + \vrule width \overfullrule + \typeout{Package knit warning: Stitch count mismatch on input line \the\inputlineno.} + \fi \fi} \newcommand \countstitches[1]{% \global\c@stitchcountinprev = \c@stitchcountin - \setbox0 = \hbox{\def\passnum@knit{3}\countingout@knittrue \fontshape{out}\selectfont #1}% + \setbox0 = \hbox{\def\passnum@knit{3}\countingout@knittrue \let\stitchwd\stitchwd@count@knit \fontshape{out}\selectfont #1}% \c@stitchcountout = \wd0 - \dimen0 = 0.5\stitchwd \advance \c@stitchcountout \dimen0 - \global\divide \c@stitchcountout \stitchwd - \setbox1 = \hbox{\def\passnum@knit{3}\countingout@knitfalse \fontshape{in}\selectfont #1}% + \dimen0 = 0.5\stitchwd@count@knit \advance \c@stitchcountout \dimen0 + \global\divide \c@stitchcountout \stitchwd@count@knit + \setbox1 = \hbox{\def\passnum@knit{3}\countingout@knitfalse \let\stitchwd\stitchwd@count@knit \fontshape{in}\selectfont #1}% \c@stitchcountin = \wd1 - \dimen1 = 0.5\stitchwd \advance \c@stitchcountin \dimen1 - \global\divide \c@stitchcountin \stitchwd - \ifnum\c@stitchcountinprev < -99 - \global\c@stitchcountinprev = \c@stitchcountout - \fi + \dimen1 = 0.5\stitchwd@count@knit \advance \c@stitchcountin \dimen1 + \global\divide \c@stitchcountin \stitchwd@count@knit } -\newcommand \stitchcountchart[1][]{\begingroup \catcode`\|=\active \def\chartrn@knit{#1}\obeylines \afterassignment \printstitchcountchart@knit \toks0 =} +\newcommand \stitchcountchart[1][]{\begingroup \catcode`\|=\active \catcode`\# = 12 \catcode`\& = 12 \def\chartrn@knit{#1}\obeylines \afterassignment \printstitchcountchart@knit \toks0 =} \newcommand \printstitchcountchart@knit{\smallpage@knit\hbox{% \ifx\relax\printleftstitchcount\else\ifx \empty@knit \printleftstitchcount\else - \let\printstitchcount@knit\printleftstitchcount \def\stitchcountside@knit{0}\makestitchcounts@knit \fi\fi + \let\printstitchcount@knit\printleftstitchcount + \def\stitchcountside@knit{0}\makestitchcounts@knit \fi\fi \chart[\chartrn@knit]{\the\toks0}% \ifx\relax\printrightstitchcount\else\ifx \empty@knit \printrightstitchcount\else \let\printstitchcount@knit\printrightstitchcount @@ -708,34 +815,85 @@ {\obeylines \gdef\countstitcheseachrow@knit#1^^M{% + \setbox1 = \hbox{#1}% + \ifCountStsThisRow@knit% \countstitches{#1}% - \setbox0=\hbox{\def\passnum@knit{2}\strut@knit \printstitchcount@knit\stitchcountwarningbar}% - \setbox1=\hbox{#1}% - \ifdim \wd0 > \stitchcountwidth@knit \global\stitchcountwidth@knit = \wd0 \fi + \setstitchcountlabel@knit% + \else% + \global\CountStsThisRow@knittrue% + \setbox0=\hbox{}% + \fi% + \printstitchcountlabel@knit} +\gdef\shortrows@countstitcheseachrow@knit#1^^M{\countstitches{#1} % + \ifx \relax \shortrowrowcount@knit % + \global\advance \c@shortrowstsin@knit \c@stitchcountin \global\advance \c@shortrowstsout@knit \c@stitchcountout % + \global\let \shortrowrowcount@knit 2 + % For some reason, we MUST NOT have a % after the 2. + \else% + \global\advance \c@shortrowstsin@knit -\c@stitchcountout \global\advance \c@shortrowstsout@knit -\c@stitchcountin % + \global\let \shortrowrowcount@knit \relax + \fi% + \global\c@stitchcountin = \c@stitchcountinprev % + } +\gdef\shortrows@printstitchcountlabel@knit#1^^M{\setbox1 = \hbox{#1}\printstitchcountlabel@knit\setbox0=\hbox{}} +\gdef\shortrows#1{\ifnum \passnum@knit = 3 + \c@shortrowstsin@knit = 0 \c@shortrowstsout@knit = 0 \global\let \shortrowrowcount@knit \relax % + \setbox2 = \vbox{\everypar = {\shortrows@countstitcheseachrow@knit}% + #1 + }% + \ifx \shortrowrowcount@knit \relax \advance \c@stitchcountin \c@shortrowstsin@knit \advance \c@stitchcountin -\c@shortrowstsout@knit % + \else + \c@stitchcountinprev = \c@stitchcountin \c@stitchcountin = \c@shortrowstsin@knit \c@stitchcountout = \c@shortrowstsout@knit % + \fi % + \setstitchcountlabel@knit% + \vbox{\everypar = {\shortrows@printstitchcountlabel@knit}% + \ifx \shortrowrowcount@knit \relax \setbox0=\hbox{} \else + \ifCountStsThisRow@knit\else \setbox0=\hbox{} \global\CountStsThisRow@knittrue \fi \fi + % If there are an even number of short rows, we don't know the stitch count, + % so we don't print it + #1 + }% + \else% + #1 + \fi% + \par} + } + +\def\setstitchcountlabel@knit{\setbox0=\hbox{\def\passnum@knit{2}\strut@knit \printstitchcount@knit\stitchcountwarningbar}} +\def\printstitchcountlabel@knit{\ifdim \wd0 > \stitchcountwidth@knit \global\stitchcountwidth@knit = \wd0 \fi \hbox to 0pt{\ifnum\stitchcountside@knit = 0 \hss\fi - \vrule width 0pt height \ht1 depth \dp1 \smash{\box0}% - \ifnum\stitchcountside@knit = 1 \hss\fi}% - \par}} + \vrule width 0pt height \ht1 depth \dp1 \smash{\box0}% + \ifnum\stitchcountside@knit = 1 \hss\fi}% + \par} -\def\makestitchcounts@knit{\hbox{\setbox1=\vbox{\c@stitchcountin = -1001 \global\stitchcountwidth@knit=0pt +\def\makestitchcounts@knit{\hbox{\setbox1=\vbox{\c@stitchcountin = -1001 + \global\stitchcountwidth@knit=0pt + \global\CountStsThisRow@knittrue \parindent=0pt \def\passnum@knit{3} + \def\doifcounting@knit##1{##1} \ff@knit \commands@knit \everypar={\countstitcheseachrow@knit} \offinterlineskip \the\toks0 - }% - \ifnum\stitchcountside@knit = 0 - \hskip \stitchcountwidth@knit\rlap{\box1}% - \else - \rlap{\box1}\hskip \stitchcountwidth@knit - \fi + }% + \ifnum\stitchcountside@knit = 0 + \hskip \stitchcountwidth@knit\rlap{\box1}% + \else + \rlap{\box1}\hskip \stitchcountwidth@knit + \fi }} -\newcommand \empty@knit{} -% This is needed because the plain TeX \empty is -% defined with \def and not \newcommand +\def\nostitchcount{\ifnum \passnum@knit = 3 \global \CountStsThisRow@knitfalse \fi} \newcommand \printleftstitchcount{{\color{rncolor}\textnormal{(\thestitchcountout\ sts) }}} \newcommand \printrightstitchcount{} +\newcommand \knitdebug{\renewcommand \printleftstitchcount{{\color{rncolor}\textnormal{(\thestitchcountout\ out, \thestitchcountin\ in) }}}} + + + +\newcommand \empty@knit{} +% This is needed because the plain TeX \empty is +% defined with \def and not \newcommand + diff --git a/Master/texmf-dist/tex/latex/knitting/uknit.fd b/Master/texmf-dist/tex/latex/knitting/uknit.fd index 4291ea68280..afa6358a784 100644 --- a/Master/texmf-dist/tex/latex/knitting/uknit.fd +++ b/Master/texmf-dist/tex/latex/knitting/uknit.fd @@ -1,4 +1,4 @@ -\ProvidesFile{T1knit.fd}[2010/08/09 Knit fonts] +\ProvidesFile{T1knit.fd}[2019/04/03 Knit fonts] \DeclareFontFamily{U}{knit}{} @@ -9,6 +9,14 @@ \DeclareFontShape{U}{knit}{n}{in}{<-> knitn_sc_in}{} \DeclareFontShape{U}{knit}{n}{out}{<-> knitn_sc_out}{} +\DeclareFontShape{U}{knit}{m}{n}{<-> knitmn}{} +\DeclareFontShape{U}{knit}{m}{p}{<-> knitmp}{} +\DeclareFontShape{U}{knit}{m}{r}{<-> knitmr}{} +\DeclareFontShape{U}{knit}{m}{l}{<-> knitml}{} +\DeclareFontShape{U}{knit}{m}{g}{<-> knitmg}{} +\DeclareFontShape{U}{knit}{m}{in}{<-> knitn_sc_in}{} +\DeclareFontShape{U}{knit}{m}{out}{<-> knitn_sc_out}{} + \DeclareFontShape{U}{knit}{g}{n}{<-> knitgn}{} \DeclareFontShape{U}{knit}{g}{p}{<-> knitgp}{} \DeclareFontShape{U}{knit}{g}{g}{<-> knitgg}{} @@ -18,5 +26,5 @@ \DeclareFontShape{U}{knit}{w}{n}{<-> knitwn}{} \DeclareFontShape{U}{knit}{w}{p}{<-> knitwp}{} \DeclareFontShape{U}{knit}{w}{g}{<-> knitwg}{} -\DeclareFontShape{U}{knit}{w}{in}{<-> knitw_sc_in}{} -\DeclareFontShape{U}{knit}{w}{out}{<-> knitw_sc_out}{} +\DeclareFontShape{U}{knit}{w}{in}{<-> knitg_sc_in}{} +\DeclareFontShape{U}{knit}{w}{out}{<-> knitg_sc_out}{} diff --git a/Master/texmf-dist/tex/plain/knitting/knitting.tex b/Master/texmf-dist/tex/plain/knitting/knitting.tex index 509d291a7ca..17b6a0c242e 100644 --- a/Master/texmf-dist/tex/plain/knitting/knitting.tex +++ b/Master/texmf-dist/tex/plain/knitting/knitting.tex @@ -20,9 +20,9 @@ % The complete list of files considered part of this work is in % the file `knitting-doc.pdf' and its source code `knitting-doc.tex'. % -% Version: 2 +% Version: 3 -% Date: 2010/08/29 +% Date: 2019/04/03 %\pdfmapfile{+knitfont.map} @@ -31,24 +31,37 @@ \catcode`@=11 \fi +% +% Boolean variables +% + \newif \ifchartsonly \chartsonlyfalse \newif \ifgrid +\newif \ifknitsymbol \newif \ifresetrn \resetrntrue \newif \ifleftrn@knit \newif \ifshowrn@knit \showrn@knittrue \newif \ifpdf@knit \newif \ifcountingout@knit +\newif \ifCountStsThisRow@knit \CountStsThisRow@knittrue \pdf@knittrue \ifx \pdfoutput \undefined \pdf@knitfalse \fi \ifx \pdfoutput \relax \pdf@knitfalse \fi -% This defines pdfTeX-friendly or dvips-friendly grays. +% +% Color commands +% + +% This defines pdfTeX-friendly or dvips-friendly color. % Change them to use your driver's syntax if you insist on % not using pdfTeX. -% For black lines, just say \let\knitlinecolor \relax +% For black lines, just say \let \knitlinecolor \relax +% If grayscale really just isn't working at all, +% go down and redefine \changeknitsize \ifpdf@knit \ifnum \pdftexversion < 140 + \def\forecolor {\pdfliteral {0 g 0 G}\aftergroup\makenormalcolorknit} \def\purlgray {\pdfliteral {0.65 g 0.65 G}\aftergroup\makenormalcolorknit} \def\gridcolor {\pdfliteral {0.3 g 0.3 G}\aftergroup\makenormalcolorknit} \def\knitlinecolor {\pdfliteral {0.7 0 0 rg 0.7 0 0 RG}\aftergroup\makenormalcolorknit} @@ -56,6 +69,7 @@ \def\rnarrowcolor{\pdfliteral {0.35 0 0 rg 0.35 0 0 RG}\aftergroup\makenormalcolorknit} \def\makenormalcolorknit{\ifcase \passnum@knit \pdfliteral {0.65 g 0.65 G}\or \pdfliteral {0.3 g 0.3 G}\else \pdfliteral {0 g 0 G}\fi} \else + \def\forecolor {\pdfcolorstack 0 push {0 g 0 G}\aftergroup\makenormalcolorknit} \def\purlgray {\pdfcolorstack 0 push {0.65 g 0.65 G}\aftergroup\makenormalcolorknit} \def\gridcolor {\pdfcolorstack 0 push {0.3 g 0.3 G}\aftergroup\makenormalcolorknit} \def\knitlinecolor {\pdfcolorstack 0 push {0.7 0 0 rg 0.7 0 0 RG}\aftergroup\makenormalcolorknit} @@ -64,6 +78,7 @@ \def\makenormalcolorknit{\pdfcolorstack 0 pop} \fi \else + \def\forecolor {\special{color push gray 0}\aftergroup\makenormalcolorknit} \def\purlgray {\special{color push gray 0.65}\aftergroup\makenormalcolorknit} \def\gridcolor {\special{color push gray 0.3}\aftergroup\makenormalcolorknit} \def\knitlinecolor {\special{color push rgb 0.7 0 0}\aftergroup\makenormalcolorknit} @@ -71,40 +86,11 @@ \def\rnarrowcolor{\special{color push rgb 0.35 0 0}\aftergroup\makenormalcolorknit} \def\makenormalcolorknit{\special{color pop}} \fi +\def\knitoverlinecolor{\knitlinecolor} -% If grayscale really just isn't working at all, -% go down and redefine \changeknitsize - -\newdimen \leftgap@knit -\newdimen \bgshift@knit -\newdimen \chartwidth@knit -\newdimen \stitchcountwidth@knit -\newdimen \rnleftwd@knit -\newdimen \rnrightwd@knit -\newdimen \fontsize@knit - -\newbox\bgbox@knit -\newbox\fgbox@knit -\newbox\ggbox@knit - -\newcount \rownumber -\newcount \tempcount@knit -\newcount \rownumberskip \rownumberskip = 1 -\newcount \stitchcountin -\newcount \stitchcountinprev -\newcount \stitchcountout - -\def \passnum@knit{2} -\def \stitchwd{\fontdimen6\ff@knit} -\def \stitchht{\fontdimen5\ff@knit} -\def \stitchdp{\fontdimen8\ff@knit} -% fontdimen9 is the LaTeX stitch height -\def \gridwidth{\fontdimen10\ff@knit} -\def \knitlinewd{\fontdimen11\ff@knit} -\def \narrowincraise@knit{\fontdimen12\the\font} -\def \fontvoffset@knit{\fontdimen13\the\font} -\def \purlextend@knit{\fontdimen14\ff@knit} -\def \rownumberwd{\fontdimen6\ff@knit} +% +% Plain TeX-only material (change knit size) +% \def \changeknitsize#1{\fontsize@knit = #1 \font\knitsf = cmss10 at \fontsize@knit @@ -118,23 +104,35 @@ \font\gff@knit = knitgn at \fontsize@knit \font\wff@knit = knitwn at \fontsize@knit \font\nff@knit = knitnn at \fontsize@knit + \font\mff@knit = knitmn at \fontsize@knit % \font\ggf@knit = knitgg at \fontsize@knit \font\wgf@knit = knitwg at \fontsize@knit - \font\raiseff@knit = knitnr at \fontsize@knit - \font\lowerff@knit = knitnl at \fontsize@knit + \font\mgf@knit = knitmg at \fontsize@knit % \font\gpf@knit = knitgp at \fontsize@knit \font\wpf@knit = knitwp at \fontsize@knit \font\npf@knit = knitnp at \fontsize@knit + \font\mpf@knit = knitmp at \fontsize@knit + % + \font\raisen@knit = knitnr at \fontsize@knit + \font\lowern@knit = knitnl at \fontsize@knit + \font\raisem@knit = knitmr at \fontsize@knit + \font\lowerm@knit = knitml at \fontsize@knit + \let \raiseg@knit \raisem@knit + \let \raisew@knit \raisem@knit + \let \lowerg@knit \lowerm@knit + \let \lowerw@knit \lowerm@knit % \font \nstsout@knit = knitn_sc_out at \fontsize@knit \font \nstsin@knit = knitn_sc_in at \fontsize@knit \font \gstsout@knit = knitg_sc_out at \fontsize@knit \font \gstsin@knit = knitg_sc_in at \fontsize@knit - \font \wstsout@knit = knitw_sc_out at \fontsize@knit - \font \wstsin@knit = knitw_sc_in at \fontsize@knit - % + \let \wstsout@knit \gstsout@knit + \let \wstsin@knit \gstsin@knit + \let \mstsout@knit \nstsout@knit + \let \mstsin@knit \nstsin@knit + % %%% Use the following if you can't get the grays to work. %%% In this case, don't use \Purl or \purlbox. % \let \gridpf@knit \nullfont @@ -144,12 +142,71 @@ } \let \ngf@knit \nullfont + +% +% Dimensions +% + +\newdimen \leftgap@knit +\newdimen \bgshift@knit +\newdimen \chartwidth@knit +\newdimen \stitchcountwidth@knit +\newdimen \rnleftwd@knit +\newdimen \rnrightwd@knit +\newdimen \fontsize@knit + +\newbox\bgbox@knit +\newbox\fgbox@knit +\newbox\ggbox@knit + +\newcount \rownumber +\newcount \tempcount@knit +\newcount \rownumberskip \rownumberskip = 1 +\newcount \stitchcountin +\newcount \stitchcountinprev +\newcount \stitchcountout +\newcount \shortrowstsin@knit +\newcount \shortrowstsout@knit + +\def \passnum@knit{2} +\def \stitchwd{\fontdimen6\ff@knit} +\def \stitchwd@count@knit{\fontdimen6\stsout@knit} +\def \stitchht{\fontdimen5\ff@knit} +\def \stitchdp{\fontdimen8\ff@knit} +% fontdimen9 is the LaTeX stitch height +\def \gridwidth{\fontdimen10\ff@knit} +\def \knitlinewd{\fontdimen11\ff@knit} +\def \narrowincraise@knit{\fontdimen12\the\font} +\def \fontvoffset@knit{\fontdimen13\the\font} +\def \purlextend@knit{\fontdimen14\ff@knit} +\def \rownumberwd{\fontdimen6\ff@knit} +% The rest of them aren't \the\font because I want them to still work outside of a chart + +% +% Fonts +% + \def \ff@knit{\csname \series@knit ff@knit\endcsname} \def \gf@knit{\csname \series@knit gf@knit\endcsname} \def \pf@knit{\csname \series@knit pf@knit\endcsname} +\def \raiseff@knit{\csname raise\series@knit @knit\endcsname} +\def \lowerff@knit{\csname lower\series@knit @knit\endcsname} \def \stsout@knit{\csname \series@knit stsout@knit\endcsname} \def \stsin@knit{\csname \series@knit stsin@knit\endcsname} +\def \knitnogrid{\gridfalse\knitsymboltrue \def\series@knit{n}} +\def \knitgrid{\gridtrue \knitsymbolfalse\def\series@knit{g}} +\def \knitwide{\gridtrue \knitsymbolfalse\def\series@knit{w}} +\def \knitmixed{\gridtrue \knitsymboltrue \def\series@knit{m}} + +\changeknitsize{10pt} + +\knitgrid + +% +% Single-pass commands +% + \def \purlpass{\futurelet\next@knit\purlpass@@knit} \def \gridpass{\futurelet\next@knit\gridpass@@knit} \def \mainpass{\futurelet\next@knit\mainpass@@knit} @@ -158,52 +215,55 @@ \def \gridpass@@knit{\ifx\next@knit[\def\nextstep@knit{\gridpass@knit}\else\def\nextstep@knit{\gridpass@knit[]}\fi\nextstep@knit} \def \mainpass@@knit{\ifx\next@knit[\def\nextstep@knit{\mainpass@knit}\else\def\nextstep@knit{\mainpass@knit[]}\fi\nextstep@knit} \def \countpass@@knit{\ifx\next@knit[\def\nextstep@knit{\countpass@knit}\else\def\nextstep@knit{\countpass@knit[]}\fi\nextstep@knit} +\def \purlpass@knit[#1]#2{\ifnum\passnum@knit = 0 \def\nextstep@@knit{#2}\else \def\nextstep@@knit{#1}\fi\nextstep@@knit} \def \purlpass@knit[#1]#2{\ifnum\passnum@knit = 0 #2\else #1\fi} \def \gridpass@knit[#1]#2{\ifnum\passnum@knit = 1 #2\else #1\fi} \def \mainpass@knit[#1]#2{\ifnum\passnum@knit = 2 #2\else #1\fi} \def \countpass@knit[#1]#2{\ifnum\passnum@knit = 3 #2\else #1\fi} -\changeknitsize{10pt} - -\def \knitnogrid{\gridfalse\def\series@knit{n}} -\def \knitgrid{\gridtrue \def\series@knit{g}} -\def \knitwide{\gridtrue \def\series@knit{w}} - -\knitgrid +% +% Text knit +% -\def \textknit#1{\leavevmode\hbox{\ff@knit +\def \textknit#1{\leavevmode\hbox{\let\|\bar@knit\let\!\barthin@knit + \ff@knit \forecolor \rlap{\pf@knit \purlgray \def\passnum@knit{0}#1}% \ifgrid\rlap{\gf@knit \gridcolor \def\passnum@knit{1}#1}\fi \def\passnum@knit{2}#1}} \def \do@endofpar@knit#1{\def\par{#1\endgraf\let\par\endgraf}} +% % Special symbols +% -\def \narrowdecrease#1{\genbobble@knit{#1}{1}{-\narrowincraise@knit}\adjuststitchcount[#1]{0}\adjuststitchcount[-1]{0}} -\def \pnarrowdecrease#1{\genbobble@knit{#1}{2}{-\narrowincraise@knit}\adjuststitchcount[#1]{0}\adjuststitchcount[-1]{0}} -\def \narrowincrease#1{\genbobble@knit{#1}{3}{\narrowincraise@knit}\adjuststitchcount[0]{#1}\adjuststitchcount[0]{-1}} -\def \pnarrowincrease#1{\genbobble@knit{#1}{4}{\narrowincraise@knit}\adjuststitchcount[0]{#1}\adjuststitchcount[0]{-1}} +\def\narrowincreasestartnumber{1} +\def\narrowdecreaseendnumber{1} + +\def \narrowdecrease#1{\genbobble@knit{#1}{1}{-\narrowincraise@knit}\adjuststitchcount[#1]{\narrowdecreaseendnumber}\adjuststitchcount[-1]{-1}} +\def \pnarrowdecrease#1{\genbobble@knit{#1}{2}{-\narrowincraise@knit}\adjuststitchcount[#1]{\narrowdecreaseendnumber}\adjuststitchcount[-1]{-1}} +\def \narrowincrease#1{\genbobble@knit{#1}{3}{\narrowincraise@knit}\adjuststitchcount[\narrowincreasestartnumber]{#1}\adjuststitchcount[-1]{-1}} +\def \pnarrowincrease#1{\genbobble@knit{#1}{4}{\narrowincraise@knit}\adjuststitchcount[\narrowincreasestartnumber]{#1}\adjuststitchcount[-1]{-1}} \def \bobble#1{\genbobble@knit{#1}{0}{0pt}} -\def\genbobble@knit#1#2#3{\char#2 \ifnum \passnum@knit = 2 +\def \genbobble@knit#1#2#3{\char#2 \ifnum \passnum@knit = 2 \llap{\vbox to\stitchht{\vss \vskip\stitchdp \vskip\fontvoffset@knit \hbox to \stitchwd{\hfil\knitsfsmall@knit #1\hfil}\vskip #3\vss}}\fi} \def \wideincrease#1{\strut@knit \ifnum\passnum@knit = 3 \narrowincrease{#1}\else \hbox to #1\stitchwd{\char25 - \hskip-0.1pt\leaders\hbox{\char22}\hfil\hskip-0.1pt - \char29 - \hskip-0.1pt\leaders\hbox{\char22}\hfil\hskip-0.1pt - \char26}\fi} + \hskip-0.1pt\leaders\hbox{\char22}\hfil\hskip-0.1pt + \char29 + \hskip-0.1pt\leaders\hbox{\char22}\hfil\hskip-0.1pt + \char26}\fi} \def \widedecrease#1{\strut@knit \ifnum #1 = 5 \char31 \else \ifnum\passnum@knit = 3 \narrowdecrease{#1}\else \hbox to #1\stitchwd{\char27 - \hskip-0.1pt\leaders\hbox{\char22}\hfil\hskip-0.1pt - \char30 - \hskip-0.1pt\leaders\hbox{\char22}\hfil\hskip-0.1pt - \char28}\fi\fi} + \hskip-0.1pt\leaders\hbox{\char22}\hfil\hskip-0.1pt + \char30 + \hskip-0.1pt\leaders\hbox{\char22}\hfil\hskip-0.1pt + \char28}\fi\fi} % Standard chart commands @@ -220,9 +280,9 @@ \let \! \barthin@knit \let \| \bar@knit \let | \bar@knit - \let \_ \horizline@knit + \let \_ \horizlinenarrow@knit \let \= \horizlinewide@knit - \let \- \horizlinenarrow@knit + \let \- \horizline@knit \let\overline\overline@knit \let\underline\underline@knit \let\rn\rn@knit @@ -245,23 +305,27 @@ % Drawing lines on the chart -\def \horizline@knit{\ifnum\passnum@knit<3 \ifvmode\nonumber\leavevmode\fi \dimen0 = \stitchwd \advance \dimen0 \knitlinewd +\def \horizlinenarrow@knit{\ifnum\passnum@knit<3 \ifvmode\nonumber\leavevmode\fi \dimen0 = \stitchwd \advance \dimen0 \knitlinewd \ifnum\passnum@knit = 2 - \hskip -0.5\knitlinewd\smash{{\knitlinecolor \vrule width \dimen0 height 0.5\knitlinewd depth 0.5\knitlinewd}}\hskip -0.5\knitlinewd + \hskip -0.5\knitlinewd\smash{{\knitoverlinecolor \vrule width \dimen0 height 0.5\knitlinewd depth 0.5\knitlinewd}}\hskip -0.5\knitlinewd \else\hskip \stitchwd \fi\fi} -\def \horizlinenarrow@knit#1{\ifnum\passnum@knit<3 \ifvmode\nonumber\leavevmode\fi \dimen0 = #1\stitchwd \advance \dimen0 \gridwidth - \ifnum\passnum@knit = 2 - \hskip -0.5\gridwidth \smash{{\knitlinecolor \vrule width \dimen0 height 0.5\knitlinewd depth 0.5\knitlinewd}}\hskip -0.5\gridwidth - \else\hskip #1\stitchwd \fi\fi} \def \horizlinewide@knit#1{\ifnum\passnum@knit<3 \ifvmode\nonumber\leavevmode\fi \dimen0 = #1\stitchwd \advance \dimen0 \knitlinewd \ifnum\passnum@knit = 2 - \smash{{\knitlinecolor \vrule width \dimen0 height 0.5\knitlinewd depth 0.5\knitlinewd}} + \smash{{\knitoverlinecolor \vrule width \dimen0 height 0.5\knitlinewd depth 0.5\knitlinewd}} \else\hskip \dimen0 \fi\fi} +\def \horizline@knit{\futurelet\next@knit\horizline@@knit} +\def \horizline@@knit{\ifx\next@knit*% + \def\nextstep@knit{\horizlinestar@knit}\else + \def\nextstep@knit{\horizlinenostar@knit}\fi\nextstep@knit} + +\def \horizlinestar@knit#1{\nonumber\nostitchcount\overlinestar@knit{\hskip#1\stitchwd}} +\def \horizlinenostar@knit#1{\nonumber\nostitchcount\overlinenostar@knit{\hskip#1\stitchwd}} + \def \bar@knit{\ifnum\passnum@knit < 3 \leavevmode \ifgrid \ifnum \passnum@knit = 0 - \hbox{\knitlinecolor \vrule width \knitlinewd depth \stitchdp height \stitchht}% + \hbox{{\knitlinecolor \vrule width \knitlinewd depth \stitchdp height \stitchht}}% \else \kern \knitlinewd \fi @@ -293,14 +357,14 @@ \ifgrid \ifnum \passnum@knit = 0 \dimen1=\wd0 \advance\dimen1 by \gridwidth - {\rlap{\raise\ht0\hbox{\hskip -0.5\gridwidth\knitlinecolor \vrule width \dimen1 height \knitlinewd depth 0pt}}}% + {\rlap{\raise\ht0\hbox{\hskip -0.5\gridwidth\knitoverlinecolor \vrule width \dimen1 height \knitlinewd depth 0pt}}}% \else \raise\ht0\hbox{\vrule width 0pt height \knitlinewd depth 0pt}% \fi \else \ifnum \passnum@knit = 2 \dimen1=\wd0 \advance\dimen1 by \gridwidth - {\rlap{\raise\ht0\hbox{\hskip -0.5\gridwidth\knitlinecolor \vrule width \dimen1 height \knitlinewd depth 0pt}}}% + {\rlap{\raise\ht0\hbox{\hskip -0.5\gridwidth\knitoverlinecolor \vrule width \dimen1 height \knitlinewd depth 0pt}}}% \else \dimen0=\ht0 \advance \dimen0 \knitlinewd \vrule width 0pt height \dimen0 depth 0pt @@ -311,7 +375,7 @@ \setbox0 = \hbox{#2}% \ifnum \passnum@knit = 2 \dimen1=\wd0 \advance\dimen1 by \gridwidth - \smash{\rlap{\raise\ht0\hbox{\hskip -0.5\gridwidth\knitlinecolor \vrule width \dimen1 height 0.5\knitlinewd depth 0.5\knitlinewd}}}% + \smash{\rlap{\raise\ht0\hbox{\hskip -0.5\gridwidth\knitoverlinecolor \vrule width \dimen1 height 0.5\knitlinewd depth 0.5\knitlinewd}}}% \fi #2}} @@ -325,14 +389,14 @@ \ifgrid \ifnum \passnum@knit = 0 \dimen1=\wd0 \advance\dimen1 by \gridwidth - \rlap{\raise-\dp0\hbox{\hskip -0.5\gridwidth\knitlinecolor \vrule width \dimen1 height 0pt depth \knitlinewd \hskip -0.5\gridwidth}}% + \rlap{\raise-\dp0\hbox{\hskip -0.5\gridwidth\knitoverlinecolor \vrule width \dimen1 height 0pt depth \knitlinewd \hskip -0.5\gridwidth}}% \else \rlap{\raise-\dp0\hbox{\vrule width 0pt height 0pt depth \knitlinewd}}% \fi \else \ifnum \passnum@knit = 2 \dimen1=\wd0 \advance\dimen1 by \gridwidth - \rlap{\raise-\dp0\hbox{\hskip -0.5\gridwidth\knitlinecolor \vrule width \dimen1 height 0pt depth \knitlinewd \hskip -0.5\gridwidth}}% + \rlap{\raise-\dp0\hbox{\hskip -0.5\gridwidth\knitoverlinecolor \vrule width \dimen1 height 0pt depth \knitlinewd \hskip -0.5\gridwidth}}% \else \rlap{\raise-\dp0\hbox{\vrule width 0pt height 0pt depth \knitlinewd}}% \fi \fi @@ -342,46 +406,55 @@ \setbox0 = \hbox{#2}% \ifnum \passnum@knit = 2 \dimen1=\wd0 \advance\dimen1 by \gridwidth - \smash{\rlap{\raise-\dp0\hbox{\hskip -0.5\gridwidth\knitlinecolor \vrule width \dimen1 height 0.5\knitlinewd depth 0.5\knitlinewd \hskip -0.5\gridwidth}}}% + \smash{\rlap{\raise-\dp0\hbox{\hskip -0.5\gridwidth\knitoverlinecolor \vrule width \dimen1 height 0.5\knitlinewd depth 0.5\knitlinewd \hskip -0.5\gridwidth}}}% \fi #2}} % Fancy cabling -\def \overcableleft@knit#1{% - \setbox0=\hbox{#1}% - \rlap{#1}% - \hbox to \wd0{\leaders\hbox to \stitchwd{\hfil\char5}\hfil\hskip\stitchwd\char10}} -\def \undercableleft@knit#1{% - \setbox0=\hbox{#1}% - \rlap{#1}% - \hbox to \wd0{\leaders\hbox to \stitchwd{\hfil\char6}\hfil\hskip\stitchwd\char9}} -\def \undercableright@knit#1{% - \setbox0=\hbox{#1}% - \rlap{#1}% - \hbox to \wd0{\char13\char12\hskip\stitchwd\leaders\hbox to \stitchwd{\char8\hfil}\hfil}} -\def \overcableright@knit#1{% - \setbox0=\hbox{#1}% - \rlap{#1}% - \hbox to \wd0{\char14\char11\hskip\stitchwd\leaders\hbox to \stitchwd{\char7\hfil}\hfil}} - -\def \cableleft#1#2{\leavevmode{\knitnogrid +% \ifnum \passnum@knit = 3 \leavevmode \fi causes problems +% due to the weird things we do automatically at the start of a paragraph +\def\doifcounting@knit#1{} + +\def\cablebackground#1{\doifcounting@knit{\leavevmode}% + \ifnum \passnum@knit = 0 \leavevmode \hbox to \stitchwd{#1\hss {\raiseff@knit \def\passnum@knit{2}\forecolor#1}}\else \char255 \fi} +\def\cableforeground#1{\doifcounting@knit{\leavevmode}% + \ifnum \passnum@knit = 0 \leavevmode \hbox to \stitchwd{#1\hss {\lowerff@knit \def\passnum@knit{2}\forecolor#1}}\else \char254 \fi} + +\def\orphancablewarning@knit{\message{Package knit warning: Orphaned half cable on input line \the\inputlineno.}} + +\def \cableleft#1#2{\leavevmode{\ifgrid\knitmixed\fi \ifcase\passnum@knit - \hbox{\pf@knit #1#2} + \hbox{\pf@knit #1#2}% \or - \setbox0=\hbox{\pf@knit #1#2} - \vrule width \wd0 height 0pt depth 0pt \vrule width 0pt height \ht0 depth \dp0 + \setbox0=\hbox{\pf@knit #1#2}% + \hbox to \wd0{\char6\leaders\hbox{\char5}\hfil\char6}% \or - \hbox{\let\knitsf \cablesf@knit \let \knitsfsmall@knit \cablesfsmall@knit {\lowerff@knit \overcableleft@knit{#1}}{\raiseff@knit \undercableright@knit{#2}}} + \hbox{\let\knitsf \cablesf@knit \let \knitsfsmall@knit \cablesfsmall@knit % + \setbox1=\hbox{#1}% + \setbox2=\hbox{#2}% + \ifdim \wd1 = 0pt \orphancablewarning@knit \fi + \ifdim \wd2 = 0pt \orphancablewarning@knit \fi + {\lowerff@knit \rlap{#1}\hbox to \wd1{\leaders\hbox to \stitchwd{\hfil\char15}\hfil\ifdim\wd1>0pt \hskip\stitchwd\char10\fi}% + \ifdim\wd1>0pt \ifdim \wd2>0pt \char13\fi \fi }% + {\raiseff@knit \rlap{#2}\hbox to \wd2{\ifdim\wd2>0pt \char12\hskip\stitchwd\fi\leaders\hbox to \stitchwd{\char8\hfil}\hfil}}}% \else #1#2\fi}} -\def \cableright#1#2{\leavevmode{\knitnogrid +\def \cableright#1#2{\leavevmode{\ifgrid\knitmixed\fi \ifcase\passnum@knit - \hbox{\pf@knit #1#2} + \hbox{\pf@knit #1#2}% \or - \setbox0=\hbox{\pf@knit #1#2} \vrule width \wd0 height 0pt depth 0pt \vrule width 0pt height \ht0 depth \dp0 + \setbox0=\hbox{\pf@knit #1#2}% + \hbox to \wd0{\char6\leaders\hbox{\char5}\hfil\char6}% \or - \hbox{\let \knitsf \cablesf@knit \let \knitsfsmall@knit \cablesfsmall@knit {\raiseff@knit \undercableleft@knit{#1}}{\lowerff@knit \overcableright@knit{#2}}} + \hbox{\let\knitsf \cablesf@knit \let \knitsfsmall@knit \cablesfsmall@knit % + \setbox1=\hbox{#1}% + \setbox2=\hbox{#2}% + \ifdim \wd1 = 0pt \orphancablewarning@knit \fi + \ifdim \wd2 = 0pt \orphancablewarning@knit \fi + {\raiseff@knit \rlap{#1}\hbox to \wd1{\leaders\hbox to \stitchwd{\hfil\char16}\hfil\ifdim\wd1>0pt \hskip\stitchwd\char9\fi}% + \ifdim\wd1>0pt \ifdim \wd2>0pt \char14\fi \fi }% + {\lowerff@knit \rlap{#2}\hbox to \wd2{\ifdim\wd2>0pt \char11\hskip\stitchwd \fi\leaders\hbox to \stitchwd{\char7\hfil}\hfil}}}% \else #1#2\fi}} @@ -407,15 +480,27 @@ \else {\knitboxbackground \purlbackground{\vrule width #3\stitchwd depth \stitchdp height \stitchht}}\fi \or - \rlap{\hbox to #3\stitchwd{\leaders\hbox{\char5}\hfil}}% - \hbox to #3\stitchwd{\leaders\hbox to \stitchwd{\char6\hfil\char6}\hskip #1\stitchwd plus 1fil \hskip\wd0\leaders\hbox to \stitchwd{\char6\hfil\char6}\hfil}% + \ifknitsymbol + \hbox to #3\stitchwd{\char6\leaders\hbox{\char5}\hfil\char6}% + \else + \hbox{\hbox to #3\stitchwd{% + \leaders \hbox to \stitchwd{\char6\hfil\char6}\hfil + \hskip \wd0 + \leaders \hbox to \stitchwd{\char6\hfil\char6}\hfil}% + \hskip -#3\stitchwd + \hbox to #3\stitchwd{\char6\leaders\hbox{\char5}\hfil\char6}}% + \fi \or \hbox to #3\stitchwd{% - {\knitboxforeground\leaders\hbox{-}\hskip #1\stitchwd plus 1fil }% + {\knitboxforeground\leaders\hbox{-}% + \ifnum #1>0 \hskip #1\stitchwd plus 1fil minus #1\stitchwd \else\hfil\fi + }% \lower\stitchdp\vbox to\stitchht{\vss\vskip\fontvoffset@knit\hbox{\knitsf #2}\vss\vskip\stitchdp} - {\knitboxforeground\leaders\hbox{-}\hfil}}% + {\knitboxforeground \count255 = -#1 \leaders\hbox{-}% + \ifnum #1<0 \hskip \count255\stitchwd plus 1fil minus \count255\stitchwd \else\hfil\fi + }}% \or - \hbox to #3\stitchwd{\hfil} + \hbox to \Knitstitchcount{#2}{#3}\stitchwd{\hfil} \fi} \def \Purl{\futurelet\next@knit\Purl@knit} \def \Purl@knit{\ifx\next@knit[% @@ -429,17 +514,34 @@ \else {\purlboxbackground \purlbackground{\vrule width #3\stitchwd depth \stitchdp height \stitchht}}\fi \or - \rlap{\hbox to #3\stitchwd{\leaders\hbox{\char5}\hfil}}% - \hbox to #3\stitchwd{\leaders\hbox to \stitchwd{\char6\hfil\char6}\hskip #1\stitchwd plus 1fil \hskip\wd0\leaders\hbox to \stitchwd{\char6\hfil\char6}\hfil}% + \ifknitsymbol + \hbox to #3\stitchwd{\char6\leaders\hbox{\char5}\hfil\char6}% + \else + \hbox{\hbox to #3\stitchwd{% + \leaders \hbox to \stitchwd{\char6\hfil\char6}\hfil + \hskip \wd0 + \leaders \hbox to \stitchwd{\char6\hfil\char6}\hfil}% + \hskip -#3\stitchwd + \hbox to #3\stitchwd{\char6\leaders\hbox{\char5}\hfil\char6}}% + \fi \or \hbox to #3\stitchwd{% - {\purlboxforeground\leaders\hbox{=}\hskip #1\stitchwd plus 1fil }% + {\purlboxforeground\leaders\hbox{=}% + \ifnum #1>0 \hskip #1\stitchwd plus 1fil minus #1\stitchwd \else\hfil\fi + }% \lower\stitchdp\vbox to\stitchht{\vss\vskip\fontvoffset@knit\hbox{\knitsf #2}\vss\vskip\stitchdp} - {\purlboxforeground\leaders\hbox{=}\hfil}}% + {\purlboxforeground \count255 = -#1 \leaders\hbox{=}% + \ifnum #1<0 \hskip \count255\stitchwd plus 1fil minus \count255\stitchwd \else\hfil\fi + }}% \or - \hbox to #3\stitchwd{\hfil} + \hbox to \Purlstitchcount{#2}{#3}\stitchwd{\hfil} \fi} +\def \Knitstitchcount#1#2{#2} +\def \Purlstitchcount#1#2{#2} +\def \knitboxstitchcount#1#2{#2} +\def \purlboxstitchcount#1#2{#2} + \def \knitbox{\futurelet\next@knit\knitbox@knit} \def \knitbox@knit{\ifx\next@knit[% \def\nextstep@knit{\knitbox@@knit}\else @@ -453,9 +555,14 @@ \or \hbox to #3\stitchwd{\char6\leaders\hbox{\char5}\hfil\char6}% \or - \hbox to #3\stitchwd{\hskip #1\stitchwd plus 1fil \lower\stitchdp\vbox to\stitchht{\vss\vskip\fontvoffset@knit\hbox{\knitsf #2}\vss\vskip\stitchdp}\hfil} + \lower\stitchdp\vbox to\stitchht{% + \vss\vskip\fontvoffset@knit + \hbox to #3\stitchwd{\ifnum #1>0 \hskip #1\stitchwd plus 1fil minus #1\stitchwd \else\hfil\fi + {\knitsf #2}% + \count255 = -#1 \ifnum #1<0 \hskip \count255\stitchwd plus 1fil minus \count255\stitchwd \else\hfil\fi}% + \vss\vskip\stitchdp}% \or - \hbox to #3\stitchwd{\hfil} + \hbox to \knitboxstitchcount{#2}{#3}\stitchwd{\hfil} \fi} \def \purlbox{\futurelet\next@knit\purlbox@knit} \def \purlbox@knit{\ifx\next@knit[% @@ -470,21 +577,43 @@ \or \hbox to #3\stitchwd{\char6\leaders\hbox{\char5}\hfil\char6}% \or - \hbox to #3\stitchwd{\hskip #1\stitchwd plus 1fil \lower\stitchdp\vbox to\stitchht{\vss\vskip\fontvoffset@knit\hbox{\knitsf #2}\vss\vskip\stitchdp}\hfil}% + \lower\stitchdp\vbox to\stitchht{% + \vss\vskip\fontvoffset@knit + \hbox to #3\stitchwd{\ifnum #1>0 \hskip #1\stitchwd plus 1fil minus #1\stitchwd \else\hfil\fi + {\knitsf #2}% + \count255 = -#1 \ifnum #1<0 \hskip \count255\stitchwd plus 1fil minus \count255\stitchwd \else\hfil\fi}% + \vss\vskip\stitchdp}% \or - \hbox to #3\stitchwd{\hfil}% + \hbox to \purlboxstitchcount{#2}{#3}\stitchwd{\hfil}% \fi} -\def \purlbackground#1{\leavevmode\setbox0=\hbox{#1}% - \dimen0 = \wd0 \advance\dimen0 2\purlextend@knit - \dimen1 = \stitchht \advance\dimen1 \purlextend@knit - \dimen2 = \stitchdp \advance\dimen2 \purlextend@knit - \ifnum \passnum@knit = 0 \kern-\purlextend@knit +\def \purlbackground#1{% + \ifnum\passnum@knit=0 + \setbox0=\hbox{#1}% + \dimen0 = \wd0 \advance\dimen0 2\purlextend@knit + \dimen1 = \stitchht \advance\dimen1 \purlextend@knit + \dimen2 = \stitchdp \advance\dimen2 \purlextend@knit \vrule width 0pt height \ht0 depth \dp0 \smash{\vrule width \dimen0 height \dimen1 depth \dimen2}% \kern-\purlextend@knit - \else\box0\fi} - + \else#1\fi} + +\def \widesymbol{\futurelet\next@knit\widesymbol@knit} +\def \widesymbol@knit{\ifx\next@knit[% + \def\nextstep@knit{\widesymbol@@knit}\else + \def\nextstep@knit{\widesymbol@@knit[0]}\fi\nextstep@knit} +\def \widesymbol@@knit[#1]#2#3{\strut@knit + \ifcase \passnum@knit + \knitbox{}{#3}\or + \knitbox{}{#3}\or + \hbox to #3\stitchwd{\ifnum #1>0 \hskip #1\stitchwd plus 1fil minus #1\stitchwd \else\hfil\fi + #2% + \count255 = -#1 \ifnum #1<0 \hskip \count255\stitchwd plus 1fil minus \count255\stitchwd \else\hfil\fi}\else + \widesymbolspacer{#2}{#3}\relax\fi} + +\def\widesymbolspacer#1#2{#1} + + % Row number commands \def \numberrow#1#2#3{\ifnum\passnum@knit=3 \ifvmode\vskip\stitchht\fi\else @@ -522,15 +651,15 @@ \hbox to \stitchwd{\hss\ifnum \passnum@knit = 2 \rncolor \knitrm#3\fi \hss}% \fi} -\def \rnoddonly{\def\rncore@knit##1{\ifshowrn@knit \ifodd\rownumber\csname print##1rownumber\endcsname{\therownumber}\fi\fi}} -\def \rnevenonly{\def\rncore@knit##1{\ifshowrn@knit \ifodd\rownumber\else\csname print##1rownumber\endcsname{\therownumber}\fi\fi}} +\def \rnoddonly{\def\rncore@knit##1{\ifshowrn@knit \ifodd\rownumber \csname print##1rownumber\endcsname{\therownumber}\fi\fi}} +\def \rnevenonly{\def\rncore@knit##1{\ifshowrn@knit \ifodd\rownumber \else\csname print##1rownumber\endcsname{\therownumber}\fi\fi}} \def \rnnormal{\def\rncore@knit##1{\ifshowrn@knit \csname print##1rownumber\endcsname{\therownumber}\fi}} \def \rncore@knit#1{\ifshowrn@knit \csname print#1rownumber\endcsname{\therownumber}\fi} \def \rnstep@knit{\ifshowrn@knit - \ifnum \passnum@knit = 2 \global\advance\rownumber -\rownumberskip\relax\fi - \ifnum \passnum@knit = 0 \global\advance\rownumber -\rownumberskip\relax\fi - \else\global\showrn@knittrue\fi} + \ifnum \passnum@knit = 2 \global\advance\rownumber -\rownumberskip \relax\fi + \ifnum \passnum@knit = 0 \global\advance\rownumber -\rownumberskip \relax\fi + \else\global\showrn@knittrue\fi} \def \printrownumber#1{{\rncolor \knitrm #1}} \def \printrightrownumber#1{\knitleftarrowhead{\rncolor \knitrm #1}} @@ -569,13 +698,17 @@ \ifchartsonly \advance \dimen0 1pt \fi \ifdim \dimen0 > \rnrightwd@knit \global\rnrightwd@knit = \dimen0 \fi \hbox to 0pt{\box0\hss}\fi} + +% Title for the chart +\def\charttitle@knit{} +\def\titlechart#1{\def\charttitle@knit{#1}} % The chart commands \def \chart{\futurelet\next@knit\chart@@knit} \def \chart@@knit{\ifx\next@knit[% - \def\nextstep@knit{\smallpage@knit\obeylines \catcode`\|=\active \chart@knit}\else - \def\nextstep@knit{\smallpage@knit\obeylines \catcode`\|=\active \chart@knit[]}\fi\nextstep@knit} + \def\nextstep@knit{\smallpage@knit\obeylines \catcode`\|=\active \catcode`\# = 12 \chart@knit}\else + \def\nextstep@knit{\smallpage@knit\obeylines \catcode`\|=\active \catcode`\# = 12 \chart@knit[]}\fi\nextstep@knit} % Some special stuff for chartsonly mode \let\extracommands@knit\relax @@ -616,7 +749,7 @@ \def\nonumber{\global\showrn@knitfalse}% \csname auto#1@knit\endcsname #2\par}% \fi - \rownumber = \tempcount@knit + \rownumber = \tempcount@knit % \global \rnleftwd@knit = 0pt \global \rnrightwd@knit = 0pt \setbox\fgbox@knit=\vbox{\def\passnum@knit{2}\hsize=\maxdimen @@ -634,9 +767,11 @@ \csname auto#1@knit\endcsname #2\par}% \global\advance \chartwidth@knit \rnleftwd@knit \global\advance \chartwidth@knit \rnrightwd@knit + \ifchartsonly \global\advance \chartwidth@knit 0.5\gridwidth \fi \hbox to \chartwidth@knit{\hskip \rnleftwd@knit \rlap{\purlgray \box\bgbox@knit}% \ifgrid\rlap{\gridcolor \box\ggbox@knit}\fi + % \ifchartsonly \dimen2 = \dp \fgbox@knit \dimen3 = \ht \fgbox@knit \advance\dimen2 0.5\gridwidth \advance\dimen3 0.5\gridwidth @@ -647,37 +782,73 @@ % But if we aren't, we want adjacent charts to merge seamlessly % because using separate charts is the only way to allow charts to % break across pages. - \box\fgbox@knit% + \vbox{% + \ifx\empty\charttitle@knit\empty\else + \hbox to \chartwidth@knit{\hskip \rnleftwd@knit\printcharttitle{\charttitle@knit}\hskip \rnrightwd@knit}\fi + \box\fgbox@knit}% \hss}% \endsmallpage@knit + \gdef\charttitle@knit{} } +\def\printcharttitle#1{\hfil\vrule depth 3pt height 9pt width 0pt \relax #1\hfil} + % Special charts only macros +\newif \ifchartsonlysideways \chartsonlysidewaysfalse + \def \chartsonly{\chartsonlytrue - \ifpdf@knit\else\errmessage{\chartsonly should only be used with pdfTeX.}\fi% + \ifpdf@knit\else\errmessage{Package knit error: \chartsonly should only be used with pdfTeX.}\fi% \hoffset=-1in \voffset=-1in \vsize = 120in + \topskip = 0pt % Causes problems in one-row charts if this isn't present \def\smallpage{\vfil\break \global\chartwidth@knit=0pt \setbox0 = \vbox\bgroup \def\smallpage@knit{\let\endsmallpage@knit\egroup \noindent \hbox\bgroup}% } \def\endsmallpage{\egroup% - % - \pdfpagewidth=\wd0 - % - \dimen0=\ht0 \advance \dimen0 by \dp0 - \pdfpageheight=\dimen0 - % - \ifdim \pdfpageheight > \vsize - {\newlinechar=`| - \message{||You need to increase \string\vsize.} - \message{What do you want such a big chart for, anyway?||}} - \fi - % - \box0 + \ifchartsonlysideways + % + \pdfpageheight=\wd0 + % + \dimen0=\ht0 \advance \dimen0 by \dp0 + \pdfpagewidth=\dimen0 + % + \ifdim \pdfpagewidth > \vsize + %{\newlinechar=`| + %\message{||The chart ending on line \the\inputlineno\space is too big.} + %\message{|Compensate by increasing \string\vsize\space or by breaking the chart into pieces.}% + %\message{|What do you want such a big chart for, anyway?||}}% + \fi + % + % Commands borrowed from samplepdf.tex + \setbox1=\hbox{\copy0}% + \wd1 = 0pt + \ht1 = 0pt + \dp1 = 0pt + \vtop{\vskip\wd0 + \leftline{\hskip-2pt\hskip\ht0\hskip\dp0% + \pdfliteral{q 0 1 -1 0 0 0 cm}% + \box1 + \pdfliteral{Q}}} + \else + % + \pdfpagewidth=\wd0 + % + \dimen0=\ht0 \advance \dimen0 by \dp0 + \pdfpageheight=\dimen0 + % + \ifdim \pdfpageheight > \vsize + %{\newlinechar=`| + %\message{||The chart ending on line \the\inputlineno\space is too big.} + %\message{Compensate by increasing \string\vsize\space or by breaking the chart into pieces.}% + %\message{What do you want such a big chart for, anyway?||}}% + \fi + % + \box0 + \fi \vfil\break } \let\smallpage@knit\smallpage @@ -685,6 +856,7 @@ \def\extracommands@knit{% \leftskip = 0.5\gridwidth \rightskip = 0.5\gridwidth + %\vskip \gridwidth } } \let\smallpage\begingroup @@ -698,13 +870,13 @@ \def \autoleft@knit{\everypar={\everypar@knit\rnleft@knit\do@endofpar@knit{\adjustchartwidth@knit}}} \def \autoright@knit{\everypar={\everypar@knit\do@endofpar@knit{\rnright@knit\adjustchartwidth@knit}}} \def \autooddleft@knit{\everypar={\everypar@knit - \ifodd \rownumber - \rnleft@knit\do@endofpar@knit{\adjustchartwidth@knit}% - \else %\hskip\rownumberwd - \do@endofpar@knit{\rnright@knit\adjustchartwidth@knit}\fi}} + \ifodd \rownumber % + \rnleft@knit\do@endofpar@knit{\adjustchartwidth@knit}% + \else %\hskip\rownumberwd + \do@endofpar@knit{\rnright@knit\adjustchartwidth@knit}\fi}} \def \autooddright@knit{\everypar={\everypar@knit - \ifodd \rownumber %\hskip\rownumberwd - \do@endofpar@knit{\rnright@knit\adjustchartwidth@knit}% + \ifodd \rownumber %\hskip\rownumberwd + \do@endofpar@knit{\rnright@knit\adjustchartwidth@knit}% \else\rnleft@knit\do@endofpar@knit{\adjustchartwidth@knit}\fi}} \def \autoboth@knit{\everypar={\everypar@knit\rnleft@knit\global\advance\rownumber 1 \do@endofpar@knit{\rnright@knit\adjustchartwidth@knit}}} \let\autoevenleft@knit\autooddright@knit @@ -726,28 +898,30 @@ \leavevmode\ifnum\passnum@knit=3 \null \ifcountingout@knit \kern #2\stitchwd \else \ifx#1\relax \kern#2\stitchwd \else \kern #1\stitchwd \fi \fi \null\fi} -\def \stitchcountwarningbar{\ifnum \stitchcountinprev = \stitchcountout \else \vrule width \overfullrule \fi} +\def \stitchcountwarningbar{% + \ifnum \stitchcountinprev = \stitchcountout \else + \ifnum \stitchcountinprev > -99 + \vrule width \overfullrule + \message{Package knit warning: Stitch count mismatch on input line \the\inputlineno.} + \fi \fi} \def \countstitches#1{% \global\stitchcountinprev = \stitchcountin - \setbox0 = \hbox{\def\passnum@knit{3}\countingout@knittrue \stsout@knit #1}% + \setbox0 = \hbox{\def\passnum@knit{3}\countingout@knittrue \let\stitchwd\stitchwd@count@knit \stsout@knit #1}% \stitchcountout = \wd0 - \dimen0 = 0.5\stitchwd \advance \stitchcountout \dimen0 - \global\divide \stitchcountout \stitchwd - \setbox1 = \hbox{\def\passnum@knit{3}\countingout@knitfalse \stsin@knit #1}% + \dimen0 = 0.5\stitchwd@count@knit \advance \stitchcountout \dimen0 + \global\divide \stitchcountout \stitchwd@count@knit + \setbox1 = \hbox{\def\passnum@knit{3}\countingout@knitfalse \let\stitchwd\stitchwd@count@knit \stsin@knit #1}% \stitchcountin = \wd1 - \dimen1 = 0.5\stitchwd \advance \stitchcountin \dimen1 - \global\divide \stitchcountin \stitchwd - \ifnum\stitchcountinprev < -99 - \global\stitchcountinprev = \stitchcountout - \fi + \dimen1 = 0.5\stitchwd@count@knit \advance \stitchcountin \dimen1 + \global\divide \stitchcountin \stitchwd@count@knit } \def \stitchcountchart{\futurelet\next@knit\stitchcountchart@knit} \def \stitchcountchart@knit{\ifx\next@knit[% \def\nextstep@knit{\stitchcountchart@@knit}\else \def\nextstep@knit{\stitchcountchart@@knit[]}\fi\nextstep@knit} -\def \stitchcountchart@@knit[#1]{\begingroup \catcode`\|=\active \def\chartrn@knit{#1}\obeylines \afterassignment \printstitchcountchart@knit \toks0 =} +\def \stitchcountchart@@knit[#1]{\begingroup \catcode`\|=\active \catcode`\# = 12 \def\chartrn@knit{#1}\obeylines \afterassignment \printstitchcountchart@knit \toks0 =} \def \printstitchcountchart@knit{\smallpage@knit\hbox{% \ifx\relax\printleftstitchcount\else\ifx \empty \printleftstitchcount\else @@ -762,18 +936,63 @@ {\obeylines \gdef\countstitcheseachrow@knit#1^^M{% + \setbox1 = \hbox{#1}% + \ifCountStsThisRow@knit% \countstitches{#1}% - \setbox0=\hbox{\def\passnum@knit{2}\strut@knit \printstitchcount@knit\stitchcountwarningbar}% - \setbox1=\hbox{#1}% - \ifdim \wd0 > \stitchcountwidth@knit \global\stitchcountwidth@knit = \wd0 \fi + \setstitchcountlabel@knit% + \else% + \global\CountStsThisRow@knittrue% + \setbox0=\hbox{}% + \fi% + \printstitchcountlabel@knit} +\gdef\shortrows@countstitcheseachrow@knit#1^^M{\countstitches{#1} % + \ifx \relax \shortrowrowcount@knit % + \global\advance \shortrowstsin@knit \stitchcountin \global\advance \shortrowstsout@knit \stitchcountout % + \global\let \shortrowrowcount@knit 2 + % For some reason, we MUST NOT have a % after the 2. + \else% + \global\advance \shortrowstsin@knit -\stitchcountout \global\advance \shortrowstsout@knit -\stitchcountin % + \global\let \shortrowrowcount@knit \relax + \fi% + \global\stitchcountin = \stitchcountinprev % + } +\gdef\shortrows@printstitchcountlabel@knit#1^^M{\setbox1 = \hbox{#1}\printstitchcountlabel@knit\setbox0=\hbox{}} +\gdef\shortrows#1{% + \ifnum \passnum@knit = 3 + \shortrowstsin@knit = 0 \shortrowstsout@knit = 0 \global\let \shortrowrowcount@knit \relax % + \setbox2 = \vbox{\everypar = {\shortrows@countstitcheseachrow@knit}% + #1 + }% + \ifx \shortrowrowcount@knit \relax + \advance \stitchcountin \shortrowstsin@knit \advance \stitchcountin -\shortrowstsout@knit % + \else + \stitchcountinprev = \stitchcountin \stitchcountin = \shortrowstsin@knit \stitchcountout = \shortrowstsout@knit % + \fi % + \setstitchcountlabel@knit% + \vbox{\everypar = {\shortrows@printstitchcountlabel@knit}% + \ifx \shortrowrowcount@knit \relax \setbox0=\hbox{} \else + \ifCountStsThisRow@knit\else \setbox0=\hbox{} \global\CountStsThisRow@knittrue \fi \fi + #1 + }% + \else% + #1 + \fi% + \par} + } + +\def\setstitchcountlabel@knit{\setbox0=\hbox{\def\passnum@knit{2}\strut@knit \printstitchcount@knit\stitchcountwarningbar}} +\def\printstitchcountlabel@knit{\ifdim \wd0 > \stitchcountwidth@knit \global\stitchcountwidth@knit = \wd0 \fi \hbox to 0pt{\ifnum\stitchcountside@knit = 0 \hss\fi \vrule width 0pt height \ht1 depth \dp1 \smash{\box0}% \ifnum\stitchcountside@knit = 1 \hss\fi}% - \par}} + \par} -\def\makestitchcounts@knit{\hbox{\setbox1=\vbox{\stitchcountin = -1001 \global\stitchcountwidth@knit=0pt +\def\makestitchcounts@knit{\hbox{\setbox1=\vbox{\stitchcountin = -1001 + \global\stitchcountwidth@knit=0pt + \global\CountStsThisRow@knittrue \parindent=0pt \def\passnum@knit{3} + \def\doifcounting@knit##1{##1} \ff@knit \commands@knit \everypar={\countstitcheseachrow@knit} \offinterlineskip @@ -786,8 +1005,14 @@ \fi }} +\def\nostitchcount{\ifnum \passnum@knit = 3 \global \CountStsThisRow@knitfalse \fi} + +\def \knitdebug{\def \printleftstitchcount{{\rncolor \knitrm(\the\stitchcountout\ out, \the\stitchcountin\ in) }}} + \def \printleftstitchcount{{\rncolor \knitrm(\the\stitchcountout\ sts) }} \def \printrightstitchcount{} +\def \knitdebugging{\def \printleftstitchcount{{\rncolor \knitrm(\the\stitchcountout\ out/\the\stitchcountin\ in) }}} + \catcode`\@=\catcountknit |