%   Basic control strings and macros for tib bibliography formatting,
%   and default definitions.
%
%   tib and the accompaning TeX macros assume the \catcode of plain TeX
%   e.g. { demarks the beginning of a group, % demarks a comment, etc.
%   See D.E. Knuth, The TeXbook, p. 37.
%   So far as possible, definitions have been reduced to primitive TeX
%   strings, to make tib as compatible with any TeX as possible.
%   Two possible exceptions: the fonts \rm, \sl, \sevenrm are assumed
%   to have been loaded by TeX.  If not, this file should be modified below.
%   Also macros for footnotes are tailored to the particular TeX, since
%   the footnote macros of different TeXs differ.  Footnote macro files
%   ending in .p are for plain TeX; those ending in .l are for LaTeX.
%
%   \Resetstrings and \Refformat are called within a local group---
%   the string names will not conflict with uses elsewhere in the document.
%   Other control strings are defined globally.  The following is
%   a complete list of such globally defined control strings (except those
%   the user might define in a private tib formatting file).
%
%      \Resetstrings     \Refformat        \Rpunct           \Lpunct
%      \Lspace           \Lperiod          \Lcomma           \Lquest
%      \Lcolon           \Lscolon          \Lbang            \Lquote
%      \Lqquote          \Lrquote          \Rspace           \Rperiod
%      \Rcomma           \Rquest           \Rcolon           \Rscolon
%      \Rbang            \Rquote           \Rqquote          \Rrquote
%      \Refstd           \Refstda          \Smallcapsaand    \Smallcapseand
%      \Acomma           \Aand             \Aandd            \Ecomma
%      \Eand             \Eandd            \acomma           \aand
%      \aandd            \ecomma           \eand             \eandd
%      \Namecomma        \Nameand          \Nameandd         \Revcomma
%      \Initper          \Initgap          \Citefont         \ACitefont
%      \Authfont         \Titlefont        \Tomefont         \Volfont
%      \Flagfont         \Reffont          \Smallcapsfont    \Underlinemark
%      \Citebrackets     \Citeparen        \Citesuper        \Citenamedate
%      \Lcitemark        \Rcitemark        \LAcitemark       \RAcitemark
%      \LIcitemark       \RIcitemark       \Citehyphen       \Citecomma
%      \Citebreak        \Resetstrings     \ztest            \zstr
%      \Ztest            \Zstr
%      \journalarticleformat      \conferencereportformat    \bookformat
%      \technicalreportformat     \bookarticleformat         \otherformat
%
%   This file is \input first in a document processed by tib.
%   Secondly any tib format files are processed.  Then the input
%   document file is read and processed.  Thus the default definitions
%   of this file can be overridden either in the tib format files
%   or the input document.
%
%   \Refformat calls macros for creating the actual bibliography listings.
%   Such macros are generally kept in tibtex files and \input by a statement
%   in the tib format file.

\def\Resetstrings{%Clears all strings before processing reference listing.
%   The strings (\Astr, etc.) are fields taken from the database.
%   If the string is present, the appropriate test (\Atest, etc) is set
%   equal to \present---thus allowing the macros to test for the presence
%   or absence of a field.  All reference processing is done in a local
%   group--the control string names will not conflict with uses
%   elsewhere in the document.
   \def\present{ }\let\bgroup={\let\egroup=}%primitive TeX
   \def\Astr{}\def\astr{}\def\Atest{}\def\atest{}%
   \def\Bstr{}\def\bstr{}\def\Btest{}\def\btest{}%
   \def\Cstr{}\def\cstr{}\def\Ctest{}\def\ctest{}%
   \def\Dstr{}\def\dstr{}\def\Dtest{}\def\dtest{}%
   \def\Estr{}\def\estr{}\def\Etest{}\def\etest{}%
   \def\Fstr{}\def\fstr{}\def\Ftest{}\def\ftest{}%
   \def\Gstr{}\def\gstr{}\def\Gtest{}\def\gtest{}%
   \def\Hstr{}\def\hstr{}\def\Htest{}\def\htest{}%
   \def\Istr{}\def\istr{}\def\Itest{}\def\itest{}%
   \def\Jstr{}\def\jstr{}\def\Jtest{}\def\jtest{}%
   \def\Kstr{}\def\kstr{}\def\Ktest{}\def\ktest{}%
   \def\Lstr{}\def\lstr{}\def\Ltest{}\def\ltest{}%
   \def\Mstr{}\def\mstr{}\def\Mtest{}\def\mtest{}%
   \def\Nstr{}\def\nstr{}\def\Ntest{}\def\ntest{}%
   \def\Ostr{}\def\ostr{}\def\Otest{}\def\otest{}%
   \def\Pstr{}\def\pstr{}\def\Ptest{}\def\ptest{}%
   \def\Qstr{}\def\qstr{}\def\Qtest{}\def\qtest{}%
   \def\Rstr{}\def\rstr{}\def\Rtest{}\def\rtest{}%
   \def\Sstr{}\def\sstr{}\def\Stest{}\def\stest{}%
   \def\Tstr{}\def\tstr{}\def\Ttest{}\def\ttest{}%
   \def\Ustr{}\def\ustr{}\def\Utest{}\def\utest{}%
   \def\Vstr{}\def\vstr{}\def\Vtest{}\def\vtest{}%
   \def\Wstr{}\def\wstr{}\def\Wtest{}\def\wtest{}%
   \def\Xstr{}\def\xstr{}\def\Xtest{}\def\xtest{}%
   \def\Ystr{}\def\ystr{}\def\Ytest{}\def\ytest{}%
}
\Resetstrings\def\Ztest{}\def\ztest{}

\def\Refformat{%Determines the kind of reference by the presence or
%   absence of certain fields in the database listing, and calls the
%   appropriate macro.
        \if\Jtest\present
            {\if\Vtest\present\journalarticleformat
                 \else\conferencereportformat\fi}
           \else\if\Btest\present\bookarticleformat
              \else\if\Rtest\present\technicalreportformat
                 \else\if\Itest\present\bookformat
                    \else\otherformat\fi\fi\fi\fi}

\def\Rpunct{%Default punctuation control strings if the punctuation
%   is to appear after the citation.  (tib looks for punctuation to
%   precede the incomplete citation in the input document; the TeX
%   output puts it to the left or right depending on the style of citation.)
  \def\Lspace{ }%
  \def\Lperiod{ }%  .
  \def\Lcomma{ }%    ,
  \def\Lquest{ }%     ?
  \def\Lcolon{ }%   :
  \def\Lscolon{ }%   ;
  \def\Lbang{ }%      !
  \def\Lquote{ }%   '
  \def\Lqquote{ }%   "
  \def\Lrquote{ }%    `
  \def\Rspace{}%
  \def\Rperiod{.}%  .
  \def\Rcomma{,}%    ,
  \def\Rquest{?}%     ?
  \def\Rcolon{:}%   :
  \def\Rscolon{;}%   ;
  \def\Rbang{!}%      !
  \def\Rquote{'}%   '
  \def\Rqquote{"}%   "
  \def\Rrquote{`}%    `
  }

\def\Lpunct{%Default punctuation control strings if the punctuation
%   is to appear before the citation.  (tib looks for punctuation to
%   precede the incomplete citation in the input document; the TeX
%   output puts it to the left or right depending on the style of citation.)
  \def\Lspace{}%
  \def\Lperiod{\unskip.}%  .
  \def\Lcomma{\unskip,}%    ,
  \def\Lquest{\unskip?}%     ?
  \def\Lcolon{\unskip:}%   :
  \def\Lscolon{\unskip;}%   ;
  \def\Lbang{\unskip!}%      !
  \def\Lquote{\unskip'}%   '
  \def\Lqquote{\unskip"}%   "
  \def\Lrquote{\unskip`}%    `
  \def\Rspace{\spacefactor=1000}%
  \def\Rperiod{\spacefactor=3000}%  .
  \def\Rcomma{\spacefactor=1250}%    ,
  \def\Rquest{\spacefactor=3000}%     ?
  \def\Rcolon{\spacefactor=2000}%   :
  \def\Rscolon{\spacefactor=1250}%   ;
  \def\Rbang{\spacefactor=3000}%      !
  \def\Rquote{\spacefactor=1000}%   '
  \def\Rqquote{\spacefactor=1000}%   "
  \def\Rrquote{\spacefactor=1000}%    `
  }

