%
%				LGREEK.TEX
%				---------
%
%			      K J Dryllerakis
%
%				Dec 7, 1992
%
%				VERSION: 3.1
%
%	This is the source file for building the greek format for the
%	kd family of fonts.
%	This is based on Greek.tex
%
% 	Greek is defined to be language 1 or actually last_language+1.
%
%	Pleaaaaaaaaase don't modify this file
%
%		Note: Used in conjunction with KD Fonts
%
%	Revision History:
%				VERSION 3.1
%			Level a. Official Release
%				Ver 3.0
%			Level c. Official Release
%			Level d. Corrected alphgr mistake (KJD 2.11.91)
%
%
% \input plain% 			Load the standard macro package
% For GreekLatex we need to preload the lplain format
\input lplain%
%
% Add some LaTeX Information
%
\everyjob{\typeout{Greek LaTeX Version 2.09-3.1 <7 Dec 1992>}}
\immediate\write10{Greek LaTeX Version 2.09-3.1 <7 Dec 1992>}
%
\message{Greek Definitions:}
%
\message{general definitions,}
%
\catcode`\@=11			% We will access TeX private macros
%\newwrite\@screen		% Define a screen ouput
%\def\showstring#1{\immediate\write\@screen{#1}}
\let\showstring\typeout
\def\sp@{ }\def\sp@s{\sp@\sp@\sp@\sp@\sp@\sp@\sp@\sp@\sp@}
\def\c@p{\showstring{}\showstring{\sp@s\sp@s\sp@s GreekTeX -- Version 3.1}%
\showstring{\sp@s\sp@s\sp@s  ---------------------------}
\showstring{\sp@s GreekTeX is a macro package for typesetting greek texts.}
\showstring{\sp@s It is maily compatible with the haralambous package,}
\showstring{\sp@s from which it inherits the top level macros.}
\showstring{\sp@s GreekTeX includes easy access to font families, a choise}
\showstring{\sp@s of delimiters, and makes typesetting scientific papers}
\showstring{\sp@s in greek as easy as in TeX itself.}
\showstring{\sp@s}
\showstring{\sp@s\sp@s\sp@s Copyright K J Dryllerakis 1991-1992}
\showstring{\sp@s\sp@s\sp@s ------------------------------}%
}
\c@p
%
%	A List of Reserved Keywords that should not be redefined
%	^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
%
%		a. accesible from the document
%
%	\|		The character |
%	\begingreek	Begin a group of greek text
%	\endgreek	End a group of greek text
%	\greek		A new language definition
%	\gr		switch to classical greek font
%	\gbf		switch to classical boldface font
%	\git		switch to classical italics font
%	\gsl		switch to classical slanted font
%	\gtt		switch to classical typewritter font
%	\gt		Greater than > symbol
%	\lt		Less than < symbol
%	\math		If we are using $ as del. it is equiv to $
%	\setgreek	Select greek mode to be the primary mode
%	\setlatin	Restore standard mode (at any stage)
%	\showstring	Log a string on the terminal
%
%		b. Internal Control Sequences
%
%	\gr@@kdelimsbar Use | as begin- and end-greek
%	\gr@@kdelimsdol Use $ as begin- and end-greek
%	\@ldend		A copy of plain TeX's \end
%	\@screen	Screen Output for messages
%	\t@f@nt		Remembers greek font used last
%	\t@f@m		Remembers greek family used last
%	\t@size		Remembers greek point size used last
%	\c@p		Product Copyright Notice
%	\grfam		Greek classic font family register
%	\grslfam	Greek slanted font family register
%	\grttfam	Greek typewriter font family register
%	\grbffam	Greek boldface font family register
%	\grifam		Greek italics font family register
%	\l@tinm@de	Definition to restore plain TeX's mode
%
%			Start Up Definitions
%			--------------------
%
\ifx\gr@@kformatloaded\relax\catcode`\@=\active%
 \endinput\else\let\gr@@kformatloaded\relax\fi
