summaryrefslogtreecommitdiff
path: root/info/maketexwork
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /info/maketexwork
Initial commit
Diffstat (limited to 'info/maketexwork')
-rw-r--r--info/maketexwork/README56
-rw-r--r--info/maketexwork/ex-01-018
-rw-r--r--info/maketexwork/ex-01-029
-rw-r--r--info/maketexwork/ex-02-016
-rw-r--r--info/maketexwork/ex-02-024
-rw-r--r--info/maketexwork/ex-02-0312
-rw-r--r--info/maketexwork/ex-02-0433
-rw-r--r--info/maketexwork/ex-03-0122
-rw-r--r--info/maketexwork/ex-04-0132
-rw-r--r--info/maketexwork/ex-04-0225
-rw-r--r--info/maketexwork/ex-04-0325
-rw-r--r--info/maketexwork/ex-04-0427
-rw-r--r--info/maketexwork/ex-04-0542
-rw-r--r--info/maketexwork/ex-04-0638
-rw-r--r--info/maketexwork/ex-04-077
-rw-r--r--info/maketexwork/ex-04-0817
-rw-r--r--info/maketexwork/ex-04-0916
-rw-r--r--info/maketexwork/ex-05-015
-rw-r--r--info/maketexwork/ex-05-025
-rw-r--r--info/maketexwork/ex-05-0348
-rw-r--r--info/maketexwork/ex-06-0112
-rw-r--r--info/maketexwork/ex-06-0243
-rw-r--r--info/maketexwork/ex-06-0314
-rw-r--r--info/maketexwork/ex-06-0425
-rw-r--r--info/maketexwork/ex-06-0591
-rw-r--r--info/maketexwork/ex-06-0646
-rw-r--r--info/maketexwork/ex-06-0759
-rw-r--r--info/maketexwork/ex-06-0881
-rw-r--r--info/maketexwork/ex-06-0933
-rw-r--r--info/maketexwork/ex-07-018
-rw-r--r--info/maketexwork/ex-10-0138
-rw-r--r--info/maketexwork/ex-11-0119
-rw-r--r--info/maketexwork/ex-12-017
-rw-r--r--info/maketexwork/ex-12-024
-rw-r--r--info/maketexwork/ex-D-01568
-rw-r--r--info/maketexwork/ex-D-02427
-rw-r--r--info/maketexwork/ex-D-03215
-rw-r--r--info/maketexwork/ex-D-04151
-rw-r--r--info/maketexwork/ex-D-05174
-rw-r--r--info/maketexwork/ex-D-06181
-rw-r--r--info/maketexwork/ex-D-0764
-rw-r--r--info/maketexwork/ex-D-08191
42 files changed, 2888 insertions, 0 deletions
diff --git a/info/maketexwork/README b/info/maketexwork/README
new file mode 100644
index 0000000000..d6c07fe3d7
--- /dev/null
+++ b/info/maketexwork/README
@@ -0,0 +1,56 @@
+This file is README dated 18 Apr 1994.
+
+This directory contains the examples from _Making TeX Work_:
+
+Title : Making TeX Work
+Author : Norman Walsh
+Publisher : O'Reilly and Associates
+Date : April, 1994
+ISBN : 1-56592-051-1
+Pages : 518
+Price : US$29.95
+
+The examples are:
+
+ex-01-01: example 1-1: An Example of a TeX Document
+ex-01-02: example 1-2: A typical bibliography database entry
+ex-02-01: example 2-1: A Simple Driver File
+ex-02-02: example 2-2: Local Variables in an Emacs Buffer
+ex-02-03: example 2-3: A Contrived Error
+ex-02-04: example 2-4: Revision Control Macros for TeX Documents Using RCS
+ex-03-01: example 3-1: The Document BADFONT.TeX
+ex-04-01: example 4-1: Plain TeX Input
+ex-04-02: example 4-2: LaTeX2e Input
+ex-04-03: example 4-3: LaTeX Input File
+ex-04-04: example 4-4: AMS-TeX Input File
+ex-04-05: example 4-5: Lollipop Input File
+ex-04-06: example 4-6: TeXinfo Input
+ex-04-07: example 4-7: The ChemTeX Source for Caffeine
+ex-04-08: example 4-8: The ChemStruct Source for the Lithium Cation
+ex-04-09: example 4-9: The MusicTeX Source for Figure 4-7
+ex-05-01: example 5-1: Font-shape Declaration with NFSS2
+ex-05-02: example 5-2: Font-shape declaration with NFSS2 (simplified)
+ex-05-03: example 5-3: The PStoTeXfont script
+ex-06-01: example 6-1: The Input for the Plain TeX Diagram
+ex-06-02: example 6-2: The LaTeX Input for Figure 6-2
+ex-06-03: example 6-3: The epic Input for Figure 6-3
+ex-06-04: example 6-4: The Input for Figure 6-4
+ex-06-05: example 6-5: PiCTeX Input for Figure 6-5
+ex-06-06: example 6-6: The XY-pic Input for Figure 6-6
+ex-06-07: example 6-7: The DraTeX Input for Figure 6-7
+ex-06-08: example 6-8: Converting EPS to a Bitmap with Ghostview
+ex-06-09: example 6-9: Script for Inserting a Captured TeXt Screen
+ex-07-01: example 7-1: A Sample Multilingual Document Using English and French
+ex-10-01: example 10-1: TeXinfo Commands
+ex-11-01: example 11-1: The Code for the Figure Eight
+ex-12-01: example 12-1: A Sample BIBTeX entry
+ex-12-02: example 12-2: A Tib style database entry
+ex-D-01 : example D-1: MakeTeXPK.pl
+ex-D-02 : example D-2: MakeTeXTFM.pl
+ex-D-03 : example D-3: dvidxx.btm
+ex-D-04 : example D-4: makepk.btm
+ex-D-05 : example D-5: enc-afm.pl
+ex-D-06 : example D-6: TeXtoXfont
+ex-D-07 : example D-7: PStoXfont
+ex-D-08 : example D-8: txt2verb.pl
+
diff --git a/info/maketexwork/ex-01-01 b/info/maketexwork/ex-01-01
new file mode 100644
index 0000000000..acb17e7c03
--- /dev/null
+++ b/info/maketexwork/ex-01-01
@@ -0,0 +1,8 @@
+\def\ora{O'Reilly \& Associates}
+\font\orafont=grlg10
+\parskip=\baselineskip
+\parindent=0pt
+\pageno=5
+This book is published by \ora\ in
+the \textit{Nutshell} series.
+\bye
diff --git a/info/maketexwork/ex-01-02 b/info/maketexwork/ex-01-02
new file mode 100644
index 0000000000..8439f035ed
--- /dev/null
+++ b/info/maketexwork/ex-01-02
@@ -0,0 +1,9 @@
+@Book{kn:texbook,
+ author = "Donald E. Knuth",
+ title = "The {\TeX}book",
+ publisher = "Addison-Wesley",
+ year = 1989,
+ edition = "Fifteenth",
+ isbn = "0-201-13447-0"
+ note = "Paperback ISBN: 0-201-13448-9"
+}
diff --git a/info/maketexwork/ex-02-01 b/info/maketexwork/ex-02-01
new file mode 100644
index 0000000000..09e32f3cde
--- /dev/null
+++ b/info/maketexwork/ex-02-01
@@ -0,0 +1,6 @@
+\documentstyle[ora]{book}
+\begin{document}
+ \input{intro}
+ \input{chap1}
+ \input{chap2}
+\end{document}
diff --git a/info/maketexwork/ex-02-02 b/info/maketexwork/ex-02-02
new file mode 100644
index 0000000000..45593e4c7d
--- /dev/null
+++ b/info/maketexwork/ex-02-02
@@ -0,0 +1,4 @@
+% Local Variables:
+% TeX-master: "driver.tex"
+% TeX-command-default: "LaTeX"
+% End:
diff --git a/info/maketexwork/ex-02-03 b/info/maketexwork/ex-02-03
new file mode 100644
index 0000000000..4992587b60
--- /dev/null
+++ b/info/maketexwork/ex-02-03
@@ -0,0 +1,12 @@
+This is TeX version 3.141...
+** (flintstone.tex
+some
+messages [1]
+(fred.tex [2]
+some more
+messages
+[3] ) (wilma.tex [4]
+! Undefined control sequence.
+the dog \dino
+ tipped over the car.
+l.6 the dog \dino\ tipped over the car.
diff --git a/info/maketexwork/ex-02-04 b/info/maketexwork/ex-02-04
new file mode 100644
index 0000000000..a949b91690
--- /dev/null
+++ b/info/maketexwork/ex-02-04
@@ -0,0 +1,33 @@
+ Documents Using RCS}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% RCS definitions...
+%
+\newif\ifdraft
+\def\RCSID$#1${%
+ \ifdraft{\tolerance=100000%
+ \hbadness=100000%
+ \raggedright%
+ \marginpar{\tiny Draft #1}}%
+ \typeout{Draft #1}%
+ \else\typeout{Production run #1}\fi%
+}
+
+\def\RCSmargid$#1: #2 #3 #4 #5 #6 #7${%
+% #1 = ``Id''
+% #2 = filename
+% #3 = vers
+% #4 = date
+% #5 = time
+% #6 = author
+% #7 = state [locker]
+ \ifdraft
+ \setbox0=\hbox to 0pt{%
+ \tolerance=100000%
+ \hbadness=100000%
+ \parbox{4in}{%
+ \rm\tiny #2\\ #3\\ #4}%
+ \hss}%
+ \marginpar{\box0}%
+ \typeout{Draft Id: #2 #3 #4 #5 #6 #7}%
+ \fi
+}
diff --git a/info/maketexwork/ex-03-01 b/info/maketexwork/ex-03-01
new file mode 100644
index 0000000000..3905e43def
--- /dev/null
+++ b/info/maketexwork/ex-03-01
@@ -0,0 +1,22 @@
+\documentstyle{article}
+% The following definition changes the font that LaTeX
+% uses for the 'Large' font. I have introduced a typo
+% into the definition, ``\fontsiz'' should be ``\fontsize''.
+%
+% The first time a \Large font is requested, an error will occur.
+%
+\renewcommand{\Large}{\fontsiz{17}{20pt}\selectfont}
+\begin{document}
+
+This text precedes the first section header.
+
+% Note: LaTeX uses the \Large font in section
+% headers...this will fail in a confusing way
+% because the error is deep within the definition
+% of \section where \Large is used...
+%
+\section{First Section}
+
+This is the first and only sentence of the first section.
+
+\end{document}
diff --git a/info/maketexwork/ex-04-01 b/info/maketexwork/ex-04-01
new file mode 100644
index 0000000000..1b7d26d938
--- /dev/null
+++ b/info/maketexwork/ex-04-01
@@ -0,0 +1,32 @@
+% Format: Plain
+\font\chapfont=cmbx12 scaled 1728
+\font\titlefont=cmbx12 scaled 2073
+\font\secfont=cmbx12 scaled 1200
+
+\parskip=\baselineskip
+\parindent=0pt
+\hsize=5in
+\hoffset=.75in
+
+\leftline{\chapfont Chapter 1}
+\vskip36pt
+
+\leftline{\titlefont Unsolved Problems}
+\vskip36pt
+
+\leftline{\secfont 1.1\ \ Odd Perfect Numbers}
+\vskip12pt
+
+A number is said to be {\it perfect\/} if it
+is the sum of its divisors. For example, $6$ is
+perfect because $1+2+3 = 6$, and $1$, $2$, and $3$
+are the only numbers that divide evenly into $6$
+(apart from $6$ itself).
+
+It has been shown that all even perfect numbers
+have the form $$2^{p-1}(2^{p}-1)$$ where $p$
+and $2^{p}-1$ are both prime.
+
+The existence of {\it odd\/} perfect numbers is
+an open question.
+\bye
diff --git a/info/maketexwork/ex-04-02 b/info/maketexwork/ex-04-02
new file mode 100644
index 0000000000..fd640088e0
--- /dev/null
+++ b/info/maketexwork/ex-04-02
@@ -0,0 +1,25 @@
+% Format: LaTeX2e
+\documentclass{report}
+
+\setlength{\parskip}{\baselineskip}
+\setlength{\parindent}{0pt}
+
+\begin{document}
+
+\chapter{Unsolved Problems}
+
+\section{Odd Perfect Numbers}
+
+A number is said to be \emph{perfect} if it
+is the sum of its divisors. For example, $6$ is
+perfect because \(1+2+3 = 6\), and $1$, $2$, and $3$
+are the only numbers that divide evenly into $6$
+(apart from 6 itself).
+
+It has been shown that all even perfect numbers
+have the form \[2^{p-1}(2^{p}-1)\] where $p$
+and \(2^{p}-1\) are both prime.
+
+The existence of \emph{odd} perfect numbers is
+an open question.
+\end{document}
diff --git a/info/maketexwork/ex-04-03 b/info/maketexwork/ex-04-03
new file mode 100644
index 0000000000..3119cf8bab
--- /dev/null
+++ b/info/maketexwork/ex-04-03
@@ -0,0 +1,25 @@
+% Format: LaTeX
+\documentstyle{report}
+
+\setlength{\parskip}{\baselineskip}
+\setlength{\parindent}{0pt}
+
+\begin{document}
+
+\chapter{Unsolved Problems}
+
+\section{Odd Perfect Numbers}
+
+A number is said to be {\em perfect\/} if it
+is the sum of its divisors. For example, $6$ is
+perfect because \(1+2+3 = 6\), and $1$, $2$, and $3$
+are the only numbers that divide evenly into $6$
+(apart from 6 itself).
+
+It has been shown that all even perfect numbers
+have the form \[2^{p-1}(2^{p}-1)\] where $p$
+and \(2^{p}-1\) are both prime.
+
+The existence of {\em odd\/} perfect numbers is
+an open question.
+\end{document}
diff --git a/info/maketexwork/ex-04-04 b/info/maketexwork/ex-04-04
new file mode 100644
index 0000000000..f6ac1adcc9
--- /dev/null
+++ b/info/maketexwork/ex-04-04
@@ -0,0 +1,27 @@
+% Format: AMSTeX
+\documentstyle{amsppt}
+
+\parindent=0pt
+\parskip=\baselineskip
+\hoffset=.75in
+
+\topmatter
+\title \chapter{1} Unsolved Problems\endtitle
+\endtopmatter
+
+\document
+\head{1.1} Odd Perfect Numbers\endhead
+
+A number is said to be {\it perfect\/} if it
+is the sum of its divisors. For example, $6$ is
+perfect because $1+2+3 = 6$, and $1$, $2$, and $3$
+are the only numbers that divide evenly into $6$
+(apart from $6$ itself).
+
+It has been shown that all even perfect numbers
+have the form $$2^{p-1}(2^{p}-1)$$ where $p$
+and $2^{p}-1$ are both prime.
+
+The existence of {\it odd\/} perfect numbers is
+an open question.
+\enddocument
diff --git a/info/maketexwork/ex-04-05 b/info/maketexwork/ex-04-05
new file mode 100644
index 0000000000..cccb0e9560
--- /dev/null
+++ b/info/maketexwork/ex-04-05
@@ -0,0 +1,42 @@
+% Format: Lollipop
+\DefineHeading:Chapter
+ breakbefore:yes whiteafter:12pt
+ line:start PointSize:20 Style:bold
+ literal:Chapter Spaces:1 ChapterCounter
+ line:stop
+ vwhite:36pt
+ line:start PointSize:24 Style:bold title
+ line:stop
+ vwhite:24pt
+ Stop
+\DefineHeading:Section
+ whitebefore:{20pt plus 2pt} whiteafter:14pt
+ line:start PointSize:14 Style:bold
+ ChapterCounter . SectionCounter
+ Spaces:1 title line:stop
+ label:start ChapterCounter . SectionCounter
+ label:stop
+ Stop
+\GoverningCounter:Section=Chapter
+\AlwaysIndent:no
+\Distance:parskip=12pt
+\Distance:hoffset=.75in
+\Distance:voffset=.5in
+\Start
+\Chapter Unsolved Problems
+
+\Section Odd Perfect Numbers
+
+A number is said to be {\it perfect\/} if it
+is the sum of its divisors. For example, $6$ is
+perfect because $1+2+3 = 6$, and $1$, $2$, and $3$
+are the only numbers that divide evenly into $6$
+(apart from $6$ itself).
+
+It has been shown that all even perfect numbers
+have the form $$2^{p-1}(2^{p}-1)$$ where $p$
+and $2^{p}-1$ are both prime.
+
+The existence of {\it odd\/} perfect numbers is
+an open question.
+\Stop
diff --git a/info/maketexwork/ex-04-06 b/info/maketexwork/ex-04-06
new file mode 100644
index 0000000000..cc95fc65a9
--- /dev/null
+++ b/info/maketexwork/ex-04-06
@@ -0,0 +1,38 @@
+\input texinfo @c -*- TeXinfo -*-
+@setfilename perf-inf.inf
+@ifinfo
+ @paragraphindent 0
+@end ifinfo
+@iftex
+ @defaultparindent=0pt @parindent=0pt
+@end iftex
+
+@node Top, , (dir), (dir)
+@chapter Unsolved Problems
+@section Odd Perfect Numbers
+
+A number is said to be @i{perfect} if it is
+the sum of its divisors. For example, 6 is
+perfect because
+@tex $1+2+3 = 6$,
+@end tex
+@ifinfo
+1+2+3 = 6,
+@end ifinfo
+and 1, 2, and 3 are the only numbers that divide
+evenly into 6 (apart from 6 itself).
+
+It has been shown that all even perfect numbers
+have the form
+@tex $$2^{p-1}(2^{p}-1)$$ where $p$ and $2^{p}-1$
+@end tex
+@ifinfo
+@center 2^(p-1) (2^p - 1)
+
+where p and 2^p - 1
+@end ifinfo
+are both prime.
+
+The existence of @i{odd} perfect numbers is an
+open question.
+@bye
diff --git a/info/maketexwork/ex-04-07 b/info/maketexwork/ex-04-07
new file mode 100644
index 0000000000..45d24e38c5
--- /dev/null
+++ b/info/maketexwork/ex-04-07
@@ -0,0 +1,7 @@
+\initial
+\len=4
+\def\H{\hbox{\rm H}}
+\def\C{\hbox{\rm C}}
+\def\O{\hbox{\rm O}}
+
+\[ \purine{$\H_3\C$}{$\O$}{$\C\H_3$}{Q}{$\O$}{Q}{Q}{D}{$\C\H_3$} \]
diff --git a/info/maketexwork/ex-04-08 b/info/maketexwork/ex-04-08
new file mode 100644
index 0000000000..d8c9b95343
--- /dev/null
+++ b/info/maketexwork/ex-04-08
@@ -0,0 +1,17 @@
+\structure{\atom{~~Li$^+$}
+\side{\nwbelow\atom{O}
+\side{\nsingle\atom{H}\nnwbelow\atom{O}\side{\wsingle\atom{H}}
+\nsingle\atom{H}}\swsingle\atom{H}\wnwbelow\atom{O}
+\side{\wsingle\atom{H}}\nsingle\atom{H}}
+\side{\nebelow\atom{O}
+\side{\nsingle\atom{H}\nnebelow\atom{O}\side{\esingle\atom{H}}
+\nsingle\atom{H}}\sesingle\atom{H}\enebelow\atom{O}
+\side{\esingle\atom{H}}\nsingle\atom{H}}
+\side{\swbelow\atom{O}
+\side{\ssingle\atom{H}\sswbelow\atom{O}\side{\wsingle\atom{H}}
+\ssingle\atom{H}}\nwsingle\atom{H}\wswbelow\atom{O}
+\side{\wsingle\atom{H}}\ssingle\atom{H}}
+\side{\sebelow\atom{O}
+\side{\ssingle\atom{H}\ssebelow\atom{O}\side{\esingle\atom{H}}
+\ssingle\atom{H}}\nesingle\atom{H}\esebelow\atom{O}
+\side{\esingle\atom{H}}\ssingle\atom{H}}}
diff --git a/info/maketexwork/ex-04-09 b/info/maketexwork/ex-04-09
new file mode 100644
index 0000000000..c86290fcc8
--- /dev/null
+++ b/info/maketexwork/ex-04-09
@@ -0,0 +1,16 @@
+\begin{music}
+\parindent 1cm
+\def\nbinstruments{1}\relax
+\def\instrumenti{Piano}%
+\nbporteesi=2\relax
+\generalmeter{\meterfrac{4}{4}}\relax
+\debutextrait
+\normal
+\temps\Notes\ibu0f0\qh0{cge}\tbu0\qh0g|\hl j\enotes
+\temps\Notes\ibu0f0\qh0{cge}\tbu0\qh0g|\ql l\sk\ql n\enotes
+\barre
+\Notes\ibu0f0\qh0{dgf}|\qlp i\enotes
+\notes\tbu0\qh0g|\ibbl1j3\qb1j\tbl1\qb1k\enotes
+\temps\Notes\ibu0f0\qh0{cge}\tbu0\qh0g|\hl j\enotes
+\finextrait
+\end{music}
diff --git a/info/maketexwork/ex-05-01 b/info/maketexwork/ex-05-01
new file mode 100644
index 0000000000..48a3a5809a
--- /dev/null
+++ b/info/maketexwork/ex-05-01
@@ -0,0 +1,5 @@
+\DeclareFontShape{OT1}{logo}{m}{n}{%
+ <-8>sub * cmr/m/n%
+ <8><9><10>gen * logo%
+ <10.95>logo10 at 10.95pt%
+ <12->logo10}{}
diff --git a/info/maketexwork/ex-05-02 b/info/maketexwork/ex-05-02
new file mode 100644
index 0000000000..29914979d0
--- /dev/null
+++ b/info/maketexwork/ex-05-02
@@ -0,0 +1,5 @@
+\DeclareFontShape{OT1}{logo}{m}{n}{%
+ <-8>sub * cmr/m/n%
+ <8-9>logo8%
+ <9-10>logo9%
+ <10->logo10}{}
diff --git a/info/maketexwork/ex-05-03 b/info/maketexwork/ex-05-03
new file mode 100644
index 0000000000..89f65e1c98
--- /dev/null
+++ b/info/maketexwork/ex-05-03
@@ -0,0 +1,48 @@
+#!/usr/local/bin/bash
+#
+# This script file makes a new TeX font from a PS outline.
+#
+# Parameters are:
+#
+# name dpi bdpi [mag mode destdir]
+#
+# `name' is the name of the font, such as `ptmr'. `dpi'
+# is the resolution the font is needed at. `bdpi' is
+# the base resolution.
+#
+# This script ignores the remaining parameters. They are
+# left here to document the fact that the caller may provide
+# them. They may be provided because the caller thinks
+# MetaFont is going to do the work...
+#
+# Of course, this needs to be set up for your site.
+#
+# TEMPDIR needs to be unique for each process because of the
+# possibility of simultaneous processes running this script.
+
+TEMPDIR=/tmp/temp-tex-PS.$$
+NAME=$1
+DPI=$2
+BDPI=$3
+
+LOCALDIR=/usr/local/lib/mf/fonts
+DESTDIR=$LOCALDIR/pk
+
+BASENAME=$NAME.$DPI
+PFADIR=/usr/local/lib/tex/ps/outlines
+
+# Clean up on normal or abnormal exit
+trap "cd /; rm -rf $TEMPDIR" 0 1 2 15
+
+mkdir $TEMPDIR
+cd $TEMPDIR
+
+# We proceed by making a 10pt font at the resolution
+# requested...
+echo Making ${DPI}dpi version of $NAME.
+ps2pk -X$DPI -P10 -a$PFADIR/$NAME.afm \
+ $PFADIR/$NAME.pfa ${BASENAME}pk
+
+mv ${BASENAME}pk $DESTDIR
+
+exit 0
diff --git a/info/maketexwork/ex-06-01 b/info/maketexwork/ex-06-01
new file mode 100644
index 0000000000..173cc3c360
--- /dev/null
+++ b/info/maketexwork/ex-06-01
@@ -0,0 +1,12 @@
+\newdimen\unitlength
+\unitlength=1cm
+
+\def\plot(#1,#2){%
+ \rlap{\kern#1\unitlength\raise#2\unitlength%
+ \hbox{$\scriptstyle\bullet\;(#1,#2)$}}}
+
+\centerline{%
+ \hbox{\plot(0,0)
+ \plot(1,1)
+ \plot(-3,2)}%
+}
diff --git a/info/maketexwork/ex-06-02 b/info/maketexwork/ex-06-02
new file mode 100644
index 0000000000..e1bf051272
--- /dev/null
+++ b/info/maketexwork/ex-06-02
@@ -0,0 +1,43 @@
+\unitlength=1.00mm
+\special{em:linewidth 0.4pt}
+\linethickness{0.4pt}
+\begin{picture}(93.00,40.00)
+\put(0.00,10.00){\line(1,0){70.00}}
+\put(70.00,10.00){\line(2,3){20.00}}
+\put(90.00,40.00){\line(-1,0){70.00}}
+\put(20.00,40.00){\line(-2,-3){20.00}}
+\put(70.00,10.00){\line(1,0){1.00}}
+\put(72.00,10.00){\line(1,0){1.00}}
+\put(74.00,10.00){\line(1,0){1.00}}
+\put(76.00,10.00){\line(1,0){1.00}}
+\put(78.00,10.00){\line(1,0){1.00}}
+\put(80.00,10.00){\line(1,0){1.00}}
+\put(82.00,10.00){\line(1,0){1.00}}
+\put(84.00,10.00){\line(1,0){1.00}}
+\put(86.00,10.00){\line(1,0){1.00}}
+\put(88.00,10.00){\line(1,0){1.00}}
+\put(90.00,10.00){\line(0,1){1.00}}
+\put(90.00,12.00){\line(0,1){1.00}}
+\put(90.00,14.00){\line(0,1){1.00}}
+\put(90.00,16.00){\line(0,1){1.00}}
+\put(90.00,18.00){\line(0,1){1.00}}
+\put(90.00,20.00){\line(0,1){1.00}}
+\put(90.00,22.00){\line(0,1){1.00}}
+\put(90.00,24.00){\line(0,1){1.00}}
+\put(90.00,26.00){\line(0,1){1.00}}
+\put(90.00,28.00){\line(0,1){1.00}}
+\put(90.00,30.00){\line(0,1){1.00}}
+\put(90.00,32.00){\line(0,1){1.00}}
+\put(90.00,34.00){\line(0,1){1.00}}
+\put(90.00,36.00){\line(0,1){1.00}}
+\put(90.00,38.00){\line(0,1){1.00}}
+\put(87.00,10.00){\line(0,1){3.00}}
+\put(87.00,13.00){\line(1,0){3.00}}
+\put(93.00,20.00){\vector(0,-1){10.00}}
+\put(93.00,30.00){\vector(0,1){10.00}}
+\put(93.00,25.00){\makebox(0,0)[cc]{$h$}}
+\put(30.00,7.00){\vector(-1,0){30.00}}
+\put(40.00,7.00){\vector(1,0){30.00}}
+\put(35.00,7.00){\makebox(0,0)[cc]{$w$}}
+\put(45.00,25.00){\makebox(0,0)[cc]{$A=h\times w$}}
+\end{picture}
diff --git a/info/maketexwork/ex-06-03 b/info/maketexwork/ex-06-03
new file mode 100644
index 0000000000..3ab8143aca
--- /dev/null
+++ b/info/maketexwork/ex-06-03
@@ -0,0 +1,14 @@
+\unitlength = 1mm
+\begin{picture}(50,100)(0,0)
+\put(0,0){\tiny \grid(50,50)(5,5)[0,0]}
+\put(25,25){\circle{50}}
+\drawline(15,0)(20,5)(30,10)(50,35)
+\drawline[-50](10,5)(15,10)(25,15)(45,40)
+\thicklines
+\dottedline{1.4}(5,10)(10,15)(15,25)(40,45)
+\dashline{2}(0,15)(5,20)(10,30)(35,50)
+\thinlines
+\begin{drawjoin}
+\jputfile{epicdata}{\picsquare}
+\end{drawjoin}
+\end{picture}
diff --git a/info/maketexwork/ex-06-04 b/info/maketexwork/ex-06-04
new file mode 100644
index 0000000000..0aeedce249
--- /dev/null
+++ b/info/maketexwork/ex-06-04
@@ -0,0 +1,25 @@
+\unitlength = 1mm
+\begin{picture}(100,50)(0,0)
+\put(0,0){\tiny \grid(100,50)(10,10)[0,0]}
+\bezier{500}(0,0)(0,0)(100,50)
+\bezier{500}(0,0)(10,0)(100,50)
+\bezier{500}(0,0)(20,0)(100,50)
+\bezier{500}(0,0)(30,0)(100,50)
+\bezier{500}(0,0)(40,0)(100,50)
+\bezier{500}(0,0)(50,0)(100,50)
+\bezier{500}(0,0)(60,0)(100,50)
+\bezier{500}(0,0)(70,0)(100,50)
+\bezier{500}(0,0)(80,0)(100,50)
+\bezier{500}(0,0)(90,0)(100,50)
+\bezier{500}(0,0)(100,0)(100,50)
+
+\bezier{500}(0,0)(0,50)(100,50)
+\bezier{500}(0,0)(0,40)(100,50)
+\bezier{500}(0,0)(0,30)(100,50)
+\bezier{500}(0,0)(0,20)(100,50)
+\bezier{500}(0,0)(0,10)(100,50)
+\bezier{500}(0,0)(0,0)(100,50)
+
+\multiput(0,0)(10,0){11}{\circle*{1}}
+\multiput(0,0)(0,10){6}{\circle*{1}}
+\end{picture}
diff --git a/info/maketexwork/ex-06-05 b/info/maketexwork/ex-06-05
new file mode 100644
index 0000000000..6be82ab752
--- /dev/null
+++ b/info/maketexwork/ex-06-05
@@ -0,0 +1,91 @@
+\newdimen\unit \unit=1.375in
+\newdimen\shadeunit
+\newif \ifFirstPass
+\FirstPasstrue
+%\FirstPassfalse % uncomment this after you have the size you want
+%
+\def\DF{{\cal A}}%
+%
+%The following figure appears in the preface to the \PiCTeX\ manual
+%
+$$
+\beginpicture
+ \ifFirstPass
+ \savelinesandcurves on "pictex-Arcsine.tex"
+ \else
+ \replot "pictex-Arcsine.tex"
+ \fi
+% \ninepoint % (See Appendix E of the TeXbook.)
+ \normalgraphs
+ % Density plot
+ \setcoordinatesystem units <\unit,.4\unit> point at 0 0
+ \setplotarea x from 0 to 1, y from 0 to 2.5
+ \axis bottom invisible label {\lines {$t$\cr
+ shaded area is $\DF(\beta) - \DF(\alpha)$\cr}} ticks
+ numbered from 0.0 to 1.0 by 0.5
+ unlabeled short quantity 11
+ length <0pt> withvalues $\alpha$ $\beta$ / at .65 .85 / /
+ \axis left invisible label {$a(t)$} ticks
+ numbered from 0.0 to 2.0 by 1.0
+ unlabeled short from 0.5 to 2.5 by 1.0 /
+ \plotheading{\lineskiplimit=1pt \lines{%
+ Density\cr
+ $a(t) = 1\big/\bigl(\pi \sqrt{t(1-t)}\,\bigr)$\cr
+ of the arc sine law\cr}}
+ \grid 1 1
+ \putrule from .65 0.0 to .65 .66736
+ \putrule from .85 0.0 to .85 .89145
+ \shadeunit=.2\unit \divide\shadeunit by 12
+ \setshadegrid span <\shadeunit> point at .75 0
+ \setquadratic
+ \vshade .65 0 .66736 <,,,1pt> .75 0 .73511 .85 0 .89145 /
+ % Move origin to (.5,0)
+ % Left half}
+ \ifFirstPass
+ \setcoordinatesystem point at -.5 0
+ \inboundscheckon
+ \plot -.48429 2.55990 -.47553 2.06015 -.46489 1.72936 /
+ \inboundscheckoff
+ \plot -.46489 1.72936 -.43815 1.32146 -.40451 1.08308
+ -.36448 .92999 -.31871 .82623 -.26791 .75400
+ -.21289 .70358 -.12434 .65727 .0 .63662 /
+ % Right half
+ \inboundscheckon
+ \plot .48429 2.55990 .47553 2.06015 .46489 1.72936 /
+ \inboundscheckoff
+ \plot .46489 1.72936 .43815 1.32146 .40451 1.08308
+ .36448 .92999 .31871 .82623 .26791 .75400
+ .21289 .70358 .12434 .65727 .0 .63662 /
+ \fi
+ % Distribution function
+ % Set origin of new coordinate system 1.7*1.375in=2.34in
+ % to the right of the original origin.
+ \setcoordinatesystem units <\unit,\unit> point at -1.7 0
+ \setplotarea x from 0 to 1, y from 0 to 1
+ \axis bottom label {$x\vphantom{t}$} ticks
+ numbered from 0.0 to 1.0 by 0.5 unlabeled short quantity 11 /
+ \axis left label {$\DF(x)$} ticks
+ numbered from 0.0 to 1.0 by 0.5 unlabeled short quantity 11 /
+ \plotheading{\lines{%
+ Distribution function\cr
+ $\DF(x) = {2\over \raise1pt\hbox{\seveni ^^Y}}
+ \arcsin(\sqrt{x}\,)$\cr
+ of the arc sine law\cr}}
+ \linethickness=.25pt \grid {20} {20}
+ \linethickness=.4pt \grid 2 2
+ % Left half
+ % Now move origin of coordinate system up to (.5,.5)
+ \ifFirstPass
+ \setcoordinatesystem point at -2.2 -.5
+ \plot -.50000 -.50 -.49901 -.48 -.49606 -.46
+ -.49104 -.44 -.48439 -.42 -.47553 -.40 -.46489 -.38
+ -.43815 -.34 -.40451 -.30 -.36448 -.26 -.31871 -.22
+ -.26791 -.18 -.21289 -.14 -.12434 -.08 .0 .0 /
+ % Right half
+ \plot .50000 .50 .49901 .48 .49606 .46
+ .49104 .44 .48439 .42 .47553 .40 .46489 .38
+ .43815 .34 .40451 .30 .36448 .26 .31871 .22
+ .26791 .18 .21289 .14 .12434 .08 .0 .0 /
+ \fi
+\endpicture
+$$
diff --git a/info/maketexwork/ex-06-06 b/info/maketexwork/ex-06-06
new file mode 100644
index 0000000000..c589bdde90
--- /dev/null
+++ b/info/maketexwork/ex-06-06
@@ -0,0 +1,46 @@
+% Graph representing BAWL term [1]++[2]. [XY-pic & -*-tex-*-]
+% by Kristoffer H. Rose <kris@diku.dk>
+%
+\def\n#1{\llap{{\sevenit#1\/}:\,}}
+\def\op#1{(\mskip-.5\thinmuskip{#1}\mskip-.5\thinmuskip)}
+\def\concat{\mathbin{\text{\rm+\kern-.5em+}}}
+%
+\def\du#1#2{%
+ % #1: slidesign, #2: #rows to go down.
+ \save\aftergo{\go="p",[0,0]!<#1\jot,0pt>%
+ \xto`d[#2,0]+<-2.5pc,-.8pc>`"p" "p"\restore}}
+%
+\def\dul#1#2#3{%
+% #1: slidesign, #2: #rows to go down; #3: #columns to go left.
+\save\aftergo{\go="p",[0,0]!<#1\jot,0pt>%
+\xto`d[#2,0]+<-2.5pc,-.8pc>`[#2,-#3]+<-2.5pc,0pc> `"p" "p"\restore}}
+%
+\spreaddiagramrows{-1.4pc}
+\spreaddiagramcolumns{-1pc}
+%
+$$
+\displaylines{\quad
+ \left\lceil\openup-\jot\eqalign{
+ [1]\concat[2] \quad\text{where}\qquad
+ [\,] \concat ys &= ys \cr
+ (x:xs) \concat ys &= x:(xs \concat ys)}\right\rceil
+\hfill\cr\hfill
+ =\qquad
+ {\diagram&& & & &&\n1\@\dlto\xto[2,2]\\
+ & & & & &\n2{!\@}\xto[3,-2]\drto\\
+ & & & & &&\n3\op:\dlto\dto&&\n4\op:\dlto\dto\\
+ & & & & &\n51&\n6[\,] &\n72&\n8[\,]\\
+ & & &\n{10}\lor\dlto\drrto \go+<-3em,0em>="10"\\
+ & &\n{11}\lambda \dlto\ddto&&&\n{12}\lambda \dlto\drto\\
+ &\n{13}\@\dlto\drto&& &\n{14}\@\dlto\drto
+ &&\n{15}\op:\du04[3,-2]\drrto\\
+\n{16}{!\@}\dul000"10"\drto&&\n{17}{?}&\n{18}{!\@} \dul023"10" \drto
+ &&\n{19}{?}&&&\n{20}\@\ddlto\du00[0,-3]\\
+ &\n{21}[\,]& & &\n{22}\op:\dto\drto&& & &\\
+ & & & &\n{23}{?}&\n{24}{?}
+ &&\n{25}\@ \dul-27"10"\du+3[0,-2]\\
+ & & & & & & &\\
+ & & & & & & &\\
+ & & & & & & &\enddiagram}
+\quad\cr}
+$$
diff --git a/info/maketexwork/ex-06-07 b/info/maketexwork/ex-06-07
new file mode 100644
index 0000000000..e203af7fad
--- /dev/null
+++ b/info/maketexwork/ex-06-07
@@ -0,0 +1,59 @@
+\Draw \Ragged(4) %%%%%%%%% tree %%%%%%%%%%%
+
+\Define\DotsToLoc(1){ \MarkLoc(x)
+ \CSeg\DoLine(x,#1)(5){
+ \MoveF(-3)\LineF(1)} }
+\PictNode(3){ \IF \EqText(,#2) \THEN \Text(--#1--) \ELSE
+ \ThreeDim(#1,#2,#3)
+ \MarkPLoc(1) \Line(50,0,0) \MarkPLoc(2) \Line(0,50,0)
+ \MarkPLoc(3) \Line(-50,0,0) \MarkPLoc(4) \Line(0,-50,0)
+ \Move(0,0,50) \MarkPLoc(1')
+ \Move(50,0,0) \MarkPLoc(2') {\Line(0,0,-50)}
+ \Line(0,50,0) \MarkPLoc(3') {\Line(0,0,-50)}
+ \Line(-50,0,0) \MarkPLoc(4') {\Line(0,0,-50)}
+ \Do(1,4){ \Do(1,4){
+ \MarkPLoc(p\Val\I) \I+1; \Move(0,0,-16.66666)
+ } \Move(16.66666,0,66.66666) }
+ \TwoDim
+ \MoveToLL(3,4)(4',1') \DotsToLoc(1') \DotsToLoc(1)
+ \MoveToLL(2,3)(1',2') \DotsToLoc(1')
+ \PaintQuad(p0,p1,p5,p4) \PaintQuad(p2,p3,p7,p6)
+ \PaintQuad(p5,p6,p10,p9) \PaintQuad(p8,p9,p13,p12)
+ \PaintQuad(p10,p11,p15,p14)
+ \MoveToLoc(1) \CSeg[0.5]\Move(1,2) \Move(0,-5)
+ \EntryExit(0,1,0,0) \Text(--(#1,#2,#3)--)
+ \EndTwoDim
+ \EndThreeDim \FI }
+
+\Define\MyEdge(2){\EdgeTo(#1,#2,0,1)} \TreeAlign(V,0,-1)(0,0,0)
+\TreeSpec(o,\OvalNode&r,\RectNode)()(\MyEdge)
+\TreeSpace(C,10,15) \AdjTree(A,0..0,0,-201,201,0 )
+\Tree()(
+ 3,o,perspective~~projections~~eye~at~{(x,y,z)},, //
+ 2,r,125,100,-100 & 0,r,75,75,-100 & 0,r,125,75,-100 //
+ 0,r,125,125,-200 & 0,r,75,75,-200 //)
+
+%%%%%%%%% graph %%%%%%%%%%%
+
+\MoveToNode(2..1,2.5,-1) \MarkLoc(1)
+\MoveToNode(1..2,1,-1.5) \MarkLoc(2)
+\CSeg\Scale(1,2) \Scale(0.16666,0.14286)
+
+\Axis(1,2)(E3,&&&&&&&)
+\Axis(1,2)(S3,0&1&2&3&4&5&6)
+ \MoveToLoc(1)
+\Table\x{ -1,2 & 0,5 & 4,-3 & -1,-4 & -2,0 }
+ \PenSize(1.5pt) \Move(1,0) \x(0,99){\Line}
+\Table\x{ 3,3 & 1,-5 & -1,-2 & -3,4 }
+ \Move(1,4) \x(0,99){\Line}
+
+%%%%%%%%% DraTeX+AlDraTeX logos %%%%%%%%%%%
+
+\it \TextNode(1){\Text(--#1--)}
+\MoveToNode(0..0,0,1) \Units(1pt,1pt) \Move(-60,0)
+\EntryExit(1,1,0,0) \Node(d)(--Dra\TeX--)
+\MoveToNode(2..0,-1,1) \Move(0,40) \EntryExit(-1,-1,0,0)
+\Node(a)(--Al~~Dra~~\TeX--) \PenSize(0.75pt)
+\ArrowHeads(2) \CurvedEdgeAt(d,-1,-1,a,0,1)(225,1.1,70,1.3)
+
+\EndDraw
diff --git a/info/maketexwork/ex-06-08 b/info/maketexwork/ex-06-08
new file mode 100644
index 0000000000..9cbd15ae66
--- /dev/null
+++ b/info/maketexwork/ex-06-08
@@ -0,0 +1,81 @@
+#! perl
+#
+# Usage: gs-eps epsfile <outputfile> <resolution> <device>
+#
+# Where: epsfile is the encapsulated postscript file
+# outputfile is the output file (the default name
+# is <basename epsfile>.<device>)
+# resolution is the output resolution (default=300)
+# device is the GS driver to use (default=pbm)
+
+($epsfile,$outputfile,$res,$device) = @ARGV;
+
+if (! $epsfile) {
+ printf "Usage: gs-eps epsfile <outputfile> <resolution>";
+ printf " <gsdriver>\n";
+ printf "Note: parameters are positional. To specify a";
+ printf " driver, you\n";
+ printf "must also specify an outputfile and resolution.\n";
+ exit 1;
+ }
+
+$epsfile =~ tr/\\/\//; # translate \foo\bar -> /foo/bar
+
+if (! -r $epsfile) {
+ printf "Cannot read file: $epsfile\n";
+ exit 1;
+ }
+
+if (! $res) { $res = 300 }
+if (! $device) { $device = "pbm" }
+
+if (! $outputfile ) {
+ @pathname = split(/\//,$epsfile);
+ $outputfile = $pathname[$#pathname];
+ $outputfile =~ s/.eps$//;
+ $outputfile = join(".", $outputfile, $device);
+ }
+
+printf "Converting $epsfile to $outputfile at ${res}dpi...\n";
+
+open (EPSFILE,$epsfile);
+
+undef $bbox;
+undef $showpg;
+while (<EPSFILE>) {
+ $bbox = $_ if /\%\%\s*BoundingBox:\s*\d+\s+\d+\s+\d+\s+\d+/;
+ $showpage = $_ if /showpage/;
+ last if ($bbox && $showpage);
+ }
+
+if (! $bbox) {
+ printf "Cannot find a bounding box in $epsfile";
+ exit 1;
+ }
+
+$bbox =~ s/\D*//; # remove everything preceding the digits
+
+($llx,$lly,$urx,$ury) = split(/\s/,$bbox);
+
+$xsize = sprintf("%d", (($urx - $llx) * $res / 72) + 0.5);
+$ysize = sprintf("%d", (($ury - $lly) * $res / 72) + 0.5);
+
+printf "$llx neg $lly neg translate .gt. gs-eps-a.$$\n";
+printf "quit .gt. gs-eps-b.$$\n";
+
+if (! $showpg) {
+ printf "showpage .gt. gs-eps-b.$$\n";
+ printf "quit .gtgt. gs-eps-b.$$\n";
+ }
+
+# join sillyness to keep the length of lines in the
+# script small enough to print in the book.
+$gscmd = join(" ", "gs -sDEVICE=$device",
+ "-q -sOutputFile=$outputfile",
+ "-g${xsize}x${ysize} -r$res",
+ "gs-eps-a.$$ $epsfile -",
+ ".lt. gs-eps-b.$$");
+
+printf "$gscmd\n";
+
+printf "rm -f gs-eps-a.$$ gs-eps-b.$$\n";
diff --git a/info/maketexwork/ex-06-09 b/info/maketexwork/ex-06-09
new file mode 100644
index 0000000000..0852abdb0c
--- /dev/null
+++ b/info/maketexwork/ex-06-09
@@ -0,0 +1,33 @@
+% use any IBM OEM encoded fixed width font!
+\font\screenfont=ncrr-ibm at 7pt
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% These macros are derived from The TeXbook pg 380-381
+\def\uncatcodespecials{\def\do##1{\catcode`##1=12 }\dospecials}
+\def\setupverbatim{\screenfont%
+ \def\par{\leavevmode\endgraf\relax}%
+ \obeylines\uncatcodespecials%
+ \catcode`\\=0\catcode`\{=1\catcode`\}=2\obeyspaces}
+{\obeyspaces\global\let =\ } % let active space be a control space
+\def\screenlisting#1{\par\begingroup%
+ \def\c##1{\char##1}\setupverbatim\input{#1}%
+ \endgroup}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\def\screenbox#1{%
+ \vbox{\offinterlineskip%
+ \parskip=0pt\parindent=0pt%
+ \screenlisting{#1}}}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Input converted file '#1' and set it inside a box with '#2' padding
+% space around the image.
+\def\screendump#1#2{%
+ \hbox{\vrule%
+ \vbox{\hrule%
+ \hbox{\hskip#2%
+ \vbox{\vskip#2%
+ \def\twentyxs{xxxxxxxxxxxxxxxxxxxx}%
+ \setbox0=\hbox{\screenfont\twentyxs\twentyxs\twentyxs\twentyxs}%
+ \hbox to \wd0{\screenbox{#1}\hss}%
+ \vskip#2}%
+ \hskip#2}%
+ \hrule}%
+ \vrule\hss}}
diff --git a/info/maketexwork/ex-07-01 b/info/maketexwork/ex-07-01
new file mode 100644
index 0000000000..fa87ff6c02
--- /dev/null
+++ b/info/maketexwork/ex-07-01
@@ -0,0 +1,8 @@
+ Using English and French}
+\documentstyle[english,francais]{article}
+\begin{document}
+This is a document which uses both English and
+French. \selectlanguage{french} Mais, Je ne parle plus
+la francais. \selectlanguage{english} So I won't try
+to make this example very long.
+\end{document}
diff --git a/info/maketexwork/ex-10-01 b/info/maketexwork/ex-10-01
new file mode 100644
index 0000000000..cc95fc65a9
--- /dev/null
+++ b/info/maketexwork/ex-10-01
@@ -0,0 +1,38 @@
+\input texinfo @c -*- TeXinfo -*-
+@setfilename perf-inf.inf
+@ifinfo
+ @paragraphindent 0
+@end ifinfo
+@iftex
+ @defaultparindent=0pt @parindent=0pt
+@end iftex
+
+@node Top, , (dir), (dir)
+@chapter Unsolved Problems
+@section Odd Perfect Numbers
+
+A number is said to be @i{perfect} if it is
+the sum of its divisors. For example, 6 is
+perfect because
+@tex $1+2+3 = 6$,
+@end tex
+@ifinfo
+1+2+3 = 6,
+@end ifinfo
+and 1, 2, and 3 are the only numbers that divide
+evenly into 6 (apart from 6 itself).
+
+It has been shown that all even perfect numbers
+have the form
+@tex $$2^{p-1}(2^{p}-1)$$ where $p$ and $2^{p}-1$
+@end tex
+@ifinfo
+@center 2^(p-1) (2^p - 1)
+
+where p and 2^p - 1
+@end ifinfo
+are both prime.
+
+The existence of @i{odd} perfect numbers is an
+open question.
+@bye
diff --git a/info/maketexwork/ex-11-01 b/info/maketexwork/ex-11-01
new file mode 100644
index 0000000000..ea60ed245c
--- /dev/null
+++ b/info/maketexwork/ex-11-01
@@ -0,0 +1,19 @@
+mode_setup;
+u# := 2mm#;
+define_pixels(u);
+
+beginchar("A", 8u#, 9u#, 5u#);
+ z1 = ( 0u, 0u);
+ z2 = ( 8u, 0u);
+ z3 = ( 1u, 8u);
+ z4 = ( 7u, 8u);
+ pickup pencircle scaled 1u#;
+ draw z4 .. z1 .. z2 .. z3 .. cycle;
+ pickup pencircle scaled 3u#;
+ drawdot z1;
+ drawdot z2;
+ drawdot z3;
+ drawdot z4;
+endchar;
+
+\end
diff --git a/info/maketexwork/ex-12-01 b/info/maketexwork/ex-12-01
new file mode 100644
index 0000000000..0f0ccfadbb
--- /dev/null
+++ b/info/maketexwork/ex-12-01
@@ -0,0 +1,7 @@
+@book{kn:texbook,
+ author = "Donald E. Knuth",
+ title = "The {\TeX}book",
+ publisher = "Addison-Wesley",
+ year = 1989,
+ edition = "Fifteenth",
+}
diff --git a/info/maketexwork/ex-12-02 b/info/maketexwork/ex-12-02
new file mode 100644
index 0000000000..36100d1df0
--- /dev/null
+++ b/info/maketexwork/ex-12-02
@@ -0,0 +1,4 @@
+%A Donald E. Knuth
+%T The \TeX{}book
+%I Addison-Wesley
+%D 1989
diff --git a/info/maketexwork/ex-D-01 b/info/maketexwork/ex-D-01
new file mode 100644
index 0000000000..391127e360
--- /dev/null
+++ b/info/maketexwork/ex-D-01
@@ -0,0 +1,568 @@
+#!/usr/local/bin/perl
+#
+# MakeTeXPK.pl version 1.0, Copyright (C) 1993,94 by Norman Walsh.
+# NO WARRANTY. Distribute freely under the GNU GPL.
+#
+# This script attempts to make a new TeX PK font, because one wasn't
+# found. Parameters are:
+#
+# name dpi bdpi [[[magnification] mode] subdir]
+#
+# `name' is the name of the font, such as `cmr10' (*NOT* cmr10.mf).
+# `dpi' is the resolution the font is needed at.
+# `bdpi' is the base resolution, useful for figuring out the mode to
+# make the font in.
+# `magnification' is a string to pass to MF as the magnification.
+# `mode' if supplied, is the mode to use.
+#
+# This script was designed with two goals in mind: to support recursive
+# subdirectory searching for fonts and to provide support for PK files
+# built from both MF fonts and PS fonts. It also supports the Sauter
+# and DC fonts which can be built at any design size.
+#
+# This script was designed and tested with the following directory structure
+# in mind: each typeface is stored in its own directory with appropriate
+# subdirectories for font sources, metrics, and glyphs. The script may not
+# work exactly right if you use a different directory structure (the font
+# installation, in particular, will probably be incorrect). However,
+# several other versions of MakeTeXPK exist which will handle simpler
+# directory structures, so you need not feel compelled to use the one
+# described here.
+#
+# For MF fonts: (... is usually something like /usr/local/lib/tex/fonts)
+#
+# .../typeface/src holds the sources
+# /tfm holds the TFM files
+# /glyphs root for glyphs
+# /glyphs/mode holds the PK files for "mode".
+#
+# For PS fonts: (... is usually something like /usr/local/lib/tex/fonts)
+#
+# .../typeface/afm holds the AFM files
+# /tfm holds the TFM files
+# /vf holds the VF files
+# /vpl holds the VPL files
+# /glyphs root for glyphs
+# /glyphs/pk/999dpi holds the PK files at 999 dpi created by ps2pk
+# /glpyhs/type1 holds the type1 PFA/PFB sources for the fonts
+#
+
+require "getopts.pl";
+$rc = &Getopts ('v'); # Get options from the user...
+
+$USE_MODE_IN_DEST = 1; # Does the destination directory name include
+ # the name of the mode?
+
+$VERBOSE = $opt_v || $ENV{"DEBUG_MAKETEXPK"}; # Verbose?
+
+chop($CWD = `pwd`); # Where are we?
+$TEMPDIR = "/tmp/mkPK.$$"; # Where do temp files go?
+$MFBASE = "&plain"; # What MF base do we use by default?
+
+# Where are fonts stored?
+$TEXFONTS = $ENV{"TEXFONTS"} || ".:/usr/local/lib/fonts//";
+
+# Define modes that should be used for base resolutions...
+$DPI_MODES{300} = "laserwriter";
+$DPI_MODES{200} = "FAX";
+$DPI_MODES{360} = "lqhires";
+$DPI_MODES{400} = "nexthi";
+$DPI_MODES{600} = "QMSmoa";
+$DPI_MODES{100} = "nextscreen";
+
+$DPI_MODES{100} = "videodisplayi";
+$DPI_MODES{110} = "videodisplayii";
+$DPI_MODES{118} = "videodisplayiii";
+$DPI_MODES{120} = "videodisplayiv";
+$DPI_MODES{124} = "videodisplayv";
+$DPI_MODES{130} = "videodisplayvi";
+$DPI_MODES{140} = "videodisplayvii";
+$DPI_MODES{150} = "videodisplayviii";
+
+$DPI_MODES{72} = "MacTrueSize";
+$DPI_MODES{635} = "linolo";
+$DPI_MODES{1270} = "linohi";
+$DPI_MODES{2540} = "linosuper";
+
+# Where are the DC fonts stored and what base names can be used?
+$DCR_DIR = '/usr/local/lib/fonts/free/dc/src';
+@DCR_GEN = ('dcb','dcbom','dcbx','dcbxsl','dcbxti','dccsc','dcdunh','dcff',
+ 'dcfi','dcfib','dcitt','dcr','dcsl','dcsltt','dcss','dcssbx',
+ 'dcssi','dctcsc','dcti','dctt','dcu','dcvtt' );
+
+# Where are the Sauter fonts stored and what base names can be used?
+$SAUTER_DIR = '/usr/local/lib/fonts/free/sauter/src';
+@SAUTER_GEN = ('cmb','cmbizx','cmbozx','cmbsy','cmbszx','cmbx','cmbxsl',
+ 'cmbxti', 'cmbz', 'cmbzx', 'cmcsc', 'cmdszc', 'cmdunh',
+ 'cmex', 'cmff', 'cmfi', 'cmfib', 'cminch', 'cmitt', 'cmmi',
+ 'cmmib', 'cmr', 'cmrcz', 'cmrisz', 'cmritz', 'cmriz',
+ 'cmrotz', 'cmroz', 'cmrsz', 'cmrtz', 'cmruz', 'cmrz',
+ 'cmsl', 'cmsltt', 'cmss', 'cmssbx', 'cmssdc', 'cmssi',
+ 'cmssq', 'cmssqi', 'cmsy', 'cmtcsc', 'cmtex', 'cmti',
+ 'cmtt', 'cmu', 'cmvtt', 'czinch', 'czssq', 'czssqi',
+ 'lasy', 'lasyb');
+
+$SAUTER_ROUNDING{11} = '10.954451';
+$SAUTER_ROUNDING{14} = '14.4';
+$SAUTER_ROUNDING{17} = '17.28';
+$SAUTER_ROUNDING{20} = '20.736';
+$SAUTER_ROUNDING{25} = '24.8832';
+$SAUTER_ROUNDING{30} = '29.8685984';
+
+# Get the command line arguments...
+($NAME, $DPI, $BDPI, $MAG, $MODE, $FORCEDEST, $EXTRA) = @ARGV;
+
+open (TTY, ">/dev/tty"); # Open the TTY (so we can print messages
+select (TTY); $| = 1; select(STDOUT); # even if STDERR and STDOUT are both
+ # redirected)
+
+if ($VERBOSE) {
+ print TTY "$0: font name: $NAME\n";
+ print TTY "$0: dpi: $DPI\n";
+ print TTY "$0: base dpi: $BDPI\n";
+ print TTY "$0: magnification: $MAG\n" if $MAG;
+ print TTY "$0: mode: $MODE\n" if $MODE;
+ print TTY "$0: force destination directory: $FORCEDEST\n" if $FORCEDEST;
+ print TTY "$0: extra: $EXTRA\n" if $EXTRA;
+}
+
+# Make sure we got enough arguments, but not too many...
+die "$0: Invalid arguments.\n" if ($BDPI eq "" || $EXTRA ne "");
+
+# Calculate the magnification from the requested resolutions if no
+# magnification string was provided.
+if (!$MAG) {
+ $MAG = "$DPI/$BDPI";
+ print TTY "$0: magnification: $MAG\n" if $VERBOSE;
+}
+
+# Calculate the mode if the mode was not given. Die if we don't know
+# what mode to use for the requested base resolution.
+if ($MODE eq "") {
+ $MODE = $DPI_MODES{$BDPI};
+ die "$0: No mode for ${BDPI}dpi base resolution.\n" if $MODE eq "";
+ print TTY "$0: mode: $MODE\n" if $VERBOSE;
+}
+
+########################################################################
+
+# Really start the work...
+print TTY "Attempting to build PK file for: $NAME at ${DPI}dpi.\n";
+
+$mfFile = $NAME;
+$mfFile =~ /^(.*[^0-9])(\d+)$/;
+$mfBase = $1;
+$mfSize = $2;
+
+# Presumably, we got here because the PK file doesn't exist. Let's look
+# for the MF file or the PFA or PFB file...
+
+# ... it's more complicated than that...
+
+# If the font is from a PFA/B file, it may have the name "rxxx" or
+# "xxx0" because virtual fonts extract glyphs from the "raw" font.
+# We need to find the PFA/B file and install the font with the right name.
+# I'm not sure what the best solution would really be, but this will work.
+# Luckily, it gets installed with the right name 'cause we already
+# figured that out...
+#
+# A better solution on Unix machines might be to make "xxx0.pfa" or
+# "rxxx.pfa" a symbolic link to "xxx.pfa". But that won't work for other
+# architectures...
+
+$t1source = "";
+$t1source = $1 if $mfFile =~ /^r(.*)$/;
+$t1source = $1 if $mfFile =~ /^(.*)0$/ && ($t1source eq "");
+
+if ($t1source) {
+ $fontSource = &find_fonts($TEXFONTS,
+ ("$mfFile.mf", "$mfFile.pfa", "$mfFile.pfb",
+ "$t1source.pfa", "$t1source.pfb"));
+} else {
+ $fontSource = &find_fonts($TEXFONTS,
+ ("$mfFile.mf", "$mfFile.pfa", "$mfFile.pfb"));
+}
+
+if ($fontSource) {
+ if ($fontSource =~ /\.pfa$/ || $fontSource =~ /\.pfb$/) {
+ print TTY "Building PK file from PostScript source.\n";
+ &make_and_cd_tempdir();
+ &make_from_ps($fontSource);
+ } elsif ($fontSource =~ /\.mf$/) {
+ local($fpath, $fname);
+ print TTY "Building PK file from MF source.\n";
+ &make_and_cd_tempdir();
+
+ if ($fontSource =~ /^(.*)\/([^\/]*)$/) {
+ $fpath = $1;
+ $fname = $2;
+
+ $fpath = $CWD if $fpath eq ".";
+ $fpath = "$CWD/.." if $fpath eq "..";
+ } else {
+ $fpath = "";
+ $fname = $fontSource;
+ }
+
+ &make_from_mf($fpath, $fname);
+ } else {
+ print TTY "$0: Cannot build PK font for $NAME.\n";
+ print TTY " " x length($0), " Unprepared for $fontSource.\n";
+ die "\n";
+ }
+} else {
+ if (grep(/^$mfBase$/, @DCR_GEN)) {
+
+ print TTY "Building PK file from DC source.\n";
+
+ &make_and_cd_tempdir();
+
+ $MFBASE = "&dxbase";
+ open (MFFILE, ">$mfFile.mf");
+ print MFFILE "gensize:=$mfSize; generate $mfBase;\n";
+ close (MFFILE);
+
+ &make_from_mf("$DCR_DIR","$mfFile.mf");
+
+ } elsif (grep(/^$mfBase$/, @SAUTER_GEN)) {
+
+ print TTY "Building PK file from Sauter source.\n";
+
+ &make_and_cd_tempdir();
+
+ if (defined($SAUTER_ROUNDING{$mfSize})) {
+ $designSize = $SAUTER_ROUNDING{$mfSize};
+ } else {
+ $designSize = $mfSize;
+ }
+
+ open (MFFILE, ">$mfFile.mf");
+ print MFFILE "design_size := $designSize;\n";
+ print MFFILE "input b-$mfBase;\n";
+ close (MFFILE);
+
+ &make_from_mf("$SAUTER_DIR","$mfFile.mf");
+
+ } else {
+ print TTY "$0: Cannot build PK file. Can't find source.\n";
+ die "\n";
+ }
+}
+
+&cleanup();
+
+exit 0;
+
+########################################################################
+
+sub run {
+ local(@cmd) = @_;
+ local($rc);
+
+ open (SAVEOUT, ">&STDOUT");
+ open (SAVEERR, ">&STDERR");
+ close (STDOUT);
+ open (STDOUT, ">&TTY");
+ close (STDERR);
+ open (STDERR, ">&TTY");
+
+ # Chdir seems to return a funny exit code. So do it internally...
+ # (this is a hack)
+ if (@cmd[0] eq "chdir") {
+ $rc = chdir(@cmd[1]);
+ $rc = !$rc;
+ } else {
+ $rc = system(@cmd);
+ }
+
+ close (STDOUT);
+ open (STDOUT, ">&SAVEOUT");
+ close (SAVEOUT);
+
+ close (STDERR);
+ open (STDERR, ">&SAVEERR");
+ close (SAVEERR);
+
+ if ($rc) {
+ printf TTY "%s\n", "*" x 72;
+ print TTY "$0 error : system return code: $rc\n";
+ print TTY "$0 failed: @cmd\n";
+ printf TTY "%s\n", "*" x 72;
+ }
+
+ $rc;
+}
+
+sub make_and_cd_tempdir {
+ &run ("mkdir", "$TEMPDIR");
+ &run ("chdir", "$TEMPDIR");
+}
+
+sub cleanup {
+ &run ("chdir", "$CWD");
+ &run ("rm", "-rf", "$TEMPDIR");
+}
+
+sub install_font {
+ local($source_path, $font, $subdir, $mode) = @_;
+ local($pkdirs, @paths, $ptarget);
+ local($target) = "";
+
+ if ($VERBOSE) {
+ print "Install: source_path: $source_path\n";
+ print "Install: font : $font\n";
+ print "Install: subdir : $subdir\n";
+ print "Install: mode : $mode\n";
+ }
+
+ $pkdirs = $ENV{"TEXPKS"} || $ENV{"PKFONTS"} || "";
+ @paths = split(/:|;/,$pkdirs);
+
+ # Need to find an installable target for the PK files. Try
+ # ../glyphs/$subdir and ../$subdir then give up and use the best $pkdirs
+ # path...
+
+ if (!$target) {
+ ($ptarget = $source_path) =~ s#/[^/]*$##;
+ $target = "$ptarget/glyphs/$subdir"
+ if -d "$ptarget/glyphs/$subdir"
+ || (-d "$ptarget/glyphs"
+ && -w "$ptarget/glyphs"
+ && ! -f "$ptarget/glyphs/$subdir");
+ }
+
+ if (!$target) {
+ ($ptarget = $source_path) =~ s#/[^/]*$##;
+ $target = "$ptarget/$subdir"
+ if -d "$ptarget/$subdir"
+ || (-d $ptarget && -w $ptarget && ! -f "$ptarget/$subdir");
+
+ # what a minute, suppose we just made a font in the current
+ # directory...let's put the PK file there too...
+ if (! -d "$target" && ($source_path eq $CWD)) {
+ $target = $source_path;
+ $USE_MODE_IN_DEST = 0;
+ }
+ }
+
+ while (!$target && ($ptarget = shift @paths)) {
+ $target = $ptarget if ($ptarget ne "." && $ptarget ne ".."
+ && -d $ptarget && -w $ptarget);
+ }
+
+ if ($target) {
+ if (! -d $target) {
+ &run ("mkdir", "$target");
+ &run ("chmod", "777", "$target");
+ }
+
+ if ($USE_MODE_IN_DEST) {
+ $target .= "/$mode";
+ if (! -d $target) {
+ &run ("mkdir", "$target");
+ &run ("chmod", "777", "$target");
+ }
+ }
+
+ print TTY "Installing $font in $target.\n";
+ &run ("cp", "$font", "$target/fonttmp.$$");
+ &run ("chdir", "$target");
+ &run ("mv", "fonttmp.$$", "$font");
+ &run ("chmod", "a+r", "$font");
+ &run ("chdir", "$TEMPDIR");
+ print STDOUT "$target/$font\n";
+ } else {
+ print TTY "$0: Install failed: no where to put $font.\n";
+ }
+}
+
+sub make_from_mf {
+ local ($source_path, $source_file) = @_;
+ local ($mfsource, $mfinputs, $cmd);
+ local ($gfname, $pkname, $realdpi, $testdpi);
+ local ($cmpath);
+
+ print "source_path: $source_path\n" if $VERBOSE;
+ print "source_file: $source_file\n" if $VERBOSE;
+
+ &run ("chdir", "$TEMPDIR");
+
+ if (!$source_file) {
+ $mfsource = $source_path;
+ ($source_path = $mfsource) =~ s#/[^/]*$##;
+ ($source_file = $mfsource) =~ s#^.*/([^/]*)$#$1#;
+ }
+
+ $mfinputs = $ENV{"MFINPUTS"};
+ $mfinputs =~ s/^:*(.*):*$/$1/ if $mfinputs;
+ $ENV{"MFINPUTS"} = ".:$source_path";
+ $ENV{"MFINPUTS"} .= ":$mfinputs" if $mfinputs;
+
+ print "MFINPUTS: $ENV{MFINPUTS}\n" if $VERBOSE;
+
+ $cmpath = "/usr/local/lib/fonts/free/cm/src";
+ if (-d $cmpath && $ENV{"MFINPUTS"} !~ /$cmpath/) {
+ $ENV{"MFINPUTS"} .= ":$cmpath";
+ }
+
+ $cmd = "$MFBASE \\mode:=$MODE; mag:=$MAG; scrollmode; " .
+ "\\input $source_file";
+ print TTY "virmf $cmd\n";
+
+ $saveTERM = $ENV{"TERM"};
+ $saveDISPLAY = $ENV{"DISPLAY"};
+ delete $ENV{"DISPLAY"};
+ $ENV{"TERM"} = "vt100";
+
+ $rc = &run ("virmf", "$cmd");
+
+ $ENV{"DISPLAY"} = $saveDISPLAY;
+ $ENV{"TERM"} = $saveTERM;
+
+ $realdpi = $DPI;
+ $gfname = "./$mfFile.${realdpi}gf";
+
+ for ($testdpi = $realdpi-2; $testdpi < $realdpi+3; $testdpi++) {
+ $gfname = "./$mfFile.${testdpi}gf", $realdpi = $testdpi
+ if ! -f $gfname && -f "./$mfFile.${testdpi}gf";
+ }
+
+ $gfname = "./$mfFile.${realdpi}gf";
+ $pkname = "./$mfFile.${realdpi}pk";
+
+ $rc = &run ("gftopk", "$gfname", "$pkname");
+
+ &install_font($source_path, "$mfFile.${realdpi}pk", 'pk', "$MODE");
+}
+
+sub make_from_ps {
+ local ($source_path, $source_file) = @_;
+ local ($pssource, @cmd);
+ local ($basename, $afmFile, $afmtest, $part);
+
+ &run ("chdir", "$TEMPDIR");
+
+ if (!$source_file) {
+ $pssource = $source_path;
+ ($source_path = $pssource) =~ s#/[^/]*$##;
+ ($source_file = $pssource) =~ s#^.*/([^/]*)$#$1#;
+ }
+
+ # Need to find the AFM file...
+ $afmFile = "";
+ ($basename = $source_file) =~ s/\.pf[ab]$//;
+ # First, look in ../afm:
+ ($afmtest = $source_path) =~ s#/[^/]*$##;
+ $afmtest .= "/afm/$basename.afm";
+ $afmFile = $afmtest if -r $afmtest;
+
+ # Then, look in ../../afm:
+ ($afmtest = $source_path) =~ s#/[^/]*$##;
+ $afmtest =~ s#/[^/]*$##;
+ $afmtest .= "/afm/$basename.afm";
+ $afmFile = $afmtest if !$afmFile && -r $afmtest;
+
+ die "$0: Cannot find AFM file for $source_file.\n" if !$afmFile;
+
+ @cmd = ('ps2pk', "-a$afmFile", "-X$DPI",
+ "$source_path/$source_file", "./$mfFile.${DPI}pk");
+
+ foreach $part (@cmd) {
+ print TTY "$part ";
+ }
+ print TTY "\n";
+
+ $rc = &run (@cmd);
+
+ &install_font($source_path, "$mfFile.${DPI}pk", 'pk', "${DPI}dpi");
+}
+
+sub find_fonts {
+# This subroutine searches for font sources. It looks in all the directories
+# in the path specified. Recursive searches are preformed on directories
+# that end in //, !, or !!. The emTeX directive "!", which should search
+# only one level deep, is treated exactly like "!!".
+#
+ local($path, @fonts) = @_;
+ local(@dirs, $dir, $font);
+ local(@matches) = ();
+ local(@recursive_matches);
+
+ $path =~ s/!!/\/\//g;
+ $path =~ s/!/\/\//g;
+ $path =~ s/\\/\//g;
+
+ print TTY "CWD: ", `pwd` if $VERBOSE;
+ print TTY "Find: @fonts\n" if $VERBOSE;
+ print TTY "Path: $path\n" if $VERBOSE;
+
+ @dirs = split(/:|;/, $path);
+ while (@dirs) {
+ $dir = shift @dirs;
+ next if !$dir;
+
+ if ($dir =~ /\/\//) {
+ @recursive_matches = &recursive_search($dir, @fonts);
+ push (@matches, @recursive_matches)
+ if @recursive_matches;
+ } else {
+ $dir =~ s/\/*$//; # remove trailing /, if present
+ foreach $font (@fonts) {
+ push (@matches, "$dir/$font")
+ if -f "$dir/$font";
+ }
+ }
+ }
+
+ $font = shift @matches;
+
+ if (@matches) {
+ print TTY "$0: Found more than one match.\n";
+ print TTY " " x length($0), " Using: $font\n";
+ }
+
+ $font;
+}
+
+sub recursive_search {
+ local($dir, @fonts) = @_;
+ local(@matches) = ();
+ local(@dirstack, $rootdir, $font, $fontmask);
+
+ $dir =~ /^(.*)\/\/(.*)$/;
+ $rootdir = $1;
+ $fontmask = $2;
+
+ $rootdir =~ s/\/*$//; # remove trailing /'s
+
+ # Note: this perl script has to scan them all, the mask is meaningless.
+ # Especially since I'm looking for the font *source* not the TFM or
+ # PK file...
+
+ $fontmask =~ s/\$MAKETEX_BASE_DPI/$BDPI/g;
+ $fontmask =~ s/\$MAKETEX_MAG/$MAG/g;
+ $fontmask =~ s/\$MAKETEX_MODE/$MODE/g;
+
+ print TTY "Search root=$rootdir\n" if $VERBOSE;
+ print TTY "Search mask=$fontmask (ignored by $0)\n" if $VERBOSE;
+
+ @dirstack = ($rootdir);
+
+ while ($rootdir = shift @dirstack) {
+ opendir (SEARCHDIR, "$rootdir");
+ while ($dir = scalar(readdir(SEARCHDIR))) {
+ if ($dir ne "." && $dir ne ".." && -d "$rootdir/$dir") {
+ push(@dirstack, "$rootdir/$dir");
+ foreach $font (@fonts) {
+ if (-f "$rootdir/$dir/$font") {
+ print TTY "Matched: $rootdir/$dir/$font\n" if $VERBOSE;
+ push(@matches, "$rootdir/$dir/$font");
+ }
+ }
+ }
+ }
+ closedir (SEARCHDIR);
+ }
+
+ @matches;
+}
diff --git a/info/maketexwork/ex-D-02 b/info/maketexwork/ex-D-02
new file mode 100644
index 0000000000..7283ee9459
--- /dev/null
+++ b/info/maketexwork/ex-D-02
@@ -0,0 +1,427 @@
+#!/usr/local/bin/perl
+#
+# MakeTeXTFM.pl version 1.0, Copyright (C) 1993,94 by Norman Walsh.
+# NO WARRANTY. Distribute freely under the GNU GPL.
+#
+# This script attempts to make a new TeX TFM file, because one wasn't
+# found. The only argument is the name of the TFM file, such as
+# `cmr10.tfm' (*NOT* just `cmr10').
+#
+# This script was designed with two goals in mind: to support recursive
+# subdirectory searching for fonts and to provide support for PK files
+# built from both MF fonts and PS fonts. It also supports the Sauter
+# and DC fonts which can be built at any design size.
+#
+# This script was designed and tested with the following directory structure
+# in mind: each typeface is stored in its own directory with appropriate
+# subdirectories for font sources, metrics, and glyphs. The script may not
+# work exactly right if you use a different directory structure (the font
+# installation, in particular, will probably be incorrect). However,
+# several other versions of MakeTeXPK exist which will handle simpler
+# directory structures, so you need not feel compelled to use the one
+# described here.
+#
+# For MF fonts: (... is usually something like /usr/local/lib/tex/fonts)
+#
+# .../typeface/src holds the sources
+# /tfm holds the TFM files
+# /glyphs root for glyphs
+# /glyphs/mode holds the PK files for "mode".
+#
+# For PS fonts: (... is usually something like /usr/local/lib/tex/fonts)
+#
+# .../typeface/afm holds the AFM files
+# /tfm holds the TFM files
+# /vf holds the VF files
+# /vpl holds the VPL files
+# /glyphs root for glyphs
+# /glyphs/pk/999dpi holds the PK files at 999 dpi created by ps2pk
+# /glpyhs/type1 holds the type1 PFA/PFB sources for the fonts
+#
+# The TFM files constructed for PostScript fonts are mapped to the Old TeX
+# encoding.
+#
+
+require "getopts.pl";
+$rc = &Getopts ('v'); # Get options from the user...
+
+$VERBOSE = $opt_v || $ENV{"DEBUG_MAKETEXPK"}; # Verbose?
+
+chop($CWD = `pwd`); # Where are we?
+$TEMPDIR = "/tmp/mkPK.$$"; # Where do temp files go?
+$MFBASE = "&plain"; # What MF base do we use by default?
+
+# Where are fonts stored?
+$TEXFONTS = $ENV{"TEXFONTS"} || ".:/usr/local/lib/fonts//";
+
+# Define modes that should be used for base resolutions...
+$DPI_MODES{300} = "laserwriter";
+$DPI_MODES{200} = "FAX";
+$DPI_MODES{360} = "lqhires";
+$DPI_MODES{400} = "nexthi";
+$DPI_MODES{600} = "QMSmoa";
+$DPI_MODES{100} = "nextscreen";
+
+$DPI_MODES{100} = "videodisplayi";
+$DPI_MODES{110} = "videodisplayii";
+$DPI_MODES{118} = "videodisplayiii";
+$DPI_MODES{120} = "videodisplayiv";
+$DPI_MODES{124} = "videodisplayv";
+$DPI_MODES{130} = "videodisplayvi";
+$DPI_MODES{140} = "videodisplayvii";
+$DPI_MODES{150} = "videodisplayviii";
+
+$DPI_MODES{72} = "MacTrueSize";
+$DPI_MODES{635} = "linolo";
+$DPI_MODES{1270} = "linohi";
+$DPI_MODES{2540} = "linosuper";
+
+# Where are the DC fonts stored and what base names can be used?
+$DCR_DIR = '/usr/local/lib/fonts/free/dc/src';
+@DCR_GEN = ('dcb','dcbom','dcbx','dcbxsl','dcbxti','dccsc','dcdunh','dcff',
+ 'dcfi','dcfib','dcitt','dcr','dcsl','dcsltt','dcss','dcssbx',
+ 'dcssi','dctcsc','dcti','dctt','dcu','dcvtt' );
+
+# Where are the Sauter fonts stored and what base names can be used?
+$SAUTER_DIR = '/usr/local/lib/fonts/free/sauter/src';
+@SAUTER_GEN = ('cmb','cmbizx','cmbozx','cmbsy','cmbszx','cmbx','cmbxsl',
+ 'cmbxti', 'cmbz', 'cmbzx', 'cmcsc', 'cmdszc', 'cmdunh',
+ 'cmex', 'cmff', 'cmfi', 'cmfib', 'cminch', 'cmitt', 'cmmi',
+ 'cmmib', 'cmr', 'cmrcz', 'cmrisz', 'cmritz', 'cmriz',
+ 'cmrotz', 'cmroz', 'cmrsz', 'cmrtz', 'cmruz', 'cmrz',
+ 'cmsl', 'cmsltt', 'cmss', 'cmssbx', 'cmssdc', 'cmssi',
+ 'cmssq', 'cmssqi', 'cmsy', 'cmtcsc', 'cmtex', 'cmti',
+ 'cmtt', 'cmu', 'cmvtt', 'czinch', 'czssq', 'czssqi',
+ 'lasy', 'lasyb');
+
+$SAUTER_ROUNDING{11} = '10.954451';
+$SAUTER_ROUNDING{14} = '14.4';
+$SAUTER_ROUNDING{17} = '17.28';
+$SAUTER_ROUNDING{20} = '20.736';
+$SAUTER_ROUNDING{25} = '24.8832';
+$SAUTER_ROUNDING{30} = '29.8685984';
+
+open (TTY, ">/dev/tty");
+select (TTY); $| = 1; select(STDOUT);
+
+$tfmFile = @ARGV[0];
+if (!$tfmFile) {
+ print TTY "$0 error: No TFM file specified.\n";
+ die "\n";
+}
+
+print TTY "\nAttempting to build TFM file: $tfmFile.\n";
+
+# This is the *wierdest* bug I've ever seen. When this script is called
+# by virtex to build a TFM file, the argument (as interpreted by Perl)
+# has (at least one) ASCII 16 attached to the end of the argument. This
+# loop removes all control characters from the $tfmFile name string...
+$tfmFile =~ /(.)$/;
+$char = ord ($1);
+while ($char <= 32) {
+ $tfmFile = $`;
+ $tfmFile =~ /(.)$/;
+ $char = ord ($1);
+}
+
+# Now we know the name of the TFM file. Next, get the name of the MF file
+# and the base name and size of the MF file.
+
+($mfFile = $tfmFile) =~ s/\.tfm$//;
+$mfFile =~ /^(.*[^0-9])(\d+)$/;
+$mfBase = $1;
+$mfSize = $2;
+
+# Presumably, we got here because the TFM file doesn't exist. Let's look
+# for the MF file or the AFM file...
+
+$tfmSource = &find_fonts($TEXFONTS, ("$mfFile.mf", "$mfFile.afm"));
+
+if ($tfmSource) {
+ if ($tfmSource =~ /\.afm$/) {
+ print TTY "Building $tfmFile from AFM source.\n";
+ &make_and_cd_tempdir();
+ &make_from_afm($tfmSource);
+ } elsif ($tfmSource =~ /\.mf$/) {
+ local($fpath, $fname);
+ print TTY "Building $tfmFile from MF source.\n";
+ &make_and_cd_tempdir();
+
+ if ($tfmSource =~ /^(.*)\/([^\/]*)$/) {
+ $fpath = $1;
+ $fname = $2;
+
+ $fpath = $CWD if $fpath eq ".";
+ $fpath = "$CWD/.." if $fpath eq "..";
+ } else {
+ $fpath = "";
+ $fname = $tfmSource;
+ }
+
+ &make_from_mf($fpath, $fname);
+ } else {
+ print TTY "$0: Cannot build $tfmFile.\n";
+ print TTY " " x length($0), " Unprepared for $tfmSource.\n";
+ die "\n";
+ }
+} else {
+ if (grep(/^$mfBase$/, @DCR_GEN)) {
+
+ print TTY "Building $tfmFile from DC source.\n";
+
+ &make_and_cd_tempdir();
+
+ $MFBASE = "&dxbase";
+ open (MFFILE, ">$mfFile.mf");
+ print MFFILE "gensize:=$mfSize; generate $mfBase;\n";
+ close (MFFILE);
+
+ &make_from_mf("$DCR_DIR","$mfFile.mf");
+
+ } elsif (grep(/^$mfBase$/, @SAUTER_GEN)) {
+
+ print TTY "Building $tfmFile from Sauter source.\n";
+
+ &make_and_cd_tempdir();
+
+ if (defined($SAUTER_ROUNDING{$mfSize})) {
+ $designSize = $SAUTER_ROUNDING{$mfSize};
+ } else {
+ $designSize = $mfSize;
+ }
+
+ open (MFFILE, ">$mfFile.mf");
+ print MFFILE "design_size := $designSize;\n";
+ print MFFILE "input b-$mfBase;\n";
+ close (MFFILE);
+
+ &make_from_mf("$SAUTER_DIR","$mfFile.mf");
+
+ } else {
+ print TTY "$0: Cannot build $tfmFile. Can't find source.\n";
+ die "\n";
+ }
+}
+
+&cleanup();
+
+exit 0;
+
+sub run {
+ local(@cmd) = @_;
+ local($rc);
+
+ open (SAVEOUT, ">&STDOUT");
+ open (SAVEERR, ">&STDERR");
+ close (STDOUT);
+ open (STDOUT, ">&TTY");
+ close (STDERR);
+ open (STDERR, ">&TTY");
+
+ # Chdir seems to return a funny exit code. So do it internally...
+ # (this is a hack)
+ if (@cmd[0] eq "chdir") {
+ $rc = chdir(@cmd[1]);
+ $rc = !$rc;
+ } else {
+ $rc = system(@cmd);
+ }
+
+ close (STDOUT);
+ open (STDOUT, ">&SAVEOUT");
+ close (SAVEOUT);
+
+ close (STDERR);
+ open (STDERR, ">&SAVEERR");
+ close (SAVEERR);
+
+ if ($rc) {
+ printf TTY "%s\n", "*" x 72;
+ print TTY "MakeTeXTFM error : system return code: $rc\n";
+ print TTY "MakeTeXTFM failed: @cmd\n";
+ printf TTY "%s\n", "*" x 72;
+ }
+
+ $rc;
+}
+
+sub make_and_cd_tempdir {
+ &run ("mkdir", "$TEMPDIR");
+ &run ("chdir", "$TEMPDIR");
+}
+
+sub cleanup {
+ &run ("chdir", "$CWD");
+ &run ("rm", "-rf", "$TEMPDIR");
+}
+
+sub install_font {
+ local($source_path, $font, $subdir) = @_;
+ local(@paths) = split(/:|;/,$ENV{"TEXFONTS"});
+ local($target) = "";
+ local($ptarget);
+
+ if (!$target && $source_path =~ /\/src$/) {
+ $ptarget = $source_path;
+ $ptarget =~ s/(.*)\/src$/$1/;
+ $ptarget .= "/$subdir";
+ $target = $ptarget if (-d $ptarget && -w $ptarget);
+ }
+
+ if (!$target && $source_path =~ /\/afm$/) {
+ $ptarget = $source_path;
+ $ptarget =~ s/(.*)\/afm$/$1/;
+ $ptarget .= "/$subdir";
+ $target = $ptarget if (-d $ptarget && -w $ptarget);
+ }
+
+ if (!$target && ($source_path eq $CWD)) {
+ $target = $source_path;
+ }
+
+ while (!$target && ($ptarget = shift @paths)) {
+ $target = $ptarget if ($ptarget ne "." && $ptarget ne ".."
+ && -d $ptarget && -w $ptarget);
+ }
+
+ if ($target) {
+ print TTY "Installing $font in $target.\n";
+ &run ("cp", "$font", "$target/fonttmp.$$");
+ &run ("chdir", "$target");
+ &run ("mv", "fonttmp.$$", "$font");
+ &run ("chmod", "a+r", "$font");
+ &run ("chdir", "$TEMPDIR");
+ print STDOUT "$target/$font\n";
+ } else {
+ print TTY "$0: Install failed: no where to put $font.\n";
+ }
+}
+
+sub make_from_mf {
+ local ($source_path, $source_file) = @_;
+ local ($mfsource, $mfinputs, $cmd);
+
+ &run ("chdir", "$TEMPDIR");
+
+ if (!$source_file) {
+ $mfsource = $source_path;
+ ($source_path = $mfsource) =~ s#/[^/]*$##;
+ ($source_file = $mfsource) =~ s#^.*/([^/]*)$#$1#;
+ }
+
+ $mfinputs = $ENV{"MFINPUTS"};
+ $mfinputs =~ s/^:*(.*):*$/$1/ if $mfinputs;
+ $ENV{"MFINPUTS"} = ".:$source_path";
+ $ENV{"MFINPUTS"} .= ":$mfinputs" if $mfinputs;
+
+ print "MFINPUTS: $ENV{MFINPUTS}\n" if $VERBOSE;
+
+ $cmd = "$MFBASE \\mode:=laserwriter; scrollmode; \\input $source_file";
+ print TTY "virmf $cmd\n";
+
+ $saveTERM = $ENV{"TERM"};
+ $saveDISPLAY = $ENV{"DISPLAY"};
+ delete $ENV{"DISPLAY"};
+ $ENV{"TERM"} = "vt100";
+
+ $rc = &run ("virmf", "$cmd");
+
+ $ENV{"DISPLAY"} = $saveDISPLAY;
+ $ENV{"TERM"} = $saveTERM;
+
+ &install_font($source_path, $tfmFile, 'tfm');
+}
+
+sub make_from_afm {
+ local ($afmFile) = @_;
+ local ($source_path);
+
+ print TTY "afm2tfm $afmFile -v $mfFile ${mfFile}0\n";
+ $rc = &run ("afm2tfm", "$afmFile", "-v", "$mfFile", "${mfFile}0");
+
+ print TTY "vptovf $mfFile.vpl $mfFile.vf $mfFile.tfm\n";
+ $rc = &run ("vptovf", "$mfFile.vpl", "$mfFile.vf", "$mfFile.tfm");
+
+ ($source_path = $afmFile) =~ s#/[^/]*$##;
+ &install_font($source_path, "$mfFile.tfm", 'tfm');
+ &install_font($source_path, "${mfFile}0.tfm", 'tfm');
+ &install_font($source_path, "$mfFile.vpl", 'vpl');
+ &install_font($source_path, "$mfFile.vf", 'vf');
+}
+
+sub find_fonts {
+ local($path, @fonts) = @_;
+ local(@dirs, $dir, $font);
+ local(@matches) = ();
+ local(@recursive_matches);
+
+ print "Find fonts on path: $path\n" if $VERBOSE;
+
+ @dirs = split(/:|;/, $path);
+ while ($dir = shift @dirs) {
+ print "Search: $dir\n" if $VERBOSE;
+ if ($dir =~ /\/\//) {
+ @recursive_matches = &recursive_search($dir, @fonts);
+ push (@matches, @recursive_matches)
+ if @recursive_matches;
+ } else {
+ $dir =~ s/\/*$//; # remove trailing /, if present
+ foreach $font (@fonts) {
+ push (@matches, "$dir/$font")
+ if -f "$dir/$font";
+ }
+ }
+ }
+
+ $font = shift @matches;
+
+ if (@matches) {
+ print TTY "$0: Found more than one match.\n";
+ print TTY " " x length($0), " Using: $font\n";
+ }
+
+ $font;
+}
+
+sub recursive_search {
+ local($dir, @fonts) = @_;
+ local(@matches) = ();
+ local(@dirstack, $rootdir, $font, $fontmask);
+
+ $dir =~ /^(.*)\/\/(.*)$/;
+ $rootdir = $1;
+ $fontmask = $2;
+
+ $rootdir =~ s/\/*$//; # remove trailing /'s
+
+ # Note: this perl script has to scan them all, the mask is meaningless.
+ # Especially since I'm looking for the font *source* not the TFM or
+ # PK file...
+
+ $fontmask =~ s/\$MAKETEX_BASE_DPI/$BDPI/g;
+ $fontmask =~ s/\$MAKETEX_MAG/$MAG/g;
+ $fontmask =~ s/\$MAKETEX_MODE/$MODE/g;
+
+ print "Search root=$rootdir\n" if $VERBOSE;
+ print "Search mask=$fontmask (ignored by $0)\n" if $VERBOSE;
+
+ @dirstack = ($rootdir);
+
+ while ($rootdir = shift @dirstack) {
+ opendir (SEARCHDIR, "$rootdir");
+ while ($dir = scalar(readdir(SEARCHDIR))) {
+ if ($dir ne "." && $dir ne ".." && -d "$rootdir/$dir") {
+ push(@dirstack, "$rootdir/$dir");
+ foreach $font (@fonts) {
+ if (-f "$rootdir/$dir/$font") {
+ print "Matched: $rootdir/$dir/$font\n" if $VERBOSE;
+ push(@matches, "$rootdir/$dir/$font");
+ }
+ }
+ }
+ }
+ closedir (SEARCHDIR);
+ }
+
+ @matches;
+}
diff --git a/info/maketexwork/ex-D-03 b/info/maketexwork/ex-D-03
new file mode 100644
index 0000000000..7a1158292a
--- /dev/null
+++ b/info/maketexwork/ex-D-03
@@ -0,0 +1,215 @@
+@echo off
+: -----------------------------------------------------------------------
+: DVIDXX Copyright (C) 1992,94 by Norman Walsh
+:
+: This file is free. You can do anything you like with it with one
+: exception: if you change this file, you MUST rename it!
+:
+: Requirements: 4DOS, emTeX drivers 1.4s or higher, MAKEPK.BTM
+:
+: Usage: DVIDXX emtexDriver driverOptions
+:
+: Note: DVIDXX requires a fair amount of free environment space in order
+: to function properly.
+:
+: Norman Walsh
+: <norm@ora.com>
+:
+: 12/09/1992: - Vers 0.5
+: - This is a first attempt. It works, but it doesn't have
+: any bells and whistles. It would be nice, for example,
+: if it noticed that PS2PK failed for a particular font...
+: -----------------------------------------------------------------------
+:
+: This batch file is a replacement for emTeX's dvidrv program. It offers
+: one additional feature. In addition to using MFjob to build fonts that
+: don't exist, DVIDXX can use PS2PK to build PK files for PostScript fonts.
+: Note: You must have the AFM and PFA/B files for the PS fonts in question.
+:
+: Why did you write this as a 4DOS BTM file? For two reasons. First, I
+: wanted it to be interpreted rather than compiled so that it would be
+: easy to change, modify, and extend. Second, I did it in 4DOS BTM language
+: because DOS's batch language is too primitive. Yes, maybe I _could_ have
+: done it with a plain BAT file, but I had no desire to try.
+:
+: -----------------------------------------------------------------------
+:
+: This file relies on MAKEPK.BTM to actually build the fonts with PS2PK.
+:
+: Both MAKEPK and DVIDXX are somewhat dependant on the layout of your
+: hard disk. Well, on the layout of mine, actually ;-)
+:
+: Here's how my HD is organized:
+:
+: C:\PSFONTS\ Root of my PostScript fonts directory.
+: This is stored in the %[PSFONTS] env. variable
+: %[PSFONTS]\PFB Where .PFB files are kept
+: %[PSFONTS]\AFM Where .AFM files are kept
+: %[PSFONTS]\UTIL Where MAKEPK is kept
+:
+: -----------------------------------------------------------------------
+: Make sure this is 4DOS...
+if "%@eval[2+2]" == "4" goto start
+echo Sorry, this batch file can only be run with 4Dos.
+goto end
+: -----------------------------------------------------------------------
+: Call the driver (maybe we won't have to do anything else)
+: In a network environment, you may have to make the mfjob-file unique
+: for each user in some way...
+: -----------------------------------------------------------------------
+:start
+if not "%_dos" == "DOS" goto os2ok
+iff %_env lt 128 then
+ echo Sorry, this batch file requires at least 128 bytes of free environment
+ echo space. Consult your 4DOS manual for information about increasing it.
+ goto end
+endiff
+:os2ok
+setlocal
+set MFJOBFN=dvidxx.mfj
+
+%1 %2$ +mfjob-file:%MFJOBFN +batch-mode
+iff not errorlevel == 8 then
+ endlocal
+ goto end
+endiff
+: -----------------------------------------------------------------------
+: Ok, we have to build some fonts...
+:
+: NEWJOB = name of the MFjob file that will actually be used
+: PSJOB = name of the batch file that will build fonts with PS2PK
+: PSCNT = number of PS fonts to build
+: MFCNT = number of MF fonts to build
+: MFJOBLEN = number of lines in the original MFjob file
+: LNUM = current line number (in original MFjob file)
+: LINE = text of the current line
+: FONT = name of font
+: SIZE = ptsize of current font (assumes designsize of 10pt)
+: PSFNT = 0/1 flag determines if the %FONT in question is PS or not
+: -----------------------------------------------------------------------
+echo Looking at MFJob file...
+set NEWJOB=%@unique[%@path[%MFJOBFN]]
+set PSJOB=%@unique[%@path[%MFJOBFN]]
+ren %NEWJOB %NEWJOB.mfj /q
+ren %PSJOB %PSJOB.btm /q
+set NEWJOB=%NEWJOB.mfj
+set PSJOB=%PSJOB.btm
+set PSCNT=0
+set MFCNT=0
+set MFJOBLEN=%@lines[%MFJOBFN]
+set LNUM=0
+
+: Create the batch file and the new MFjob file...
+echo %% > %NEWJOB
+echo pushd %PSFONTS > %PSJOB
+
+: -----------------------------------------------------------------------
+: Loop through the entire MFjob file. Lines that begin "{font=" are
+: analyzed further to determine what kind of font it is. All other lines
+: are simply copied to the new MFjob file.
+: -----------------------------------------------------------------------
+
+:looptop
+
+if %LNUM gt %MFJOBLEN goto loopover
+
+: Deleting this percent stuff will save a small amount of time, but
+: since reading from the MFjob file is pretty slow, I find it reassuring...
+set PERC=%@eval[%LNUM / %MFJOBLEN * 100]
+set p=%@index[%PERC,.]
+if %p gt 0 set PERC=%@substr[%PERC,0,%p]
+echos %@CHAR[13]Working:
+echos %[PERC]%%
+
+set LINE=%@line[%MFJOBFN,%LNUM]
+:
+: We employ a convoluted compound test because %@substr["%foo",1,5] fails
+: with a "no closing quote" error if the %@len["%foo"] < 5...
+:
+set FOUND=0
+iff %@len["%LINE"] gt 5 then
+ if (%@substr["%LINE",1,5]) == ({font) set FOUND=1
+endiff
+
+: If we found a font, %FOUND will be 1
+iff %FOUND == 1 then
+ Rem Extract the font name and the size
+ set p=%@index["%LINE",;]
+ set FONT=%@substr["%LINE",7,%@eval[%p - 7]]
+ set p=%@index["%LINE",mag=]
+ set q=%@index["%LINE",}]
+ set SIZE=%@substr["%LINE",%@eval[%p+4],%@eval[%q-%p-5]]
+ set SIZE=%@eval[%SIZE*10]
+
+ Rem This is where we test to see if it is a PS font. I've got a really
+ Rem simple test below. Basically, I keep all my PFB files for PS fonts
+ Rem in a single directory. If the font in question isn't in that directory,
+ Rem I assume it is an MF font.
+ set PSFNT=0
+ gosub ispsfont
+ iff %PSFNT == 1 then
+ Echo %FONT at %[SIZE]pt will be built by PS2PK
+ Rem I keep MAKEPK in C:\PSFONTS\UTIL so that's what I write to the batch
+ Rem file. If you keep it somewhere else, you'll have to change this.
+ echo call %[psfonts]\util\makepk %FONT %SIZE >> %PSJOB
+ set PSCNT=%@eval[%PSCNT + 1]
+ else
+ Echo %FONT at %[SIZE]pt will be built by MFjob
+ echo %LINE >> %NEWJOB
+ set MFCNT=%@eval[%MFCNT + 1]
+ endiff
+else
+ echo %LINE >> %NEWJOB
+endiff
+
+set LNUM=%@eval[%LNUM + 1]
+goto looptop
+:loopover
+
+: -----------------------------------------------------------------------
+
+: Finish up the PSJOB file and clean up the messages on the screen
+echo popd >> %PSJOB
+echos %@CHAR[13] %@CHAR[13]
+
+: -----------------------------------------------------------------------
+
+: Go for it!
+iff %MFCNT gt 0 then
+ echo Attempting to build %MFCNT fonts with MFjob
+ mfjob %NEWJOB
+endiff
+del %NEWJOB /q
+
+: Get back the environment space that we (may) need in MAKEPK...
+unset MFJOBLEN LNUM LINE FONT SIZE PSFNT MFCNT NEWJOB
+
+iff %PSCNT gt 0 then
+ echo Attempting to build %PSCNT fonts with PS2PK
+ call %PSJOB
+endiff
+del %PSJOB /q
+
+: -----------------------------------------------------------------------
+: Try to run the driver again...this time it should succeed!
+
+del %MFJOBFN /q
+%1 %2$ +mfjob-file:%MFJOBFN +batch-mode
+iff errorlevel == 8 then
+ echo Font building must have failed for at least one font. Look in
+ echo the %MFJOBFN file to see which font(s) failed.
+endiff
+
+endlocal
+goto end
+
+: -----------------------------------------------------------------------
+: This really simple subroutine is how I look for PS fonts. This routine
+: should set PSFNT=1 iff the %FONT variable names a PostScript font.
+:
+:ispsfont
+if exist %[psfonts]\pfb\%FONT.pfb set PSFNT=1
+return
+
+: -----------------------------------------------------------------------
+:end
diff --git a/info/maketexwork/ex-D-04 b/info/maketexwork/ex-D-04
new file mode 100644
index 0000000000..7f096b4ca5
--- /dev/null
+++ b/info/maketexwork/ex-D-04
@@ -0,0 +1,151 @@
+@echo off
+: -----------------------------------------------------------------------
+: MAKEPK Copyright (C) 1992,94 by Norman Walsh
+:
+: This file is free. You can do anything you like with it with one
+: exception: if you change this file, you MUST rename it!
+:
+: Requirements: 4DOS, ps2pk, afm2tfm, pfm2afm, pkbbox
+:
+: Usage: MAKEPK fontfn ptsize [pkfn] [-opts]
+:
+: Norman Walsh
+: <norm@ora.com>
+:
+: 12/09/1992: - Vers 0.5
+:--------------------------------------------------------------------------
+: See usage info below
+:
+: This batch file relies on the following directory structure:
+:
+: C:\PSFONTS\ Root of the PostScript fonts directory.
+: This is stored in the %[PSFONTS] env. variable
+: %[PSFONTS]\PFB Where .PFB files are kept
+: %[PSFONTS]\AFM Where .AFM files are kept
+: %[PSFONTS]\PFM Where .PFM files are kept (only required if the
+: AFM file does not exist)
+: %[PSFONTS]\TFM Where _all_ TFM files are kept for PS fonts
+: C:\BIN\PS2PK Where all the PS2PK utils are kept
+:--------------------------------------------------------------------------
+: Make sure the parameters are ok...
+iff %# lt 1 then
+ echo Usage: %0 fontfn ptsize [pkfn] [-opts]
+ echo.
+ echo MAKEPK rasterizes 'fontfn' at 'ptsize' and stores it in 'pkfn'. The
+ echo default 'pkfn' is the name of the 'fontfn'. All fonts are stored in
+ echo the %[psfonts]\@Rrdpi\ directory. If -opts are supplied, they are
+ echo passed to PS2PK.
+ quit 1
+endiff
+
+: Setup local environment
+setlocal
+pushd %[psfonts]
+
+: Parse the command line
+set pfbfn=%@name[%1]
+set ptsz=%2
+set pkfn=%@name[%3]
+shift 2
+:toshift
+iff ³%@substr[%1,0,1]³ == ³-³ then
+ set pkopts=%pkopts %1
+else
+ set pkfn=%@name[%1]
+endiff
+shift
+if %# gt 0 goto toshift
+: -----------------------------------------------------------------------
+: Figure out the name of the appropriate PK directory. Create it if it
+: doesn't exist. Abort if a filename exists with that name...
+:
+: TeX seems to underestimate the font size by a very small amount. We
+: compensate (in the calculation of the directory) by adding the small
+: amount 0.0005 to the point size before truncating to integer...
+:
+set pkres=%@int[%@eval[(%@eval[%ptsz+0.0005] * 300) / 10]]
+set pkdir=%[pkres]dpi
+if isdir %pkdir goto okdir
+iff not exist %pkdir then
+ md %pkdir
+ goto okdir
+endiff
+echo MakePK: Cannot create directory: %pkdir
+quit 1
+:okdir
+: -----------------------------------------------------------------------
+: Setup the %PKFN if it wasn't set by a parameter
+if "%pkfn" == "" set pkfn=%@name[%pfbfn]
+
+: If the font and TFM alread exist, don't bother making them
+iff exist %[pkdir]\%[pkfn].pk .and. .\tfm\%@filesize[%[pkfn].tfm] gt 0 then
+ popd
+ quit 0
+endiff
+
+: Check to see if an AFM file exists (and has a reasonable size)...
+iff %@filesize[.\afm\%[pfbfn].afm] gt 0 then
+ set afmok=1
+else
+ set afmok=0
+endiff
+: -----------------------------------------------------------------------
+: Make sure we have everything we need...a PFB and an AFM or PFM...
+set ok=1
+iff not exist .\pfb\%[pfbfn].pfb then
+ echo Cannot find PFB file: .\pfb\%[pfbfn].pfb
+ set ok=0
+endiff
+iff not exist .\pfm\%[pfbfn].pfm .and. %afmok == 0 then
+ echo Cannot find PFM file (.\pfm\%[pfbfn].pfm) and
+ echo cannot find AFM file (.\afm\%[pfbfn].afm)
+ set ok=0
+endiff
+if "%ok" == "0" quit 1
+set ok=
+: -----------------------------------------------------------------------
+: If we didn't find an AFM file, make one...
+iff %afmok == 0 then
+ echo PFMtoAFM...
+ \bin\ps2pk\pfm2afm .\pfm\%[pfbfn].pfm .\afm\%[pfbfn].afm
+endiff
+
+: -----------------------------------------------------------------------
+: Build the font...
+echo Rasterizing...
+::: The lines marked *** MERGE *** should be joined onto the end of the
+::: preceding line. They were broken only to fit within the margins of
+::: this book.
+echo ps2pk -P10 -X%[pkres] -a.\afm\%[pfbfn].afm %pkopts
+*** MERGE *** .\pfb\%[pfbfn].pfb %[pkdir]\%[pkfn].pk
+ps2pk -V -P10 -X%[pkres] -a.\afm\%[pfbfn].afm %pkopts
+*** MERGE *** .\pfb\%[pfbfn].pfb %[pkdir]\%[pkfn].pk
+
+: If we didn't get a descent AFM then we built it with AFM2PFM.
+: Unfortunately, the bounding boxes are missing if we did that.
+: So add the bounding boxes with the UGLY HACKISH PKbbox program...
+iff %afmok == 0 then
+ echo PKbbox to make bounding boxes...
+ set tempafm=%@unique[.]
+ c:\tex\util\pkbbox %pkdir\%pkfn.pk .\afm\%[pfbfn].afm > %tempafm
+ move %tempafm .\afm\%[pfbfn].afm
+endiff
+
+: If there's no TFM, build it...
+iff not exist .\tfm\%[pkfn].tfm then
+ echo AFMtoTFM...
+ afm2tfm .\afm\%[pfbfn].afm .\tfm\%[pkfn].tfm
+endiff
+
+::: If we didn't build a 10pt font, scale it appropriately
+::iff not "%ptsz" == "10" then
+:: c:\tex\util\pkscale %[pkdir]\%[pkfn].pk .\tfm\%[pkfn].tfm /designsize:10
+:: del %[pkdir]\%[pkfn].bak /q
+::endiff
+
+:
+: -----------------------------------------------------------------------
+: We're all done...
+popd
+endlocal
+quit 0
diff --git a/info/maketexwork/ex-D-05 b/info/maketexwork/ex-D-05
new file mode 100644
index 0000000000..bb8e67689b
--- /dev/null
+++ b/info/maketexwork/ex-D-05
@@ -0,0 +1,174 @@
+#! /usr/local/bin/perl
+#
+# Usage: enc-afm afm-file enc-file > encoded-afm-file
+#
+# Where: afm-file is the original AFM file with an arbitrary
+# encoding enc-file is the encoding file (in PS
+# format, a la dvips .enc files) encoded-afm-file is
+# the new AFM file with 'enc-file' encoding.
+#
+
+# what about .notdef?
+
+$afmfile = @ARGV[0];
+$encfile = @ARGV[1];
+
+print STDERR "Reading encoding file: $encfile\n";
+&read_encfile($encfile);
+print STDERR "Reading AFM file: $afmfile\n";
+&read_afmfile($afmfile);
+
+# Assign the correct encoding position to each char
+$missing = 0;
+for ($count = 0; $count < $vectorlen; $count++) {
+ $missing_glyphs{@encoding[$count]} = 1, $missing = 1
+ if !defined($vectorplace{@encoding[$count]})
+ && @encoding[$count] ne ".notdef";
+ $vectorplace{@encoding[$count]} = $count;
+}
+
+&print_long_list("Note: the following glyphs are missing "
+ . "from the AFM file: ",
+ sort (keys %missing_glyphs))
+ if $missing;
+
+# Construct the CharMetrics lines
+@output_encoding = ();
+foreach $name (keys %metrics) {
+ push (@output_encoding,
+ sprintf("C %3d ; %s",
+ $vectorplace{$name}, $metrics{$name}));
+}
+
+# Sort the CharMetrics lines
+@sorted_encoding = sort (@output_encoding);
+
+# Move the unused characters to the end of the list
+@output_encoding = grep(/^C\s+\d+/, @sorted_encoding);
+@minusone_encoding = grep(/C\s+-1/, @sorted_encoding);
+push(@output_encoding, @minusone_encoding);
+
+# Print the new AFM file
+print $line, "\n" while ($line = shift @preamble);
+
+print "Comment Encoded with enc-afm from $encfile.\n";
+print "EncodingScheme $encname\n";
+printf "StartCharMetrics %d\n", $#output_encoding+1;
+print $line, "\n" while ($line = shift @output_encoding);
+print "EndCharMetrics\n";
+
+print $line, "\n" while ($line = shift @postamble);
+
+exit 0;
+
+sub read_afmfile {
+ local ($afmfile) = @_;
+ local ($inpreamble, $inmetrics, $inpostamble) = (1,0);
+ local ($width, $name, $bbox, $prname);
+
+ @preamble = ();
+ %metrics = ();
+ %vectorplace = ();
+ @postamble = ();
+
+ open (AFM, $afmfile)
+ || die "Can't open afm file: $afmfile\n";
+
+ while (<AFM>) {
+ chop;
+
+ push(@postamble, $_) if $inpostamble;
+ push(@preamble, $_)
+ if $inpreamble && ! /^EncodingScheme\s/i;
+
+ if (/^EndCharMetrics/) {
+ $inmetrics = 0;
+ $inpostamble = 1;
+ }
+
+ if ($inmetrics) {
+ $width = $1 if /[;\s]+WX\s+([0-9]+)[;\s]+/;
+ $name = $1 if /[;\s]+N\s+(\w+)[;\s]+/;
+ $bbox = $1 if /[;\s]+B\s+([^;]+)[;\s]+/;
+ die "Invalid line in AFM file: $_\n"
+ if ($name eq "");
+ $metrics{$name} = sprintf("WX %4d ; N %s ; B %s ;",
+ $width, $name, $bbox);
+ $vectorplace{$name} = -1;
+ }
+
+ if (/^StartCharMetrics/) {
+ $inpreamble = 0;
+ $inmetrics = 1;
+ }
+ }
+}
+
+sub read_encfile {
+ local ($encfile) = @_;
+ local ($place, $line);
+
+ open (ENC, $encfile)
+ || die "Can't open encoding file: $encfile\n";
+
+ $encname = "";
+ @encoding = ();
+ $#encoding = 256; # set the array length
+ $vectorlen = 0;
+ $done = 0;
+ while (<ENC>) {
+ chop;
+ next if /^\s*%/;
+
+ $line = $_;
+ if ($encname eq "") {
+ die "Invalid line in encoding file: $_\n"
+ if ! /\s*\/(.*)\s*\[(.*)$/;
+ $encname = $1;
+ $line = $2;
+ }
+
+ $place = index($line, "%");
+ $line = substr($line,$[,$place-1) if $place >= $[;
+
+ $place = index($line, "]");
+ if ($place >= $[) {
+ $line = substr($line,$[,$place-1);
+ $done = 1;
+ }
+
+ while ($line =~ /^\s*\/(\S*)\s*(.*)$/) {
+ @encoding[$vectorlen++] = $1;
+ $line = $2;
+ }
+
+ last if $done;
+ }
+}
+
+############################################################
+# This routine prints a message followed by a potentially
+# long list of items, seperated by spaces. It will never
+# allow "word wrap" to occur in the middle of a word. There
+# has to be a better way, using Perl's report generation to
+# do this, but I haven't looked yet.
+#
+sub print_long_list {
+ local ($message,@thelist) = @_;
+ local ($line) = $message;
+ local ($item, $displaystring) = ("", "");
+
+ foreach $item (@thelist) {
+ if (length($line . $item) < 73) {
+ $line .= $item . ", ";
+ } else {
+ $displaystring .= $line . "\n";
+ $line = $item . ", ";
+ }
+ }
+
+ $line =~ s/(.*),\s*$/$1/; # remove the last ", "...
+ $displaystring .= $line . "\n";
+
+ print STDERR $displaystring;
+}
diff --git a/info/maketexwork/ex-D-06 b/info/maketexwork/ex-D-06
new file mode 100644
index 0000000000..b7fb42f185
--- /dev/null
+++ b/info/maketexwork/ex-D-06
@@ -0,0 +1,181 @@
+#!/usr/local/bin/bash
+#
+# This script file makes a new X/TeX screen font, because one wasn't
+# found. Parameters are:
+#
+# name dpi bdpi magnification destdir
+#
+# `name' is the name of the font, such as `cmr10'. `dpi' is
+# the resolution the font is needed at. `bdpi' is the base
+# resolution, useful for figuring out the mode to make the font
+# in. `magnification' is a string to pass to MF as the
+# magnification. 'destdir' is the directory in which to cache the new
+# font.
+#
+# Note that this file must execute Metafont, mftobdf, and then bdftosnf,
+# and place the result in the correct location for X
+# to find it subsequently.
+#
+# Of course, it needs to be set up for your site.
+#
+# TEMPDIR needs to be unique for each process because of the possibility
+# of simultaneous processes running this script.
+TEMPDIR=/tmp/bdf-snf.$$
+NAME=$1
+DPI=$2
+BDPI=$3
+MAG=$4
+MODE=$5
+DESTDIR=$6
+umask 0
+
+#declare -i cmfound=0
+#MFDIRS=`echo $MFINPUTS | gawk -F: '{ for (i=1; i<=NF; i++) print $i }'`
+#for f in $MFDIRS
+#do
+# if [ -r $f/$NAME.mf ]; then
+# declare -i cmfound=1
+# fi
+#done
+
+if [ -r /usr/local/lib/tex/fonts/ps-outlines/$NAME.pfa ]
+then
+ echo Building X-font from PostScript outline
+ PStoXfont $1 $2 $3 $4 $5 $6
+ exit 0
+else
+ echo Building X-font from MetaFont outline
+fi
+
+# Something like the following is useful at some sites.
+GFNAME=$NAME.$DPI'gf'
+BDFNAME=$NAME.$DPI.'bdf'
+SNFNAME=$NAME.$DPI.pcf
+
+COMPRESS=1
+
+# check if we're not running with MIT server after all
+if xdpyinfo|grep -s 'vendor string: *.*MIT.*'; then
+# DESTDIR=/usr/lib/X11/fonts/xtex
+# SNFNAME=$NAME.$DPI.'snf'
+ COMPRESS=0
+ MITSERVER=1
+fi
+
+if test "$COMPRESS" = "1"
+then
+ SNFZNAME=${SNFNAME}'.Z'
+else
+ SNFZNAME=${SNFNAME}
+fi
+
+# Clean up on normal or abnormal exit
+trap "cd /; rm -rf $TEMPDIR $DESTDIR/bdftmp.$$ $DESTDIR/snftmp.$$" 0 1 2 15
+
+mkdir $TEMPDIR
+cd $TEMPDIR
+
+if test -r $DESTDIR/$BDFNAME
+then
+ echo "$DESTDIR/$BDFNAME already exists!"
+ exit 0
+fi
+
+if test -r $DESTDIR/$SNFNAME
+then
+ echo "$DESTDIR/$SNFNAME already exists!"
+ exit 0
+fi
+
+if test -r $DESTDIR/$SNFZNAME
+then
+ echo "$DESTDIR/$SNZFNAME already exists!"
+ exit 0
+fi
+
+
+##
+# First try mftobdf, maybe it exists...
+##
+
+echo "1st mftobdf -dpi" $DPI $NAME
+mftobdf -dpi $DPI $NAME
+if test ! -r $BDFNAME
+then
+ pwd
+ echo mf "\mode:=$MODE; mag:=$MAG/1000; scrollmode; input $NAME </dev/null"
+ mf "\mode:=$MODE; mag:=$MAG/1000; scrollmode; input $NAME" </dev/null
+ if test ! -r $GFNAME
+ then
+#
+# My local metafont gives bogus names occasionally. Don't know why.
+#
+ echo "Unable to find $GFNAME in directory "`pwd`
+ OLDDPI=$DPI
+ NEWDPI=`expr $DPI - 1`
+ if [ -r $NAME.$NEWDPI'gf' ] ; then
+ DPI=$NEWDPI
+ fi
+ NEWDPI=`expr $DPI + 1`
+ if [ -r $NAME.$NEWDPI'gf' ] ; then
+ DPI=$NEWDPI
+ fi
+ if [ -r $NAME.$DPI'gf' ] ; then
+ GFNAME=$NAME.$DPI'gf'
+ BDFNAME=$NAME.$DPI.'bdf'
+ SNFNAME=$NAME.$DPI.pcf
+ echo "Metafont built $GFNAME instead of $NAME.${OLDDPI}gf, \
+but that's ok..."
+ gftopk $GFNAME
+ else
+ echo "Metafont failed for some reason on $GFNAME, \
+but continuing anyway"
+ fi
+ else
+ gftopk $GFNAME
+ fi
+
+ echo "mftobdf -dpi" $DPI $NAME
+ mftobdf -dpi $DPI $NAME
+ if test ! -r $BDFNAME
+ then
+ echo "Mftobdf failed for some reason on $BDFNAME"
+ exit 1
+ fi
+fi
+
+echo "$FONTCOMPILER"
+if [ $MITSERVER ]; then
+ bdftopcf $BDFNAME > $SNFNAME
+else
+ /usr/bin/dxfc $BDFNAME > $SNFNAME
+fi
+if test ! -r $SNFNAME
+then
+ echo "Font compiler failed for some reason on $SNFNAME"
+ exit 1
+fi
+
+# Install the BDF and SNF files carefully, since others may be doing
+# the same as us simultaneously.
+
+#cp $BDFNAME $DESTDIR/bdftmp.$$
+cp $SNFNAME $DESTDIR/snftmp.$$
+cd $DESTDIR
+#mv bdftmp.$$ $BDFNAME
+mv snftmp.$$ $SNFNAME
+
+if test "$COMPRESS" = "1"
+then
+ compress -f $SNFNAME
+fi
+
+if [ $MITSERVER ]; then
+ mkfontdir $DESTDIR
+else
+ /usr/bin/dxmkfontdir $DESTDIR
+fi
+xset +fp $DESTDIR
+xset fp rehash
+
+exit 0
diff --git a/info/maketexwork/ex-D-07 b/info/maketexwork/ex-D-07
new file mode 100644
index 0000000000..5ae9a0e61c
--- /dev/null
+++ b/info/maketexwork/ex-D-07
@@ -0,0 +1,64 @@
+#!/usr/local/bin/bash
+#
+# This script file makes a new X/TeX screen font, because one wasn't
+# found. Parameters are:
+#
+# name dpi bdpi mag mode destdir
+#
+# `name' is the name of the font, such as `cmr10'. `dpi' is
+# the resolution the font is needed at. `bdpi' is the base
+# resolution, useful for figuring out the mode to make the font
+# in. `magnification' is a string to pass to MF as the
+# magnification. 'destdir' is the directory in which to cache the new
+# font.
+#
+# Note that this file must execute Metafont, mftobdf, and then bdftosnf,
+# and place the result in the correct location for X
+# to find it subsequently.
+#
+# Of course, it needs to be set up for your site.
+#
+# TEMPDIR needs to be unique for each process because of the possibility
+# of simultaneous processes running this script.
+#
+# This temp directory has to be under /users/oos/bin (or somewhere globally
+# accessible) because this script runs PS2PK on ibis even if it is started
+# elsewhere (e.g. on a Sparc). To do so, it uses the "ibis [cmd]" shortcut
+# and passes the temp directory. If the TEMPDIR was /tmp/whatever then,
+# it would fail because /tmp on a Sparc isn't /tmp on ibis.
+TEMPDIR=/users/oos/bin/PStemp/temp-X-PS.$$
+
+NAME=$1
+DPI=$2
+BDPI=$3
+MAG=$4
+MODE=$5
+DESTDIR=$6
+
+BASENAME=$NAME.$MAG.$BDPI
+PTSIZE=`echo "2 k $MAG 100 / p q" | dc`
+PFADIR=/usr/local/lib/tex/fonts/ps-outlines/
+
+# Clean up on normal or abnormal exit
+trap "cd /; rm -rf $TEMPDIR" 0 1 2 15
+
+mkdir $TEMPDIR
+cd $TEMPDIR
+
+echo Making ${PTSIZE}pt ${BDPI}dpi version of $NAME.
+ps2pk -v -X$BDPI -P$PTSIZE -a$PFADIR/$NAME.afm \
+ $PFADIR/$NAME.pfa $BASENAME.pk
+
+pktobdf $BASENAME.pk | gawk -vname=$NAME.$DPI -f \
+ /usr/local/lib/tex/ps/PStoXfont.awk > $BASENAME.bdf
+bdftopcf $BASENAME.bdf > $BASENAME.pcf
+mv $BASENAME.pcf $DESTDIR
+
+mkfontdir $DESTDIR
+xset +fp $DESTDIR
+xset fp rehash
+
+exit 0
+
+
+
diff --git a/info/maketexwork/ex-D-08 b/info/maketexwork/ex-D-08
new file mode 100644
index 0000000000..7e860797a8
--- /dev/null
+++ b/info/maketexwork/ex-D-08
@@ -0,0 +1,191 @@
+#!/usr/local/bin/perl
+#
+# txt2verb Copyright (C) 1993 by Norm Walsh <norm@ora.com>
+# Distribute freely under the terms of the GNU Copyleft.
+#
+# Converts a text "screen" into a form suitable for \inputing into TeX
+# and printing as a screen dump. The original form is assumed to be
+# a series of 80-byte lines with any character in the range 0-255 present
+# (including CR and LF in the middle of a line).
+#
+# The output form is a series of lines of varying length. There is
+# one output line for each input line. TeX special characters and all
+# characters in the ranges 0-31 and 127-255 are replaced by control
+# sequences.
+#
+# Usage:
+#
+# txt2verb screenfile <texfile>
+#
+# If texfile is not specified, stdout is assumed.
+#
+# Options:
+#
+# -l File of lines. Input file contains lines of varying length,
+# but no imbedded CR or LF chars.
+# -v Verbose: print each input line as it's read.
+# -q Quiet: no messages.
+# -L # Set line length to '#' characters.
+#
+# To incorporate the resulting screen dump in your Plain TeX or LaTeX
+# document, insert the following macro definitions before the first
+# screen dump:
+#
+# \font\screenfont=cr-pc8 at 8pt % use any IBM OEM encoded fixed width font!
+#
+# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+# % These macros are derived from The TeXbook pg 380-381
+# \def\uncatcodespecials{\def\do##1{\catcode`##1=12 }\dospecials}
+# \def\setupverbatim{\screenfont%
+# \def\par{\leavevmode\endgraf\relax}%
+# \obeylines\uncatcodespecials%
+# \catcode`\\=0\catcode`\{=1\catcode`\}=2\obeyspaces}
+# {\obeyspaces\global\let =\ } % let active space be a control space
+# \def\screenlisting#1{\par\begingroup%
+# \def\c##1{\char##1}\setupverbatim\input{#1}%
+# \endgroup}
+# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+# \def\screenbox#1{%
+# \vbox{\offinterlineskip%
+# \parskip=0pt\parindent=0pt%
+# \screenlisting{#1}}}
+# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+# % Input converted file '#1' and set it inside a box with '#2' padding
+# % space around the image.
+# \def\screendump#1#2{%
+# \hbox{\vrule%
+# \vbox{\hrule%
+# \hbox{\hskip#2%
+# \vbox{\vskip#2%
+# \def\twentyxs{xxxxxxxxxxxxxxxxxxxx}%
+# \setbox0=\hbox{\screenfont\twentyxs\twentyxs\twentyxs\twentyxs}%
+# \hbox to \wd0{\screenbox{#1}\hss}%
+# \vskip#2}%
+# \hskip#2}%
+# \hrule}%
+# \vrule\hss}}
+# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+#
+# To include the converted image 'screen.tex' in your document with 2pt
+# of padding around the image, use:
+#
+# \screendump{screen}{2pt}
+#
+# in your document. Note: since this is set as an 'hbox', you may need
+# to use \leavevmode\screendump{screen}{2pt}
+#
+##########################################################################
+
+require 'getopts.pl';
+do Getopts('lvqL:');
+
+die "$0: options make no sense: -l and -L $opt_L.\n" if $opt_l && $opt_L;
+
+$FILEOFLINES = $opt_l;
+$VERBOSE = $opt_v;
+$QUIET = $opt_q;
+$LINELENGTH = $opt_L || 80;
+
+$capturefile = @ARGV[0] || die "Usage: $0 capturefile <texfile>";
+$texfile = @ARGV[1] || "-";
+
+select(STDERR); $| = 1; select(STDOUT); # no buffering of stderr
+
+%badchars = (); # These characters are illegal on input
+
+# anything in the control character range
+for ($byte = 0; $byte < 32; $byte++) {
+ $char = sprintf("%c", $byte);
+ $badchars{$char} = "\\c{$byte}";
+}
+
+# and anything over 126
+for ($byte = 127; $byte < 256; $byte++) {
+ $char = sprintf("%c", $byte);
+ $badchars{$char} = "\\c{$byte}";
+}
+
+$badchars{"\%"} = '\%';
+$badchars{"\$"} = '\$';
+$badchars{"\&"} = '\&';
+$badchars{"\#"} = '\#';
+$badchars{"\{"} = '\c{123}';
+$badchars{"\}"} = '\c{125}';
+$badchars{"\\"} = '\c{92}';
+$badchars{"\_"} = '\c{95}';
+$badchars{"\^"} = '\c{94}';
+
+open (CAPTFILE, $capturefile)
+ || die "Can't open capture file: $capturefile\n";
+open (TEXFILE, ">$texfile")
+ || die "Can't open TeX file: $texfile\n";
+while ($line = &get_line()) {
+ print STDERR "." if $texfile ne "-" && !$VERBOSE && !$QUIET;
+ print STDERR "$line\n" if $VERBOSE;
+
+ $outputbuf = "";
+ while (length($line) > 0) {
+ $char = substr($line,0,1);
+ $line = substr($line,1);
+
+ if (defined($badchars{$char})) {
+ $outputbuf .= $badchars{$char};
+ } else {
+ $outputbuf .= $char;
+ }
+ }
+ print TEXFILE "$outputbuf\n";
+}
+
+close(CAPTFILE);
+close(TEXFILE);
+
+exit 0;
+
+sub get_text_line {
+ local($line);
+
+ if ($line = scalar(<CAPTFILE>)) {
+ chop($line);
+ }
+
+ $line;
+}
+
+sub get_data_line {
+ local($datalen, $line);
+
+ if ($datalen = read(CAPTFILE, $line, $LINELENGTH)) {
+ # if we got a complete line, look to see if the next
+ # characters in the file are CR, CR/LF, or LF. If so, remove
+ # them (assume the are line breaks in the file)
+ if ($datalen = $LINELENGTH) {
+ $place = tell(CAPTFILE);
+ $datalen = read(CAPTFILE, $line, 1);
+ if ($line eq "\015") {
+ $place++;
+ $datalen = read(CAPTFILE, $line, 1);
+ if ($line ne "\012") {
+ seek(CAPTFILE, $place, 0);
+ }
+ } elsif ($line ne "\012") {
+ seek(CAPTFILE, $place, 0);
+ }
+ }
+ } else {
+ return undef;
+ }
+
+ $line;
+}
+
+sub get_line {
+ local($line);
+ if ($FILEOFLINES) {
+ $line = &get_text_line();
+ } else {
+ $line = &get_data_line();
+ }
+
+ $line;
+}