%
% $Header: write.tex,v 1.2 86/09/14 00:20:05 sven Exp $
%
% $Log:	write.tex,v $
% Revision 1.2  86/09/14  00:20:05  sven
% Initial revision, LaTeX 2.09
% 
% Revision 1.1  86/01/15  22:36:41  sven
% Initial revision, LaTeX 2.08
% 
%
% Change the macros writing on files such that they use all of the new
% special characters, or '\', '{' and '}' may be printed on the .aux,
% and other, files. The TeX and LaTeX logos also have to be redefined
% for the same reason.

!typeout<Fix macros writing on files and redefine logos.>

!def!LaTeX<<!rm L!kern-.36em!raise.3ex!hbox<!sc a>!kern-.15em
    T!kern-.1667em!lower.7ex!hbox<E>!kern-.125emX>>

!def!TeX<T!kern-.1667em!lower.5ex!hbox<E>!kern-.125emX>

!def!include#1<!clearpage
!if@filesw !immediate!write!@mainaux<!string!@input<#1.aux>>!fi
!@tempswatrue!if@partsw !@tempswafalse!def!@tempb<#1>!@for
!@tempa:=!@partlist!do<!ifx!@tempa!@tempb!@tempswatrue!fi>!fi
!if@tempswa !if@filesw !let!@auxout=!@partaux
!immediate!openout!@partaux #1.aux
!immediate!write!@partaux<!relax>!fi!@input<#1.tex>!clearpage
!@writeckpt<#1>!if@filesw !immediate!closeout!@partaux !fi
!let!@auxout=!@mainaux!else!@nameuse<cp@#1>!fi>

!def!@writeckpt#1<!if@filesw 
!immediate!write!@partaux<!string!global!string!@namedef<cp@#1>!@charlb>% 
<!let!@elt!@wckptelt !cl@@ckpt>!immediate!write!@partaux<!@charrb>!fi>

!def!@wckptelt#1<!immediate!write!@partaux
<!string!setcounter<#1><!the!@nameuse<c@#1>>>>

<!catcode`[=1 !catcode`]=2
!catcode`<=11 !catcode`>=11
!gdef!@charlb[<]
!gdef!@charrb[>]
]% }brace matching

!def!label#1<!@bsphack!if@filesw <!let!thepage!relax
   !xdef!@gtempa<!write!@auxout<!string
      !newlabel<#1><<!@currentlabel><!thepage>>>>>!@gtempa
   !if@nobreak !ifvmode!nobreak!fi!fi!fi!@esphack>

!def!@sect#1#2#3#4#5#6(#7)#8<!ifnum #2!>!c@secnumdepth
     !def!@svsec<>!else 
     !refstepcounter<#1>!edef!@svsec<!csname the#1!endcsname!hskip 1em >!fi
     !@tempskipa #5!relax
      !ifdim !@tempskipa!>!z@ 
        !begingroup #6!relax
          !@hangfrom<!hskip #3!relax!@svsec><!interlinepenalty !@M #8!par>
        !endgroup
       !csname #1mark!endcsname<#7>!addcontentsline
         <toc><#1><!ifnum #2!>!c@secnumdepth !else
                      !protect!numberline<!csname the#1!endcsname>!fi
                    #7>!else
        !def!@svsechd<#6!hskip #3!@svsec #8!csname #1mark!endcsname
                      <#7>!addcontentsline
                           <toc><#1><!ifnum #2!>!c@secnumdepth !else
                             !protect!numberline<!csname the#1!endcsname>!fi
                       #7>>!fi
     !@xsect<#5>>

!def!addcontentsline#1#2#3<!if@filesw !begingroup
!let!label!@gobble !let!index!@gobble
!def!protect##1<!string!string!string##1!string!space
   !space>!@temptokena<!thepage>%
!edef!@tempa<!write !@auxout<!string!@writefile<#1><!protect
     !contentsline<#2><#3><!the!@temptokena>>>>!@tempa
   !if@nobreak !ifvmode!nobreak!fi!fi!endgroup!fi>

!long!def!addtocontents#1#2<!if@filesw !begingroup
!let!label!@gobble !let!index!@gobble
!def!protect##1<!string!string!string##1!string!space!space>%
!edef!@tempa<!write !@auxout <!string!@writefile<#1><#2>>>!@tempa
  !if@nobreak !ifvmode!nobreak!fi!fi!endgroup!fi>

!def!@wrindex#1#2<!let!thepage!relax
   !xdef!@gtempa<!write#1<!string
      !indexentry<#2><!thepage>>>!endgroup!@gtempa
   !if@nobreak !ifvmode!nobreak!fi!fi!@esphack>

!def!@lbibitem(#1)#2<!item(!@biblabel<#1>)!if@filesw 
      < !def!protect##1<!string ##1!space>!immediate
        !write!@auxout<!string!bibcite<#2><#1>>!fi!ignorespaces>>

!def!@bibitem#1<!item!if@filesw !immediate!write!@auxout
       <!string!bibcite<#1><!the!c@enumi>>!fi!ignorespaces>

!def!@citex(#1)#2<!if@filesw!immediate!write!@auxout<!string!citation<#2>>!fi
  !def!@citea<>!@cite<!@for!@citeb:=#2!do
    <!@citea!def!@citea<,>!@ifundefined
       <b@!@citeb><<!bf ?>!@warning
       <Citation `!@citeb' on page !thepage !space undefined>>%
!hbox<!csname b@!@citeb!endcsname>>><#1>>

!def!bibliography#1<!if@filesw!immediate!write!@auxout<!string!bibdata<#1>>!fi
  !@input<!jobname.bbl>>

!def!bibliographystyle#1<!if@filesw!immediate!write!@auxout
    <!string!bibstyle<#1>>!fi>

!long!def!@caption#1(#2)#3<!addcontentsline<!csname
  ext@#1!endcsname><#1><!protect!numberline<!csname 
  the#1!endcsname><!ignorespaces #2>>!par
  !begingroup
    !@parboxrestore
    !normalsize
    !@makecaption<!csname fnum@#1!endcsname><!ignorespaces #3>!par
  !endgroup>