\newif\ifdelimsbar\delimsbarfalse	% Check for | as delimiter
\chardef\|=`\|				% A way to access |
\gdef\t@f@nt{\gr}			% Remember font used last
%\gdef\t@size{\grtenpoint}		% Remember size used last
%
\gdef\t@f@m{\fam\grfam}			% Remember family used last
% ^ THESE ARE INITIAL VALUES. DO NOT ALTER!
\newlanguage\greek			% Define Greek as a new language
\def\lt{<}				% Remember Less than
\def\gt{>}				% and greater than signs
\language0				% Switch to default language
%
\message{fonts,}
%
\input grfonts.tex
%
%		   		Greek Font Bits
%				_______________
%
%	First we load the greek fonts and declare the families
%	Then we define point sizes for typesetting greek texts
%
%		Classic Greek Family
%		^^^^^^^^^^^^^^^^^^^^
%\newfam\grfam
%\font\tengr=kdgr10		% 10 point Classic Greek Font
%\font\ninegr=kdgr9		%  9 point Classic Greek Font
%\font\eightgr=kdgr8		%  8 point Classic Greek Font
%\font\sixgr=kdgr8 at 6truept	%  6 point simulated Classic Greek (x.75)
%\def\gr{\tengr\fam\grfam}
%%
%		Slanted Greek Family
%		^^^^^^^^^^^^^^^^^^^^
%\newfam\grslfam
%\font\tengrsl=kdsl10		% 10 Point Slanted Greek Font
%\font\ninegrsl=kdsl10 at 9truept% 9 point (sim.) Slanted Greek
%\font\eightgrsl=kdsl10 at 8truept%8 point (sim.) Slanted Greek
%\def\gsl{\tengrsl\fam\grslfam}
%%
%		Boldface Greek Family
%		^^^^^^^^^^^^^^^^^^^^^
%\newfam\grbffam
%\font\tengrbf=kdbf10		% 10 Point Boldface Greek Font
%\font\ninegrbf=kdbf10 at 9truept% 9 Point (sim.) Boldface Greek
%\font\eightgrbf=kdbf10 at 8truept% 8 Point (sim.) Boldface Greek
%\def\gbf{\tengrbf\fam\grbffam}
%
%		Italic Greek Family
%		^^^^^^^^^^^^^^^^^^^
%\newfam\grifam
%\font\tengri=kdti10		% 10 Point Italic Greek Font
%\font\ninegri=kdti10 at 9truept	%  9 Point (sim.) Italic Greek
%\font\eightgri=kdti10 at 8truept%  8 Point (sim.) Italic Greek
%\def\git{\tengri\fam\grifam}
%
%		Typerwriter Greek Family
%		^^^^^^^^^^^^^^^^^^^^^^^^
%\newfam\grttfam
%\font\tengrtt=kdtt10		% 10 Point Typewritter Greek Font
%\font\ninegrtt=kdtt10 at 9truept%  9 Point (sim.) Typewritter Greek 
%\font\eightgrtt=kdtt10 at 8truept% 8 Point (sim.) Typewritter Greek 
%\hyphenchar\eightgrtt=-1 \hyphenchar\tengrtt=-1
%\hyphenchar\ninegrtt=-1		% Supress Hyphenation
%\def\gtt{\tengrtt\fam\grttfam}
%
% 		Greek Point Size Conventions
%		^^^^^^^^^^^^^^^^^^^^^^^^^^^^
%
%\def\grtenpoint{%		GREEK TENPOINT
%\gdef\t@size{\grtenpoint}% Make a note of the font size
%\textfont\grfam=\tengr\scriptfont\grfam=\eightgr\scriptscriptfont\grfam=\sixgr%
%\textfont\grbffam=\tengrbf\scriptfont\grbffam=\ninegrbf%
%\textfont\grifam=\tengri\scriptfont\grbffam=\ninegri%
%\textfont\grttfam=\tengrtt%
%\textfont\grslfam=\tengrsl%
%\def\gr{\fam\grfam\tengr}%		Switch for classic greek
%\let\rg\gr%				Also rg for compatibility
%\def\it{\fam\grifam\tengri}%		Switch for Greek Italics
%\def\sl{\fam\grslfam\tengrsl}%		Switch for Greek Slanted
%\def\tt{\fam\grttfam\tengrtt}%		Switch for Greek Typerwriter
%\def\bf{\fam\grbffam\tengrbf}%		Switch for Greek Boldface
%\let\git\it\let\gsl\sl%
%\let\gbf\bf\let\gtt\tt%			Retain LaTeX compatibility
%\def\rm{\fam0\tenrm}%			Switch For latin roman
%\def\lit{\fam\itfam\tenit}%		Switch for latin italics
%\def\lsl{\fam\slfam\tensl}%		Switch for latin slanted
%\def\ltt{\fam\ttfam\tentt}%		Switch for latin typewriter
%\def\lbf{\fam\bffam\tenbf}%		Switch for latin boldface
%\normalbaselineskip=.6cm%		Normal Base Line distance
%\setbox\strutbox=\hbox{\vrule height8.5pt width0pt depth4.5pt}%
%\normalbaselines\gr%
%}
%\def\grninepoint{%		GREEK NINEPOINT
%\%gdef\t@size{\grninepoint}% Make a note of the font size
%\textfont\grfam=\ninegr\scriptfont\grfam=\eightgr\scriptscriptfont\grfam=\sixgr%
%\textfont\grbffam=\ninegrbf\scriptfont\grbffam=\eightgrbf%
%\%textfont\grifam=\ninegri\scriptfont\grbffam=\eightgri%
%\textfont\grttfam=\ninegrtt%
%\textfont\grslfam=\ninegrsl%
%\def\gr{\fam\grfam\ninegr}%		Switch for classic greek
%\let\rg\gr%				Also rg for compatibility
%\def\it{\fam\grifam\ninegri}%		Switch for Greek Italics
%\def\sl{\fam\grslfam\ninegrsl}%		Switch for Greek Slanted
%\def\tt{\fam\grttfam\ninegrtt}%		Switch for Greek Typerwriter
%\def\bf{\fam\grbffam\ninegrbf}%		Switch for Greek Boldface
%\let\git\it\let\gsl\sl%
%\let\gbf\bf\let\gtt\tt%			Retain LaTeX compatibility
%\def\rm{\fam0\tenrm}%			Switch For latin roman
%\def\lit{\fam\itfam\nineit}%		Switch for latin italics
%\def\lsl{\fam\slfam\ninesl}%		Switch for latin slanted
%\def\ltt{\fam\ttfam\ninett}%		Switch for latin typewriter
%\def\lbf{\fam\bffam\ninebf}%		Switch for latin boldface
%\normalbaselineskip=.52cm%		Normal Base Line distance
%\setbox\strutbox=\hbox{\vrule height8pt width0pt depth3pt}%
%\normalbaselines\gr%
%}
%\def\greightpoint{%		GREEK EIGHTPOINT
%\gdef\t@size{\greightpoint}% Make a note of the font size
%\textfont\grfam=\eightgr\scriptfont\grfam=\sixgr\scriptscriptfont\grfam=\sixgr%
%\textfont\grbffam=\eightgrbf\scriptfont\grbffam=\eightgrbf%
%\textfont\grifam=\eightgri\scriptfont\grbffam=\eightgri%
%\textfont\grttfam=\eightgrtt%
%\textfont\grslfam=\eightgrsl%
%\def\gr{\fam\grfam\eightgr}%		Switch for classic greek
%\let\rg\gr%				Also rg for compatibility
%\def\it{\fam\grifam\eightgri}%		Switch for Greek Italics
%\def\sl{\fam\grslfam\eightgrsl}%	Switch for Greek Slanted
%\def\tt{\fam\grttfam\eightgrtt}%	Switch for Greek Typerwriter
%\def\bf{\fam\grbffam\eightgrbf}%	Switch for Greek Boldface
%\let\git\it\let\gsl\sl%
%\let\gbf\bf\let\gtt\tt%			Retain LaTeX compatibility
%\def\rm{\fam0\eightrm}%			Switch For latin roman
%\def\lit{\fam\itfam\eightit}%		Switch for latin italics
%\def\lsl{\fam\slfam\eightsl}%		Switch for latin slanted
%\def\ltt{\fam\ttfam\eighttt}%		Switch for latin typewriter
%\def\lbf{\fam\bffam\eightbf}%		Switch for latin boldface
%\normalbaselineskip=.35cm%		Normal Base Line distance
%\setbox\strutbox=\hbox{\vrule height7pt width0pt depth2pt}%
%\normalbaselines\gr%
%}
%%
%%			Hyphenation Patterns
%%			^^^^^^^^^^^^^^^^^^^^
\message{hyphenation,}
%
{\language\greek
\lefthyphenmin=2 \righthyphenmin=2 % disallow x- or -x breaks
\def\lt{<}%
\def\gt{>}%
\catcode`\|=11%
\catcode`\<=11%
\catcode`\>=11%
\catcode`\'=11%
\catcode`\~=11%
\catcode`\"=11%
\lccode`\<=`\<%
\lccode`\>=`\>%
\lccode`\'=`\'%
\lccode`\~=`\~%
\lccode`\"=`\"%
\lccode`\|=`\|%
%
\input grkhyphen%
\catcode`\~=13%
}
%
\def\showgreekhyphens#1{{\setbox0\vbox{\parfillskip\z@skip\hsize\maxdimen%
\language\greek\tengr\pretolerance\m@ne\hbadness0\showboxdepth0\ #1}}}
%
%
\message{miscellaneous macros}
%
%		Macros For entering greek mode,
%		and delimiter preferences.
%		-------------------------------
%
%	\begingreek : Begin a group of Greek Text.
%	^^^^^^^^^^^^  Everything is enclosed in a group to keep
%	              changes local. Then we switch to greek hyphenation
%		      and iniciate the greekmode. This assigns the correct
%	              \catcode values to punctuation and accentuation marks.
%	              We then reload the information of the point
%	              size used last and switch to the family needed.
%	              The \t@f@nt and \t@f@m macro is used to ensure that 
%	              or fonts and families are remembered.
%
%	\endgreek :   Ends a group of Greek Text.
%	^^^^^^^^^^    Before ending the group we save information
%	              about the current font, to be used when we re-enter 
%	              greek mode.
%
%	\gr@@km@de :  Switches to greek interpretation of ascii characters
%	^^^^^^^^^^^   Normally changes are kept local but can be used
%	              as a general macro to obtain a global greek mode.
%	              Note the different use of | if this is chosen
%	              to be a delimiter.
%
%\def\begingreek{\bgroup\language\greek\gr@@km@de%
%\t@size\t@f@m\t@f@nt\ignorespaces}
% We add the currentsize info
%\def\endgreek{\xdef\t@f@nt{\the\font}\xdef\t@f@m{\noexpand\fam\the\fam}%
%\xdef\t@size{\@currsize}\egroup}
%
% Create a new LaTeX Environment
%
\newenvironment{greektext}{\language\greek\gr@@km@de%
\t@f@m\t@f@nt\ignorespaces}%
{\xdef\t@f@nt{\the\font}\xdef\t@f@m{\noexpand\fam\the\fam}}

\def\gr@@km@de{%
\ifdelimsbar\else\catcode`\|=11\fi%
\catcode`\<=11% 	Turn Everything to letters!
\catcode`\>=11% 	All accents are done through ligatures
\catcode`\'=11%
\catcode`\`=11%
\catcode`\~=11%
\catcode`\"=11%
\lccode`\<=`\<%
\lccode`\>=`\>%
\lccode`\'=`\'%
\lccode`\~=`\~%
\lccode`\"=`\"%
}
%
\def\l@tinm@de{%
\catcode`\|=12%
\catcode`\<=12% 	Turn Everything to what plain tex has
\catcode`\>=12%
\catcode`\'=12%
\catcode`\`=12%
\catcode`\~=13%
\catcode`\"=12%
\catcode`\$=3%	% Restore the math symbol!
}
%
% Switch Permenantly do greek mode
%
\def\setgreek{\delimsbarfalse\gr@@km@de\language\greek}
%
% and to latin as well
%
\def\setlatin{\l@tinm@de\language0}
%
%	It is very frequent that the user will ask to \end the document
%	before a greek group was closed. In order to prevent this we 
%	redefine the \end command after saving the old one in \@ldend.
%	The new \end checks for un-ended greek groups and if it is found
%	a warning message is issued and the group is automatically closed.
%
%	LaTeX: This is not needed in Latex since the greek environment is
%	defined to be a LaTeX Environment so that Latex takes care of that.
%\let\@ldend=\end
%\gdef\end{\ifnum\language=\greek\endgreek%
%\showstring{GreekTeX Warning: A group of greek text was automatically closed}%
%\fi\@ldend}
%
%	Since it is possible that switching from one language to
%	the other is very frequent, a special way to avoid \begingreek
%	and \endgreek is defined. This is done through the definition of
%	delimiters; available delims are | and $. If \greekdelims{bar}
%	is chosen then a greek block is marked as | ..greek text.. |
%	In order to access |, use \|.
%	If $ is used, use \math for math mode and \math\math for
%	display mode.
%
\gdef\greekdelims#1{\edef\c@mp@re{#1}\def\t@st@a{bar}\def\t@st@b{dollar}%
\ifx\c@mp@re\t@st@a\gr@@kdelimsbar\else%
\ifx\c@mp@re\t@st@b\gr@@kdelimsdol\fi\fi}
%
% 	Bar as delimeter
%
{\catcode`\|=13\gdef\gr@@kdelimsbar{\catcode`\|=13\delimsbartrue%
\def|{\ifnum\language=\greek\end{greektext}\else\begin{greektext}\fi}}
}
%
%	Dollar as delimiter
%
\let\m@thm@de=$
{\catcode`\$=13%
\gdef\gr@@kdelimsdol{\catcode`\$=13%
\def${\ifnum\language=\greek\end{greektext}\else\begin{greektext}\fi}%
\global\let\math=\m@thm@de%
\gdef\display{\math\math}\gdef\enddisplay{\math\math}}%
}

