diff options
author | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
commit | e0c6872cf40896c7be36b11dcc744620f10adf1d (patch) | |
tree | 60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/generic/labtex |
Initial commit
Diffstat (limited to 'macros/generic/labtex')
-rw-r--r-- | macros/generic/labtex/labtex.mf | 106 | ||||
-rw-r--r-- | macros/generic/labtex/labtex.tex | 153 | ||||
-rw-r--r-- | macros/generic/labtex/xminus1.mf | 40 | ||||
-rw-r--r-- | macros/generic/labtex/xminus1.tex | 26 |
4 files changed, 325 insertions, 0 deletions
diff --git a/macros/generic/labtex/labtex.mf b/macros/generic/labtex/labtex.mf new file mode 100644 index 0000000000..b8794c069d --- /dev/null +++ b/macros/generic/labtex/labtex.mf @@ -0,0 +1,106 @@ +%% This LabTeX, v 0.9
+
+% written by: Alan Hoenig, summer 1991-summer 1992.
+% Bitnet: ajhjj@cunyvm
+% Mail: 17 Bay Avenue, Huntington, NY 11743, USA
+%
+
+% This is file LABTEX.MF. You will also need the file LABTEX.TEX, as
+% well as TeX, Metafont, and their support programs.
+%
+% Here's how to use the Metafont part of the labtex macros.
+%
+% You will create a font source file with each character being a figure
+% that you want. Before the `mode_setup;' command, enter the line
+% input labtex;
+% so Metafont will know the meaning of the macros you'll be using.
+%
+% In the course of creating your figure, you will define the points
+% which serve as the anchors for the labels. After all these have been
+% defined, and before the `endchar;' command, enter
+% labtex(point list);
+% where <point list> is the list of points. If you'd like, use
+% `beginfig' and `endfig' as synonyms for `beginchar' and `endchar'.
+%
+% When Metafont creates your font, create the packed pixel file, move
+% the pk file and the tfm file to the usual place on your hard disk,
+% and prepare to create your TeX source file. See the comments in
+% labtex.tex to see what to do next.
+%
+
+numeric chars[];
+
+vardef lab@#=(x_@#, y_@#) enddef;
+def clearx_y_=save x_, y_ enddef;
+
+def char_init(expr c)= %
+clearx_y_;
+i:=c; chars[i]=1;
+enddef;
+
+extra_beginchar:=extra_beginchar&"char_init(charcode)";
+
+numeric running_label_amt; running_label_amt=0;
+numeric xx_[], yy_[]; % to store the kerns for ligtable
+numeric lpf[]; % to store labels per fig
+def char_fin=
+i:=0;
+forever:
+ exitif not known x_[i];
+ i:=i+1; endfor
+%for j=0 upto i-1: show "X",x_[j], "Y",y_[j]; endfor
+label_amt:=i;
+for i:=0 upto label_amt-1:
+ xx_[running_label_amt +i]=x_[i];
+ yy_[running_label_amt +i]=y_[i]; endfor
+lpf[charcode]=label_amt;
+running_label_amt:=running_label_amt+label_amt;
+enddef;
+
+extra_endchar:=extra_endchar&"char_fin";
+
+% fpf=figures per font
+def fillfont= % to define all chars not yet defined
+ % and to create ligtable
+ show "Now filling font. Patience, please.";
+ last_char=255;
+ for i=0 upto last_char: % need MF2!
+% show i, chars[i];
+ if not known chars[i]: beginchar(i,0,0,0); endchar;
+ if not known fpf: fpf=i; fi fi
+ endfor
+% ligtable machinations only done if at least one label in at least
+% one fig.
+if known lpf[1]:
+ doligtable; fi
+enddef;
+
+def doligtable=
+ ligtable 0: 0 kern xx_0/hppp
+ for i=1 upto running_label_amt-1: , i kern xx_[i]/hppp endfor;
+ ligtable 1: 0 kern yy_0/hppp
+ for i=1 upto running_label_amt-1: , i kern yy_[i]/hppp endfor;
+ ligtable 2: 0 kern lpf0
+ for i=1 upto fpf: , i kern lpf[i] endfor;
+enddef;
+
+vardef labtex(text t)= % t is a list of pair names
+ save I; I=0; % I is a counter
+ for $=t: lab[I]=$; I:=I+1; endfor
+enddef;
+
+
+let beginfig=beginchar;
+let endfig=endchar;
+
+inner end, bye; let savedend=end; let savedbye=bye;
+boolean filledfont; filledfont=false;
+def end= if not filledfont: filledfont:=true; fillfont; fi
+ savedend;
+enddef;
+let bye=end;
+outer end, bye;
+
+
+endinput;
+
diff --git a/macros/generic/labtex/labtex.tex b/macros/generic/labtex/labtex.tex new file mode 100644 index 0000000000..099e477b00 --- /dev/null +++ b/macros/generic/labtex/labtex.tex @@ -0,0 +1,153 @@ +% This is labtex, v 0.9.
+
+% written by: Alan Hoenig, summer 1991-summer 1992.
+% Bitnet: ajhjj@cunyvm
+% Mail: 17 Bay Avenue, Huntington, NY 11743, USA
+%
+
+% You need the file LABTEX.MF in addition to this one.
+
+% If you've got this far, you have created a special figure font. Let's
+% pretend it's called figfont. At the start of your TeX document,
+% include the lines
+% \input labtex
+% \font\labtex=figfont
+% and wherever you wnat to include a figure enter
+% \fig$
+% <label list>
+% \endfig
+% where $ represents the numeric position in the font occupied by your
+% figure. Each item in the list is one of the pointing commands defined
+% below coupled with the text of the label (eg. \blpoint{$(x,y)$}).
+% It's that simple.
+%
+
+\newif\ifdebug
+\debugfalse
+\newcount\labels
+{\catcode`.=12 \catcode`p=12 \catcode`t=12
+ \gdef\\#1.#2pt{\global\labels=#1
+ }}\let\glpf=\\
+
+\def\getx#1{\setbox2=\hbox{\labtex\char0 \char#1}%
+ \setbox0=\hbox{\labtex\char0{}\char#1}%
+ \dimen0=\wd2 \advance\dimen0 by-\wd0
+}
+\def\gety#1{\setbox2=\hbox{\labtex\char1 \char#1}%
+ \setbox0=\hbox{\labtex\char1{}\char#1}%
+ \dimen0=\wd2 \advance\dimen0 by-\wd0
+}
+\def\getlpf#1{\setbox2=\hbox{\labtex\char2 \char#1}%
+ \setbox0=\hbox{\labtex\char2{}\char#1}%
+ \dimen0=\wd2 \advance\dimen0 by-\wd0
+}
+
+\newbox\figbox % to hold figure for printing
+\newcount\coordcount \newcount\figcount
+\newdimen\x \newdimen\y
+\newdimen\figwd \newdimen\fight \newdimen\figdp
+\def\fig#1{% usage: \fig2, where 2 is the figure number
+ \figcount=#1%
+ \setbox\figbox=\hbox{\labtex \char\figcount }%
+ \global\figwd=\wd\figbox \global\fight=\ht\figbox
+ \global\figdp=\dp\figbox \zerobox\figbox%
+ \setXYpointers{#1}% ensures \coordcount's value is the char whose kern
+ % is \x; same for \y
+ \hbox\bgroup\box\figbox % now add \point'ing commands and labels
+ \vrule width0pt height\fight depth\figdp
+}
+\def\endfig{\kern\figwd\egroup}
+
+\def\zerobox#1{\wd#1=0pt \ht#1=0pt \dp#1=0pt}
+
+\newcount\scratch \newcount\totallabs
+\def\setXYpointers#1{\scratch=0 \totallabs=0%
+ \coordcount=0 % start with fresh slate
+ \loop\ifnum\scratch<#1%
+ \getlpf\scratch \expandafter\glpf\the\dimen0
+ \advance\totallabs by\labels
+ \advance\scratch by 1 \repeat
+ \coordcount=\totallabs
+}
+
+\newdimen\extradx \newdimen\extrady \newtoks\everylabel
+\newbox\labelbox \newdimen\totalht
+\newdimen\labelht \newdimen\labelwd \newdimen\labeldp
+\newdimen\vertadjust \newdimen\horadjust% vertical adjustment of labels
+\def\getparameters#1{% #1 is text of label
+ \global\vertadjust=0pt \global\horadjust=0pt
+ \setbox\labelbox=\hbox{\the\everylabel #1}%
+ \labelht=\ht\labelbox \labeldp=\dp\labelbox
+ \advance\labelht by\extrady \advance\labeldp by\extrady
+ \totalht=\labelht \advance\totalht by\labeldp
+ \setbox\labelbox=\hbox{\the\everylabel
+ \vrule width0pt height\labelht depth\labeldp
+ \hskip\extradx #1\hskip\extradx}\labelwd=\wd\labelbox %
+ \ifdebug \showthe\coordcount \fi
+ \getx\coordcount \x=\dimen0 \advance\x by\horadjust
+ \ifdebug \showthe\dimen0 \fi % \x before \horadjust
+ \gety\coordcount \y=\dimen0 \advance\y by\vertadjust
+ \ifdebug \showthe\dimen0 \fi % \y before \vertadjust
+ \ifdebug \showthe\x \showthe\y \fi % after adjustments
+ \advance\coordcount by1
+}
+\def\down{\global\vertadjust= -}
+\def\up{\global\vertadjust= }
+\def\left{\global\horadjust= -}
+\def\right{\global\horadjust= }
+
+\def\reset{% puts ref pt of \labelbox at lower left, not at baseline
+ \advance\y by \labeldp}
+
+\def\point#1{\getparameters{#1}% point to left end of Baseline
+ \rlap{\kern\x \raise\y \box\labelbox}}
+\let\Bpoint=\point \let\Blpoint=\point \let\lBpoint=\point % synonyms
+
+\def\Brpoint#1{\getparameters{#1}%
+\advance\x by-\labelwd
+ \rlap{\kern\x \raise\y \box\labelbox}}
+\let\rBpoint=\Brpoint
+
+\def\cpoint#1{\getparameters{#1}% OK
+ \reset \advance\y by-.5\totalht \advance\x by-.5\labelwd
+ \rlap{\kern\x \raise\y \box\labelbox}}
+
+\def\lpoint#1{\getparameters{#1}% OK
+ \reset \advance\y by-.5\totalht
+ \rlap{\kern\x \raise\y \box\labelbox}}
+
+\def\lbpoint#1{\getparameters{#1}%
+ \reset \rlap{\kern\x \raise\y \box\labelbox}}
+\let\blpoint=\lbpoint
+
+\def\bpoint#1{\getparameters{#1}%
+ \reset \advance\x by-.5\labelwd
+ \rlap{\kern\x \raise\y \box\labelbox}}
+
+\def\rbpoint#1{\getparameters{#1}%
+ \reset \advance\x by-\labelwd
+ \rlap{\kern\x \raise\y \box\labelbox}}
+\let\brpoint=\rbpoint
+
+\def\rpoint#1{\getparameters{#1}%
+ \reset \advance\y by-.5\totalht \advance\x by-\labelwd
+ \rlap{\kern\x \raise\y \box\labelbox}}
+
+\def\trpoint#1{\getparameters{#1}%
+ \reset \advance\y by-\totalht \advance\x by-\labelwd
+ \rlap{\kern\x \raise\y \box\labelbox}}
+\let\rtpoint=\trpoint
+
+\def\tpoint#1{\getparameters{#1}%
+ \reset \advance\y by-\totalht
+ \advance\x by-.5\labelwd
+ \rlap{\kern\x \raise\y \box\labelbox}}
+
+\def\tlpoint#1{\getparameters{#1}%
+ \reset \advance\y by-\totalht
+ \rlap{\kern\x \raise\y \box\labelbox}}
+\let\ltpoint=\tlpoint
+
+\endinput
+
+
diff --git a/macros/generic/labtex/xminus1.mf b/macros/generic/labtex/xminus1.mf new file mode 100644 index 0000000000..e99076494a --- /dev/null +++ b/macros/generic/labtex/xminus1.mf @@ -0,0 +1,40 @@ +mode_setup;
+input labtex;
+u#=12pt#; if mode=smoke: u#:=.4pt#; fi
+nib#=.5pt#; if mode=smoke: nib#:=.1pt#; fi
+define_pixels(u, nib);
+beginchar(0, 12u#, 6u#, 0);
+ pickup pencircle scaled 2nib;
+ z1=(w/8,h); z2=(w/4, h/2); z3=(w/2, h/4); % points on the curve
+ z4=(w,h/8);
+ path p; p=z1..z2..z3..z4;
+ draw p; % draw the $1/x$ curve
+ z.x=point 2.6 of p; % another point
+ z5=(x2,0); z6=(x.x,0); % points on the $x$-axis
+ pickup pencircle scaled nib;
+ draw origin--(w,0); % bottom axis
+ draw z2--z5; draw z.x--z6; % vertical struts
+ pickup pencircle scaled 6nib;
+ drawdot z2; drawdot z.x; drawdot z5; drawdot z6;
+ save I; numeric I; I=0;
+ labtex(z2, z.x, z5, (x.x,0));
+endchar;
+
+beginchar(1, 12u#, 6u#, 0);
+ pickup pencircle scaled 2nib;
+ z1=(w/8,h); z2=(w/4, h/2); z3=(w/2, h/4); % points on the curve
+ z4=(w,h/8);
+ path p; p=z1..z2..z3..z4;
+ draw p; % draw the $1/x$ curve
+ z.x=point 2.6 of p; % another point
+ z5=(x2,0); z6=(x.x,0); % points on the $x$-axis
+ pickup pencircle scaled nib;
+ draw origin--(w,0); % bottom axis
+ draw z2--z5; draw z.x--z6; % vertical struts
+ pickup pencircle scaled 6nib;
+ drawdot z2; drawdot z.x; drawdot z5; drawdot z6;
+ save I; numeric I; I=0;
+ labtex(z2, z.x, z5, (x.x,0));
+endchar;
+
+bye.
diff --git a/macros/generic/labtex/xminus1.tex b/macros/generic/labtex/xminus1.tex new file mode 100644 index 0000000000..3462a79580 --- /dev/null +++ b/macros/generic/labtex/xminus1.tex @@ -0,0 +1,26 @@ +\font\labtex=xminus1
+
+\input labtex
+
+\fig0
+\lbpoint{$(1,1)$}\lbpoint{\up2pt $(x, 1/x)$}%
+\tpoint{\down 2pt $(1,0)$}\tpoint{\down 2pt$(x,0)$}
+\endfig
+
+\bigskip
+
+\fig1
+\lbpoint{$\,\,(1,1)$}\lbpoint{\up2pt $(x, 1/x)$}%
+\tpoint{\down 2pt $(1,0)$}\tpoint{\down 2pt$(x,0)$}
+\endfig
+
+This is a test of the amazing labtex macros!!
+\centerline{
+\fig0
+\lbpoint{$(1,1)$}\lbpoint{\up2pt $(x, 1/x)$}%
+\tpoint{\down 2pt $(1,0)$}\tpoint{\down 2pt$(x,0)$}
+\endfig
+}
+This is the end of the test.
+
+\bye
|