\def\Refstd{%Standard control strings for formatting bibliography listings.
    \def\Acomma{\unskip, }%between multiple author names
    \def\Aand{\unskip\ and }%between two author names
    \def\Aandd{\unskip\ and }%between last two of multiple author names
    \def\Ecomma{\unskip, }%between multiple editor names
    \def\Eand{\unskip\ and }%between two editor names
    \def\Eandd{\unskip\ and }%between last two of multiple author names
    \def\acomma{\unskip, }%same for authors of reviewed material
    \def\aand{\unskip\ and }%same for authors of reviewed material
    \def\aandd{\unskip\ and }%same for authors of reviewed material
    \def\ecomma{\unskip, }%same for translators
    \def\eand{\unskip\ and }%same for translators
    \def\eandd{\unskip\ and }%same for translators
    \def\Namecomma{\unskip, }%same for citations using authors' names
    \def\Nameand{\unskip\ and }%same for citations using authors' names
    \def\Nameandd{\unskip\ and }%same for citations using authors' names
    \def\Revcomma{\unskip, }%between last and first name of reversed name
    \def\Initper{.\ }%punctuation after initial
    \def\Initgap{\dimen0=\spaceskip\divide\dimen0 by 2\hskip-\dimen0}%
                          %gap between initials of abbreviated first name
  }