% Here we define some handy LaTeX Use macros
\message{LaTeX greek macros,}
%
%	List Enumeration. For more details see the LaTeX explanations
%
\def\alphgr#1{\@alphgr{\@nameuse{c@#1}}}
\def\Alphgr#1{\@Alphgr{\@nameuse{c@#1}}}

\def\@alphgr#1{\ifcase#1\or a\or b\or g\or d\else\@ialphgr{#1}\fi}
\def\@ialphgr#1{\ifcase#1\or \or \or \or \or e\or st\or z\or h\or j\or i\or
   k\or l\or m\or n\or x\or o\or p\or r\or s\or t\or u\or f\or q\or y\or 
   w\else\@ctrerr\fi}
\def\@Alphgr#1{\ifcase#1\or A\or B\or G\or D\else\@Ialphgr{#1}\fi}
\def\@Ialphgr#1{\ifcase#1\or \or \or \or \or E\or ST\or Z\or H\or J\or I\or
   K\or L\or M\or N\or X\or O\or P\or R\or S\or T\or U\or F\or Q\or Y\or
   W\else\@ctrerr\fi}

\catcode`\@=12 % at signs are no longer letters
%
\def\fmtname{lgreek}\def\fmtversion{LaTeX 2.09 - Greek 3.1} % identifies the current format

\message{version \fmtversion .)}