\def\Smallcapsaand{%Smallcaps redefinition of \Aand and \Aandd for \Refstd
    \def\Aand{\unskip\bgroup{\Smallcapsfont\ AND }\egroup}%
    \def\Aandd{\unskip\bgroup{\Smallcapsfont\ AND }\egroup}%
    \def\eand{\unskip\bgroup\Smallcapsfont\ AND \egroup}%
    \def\eandd{\unskip\bgroup\Smallcapsfont\ AND \egroup}%
  }

\def\Smallcapseand{%Smallcaps redefinition of \Eand, \Eeand, etc for Refstd
    \def\Eand{\unskip\bgroup\Smallcapsfont\ AND \egroup}%
    \def\Eandd{\unskip\bgroup\Smallcapsfont\ AND \egroup}%
    \def\aand{\unskip\bgroup\Smallcapsfont\ AND \egroup}%
    \def\aandd{\unskip\bgroup\Smallcapsfont\ AND \egroup}%
  }

\def\Refstda{%Standard control strings for formatting bibliography listings.
%                         \Refstda sets an Ampersand instead of the word "and".
   \chardef\Ampersand=`\&%primitive TeX
   \def\Acomma{\unskip, }%between multiple author names
   \def\Aand{\unskip\ \Ampersand\ }%between two author names
   \def\Aandd{\unskip\ \Ampersand\ }%between last two of multiple author names
   \def\Ecomma{\unskip, }%between multiple editor names
   \def\Eand{\unskip\ \Ampersand\ }%between two editor names
   \def\Eandd{\unskip\ \Ampersand\ }%between last two of multiple author names
   \def\acomma{\unskip, }%same for authors of reviewed material
   \def\aand{\unskip\ \Ampersand\ }%same for authors of reviewed material
   \def\aandd{\unskip\ \Ampersand\ }%same for authors of reviewed material
   \def\ecomma{\unskip, }%same for translators
   \def\eand{\unskip\ \Ampersand\ }%same for translators
   \def\eandd{\unskip\ \Ampersand\ }%same for translators
   \def\Namecomma{\unskip, }%same for citations using authors' names
   \def\Nameand{\unskip\ \Ampersand\ }%same for citations using authors' names
  \def\Nameandd{\unskip\ \Ampersand\ }%same for citations using authors' names
   \def\Revcomma{\unskip, }%between last and first name of reversed name
   \def\Initper{.\ }%punctuation after initial
   \def\Initgap{\dimen0=\spaceskip\divide\dimen0 by 2\hskip-\dimen0}%
                          %gap between initials of abbreviated first name
 }

%default fonts
  \def\Citefont{}%citations
  \def\ACitefont{}%alternate citations
  \def\Authfont{}%authors
  \def\Titlefont{}%titles
  \def\Tomefont{\sl}%journals or books
  \def\Volfont{}%volume number of journal
  \def\Flagfont{}%citation flag
  \def\Reffont{\rm}%set at beginning of reference listing
  \def\Smallcapsfont{\sevenrm}%small caps
  \def\Flagstyle#1{\hangindent\parindent\indent\hbox to0pt%flag style
      {\hss[{\Flagfont#1}]\kern.5em}\ignorespaces}%        for references

\def\Underlinemark{\vrule height .7pt depth 0pt width 3pc}%for replacing
%   successive listings of identical author(s) by underline (U option
%      in tib format file or -u flag on call).

\def\Citebrackets{\Rpunct%defaults for putting citations in brackets [].
  \def\Lcitemark{\def\Cfont{\Citefont}[\bgroup\Cfont}%mark at left of citation
  \def\Rcitemark{\egroup]}%mark at right of citation
  \def\LAcitemark{\def\Cfont{\ACitefont}\bgroup\ACitefont}%
                        %mark at left of alternate citation
  \def\RAcitemark{\egroup}%mark at right of alternate citation
  \def\LIcitemark{\egroup}%mark at left of insertion in citation
  \def\RIcitemark{\bgroup\Cfont}%mark at right of insertion in citation
  \def\Citehyphen{\egroup--\bgroup\Cfont}%separater for string of citations
  \def\Citecomma{\egroup,\hskip0pt\bgroup\Cfont}%
                                         %separater for multiple citations
  \def\Citebreak{}%mark between parts of citation (e.g. author\Citebreak date)
  }

\def\Citeparen{\Rpunct%defaults for putting citations in parenthesis ().
  \def\Lcitemark{\def\Cfont{\Citefont}(\bgroup\Cfont}%mark at left of citation
  \def\Rcitemark{\egroup)}%mark at right of citation
  \def\LAcitemark{\def\Cfont{\ACitefont}\bgroup\ACitefont}%
                        %mark at left of alternate citation
  \def\RAcitemark{\egroup}%mark at right of alternate citation
  \def\LIcitemark{\egroup}%mark at left of insertion in citation
  \def\RIcitemark{\bgroup\Cfont}%mark at right of insertion in citation
  \def\Citehyphen{\egroup--\bgroup\Cfont}%separater for string of citations
  \def\Citecomma{\egroup,\hskip0pt\bgroup\Cfont}%
                                         %separater for multiple citations
  \def\Citebreak{}%mark between parts of citation (e.g. author\Citebreak date)
  }

\def\Citesuper{\Lpunct%defaults for making superscript citations
  \def\Lcitemark{\def\Cfont{\Citefont}\raise1ex\hbox\bgroup\bgroup\Cfont}%
                        %mark at left of citation
  \def\Rcitemark{\egroup\egroup}%mark at right of citation
  \def\LAcitemark{\def\Cfont{\ACitefont}\bgroup\ACitefont}%
                        %mark at left of alternate citation
  \def\RAcitemark{\egroup}%mark at right of alternate citation
  \def\LIcitemark{\egroup\egroup}%mark at left of insertion in citation
  \def\RIcitemark{\raise1ex\hbox\bgroup\bgroup\Cfont}%
                        %mark at right of insertion in citation
  \def\Citehyphen{\egroup--\bgroup\Cfont}%separater for string of citations
  \def\Citecomma{\egroup,\hskip0pt\bgroup%
     \Cfont}%separater for multiple citations
  \def\Citebreak{}%mark between parts of citation (e.g. author\Citebreak date)
  }

\def\Citenamedate{\Rpunct%defaults for making name-date citations
  \def\Lcitemark{%mark at left of citation--also sets internal punctuation
     \def\Citebreak{\egroup\ [\bgroup\Citefont}%separater in citation
     \def\Citecomma{\egroup]; %between multiple citations
        \bgroup\let\uchyph=1\Citefont}(\bgroup\let\uchyph=1\Citefont}%
  \def\Rcitemark{\egroup])}%mark at right of citation
  \def\LAcitemark{%mark at left of alternate citation
     \def\Citebreak{\egroup\ [\bgroup\Citefont}\def\Citecomma{\egroup], %
        \bgroup\ACitefont }\bgroup\let\uchyph=1\ACitefont}%
  \def\RAcitemark{\egroup]}%mark at right of alternate citation
 \def\Citehyphen{\egroup--\bgroup\Citefont}%separater for string of citations
  \def\LIcitemark{\egroup}%mark at left of insertion in citation
  \def\RIcitemark{\bgroup\Citefont}%mark at right of insertion in citation
  }