\documentstyle[a4,12pt]{article}
\begin{document}
\input{psbox}
%\hoffset 0.25in
\setcounter{page}{1}
\begin{flushright}
CERN 93/7081\\
LPTHE Orsay-93/48\\
HUTP-93/A036\\
HD-THEP-93-45\\
December 1993.
\end{flushright}
\newcommand{\be}{\begin{equation}}
\newcommand{\ee}{\end{equation}}
\newcommand{\bea}{\begin{eqnarray}}
\newcommand{\eea}{\end{eqnarray}}
\newcommand{\nn}{\nonumber}
\newcommand{\muh}{\hat\mu}
\newcommand{\dlr}{\stackrel{\leftrightarrow}{D} _\mu}
\newcommand{\vnew}{$V^{\rm{NEW}}$}
\newcommand{\vecp}{$\vec p$}
\newcommand{\dof}{{\rm d.o.f.}}
\newcommand{\prd}{Phys.Rev. \underline}
\newcommand{\pl}{Phys.Lett. \underline}
\newcommand{\prl}{Phys.Rev.Lett. \underline}
\newcommand{\np}{Nucl.Phys. \underline}
\newcommand{\vvp}{v_B\cdot v_D}
\newcommand{\dl}{\stackrel{\leftarrow}{D}}
\newcommand{\dr}{\stackrel{\rightarrow}{D}}
\newcommand{\mev}{{\rm MeV}}
\newcommand{\GeV}{{\rm GeV}}
\newcommand{\calp}{{\cal P}}
\newcommand{\pinc}{\vec p \hskip 0.3em ^{inc}}
\newcommand{\pout}{\vec p \hskip 0.3em ^{out}}
\newcommand{\ptr}{\vec p \hskip 0.3em ^{tr}}
\newcommand{\pbr}{\vec p \hskip 0.3em ^{br}}
\newcommand{\no}{\noindent}

\def\dpl {\delta p_L}
\def\dpr {\delta p_R}
\def\alw {\alpha_W}
\def\dsl#1{\mathchoice
 {\dslaux\displaystyle{#1}}
 {\dslaux\textstyle{#1}}
 {\dslaux\scriptstyle{#1}}
 {\dslaux\scriptscriptstyle{#1}}
}
\def\dslaux#1#2{\setbox0=\hbox{$#1{#2}$}
 \rlap{\hbox to \wd0{\hss$#1/$\hss}}\box0}
\let\eps\epsilon

\def\slash#1{#1\hskip-0.45em /}
\pagestyle{empty}

\centerline{\LARGE{\bf{Standard Model CP-violation and   }}}
\vskip 1 cm
\centerline{\LARGE{\bf{Baryon asymmetry}}}
\vskip 1.5cm
\centerline{\bf{M.B. Gavela,$^1$, P.Hern\'andez$^2$, J. Orloff$^3$,
O.P\`ene$^4$}}
\centerline{$^1$ CERN, TH Division,CH-1211, Geneva 23, Switzerland}
\centerline{$^2$ Lyman lab., Harvard University, Cambridge, MA
02138\footnote{Junior Fellow, Harvard Society of Fellows}}
\centerline{$^3$ Institut f\"ur Theoretische Physik, Univ.
Heidelberg}
\centerline{$^4$ LPTHE, F 91405 Orsay, France,\footnote {Laboratoire
associ\'e au Centre National de la Recherche Scientifique.}}


\date{}
\begin{abstract}
 Simply based on CP arguments, we argue against a Standard Model
explanation of the baryon asymmetry of the universe in the presence
of a
first order phase transition. A CP-asymmetry is
found in
the reflection coefficients of quarks hitting the phase boundary
 created
during the electroweak transition. The problem is analyzed both
in an academic  zero temperature case and in the realistic finite
temperature one. The building blocks are similar in
both cases: Kobayashi-Maskawa CP-violation, CP-even phases
in the reflection coefficients of quarks, and physical transitions
due to fermion self-energies. In both cases an effect is present at
order
$\alpha_W^2$ in rate. A standard GIM behaviour is found  as
intuitively
expected. In the finite temperature case, a crucial role is played
by the damping rate of quasi-particles in a hot plasma, which is
a relevant scale
together with $M_W$ and the temperature. The effect is many orders
of magnitude below what observation requires, and indicates
that non standard physics is indeed needed in the cosmological
scenario.

\end{abstract}
\newpage
\pagestyle{plain}
\section{Introduction}
 The baryon number to entropy ratio in the observed part of the
universe is estimated to be $n_B / s \sim (4-6) 10^{-11}$\cite{exp}
. In 1967, A.D. Sakharov \cite{sak} established the three building
blocks
 required from any candidate theory of baryogenesis: a) Baryon number
violation, b) C and CP violation, c) Departure from
thermal equilibrium.

The Standard Model (SM) contains a)\cite{spha}
and b)\cite{KM}, while
 c) could also be large enough \cite{trans0}\cite{trans},
if a first order
$SU(2) \times U(1)$ phase transition took place in the
evolution of the
universe \cite{trans2}. An explanation within the SM would be a very
economical solution to the baryon
asymmetry puzzle. Unfortunately, intuitive arguments lead to an
asymmetry many orders of magnitude below observation
\cite{Jarlskog}\cite{shapo1}.
However, the study of
quantum effects in the presence of a first order phase transition
is rather delicate, and traditional intuition may fail. The authors
of ref.\cite{shapo} have recently studied this issue in more
detail and claim that, at finite
temperature, the SM  is close to produce enough CP violation as to explain
the observed  $n_B / s$ ratio. In this letter, we summarize our
quantitative
study \cite{nous0}\cite{nousT}
of the Standard Model C and  CP effects in an electroweak
baryogenesis scenario. Even if one assumes an optimal sphaleron rate
and
a strong enough first order phase transition,  we discard this
scenario as an explanation of the observed baryon number to entropy
ratio.


 A first order phase transition  can be  described in terms
of bubbles of ``true" vaccuum (with an inner vaccuum expectation
value of the Higgs field $v \ne 0$) appearing and expanding in the
preexisting ``false"
vaccuum (with $v=0$ throughout).
We can  ``zoom" into the
vicinity of one of the bubbles. There the curvature of its wall  can
be
neglected and the world is divided in two zones: on the left hand
side, say, $v=0$; on the right $v\ne 0$  and
masses appear. The actual bubble  expands from the broken
phase ($v\ne 0$)
towards the unbroken one ($ v =0$). We work in the wall rest
frame in which the
plasma flows in the opposite direction. Consider thus a baryonic
flux hitting  the wall from the unbroken phase. Far enough to the
left  no
significant CP-violating effect is possible as all fermions are
massless. In consequence, the heart of the
problem lies in the reflection and transmission properties of
quarks bumpimg on the bubble wall. CP violation
distinguishes particles from antiparticles and it is $a\,\, priori$
possible to
obtain a CP asymmetry on the reflected baryonic current,
$\Delta_{CP}$. The induced baryon asymmetry is at most
$n_B/s\,\sim\,10^{-2}\,\Delta_{CP}$, in a very optimistic estimation
of the non-CP ingredients \cite{linde2}\cite{shapo}.

The symmetries of the problem have been analyzed in detail
\cite{nous0}
for a generic bubble. The analytical results correspond to the
thin wall
scenario. The latter provides an adequate physical description
for typical
momentum of the incoming particles $\vert \vec p \vert$ smaller
than the inverse
wall thickness $l$, i.e., $\vert \vec p \vert \ll 1/l$. For higher
momenta,
cutoff effects would show up, but it is reasonable to believe
that the thin wall approximation produces an upper bound for the
CP asymmetry.

The precise questions to answer in the above framework are : 1)
the nature
 of the physical process in terms of particles or quasi-particles
responsible
for CP violation, 2) the order in the electroweak coupling
constant, $\alpha_W$,
at which an effect first appears, 3) the dependence on the
quark masses and the nature of the GIM cancellations
involved.

We shall consider the problem in two steps: zero temperature scenario
in the presence of a wall ($T=0$)
 and finite temperature case. Intuition indicates that an existing
CP violating
effect already present at zero temperature will diminish when the
system is
heated because the effective v.e.v. of the Higgs field decreases
and in
consequence the fermion masses do as well (only the Yukawa
couplings already
present at $T=0$ remain unchanged). This intuition
can be misleading only if a new physical effect, absent at $T=0$
and relevant for the problem, appears at finite temperature. We
discuss and compare the building blocks of the analysis in both
cases. The $T=0$ case provides a clean analysis of
the novel aspects of the physics in a world with a two-phase vacuum.
At $T=0$ the quantum
mechanical problem is well defined and the
definition of particles, fields, in and out states, etc. is
transparent.

At finite temperature, a plasma is an incoherent mixture of states.
CP violation, being a typical quantum  phenomenon, can only be
observed if a high degree of strong \underline{and}
 electroweak coherence is present. This is however not the case in
the plasma,
where the scattering of quasiparticles with thermal gluons induces a
large  damping rate.

 The results of our analysis indicate that in the presence of a first
order phase transition, a CP-violating baryon asymmetry in the SM
appears at order $\alpha_W^2$, has a conventional type of GIM
cancellation and chiral limit, and it is well below what observation
requires in order to solve the baryon asymmetry puzzle.

\section{Zero temperature}
\label{sec-zero}
\par
The necessary CP-odd couplings of the Cabibbo-Kobayashi-Maskawa
(CKM) matrix are at work. Kinematic CP-even phases are also present,
equal for
particles and antiparticles, which interfere with the pure CP-odd
couplings to make them observable. These are the reflection
coefficients of a
given particle hitting the wall from the unbroken phase. They are
complex when
the particle energy is smaller than its (broken phase) mass. Finally,
as shown
below, the one
loop self-energy of a particle in the presence of the wall cannot
be completely
renormalized away and results in physical transitions. Such an effect
is
absent for on-shell particles in a world with just one phase. The
difference is easy to understand: the wall acts as an external source
of
momentum in the one-loop process.  The transitions
between any two flavors of the same charge produce a CP
violating baryonic
flow for any given initial chirality.

The essential
 non-perturbative effect is the wall itself. The propagation of any
particle of the SM spectrum should be exactly solved in its presence.
And this we do for a free fermion, leading to a new Feynman
propagator which
replaces and generalizes the usual one. With this exact,
non-perturbative tool, perturbation
theory is then appropiate in the gauge and Yukawa couplings of
fermions to
bosons, and the one loop computations can be performed.
Strictly speaking the
gauge boson and Higgs  propagators in the presence
of the wall are
needed, and it is possible to compute them with a similar
procedure \cite{petits}. In particular this implies to consider
loops with unbroken, broken and mixed contributions.
 For the time being, we work in a simplified
case in which the wall does not act inside
quantum loops. These are computed in the broken phase.
We start from the following unperturbed Hamiltonian for a Dirac
particle in the wall rest frame:
\be H=
\vec \alpha \cdot\vec p +\beta m \theta(z) \label{thin}\ee

The propagator for quarks in the presence
 of the wall contains massless and massive poles:

$$
S(q^f,q^i)=-1/2\bigg\{
\frac{1}{q^f_z-q^i_z+i\epsilon}
 \left(\frac{1}{\dsl q^f}+\frac{1}{\dsl q^i}\right) -
 \frac{1}{q^f_z-q^i_z-i\epsilon}
 \left(\frac{1}{\dsl q^f-m}+\frac{1}{\dsl q^i-m}\right) +
\nn
$$
$$
\frac{1}{\dsl q^f-m}\gamma_z \frac{1}{\dsl q^i}-
 \frac{1}{\dsl q^f}\gamma_z \frac{1}{\dsl q^i-m}-
\nn
$$
\be
\frac{m}{\dsl q^f(\dsl q^f-m)}
 \left[1-\frac{m \gamma_0}{E+p_z'}(1-\alpha_z)\right]
\gamma_0
 \frac{m}{\dsl q^i(\dsl q^i-m)}\bigg\}\label{prop}
\ee
where we have assumed for simplicity zero momentum parallel to
the wall ($q^i_x=q^i_y=q^f_x=q^f_y=0$). Due to the wall the initial
and
final $z$ components of the momentum need not be equal. All
denominators in the usual Feynman propagators in
eq.(\ref{prop}) should be understood as containing a
supplementary $+i\epsilon$ factor. Besides this traditional source
of  phases, the
propagator contains new CP-even ones in $p'_z=\sqrt{E^2-m^2}$,
which becomes imaginary in the case of total reflection ($E<m$
where $E$ is the fermion energy). The tree level reflection
matrix for a massless Dirac fermion hitting the wall from the
unbroken phase is given by
\be
R=\frac{m\gamma_z}{p_z+p_z'},
\label{R}\ee
the Dirac structure of which reflects the opposite chirality of the
incoming and reflected state.


The reflection amplitude should vanish in the chiral limit as some
positive powers of $m_i$ and $m_f$. When the internal loop is
computed just in the unbroken phase,    it should behave as
\be    I_{\mu}(q_\mu), \propto \dsl q
\label{gen}\ee
due to Lorentz  covariance. The insertion of eq (\ref{gen}) on the
quark propagation gives a null result whenever reflection occurs just
once, either before or after the loop insertion, due to the action of
the Dirac operator on a massless fermion. A non-trivial dependence of
the amplitude on both $m_i$ and $m_f$ is needed, and the total effect
should go to zero as some positive power of both masses, with an odd
overall dependence on fermion masses since chirality flips upon
reflection. The argument can be generalized to the situation
where the broken phase is considered inside the loop,
 the difference with eq. (\ref{gen}) being terms
independent of $\dsl q$ but proportional to the external masses,
as will be shown below.

Next, it is possible to argue the type of GIM cancellations for quark
masses inside the loop. Consider the amplitude for reflecting an
initial quark $i$ into a final one $f$. The
relevant terms correspond to the interference of diagrams
with two different internal quark masses
, $M$ and $M'$, to be
summed upon. Each individual diagram
is proportional to\footnote{ This dependence is in general a
complicated function. For transparency, only the behaviour for
$M<M_W$ is described
here. As the internal loop is  convergent
 in $M$, no pure $\log M$ terms can appear.}
\be    A(i\rightarrow f) \propto a + \frac{M^2}{M_W^2}(b + c
\log\frac{M}{M_W}) + \frac{M^4}{M_W^4}(d + e \log\frac{M}{M_W})+.....
\label{g1}\ee

Due to KM unitarity, the CP observable has to be
proportional to an
antisymmetric function of $M$ and $M'$ and must show a different
functional dependence on $M$ and
$M'$: typically
$\sim  \frac{M^2M'^2}{M_W^4}\log(M^2)$.
In practice, as shown below, it will behave as
$\frac{M^2M'^4}{M_W^6}\log M'^2$, i.e. a further mass suppression.
It is important to notice that whenever only the unbroken phase is
considered
inside the electroweak loop, $c=d=e=0$, because the fermionic mass
dependence stems
from pure Yukawa couplings. No antisymmetric function in $M,M'$ is
viable, and the effect should vanish at order $\alpha_W^2$ in total
rate. There is no reason, though, to neglect the
broken phase, and we expect an $O(\alpha_W^2)$ contribution.
The above considerations apply as well for a wall  of thickness $l\ne
0$.

For a thin wall the  non-local character of the  internal loop is
important because
 large particle momenta $\sim M_W$ are present and $l\ll M_W^{-1}$.
Our calculation suggests that an even smaller result (although always
at the same electroweak order) would follow for a more realistic
thick wall, $l\gg M_W^{-1}$, where a local appoximation could be pertinent.

We renormalize by substraction at $q^2=0$. In the region $m_i,m_f,E\ll M_W$,
the flavor changing contribution
\cite{nous0} to the CP asymmetry is\footnote{We did not compute the
flavor diagonal $O(\alpha_W^2)$ contribution. They would be of the
same order.}:
\bea \Delta^{T=0}_{CP}=\sum_{i,f} \sum_{M,M'}[|A(i_R\rightarrow
f_L)|^2-|A(\bar i_L\rightarrow
\bar f_R)|^2]= \left[\alpha_W
\frac{\pi}{16}\right]^2(-c_1c_2c_3s_1^2s_2s_3s_\delta)\nn\\
\sum_{i\ne f}\sum_{l'=l+1}(-2)\sum_{k=j+1}
S_{jk}(M_l,M_{l'})b_{jk}(E,m_i,m_f),
\label{er2}\eea
with $k=j+1$ modulo 4 and $l'=l+1$ modulo 3, and where the function
$S$
 contains the dependence on the quark masses inside the loop
\be S_{jk}(M,M')=I_j(M)I_k(M')-I_j(M')I_k(M).
\label{es}\ee
The integrals $I_{1,2,3,4}$ are defined as
\be
I_n(M)=\delta_n\int_0^1dx\left[\frac{x(1-x)}{x+
\frac{M^2}{M_W^2}(1-x)}\right]^{\gamma_n} x^{\beta_n}\,\nn \\
\label{int}\ee
with $\delta_1=3\delta_3=M^2/M_W^2$,
$\delta_2=3\delta_4/2=2+M^2/M_W^2$, $\beta_n=(0,1,0,1)$ and
$\gamma_n=(1,1,3/2,3/2)$.

   The functions $b_{jk}$ are antisymmetric
 in $j,k$. They  contain
the mass dependence for the incoming and outgoing quarks,
 \bea
b_{12}(E,m_i,m_f)&=&b_{23}(E,m_i,m_f)=-b_{13}(E,m_i,m_f)=0.\nn\\
b_{13}(E,m_i,m_f)&=&-
\left(\frac{m_im_f}{M_W^2}
\right)^2
\frac{m_f^2}{M_W}\frac{|2E+{p'_z}^f-{p'_z}^i|^2}{|E+{p'_z}^f|^2}
Re\bigg(\frac{1}{{
p'_z}^i+{p'_z}^f}\bigg)\nn\\
b_{14}(E,m_i,m_f)&=&+\left(\frac{m_im_f}{M_W^2}\right)^2
\frac{m_f^2}{M_W}\frac{1}{|E+{p'_z}^f|^2}Re\bigg(\frac
{(2E+{p'_z}^f-{p'_z}^i)(E+{
{p'_z}^f}^*-{{p'_z}^i}^*)}{{p'_z}^i+{p'_z}^f}\bigg)\nn\\
b_{24}(E,m_i,m_f)&=&-b_{14}(E,m_i,m_f)\nn\\
b_{34}(E,m_i,m_f)&=&
\left(\frac{m_im_f}{M_W^2}\right)^2
\frac{m_f^2}{M_W^2}\frac{E}{|E+{p'_z}^f|^2}Im\bigg ({p'_z}^f-{p'_z}^i\bigg).
\label{bjk}\eea

Notice that every $b_{jk}$ vanish when either $m_i$ or $m_f$ go to
zero, as we argued they should. All $b_{jk}$ but $b_{12}$ depend on
CP-even phases associated with
the non-locality of the internal loop, as well as on the tree level
CP-even phases in eq.(\ref{R}).
 $b_{12}$ depends only on the latter and could be $\ne 0$ only when
$m_i,m_f$ and $E$ are not neglected in front of $M_W$.
In each sector of quark charges the heavier
masses will
dominate the effect, as expected. Notice that a two-threshold
structure is present, corresponding to $m_i$,$m_f$.

 In the numerical results we use the exact values of the
functions $S_{jk}(M,M')$. It is instructive, though, to show a fit
for the particular case $M,M'\ll M_W$, appropiate for all quarks but
the top:
\be
S_{1,2}(M,M')\rightarrow\frac{M^2M'^2}{M_W
^4}\left[\frac{M^2}{M_W^2}log\frac{M^2}{M_W^2}-\frac{M'^2}{M_W^
2}log\frac{M'^2}{M_W^2}\right]
\label{sap}\ee
and the ratio of the remaining $S_{j,k}(M,M')$ to the result in eq.
(\ref{sap})  is given by $S_{1,3}\rightarrow -\frac{7}{15}$,
$S_{1,4}\rightarrow +1.5$,
$S_{2,3}\rightarrow -\frac{1}{30}$,
$S_{2,4}\rightarrow -\frac{1}{4}$,
 and $S_{3,4}\rightarrow +\frac{1}{6}$, in the same limit.
The total asymmetry, for ``down" type quarks, is dominated by the
$s_R\rightarrow b_L$ contribution, with a maximum value
$5\,10^{-26}$ around the $m_b$ threshold.
For ``up" type quarks,
we get a dominant
$c_R\rightarrow t_L$ contribution of order $\sim \,2.5\,10^{-25}$.
 $\Delta^{T=0}_{CP}$ is therefore many orders of magnitude smaller
than needed for baryon number generation.
Notice that the argument following eq.(\ref{gen}) fails when the wall
itself is considered inside the quantum
loops, as Lorentz covariance is lost, and the external
factor $(\frac{m_i m_f}{m_W^2})^2$ could disappear, enhancing the
effect for certain
flavors, although leaving unchanged the qualitative conclusion.  We
consider the result of the present academic  model as indicative of the
electroweak order at which the effect first shows up, and of the
well-behaved type of GIM cancellations of the
physical process under study, which shows a standard chiral limit.
It also helps to elaborate some non-pertubative tools for the physical
$T\ne 0$ case.



\section{Non zero temperature}
\label{sec-non}


The three building blocks are analogous to the $T=0$ case: CKM
CP violation, CP-even phases in the reflection
coefficients\cite{shapo} and the fact that the fermion self-energy
at finite $T$ results in physical transitions. Let us consider the
differences and new elements.

The argument  developed after eq. (\ref{gen}) fails at finite
temperature  because Lorentz invariance is lost.
A second difference stems from renormalization. At $T=0$ we
renormalize by subtraction at $q^2=0$. The remaining
contribution is thus  proportional to the virtuality, which is of the
order of the fermion masses.
At finite $T$, the additional thermal effects are not
renormalized away, and the virtuality is of  the order of the thermal
masses
 $\sim \,g_s T\,\sim\, 50$GeV. Some powers of the mass that appeared
at $T=0$ may be replaced by powers of $T$.

 At $T=0$, far to the left in the unbroken, massless world, where the existence
of the wall can be neglected, there is
freedom to perform any Cabibbo-like rotation and thus to choose a basis.
 Such a freedom is lost at finite temperature
\cite{shapo} because the spectrum is not degenerate in both phases even far
from the wall.

 A fundamental difference with the $T=0$ case is the damping rate,
$\gamma$, of quasi-particles in a plasma. Due to incoherent thermal
scattering with the medium, their energy and momentum  are not
sharply defined, but spread like a resonance of width $2\gamma$
\cite{bp}.
The quasi-particle has thus a finite life-time, turning eventually
into a new state, out of phase with the initial one. The
QCD damping rate at zero momentum is of
the order $\gamma \sim 0.15 g_s^2 T$ \cite{bp}, i.e. $\sim 19$ GeV at
$T=100$ GeV. Intuitively, a large damping rate would kill the CP
asymmetry, not unlike
what happens, for example, in $D \bar D$ mixing. Although the
imaginary part
 of the QCD self-energy is smaller than its real part, which
settles the overall scale of the quasi-particle ``masses", it is much
larger than the real part of the electroweak self-energy.
It should weaken the effect of electroweak level splitting,
essential to the asymmetry.

 A first step is the computation of the spectrum far from the wall.
The dispersion relations describing it are given by the zeros of the
self-energy,
\be \Sigma(\omega,k)= \omega +\vec \alpha \cdot \vec k + m_i\gamma_0-
Re(\delta\Sigma) - i\,2\gamma
\label{uf}\ee
where $2 i\gamma$ is the imaginary part, approximated here by its
pure QCD component.  The  QCD contribution to $Re(\delta\Sigma)$ is
described in refs.\cite{klimov}-\cite{seibert}. We compute the full
SU(3)$\times$SU(2)$\times$U(1) real part of the thermal self-energy
at the one loop level\footnote{$h(\omega,k)=\omega a(\omega,k) +
b(\omega,k)$ in the notation of ref. \cite{petitg}}.
\be
Re(\delta\Sigma)=-h(\omega,k)- a(\omega,k)\vec \alpha
\cdot \vec k +c(\omega,k)m_i \gamma_0.\label{sigmab}\ee
In the plasma rest frame and the mass basis,
\be a(\omega,k)=f\,A(m_i,0)+
\frac{g^2}{2}[\sum_{l}f_{W,l}\,A(M_l,M_W)+
f_Z\,A(m_i,M_Z)+f_H\,A(m_I,M_H)]\label{aa}\ee
with
\bea &f=[\frac {4}{3}g_s^2+Q_i^2g^2s_W^2](L+R)\quad,\quad
f_{W,l}=[(1+\frac{\lambda_l^2}{2})L+
\frac{\lambda_i\lambda_f}{2}R]K_{li}K^*_{fl}\nn\\
&f_Z=\frac{1}{2}(\frac{4}{c_W^2}(T_i^3-Q_i s^2_W)^2+
\frac{\lambda_i^2}{2})L+(\frac{4}{c_W^2}(-Q_i s^2_W)^2+
\frac{\lambda_i^2}{2})R\quad,\quad
f_H=\frac{\lambda_i^2}{4}(L+R)\nn\\
 &A(M_F,M_B)= \frac{1}{k^2} \int^\infty _0 \frac{dp}{8\pi^2}
([-\frac{(\omega^2+k^2+\Delta)}{2k}
\frac{p}{E_B}L_I^{+}(p)-
\frac{\omega p}{k}L_I^{-}(p)+
\frac{4p^2}{E_B}]n_B(E_B)+\nn\\&\qquad\qquad\qquad
[\frac{\omega^2-k^2-\Delta}{2k}
\frac{p}{E_F}L_{II}^{+}(p)-
\frac{\omega p}{k}L_{II}^{-}(p)+
\frac{4p^2}{E_F}]n_F(E_F))
\label{eqA}\eea
where
\be
L^{\pm}_I(p)= [\log\frac{2kp+2E_B
\omega+\omega^2-k^2+\Delta}{-2kp+2E_B \omega+\omega^2-k^2+\Delta}]
\pm [E_B\rightarrow -E_B]\label{LI}\ee
and $L^{\pm}_{II}(p)$ is obtained from eq. (\ref{LI}) with the
replacements $E_B\rightarrow -E_F$, $\Delta\rightarrow -\Delta$ and a
global minus sign. The remaining variables are
$E_{F,B}=\sqrt{p^2+M_{F,B}^2}$,  $\Delta=M_B^2-M_F^2$ and
$n_{F,B}(E)=(\exp{E/T}\pm 1)^{-1}$.

The function $h(\omega,k)$ differs from the expression for
$a(\omega,k)$, eq. (\ref{aa}), by a global minus sign and the
replacement of the integral $A(M_f,M_B)$, eq. (\ref{eqA}), by
\be
 H(M_F,M_B)=\frac{1}{k}
 \int^\infty_0
\frac{dp}{8\pi^2}([p L_I^{-}(p)+\frac{\omega p}{
E_B}L_I^{+}(p)]n_B(E_B)+p L_{II}^{-}(p)n_F(E_F)).
\label{eqH}\ee
The chirality breaking term $c(\omega,k)$ is given by
\be
c(\omega,k)=2 f\,C(m_i,0)+
\frac{g^2}{2}
\left[\sum_{l}\frac{M_l}{m_i}g_{W,l}\,C(M_l,M_W)+
g_Z\,C(m_i,M_Z)-f_H\,C(m_I,M_H)\right]\label{ac}\ee
with
\bea
g_{W,l}=&\frac{\lambda_M}{2}(\lambda_f L +\lambda_i
R)K_{li}K_{fl}\quad,\quad
g_Z=\frac{1}{2}[-8 Q_i s^2_W (T_3 - Q_i s_W^2) +
\frac{\lambda_i^2}{2}](L+R)\nn\\
&C(M_F,M_B)=\frac{1}{k}
\int^\infty_0
\frac{dp}{8\pi^2}(\frac{p}{ E_B}L_I^{+}(p) n_B(E_B)+\frac{p}{E_F}
L_{II}^{+}(p)n_F(E_F))
\label{more}\eea
In the unbroken world the above expressions apply with all masses
equal to zero.

 The spectrum is well approximated in  the ``linear"
region\footnote{This should be a good approximation for light quarks,
as the CP effects will diminish for higher momenta.}, i.e. for
momentum $k$ such that $k\ll\omega$,
by the effective Lagrangian:
\bea {\cal L}_{eff}=&\Psi_L^\dagger (i \partial_t -  {i}A_L \vec
\partial
\cdot
\vec \sigma -\omega_L)\Psi_L +
\Psi_R^\dagger (i \partial_t + A_R{i} \vec \partial \cdot
\vec \sigma -\omega_R)\Psi_R
\nn\\  &+ i \Psi_L^\dagger \Gamma_L \Psi_L + i \Psi_R^\dagger
\Gamma_R \Psi_R
-  (\Psi_L^\dagger \mu \Psi_R + \Psi_R^\dagger \mu^\dagger
\Psi_L)\theta(z)
 \label{leff}\eea
where $\Psi_L$ and $\Psi_R$ are respectively the left-handed and
right-handed fields for either up or down type quarks. They are
vectors in the
three-dimensional flavour space. $\omega_{L,R}$, $A_{L,R}$, $\mu$ and
$\Gamma_{L,R}$ are non-diagonal matrices in flavor space. We will
neglect their $z$ dependence. ${\cal L}_{eff}$ is not hermitean due
to the
 damping rate.

We solve the spectrum in pure $QCD$ and then perform an expansion in
$\alpha_W$. As the $QCD$ damping rate is much larger than the
electroweak effects, this is a sensible approximation\footnote{For
zero damping rate, the inclusion of the electroweak effects can shift
the poles in a way that might enhance the asymmetry. Not for a large
width. The ``exact" computation, i.e. the numerical results without
performing an expansion in $\alpha_W$, will be presented in
\cite{nousT}.}.
 At zero order in $\alpha_W$, $\Sigma(\omega,k)_{fi}$ is flavor  and
left-right diagonal and $\omega_{L,R}$ at this order are the
solutions of
\be
{\omega^0}^{ii}_{L,R}+h^{ii}_{L,R}({\omega^0}^{ii}_{L,R},0)=0\qquad
i=1\,\,to\,\,3.\label{wbw}\ee
and\footnote{ The notation L,R is kept here for later use in
left-right asymmetric contributions.}
\be
A_{L,R}= \frac{1+a_{L,R}(\omega^0_{L,R},0)}{
 s_{L,R}(\omega^0_{L,R},0)},\qquad
 \mu=\frac{m(1-c(\omega^0_R,0))}{s_{L}^{1/2}
(\omega^0_{L},0)\,s_{R}^{1/2}(\omega^0_{R},0)},\qquad
\Gamma_{L,R}=\frac{2\gamma}{s_{L,R}(\omega^0_{L,R},0)}
\label{alr}\ee
where $a_{L,R}$, $h_{L,R}$ correspond to the coefficients of the
projectors $L,R$ in $a$,$h$, and
\be
s_{L,R}(\omega_{L,R}^0,0)=1+\frac{\partial
h_{L,R}(\omega^0_{L,R},0)}{\partial \omega}.
\label{est}\ee


A numerical estimate for down quarks gives a group velocity
$A_L=A_R=0.339$ and $s_{L,R}(\omega^0_{L,R},0)=1.89$, close to the
values $1/3$ and $2$, respectively, obtained with the unbroken loop
when just the leading $T^2$ terms are considered
\cite{shapo}\footnote{For $u$ and $c$ quarks we obtain
$A_L=A_R=0.346$ and $ h_{L,R}(\omega^0_{L,R},0)=1.88$, while for the
top the results are $0.165$ and $2.5$, respectively.}. As the
numerical difference is of no practical consequence we will use the
latter values in the following arguments, even at non-trivial order
in $\alpha_W$.

 In order to fix the notations,  assume first $\gamma=0$ and thus
${\cal L}_{eff}$ hermitean. Consider quarks with a
positive spin projection along the $z$ axis, or
equivalently a right incoming chirality. The Dirac equation
resulting from eq. (\ref{leff}) is then solved for eigenstates of the
energy which are superpositions of an incoming, a reflected and
a transmitted plane wave.
For an energy $\omega$ (real) the reflection matrix $r(\omega)$
satisfies \cite{shapo}:
\def\plq{\check p_L}
\def\prq{\check p_R}
\be
{\frac{m}{2}}^\dagger+r{\frac{m}{2}}r-\plq r+r \prq=0\label{req}
\ee
where $m$ is the mass matrix of the external quarks and
\be
\plq= -(\omega-\omega_L^0 +\delta p_L ), \qquad \prq= \omega
-\omega_R^0  +\delta p_R.
\label{plq}\ee
$\omega_L^0=\omega_R^0$ contains only the gluon contribution and
$\dpl$, $\dpr$ are of order $\alw$. A CP asymmetry arises from the
interference of the non-diagonal parts of $\dpl$ and $\dpr$. These
have the general structure
\be
\dpr= \alpha_W\,\lambda_i \lambda_f \sum_l K_{li}K^*_{fl}
I_R(M_l^2),\qquad
\dpl= \alpha_W\,\sum_l K_{li}K^*_{fl} I_L(M_l^2)\label{plpr}\ee
where
\be
I_R(M_l^2)=-\pi\,H(M_l,M_W)\frac {1}{s_{L,R}},\qquad
I_L(M_l^2)=\lambda_l^2 I_R(M_l^2).
\label{plr}\ee
We expand the matrix $r$ in powers of $\alw$:
$r=r^0 +r^1 +r^2$, with
\be r^0_{ii}=\frac {m_i}{(\plq^0-\prq^0)-\sqrt{
(\plq^0-\prq^0)^2-m_i^2}}
\label{rexpand}
\ee
and $\plq^0$ and $\prq^0$ are $\plq$ and $\prq$, eq. (\ref{plq}),
computed to order 0 in $\alw$.

Notice that the reflection coefficients (\ref{rexpand}) can become
complex for certain energy ranges, corresponding to total reflection.
These are the siblings of the ones we found at $T=0$, eq.(\ref{R}).



%______________________________________
\begin{figure}
\hbox to \hsize{\hss\psboxto(0.48 \hsize;0pt){alpha2.eps}\hss}
\caption{
The dominant CP asymmetry when mass effects are included
inside thermal loops, as a function of the energy. It corresponds
 to charge 2/3
flavors  and  appears at order $(O(\alpha_W^2))$.}
\protect\label{alphatwo}
\end{figure}
%_______________________________________


Consider now a non vanishing damping rate.
 The quasiparticles that will eventually reach the wall have been
``created" somewhere in the unbroken phase, as a result of their last
scattering on a thermal particle. The creation probability is
computed by imposing that the average density of quasi-particles,
$n_F(E)$, corresponds to the Boltzmann law. The reflection density
near the wall is given by the ratio of the reflected to the incoming
flux at $(z=0,t=0)$:
\begin{equation}
n_r(z=0,t=0)=\int dE_0\int_{-\infty}^0 dz_0 \; dt_0\;
  |\psi_r(0,0;z_0,t_0,E_0)|^2 N(z_0,t_0,E_0),
\end{equation}
which is an incoherent sum of the rate $N(z_0,t_0,E_0)=2\gamma
n_F(E_0)$ of quasiparticle creation at
$(z_0,t_0)$ with average energy $E_0$, times the probability
$|\psi_r|^2$ to find the quasi-particles near (0,0) after they
reflected.
 $|\psi_r|^2$ decays like $e^{-2\gamma |t_0|}$.

  It is adequate to describe the quasi-particles by wave packets with
a small spatial extension $d$ relative to their mean free path $\sim
1/6\gamma$.
Consider gaussian wave packets. One can show \cite{nousT}, using the
analyticity of the functions
$r_{ij}(\omega)$ and via a formal
extension of the $t_0$-integral to $+\infty$, that
\begin{equation}
n_r(0,0)=\int dE_0\, n_F(E_0)\left[\int d\omega {3d\over\sqrt\pi}
  e^{-9d^2(\omega-E_0)^2}\, |r(\omega+ i\gamma)|^2
  -\alpha m^2 (3d)^3 2\gamma \right]
\label{nr}
\end{equation}
for $m\ll \gamma\ll1/3d$. $\alpha$ varies from 0 to
$(\pi-2)/8\pi^{-1/2}$ depending on the
importance of the would-be $t_0>0$ contribution\footnote{
This result is quite independent of the shape and width of the
wall. The only requirement is the analyticity of
$r(\omega)$ in the band $0 <{\rm Im}(\omega)<2\gamma$,
verified for a thin wall, eq. (\ref{rexpand}).}. The last term in eq.
(\ref{nr}) can  be neglected.

In this limit the reflected density is thus a gaussian smear-out of
$|r(\omega+i\gamma)|^2$, with  a maximum value
$|r_{max}|^2=m^2/16\gamma^2$, instead of 1 when $\gamma=0$.
One way to understand the physical origin of this reduction is to
notice that, while the quasi-particles in the plasma are widely
spread in energy and momentum, $d^{-1} \gg 6\gamma \gg m$, reflection
(i.e. CP-even
phases) is only important in a very narrow energy band, $\delta
\omega \sim m$. Hence quasi-particles can hardly be reflected, but
for the top flavor. In other words, it takes the wall a long time ($\sim 1/m$)
to emit the reflected component of a small incoming packet. If the packet
decays rapidly in a time $\sim 1/2\gamma$, it is natural to see the reflected
wave strongly depleted by a factor $\sim m/2\gamma$.
Furthermore, a CP asymmetry involves an interference between flavors
 and in consequence the
relevant energy window is $\delta \omega \sim m_c, m_s$, respectively,
for up and down sectors.
The asymmetry for small wall velocity ($v_{wall}$) is $v_{wall}
\Delta_{CP}$ \cite{shapo}, with
\be \Delta_{CP}= n_r(0,0)-\bar n_r(0,0)\simeq \int d\omega
n_F(\omega)
\Delta(\omega)\label{dcp}\ee
and
\be \Delta(\omega)={\rm
Tr}\left\{r^\dagger(\omega+i\gamma)r(\omega+i\gamma)-
\bar r^\dagger(\omega+i\gamma)\bar r(\omega+i\gamma)\right\}
\label{delta}\ee
where $\bar r$  and $\bar n$ refer to antiquarks.

The resulting asymmetry at order $\alw^2$ is
\be
\Delta(\omega)=\,\alpha_W^2\,(-c_1c_2c_3s_1^2s_2s_3s_\delta)\,4
b_{LR} S_{LR} \frac{ \vert d_0 \vert^2+2 Re(d_0^2)}
{\vert d_0 \vert^4}
\label{resdel}\ee
with $d_0= -2 i\gamma -2 \omega+\omega_R^0 + \omega_L^0$ and
\bea
S_{LR}=&\sum_{l}
I_L(M^2_l)I_R(M^2_{l+1})-I_R(M^2_l)I_L(M^2_{l+1})\nn\\
b_{LR}=&\frac{1}{i}\sum_i \lambda_i\lambda_{i+1} (r^0_{{i+1}{i+1}}
r^{0*}_{ii} -
r^0_{ii} r^{0*}_{{i+1}{i+1}})\label{triangles}\eea
with $l+1$ understood as modulo 3. $S_{LR}$ and $b_{LR}$ are the
finite temperature analogs of the $T=0$ results in eqs. (\ref{es}) to
(\ref{bjk}). In eq.(\ref{resdel}), higher powers of
$m_f^2/(2\gamma)^2$ have been neglected (the numerical results below
are computed without this approximation).

{}From the definitions (\ref{triangles}) it is easy to check that the
GIM mechanism is fully operative. In fact $S_{LR}/2$(respectively $b_{L,R}/2$)
is
the oriented area of a triangle built from the three internal
(external) flavors, with coordinates $I_{L}+iI_{R}(M_l^2)$ ($\lambda_l
r^0_{ll}$) in the complex plane, l=1,2,3. Notice that now the
flavor-diagonal damping rate dominates over the flavor-dependent
CP-even phases in the reflection matrix aligning these
coordinates.

Using the following values for the masses in GeV, $M_W=50$, $M_Z=57$,
$m_d=0.006$, $m_s=0.09$, $m_b=3.1$, $m_u=0.003$, $m_c=1.0$, $m_t=93.7$, the
Yukawa
couplings $\lambda_d=1.2\,10^{-4}$, $\lambda_s=1.8\,10^{-3}$,
$\lambda_b=6.2\,10^{-2}$, $\lambda_u=6.2\,10^{-5}$,
$\lambda_c=2\,10^{-2}$ and  $\lambda_t=1.88$, and $\alpha_s=0.1$,
$\alpha_W=0.035$ we obtain for the integrated asymmetry,
\be
\frac{\Delta^{uct}_{CP}}{T}= 1.6\,\, 10^{-21},\qquad\qquad
\frac{\Delta_{CP}^{dbs}}{T}= -3\,\,10^{-24}. \label{resultu}\ee
In both cases the asymmetry is dominated by the two heavier external
quarks. The induced baryon asymmetry $n_b/s$ cannot exceed $10^{-2}$
times \cite{shapo} these results.

Fig. \ref{alphatwo} shows $\Delta(\omega)$ for up quarks.

In ref. \cite{shapo} Farrar and Shaposhnikov (FS) obtain
$\Delta_{CP}/T\,\stackrel{>}{\sim}\,10\,^{-8}$, and conclude
$n_B/s\,\sim\,10^{-11}$
 (see eq. (10.3) in \cite{shapo}).
Their result is many orders of
magnitude above ours, eq. (\ref{resultu}).
The main origin of the discrepancy is that they have not considered
the effect of the damping rate on the  quasi-particle
spectrum\footnote{ More precisely, they take
into account the finite mean free path of the quasi-particles in the
suppression factor, i.e. what fraction of the $\Delta_{CP}$
is transformed into a baryon asymetry  by the sphalerons, but not in
the computation of $\Delta_{CP}$.}.
A further difference is that they have considered only the unbroken
phase inside the electroweak thermal loops.
 In this approximation a CP asymmetry appears first at order
$\alpha_W^3$, while we get an effect at order
$\alpha_W^2$. The reason has been discussed following eq.(\ref{g1})
for $T=0$. Similarly at $T\ne 0$  one can see from  eqs. (\ref{plpr})
and (\ref{plr}), that when $M_l$=0, the right-handed contribution is
flavor-diagonal (from $\sum_l K_{li}K^*_{fl}=\delta_{fi}$) forcing
$\dpr$ to be diagonal and killing the $\alpha_W^2$ effect.

 For the sake of comparison, we consider their approximation, i.e.,
with just the unbroken phase inside the thermal loops, both with zero
and non zero damping rate, for a thin wall. In the energy region
where the maximum asymmetry was found for $\gamma=0$ \cite{shapo} and
down quarks, the $\alw$ expansion with non zero damping rate leads
to:

\be
\Delta(\omega)=
\left[\sqrt{\frac{3\pi}{2}} \frac {\alpha_W
T}{32\sqrt{\alpha_s}}\right]^3
J\,\frac{(m_t^2-m_c^2)(m_t^2-m_u^2)(m_c^2-m_u^2)}
{M_W^6}\,
\frac{(m_b^2-m_s^2)(m_s^2-m_d^2)(m_b^2-m_d^2)}{(2\gamma)^9}\nn\\
\label{D3}\ee
where  $J=c_1c_2c_3s_1^2s_2s_3s_\delta$.
This result shows the expected GIM cancellation and  regular chiral
behaviour. Its magnitude, $\sim 4\,10^{-22}$, is lower than the
dominant one at order $\alpha_W^2$, shown in Fig. \ref{alphathree}(b).

%______________________________________
\begin{figure}
\hbox to \hsize{
\vbox{\psboxto(0.48\hsize;0pt){gam0.eps}
      \hbox to \drawingwd{\hss(a)\hss}}%
      \hss
\vbox{\psboxto(0.48\hsize;0pt){alpha3.eps}
      \hbox to \drawingwd{\hss(b)\hss}}}
\caption{(a) shows the CP asymmetry produced by
down quarks in the narrow energy range which dominates for zero
damping rate, when masses are neglected in the internal loop.  (b)
shows the dramatic effect of turning on the damping rate effects, in
the same approximation.}
\protect\label{alphathree}
\end{figure}
%_______________________________________

Furthermore, we confirm the validity of their numerical calculation
with zero damping rate, with no $\alpha_W$ expansion involved and  as
can be seen in Fig. \ref{alphathree}(a). The same computation including the
damping rate is also shown in Fig.\ref{alphathree}(b).

 A final comment on the wall thickness $l$ is pertinent. The mean
free path for quasi-particles of lifetime $\sim \frac{1}{2\gamma}$
and group velocity $\sim \frac{1}{3}$ is $\sim \frac
{1}{6\gamma}\sim\frac{1}{120}GeV^{-1}$. The thin wall approximation
is valid only for $l\ll\frac{1}{6\gamma}$, while perturbative
estimates\cite{shapo} give
$l\stackrel{>}{\sim}\frac{1}{10}GeV^{-1}\gg\frac{1}{6\gamma}$. A
realistic $CP$ asymmetry generated in such scenario will be orders of
magnitude below the thin wall estimate in eq.  (\ref{resultu}),
reinforcing thus our conclusions, because a  quasi-particle would
then collide and loose coherence long before feeling a wall effect.
This caveat should also be considered in any non-standard  scenario  of
electroweak baryogenesis, where the wall thickness is larger than the
mean free path.


We acknowledge  Tanguy Altherr, Luis Alvarez-Gaum\'e,
 Alvaro De R\'ujula, Glennys Farrar, Jean Marie Fr\`ere, Jean
Ginibre, Manolo Lozano, Jean-Yves Ollitreault, Anton Rebhan,
Dominique Schiff and Misha Shaposhnikov for many inspiring
discussions. We are specially indebted to Andy Cohen for stimulating
discussions and we thank as well Carlos Quimbay for an excellent
question. We admire the courage of Alvaro in his unsuccessful attempt
to improve our writing.







\begin{thebibliography}{999}
\bibitem{exp} G. Steigman, Ann. Rev. Astron. Astrophys.
\underline{14} (1976) 339.
\bibitem{sak} A.D. Sakharov JETP Lett. \underline{6} (1967) 24.
\bibitem{spha} G. t'Hooft, Phys. Rev. Lett. \underline{37} (1976) 8;
Phys. Rev. D \underline{14} (1976) 3432. N.S. Manton, Phys. Rev. D
\underline{28} (1983) 2019. F.R. Klinkhammer and N.S. Manton, Phys.
Rev. D \underline{30} (1984) 2212.
\bibitem{KM} M. Kobayashi and T. Maskawa, Prog. Theor. Phys.
\underline{49} (1973) 652.
\bibitem{trans0} A.D. Linde, Phys. Lett. \underline{70}B (1977) 306.
\bibitem{trans} V.A. Kuzmin, V.A. Rubakov and M.E. Shaposhnikov,
Phys. Lett. \underline{155}B (1985) 36.
\bibitem{trans2} For a recent review, see A.G. Cohen, D.B. Kaplan and
A.E. Nelson, Ann. Rev. Nucl. Part. Science \underline{43} (1993).
\bibitem{nous0} Standard Model CP-violation and Baryon asymmetry.
Part I: Zero Temperature. M.B. Gavela,  M.Lozano, J.Orloff, and
O.P\`ene, in preparation.
\bibitem{nousT} Standard Model CP-violation and Baryon asymmetry.
Part II
: Finite Temperature.M.B. Gavela, P. Hernandez, J. Orloff, O. P\`ene
and C. Quimbay, in preparation.
\bibitem{Jarlskog} C. Jarlskog Phys. Rev. Lett. \underline{55}
(1985) 1039.
\bibitem{shapo1} M.E.Shaposhnikov, JETP Letters \underline{44} (1986)
445.
\bibitem{shapo} G.R.Farrar and M.E.Shaposhnikov, Phys. Rev. Lett.
\underline{70} (1993) 2833. G.R.Farrar and M.E.Shaposhnikov,
CERN-TH.6732/93.
\bibitem{linde2}M. Dine et al, Phys. Lett. \underline{283}B (1992)
319; Phys. Rev. D \underline{46} (1992) 550.
\bibitem{petits} C. Quimbay and S. Vargas, in preparation.
\bibitem{bp} E. Brateen and R.D. Pisarski, \prd {D46} (1992) 1829 and
references therein.
R. Kobes, G. Kunstatter and K. Mak, Phys. Rev. D \underline{45}
(1992)4632.
\bibitem{klimov}V.V. Klimov, Sov. J. Nucl. Phys. {\underline 33}
(1981) 934.
\bibitem{weldon} H.A. Weldon, \prd {D26} (1982) 2789.
\bibitem{petitg} E. Petitgerard, Z. Phys. C \underline{54} (1992)
673.
\bibitem{seibert}D. Seibert, CERN-TH-7034/93.
\bibitem{se} M.B. Gavela, P. Hernandez and C. Quimbay, in
preparation.
\bibitem{ckn} A. Cohen, D. Kaplan, and A. Nelson \np {B373}
(1992) 453.

\end{thebibliography}

\end{document}
%
%       %%%%%%%    %%%%%        %%%%%%    %%%%%   %     %
%       %      %  %             %     %  %     %   %   %
%       %      %  %             %     %  %     %    % %
%       %%%%%%%    %%%%%        %%%%%%   %     %     %
%       %               %       %     %  %     %    % %
%       %               %       %     %  %     %   %   %
%       %         %%%%%%        %%%%%%    %%%%%   %     %
%
%       By Jean Orloff
%       Comments & suggestions by e-mail: ORLOFF@surya11.cern.ch
%       No modification of this file allowed if not e-sent to me.
%
% WHAT IS IT:
% psbox is a set of machine-independent TeX macros to
% 1) allow (Encapsulated) PostScript figure inclusion in all versions
%    of TeX (Plain, LaTeX) on all machines using a PostScript printer
% 2) facilitate the communication (e-mail, ftp, ...) of all the files
%    (text, macros, figs) needed to reproduce a TeX document by grouping
%    them together into a single, TeXable file.
% For more info, get the file pub/TeX/psbox/PSBOXALL.TEX by anonymous
%     ftp from cs.nyu.edu(=128.122.140.24)
%
% History:
%  1.35: \warnopenout message; \psnewinput, OzTeX & dvitps final fixes
%  1.34: \readfilename=final fix for all filename scans; try \psforptips
%  1.33: corrects \psnewinput for LaTeX (still fails if fname=a{b}c)
%  1.32: corrects \psfordvialw and adds .TEX to PSBOXALL(!)
%  1.31: adds \psfordvialw(?)
%  1.30: adds \splitfile & \joinfiles for multi-file management
%  1.24: fix error handling & add \psonlyboxes
%  1.22: makes \drawingBox \global for use in Phyzzx
%  1.21: accepts %%BoundingBox: (atend)
%  1.20: tries to add \psfordvitps for the TeXPS package.
%  1.10: adds \psforoztex, error handling...
%2345678 1 2345678 2 2345678 3 2345678 4 2345678 5 2345678 6 2345678 7 23456789
%
% Checking version no to avoid multiple loadings
\def\temp{1.35}%
\let\tempp=\relax
\expandafter\ifx\csname psboxversion\endcsname\relax
  \message{PSBOX(\temp)}%
\else
    \ifdim\temp cm>\psboxversion cm
      \message{PSBOX(\temp)}%
    \else
      \message{PSBOX(\psboxversion) is already loaded: I won't load
        PSBOX(\temp)!}%
      \let\temp=\psboxversion
      \let\tempp=\endinput
    \fi
\fi
\tempp
\message{by Jean Orloff: loading ...}
\let\psboxversion=\temp
\catcode`\@=11
% Every macro likes a little privacy...
%
%Trying to tame the variety of \special commands for Postscript: the
%  universal internal command \PSspeci@l##1##2 takes ##1 to be the
%  filename and ##2 to be the integer scale factor*1000 (as for usual
%   TeX \scale commands)
%
\def\psfortextures{%     For TeXtures on the Macintosh
%-----------------
\def\PSspeci@l##1##2{%
\special{illustration ##1\space scaled ##2}%
}}%
\def\psfordvitops{%      For the DVItoPS converter on IBM mainframes
%----------------
\def\PSspeci@l##1##2{%
\special{dvitops: import ##1\space \the\drawingwd \the\drawinght}%
}}%
\def\psfordvips{%      For DVIPS converter on VAX, UNIX and PC's
%--------------
\def\PSspeci@l##1##2{%
%    \special{/@scaleunit 1000 def}% never read dox without trying!
\d@my=0.1bp \d@mx=\drawingwd \divide\d@mx by\d@my% BUG! for large \drawingwd
\special{PSfile=##1\space llx=\psllx\space lly=\pslly\space%
urx=\psurx\space ury=\psury\space rwi=\number\d@mx
}}}%
\def\psforoztex{%        For the OzTeX shareware on the Macintosh
%--------------
\def\PSspeci@l##1##2{%
\special{##1 \space
      ##2 1000 div dup scale
      \number-\psllx\space\space \number-\pslly\space\space translate
}}}%
\def\psfordvitps{%       From the UNIX TeXPS package, vers.>3.12
%---------------
\def\dvitpsLiter@ldim##1{\dimen0=##1\relax
\special{dvitps: Literal "\number\dimen0\space"}}%
\def\PSspeci@l##1##2{%
% psfig.psr contains the def of "startTexFig": if you can locate it
% and put it somewhere in the TEXINPUTS path, this works
\at(0bp;\drawinght){%
\special{dvitps: Include0 "psfig.psr"}% contains def of "startTexFig"
\dvitpsLiter@ldim{\drawingwd}%
\dvitpsLiter@ldim{\drawinght}%
\dvitpsLiter@ldim{\psllx bp}%
\dvitpsLiter@ldim{\pslly bp}%
\dvitpsLiter@ldim{\psurx bp}%
\dvitpsLiter@ldim{\psury bp}%
\special{dvitps: Literal "startTexFig"}%
\special{dvitps: Include1 "##1"}%
\special{dvitps: Literal "endTexFig"}%
}}}%
\def\psfordvialw{%   Try for dvialw, a UNIX public domain
%---------------
\def\PSspeci@l##1##2{
\special{language "PostScript",
position = "bottom left",
literal "  \psllx\space \pslly\space translate
  ##2 1000 div dup scale
  -\psllx\space -\pslly\space translate",
include "##1"}
}}%
\def\psforptips{%   For MS-DOS; LUOMA@brandeis.bitnet
%---------------
\def\PSspeci@l##1##2{{
\d@mx=\psurx bp
\advance \d@mx by -\psllx bp
\divide \d@mx by 1000\multiply\d@mx by \xscale
\incm{\d@mx}
\let\tmpx\dimincm
\d@my=\psury bp
\advance \d@my by -\pslly bp
\divide \d@my by 1000\multiply\d@my by \xscale
\incm{\d@my}
\let\tmpy\dimincm
\d@mx=-\psllx bp
\divide \d@mx by 1000\multiply\d@mx by \xscale
\d@my=-\pslly bp
\divide \d@my by 1000\multiply\d@my by \xscale
\at(\d@mx;\d@my){\special{ps:##1 x=\tmpx cm, y=\tmpy cm}}
}}}%
\def\psonlyboxes{%     Draft-like behaviour if none of the others works
%---------------
\def\PSspeci@l##1##2{%
\at(0cm;0cm){\boxit{\vbox to\drawinght
  {\vss\hbox to\drawingwd{\at(0cm;0cm){\hbox{({\tt##1})}}\hss}}}}
}}%
\def\psloc@lerr#1{%
\let\savedPSspeci@l=\PSspeci@l%
\def\PSspeci@l##1##2{%
\at(0cm;0cm){\boxit{\vbox to\drawinght
  {\vss\hbox to\drawingwd{\at(0cm;0cm){\hbox{({\tt##1}) #1}}\hss}}}}
\let\PSspeci@l=\savedPSspeci@l% restore normal output for other figs!
}}%
%\def\psfor...  add your own!
%
% Some common defs
%
\newread\pst@mpin
\newdimen\drawinght\newdimen\drawingwd
\newdimen\psxoffset\newdimen\psyoffset
\newbox\drawingBox
\newcount\xscale \newcount\yscale \newdimen\pscm\pscm=1cm
\newdimen\d@mx \newdimen\d@my
\newdimen\pswdincr \newdimen\pshtincr
\let\ps@nnotation=\relax
{\catcode`\|=0 |catcode`|\=12 |catcode`|%=12 |catcode`~=12
|catcode`#=12 |catcode`*=14
|xdef|backslashother{\}*
|xdef|percentother{%}*
|xdef|tildeother{~}*
|xdef|sharpother{#}*
}%
% useful to display special chars in \tt; fails for \,#,%
\def\R@moveMeaningHeader#1:->{}%
\def\uncatcode#1{%
\edef#1{\expandafter\R@moveMeaningHeader\meaning#1}}%
%
\def\execute#1{#1}% NOT stupid: cs in #1 are then identified BEFORE execution
\def\psm@keother#1{\catcode`#112\relax}% borrowed from latex
\def\executeinspecs#1{%
\execute{\begingroup\let\do\psm@keother\dospecials\catcode`\^^M=9#1\endgroup}}%
\def\@mpty{}%
% \if\matchin#1#2<=> \iftrue if #1 contains #2, <=>\iffalse otherwise:
% \if\matchexpin: idem, but #1 & #2 are first fully expanded (no \if
% inside!)
% \tmpa & \tmpb contain what's before and after the occurence of #2
\def\matchexpin#1#2{
  \fi%
%\message{(#1>#2)}
  \edef\tmpb{{#2}}%
  \expandafter\makem@tchtmp\tmpb%
  \edef\tmpa{#1}\edef\tmpb{#2}%
  \expandafter\expandafter\expandafter\m@tchtmp\expandafter\tmpa\tmpb\endm@tch%
  \if\match%
}%
\def\matchin#1#2{%
  \fi%
  \makem@tchtmp{#2}%
  \m@tchtmp#1#2\endm@tch%
  \if\match%
}%
\def\makem@tchtmp#1{\def\m@tchtmp##1#1##2\endm@tch{%
  \def\tmpa{##1}\def\tmpb{##2}\let\m@tchtmp=\relax%
  \ifx\tmpb\@mpty\def\match{YN}%
  \else\def\match{YY}\fi%
}}%
% converts any dimen in cm, with 1E-4 cm precision
\def\incm#1{{\psxoffset=1cm\d@my=#1
 \d@mx=\d@my
  \divide\d@mx by \psxoffset
  \xdef\dimincm{\number\d@mx.}
  \advance\d@my by -\number\d@mx cm
  \multiply\d@my by 100
 \d@mx=\d@my
  \divide\d@mx by \psxoffset
  \edef\dimincm{\dimincm\number\d@mx}
  \advance\d@my by -\number\d@mx cm
  \multiply\d@my by 100
 \d@mx=\d@my
  \divide\d@mx by \psxoffset
  \xdef\dimincm{\dimincm\number\d@mx}
}}%
%
%  \ReadPSize{PSfilename} reads the dimensions of a PostScript drawing
%      and stores it in \drawinght(wd)
\newif\ifNotB@undingBox
\newhelp\PShelp{Proceed: you'll have a 5cm square blank box instead of
your graphics.}%
\def\s@tsize#1 #2 #3 #4\@ndsize{
  \def\psllx{#1}\def\pslly{#2}%
  \def\psurx{#3}\def\psury{#4}%  needed by a crazyness of dvips!
  \ifx\psurx\@mpty\NotB@undingBoxtrue% this is not a valid one!
  \else
    \drawinght=#4bp\advance\drawinght by-#2bp
    \drawingwd=#3bp\advance\drawingwd by-#1bp
%  !Units related by crazy factors as bp/pt=72.27/72 should be BANNED!
  \fi
  }%
\def\sc@nBBline#1:#2\@ndBBline{\edef\p@rameter{#1}\edef\v@lue{#2}}%
\def\g@bblefirstblank#1#2:{\ifx#1 \else#1\fi#2}%
{\catcode`\%=12
\xdef\B@undingBox{%%BoundingBox}}%
%% is not a true comment in PostScript, even if % is!
\def\ReadPSize#1{
 \readfilename#1\relax
 \let\PSfilename=\lastreadfilename
 \openin\pst@mpin=#1\relax
 \ifeof\pst@mpin \errhelp=\PShelp
   \errmessage{I haven't found your postscript file (\PSfilename)}%
   \psloc@lerr{was not found}%
   \s@tsize 0 0 142 142\@ndsize
   \closein\pst@mpin
 \else
% each entry in \GlobalInputList should be unique
   \if\matchexpin{\GlobalInputList}{, \lastreadfilename}%
   \else\xdef\GlobalInputList{\GlobalInputList, \lastreadfilename}%
     \immediate\write\psbj@inaux{\lastreadfilename,}%
   \fi%
   \loop
     \executeinspecs{\catcode`\ =10\global\read\pst@mpin to\n@xtline}%
     \ifeof\pst@mpin
       \errhelp=\PShelp
       \errmessage{(\PSfilename) is not an Encapsulated PostScript File:
           I could not find any \B@undingBox: line.}%
       \edef\v@lue{0 0 142 142:}%
       \psloc@lerr{is not an EPSFile}%
       \NotB@undingBoxfalse
     \else
       \expandafter\sc@nBBline\n@xtline:\@ndBBline
       \ifx\p@rameter\B@undingBox\NotB@undingBoxfalse
         \edef\t@mp{%
           \expandafter\g@bblefirstblank\v@lue\space\space\space}%
         \expandafter\s@tsize\t@mp\@ndsize
       \else\NotB@undingBoxtrue
       \fi
     \fi
   \ifNotB@undingBox\repeat
   \closein\pst@mpin
 \fi
\message{#1}%
}%
%
% \psboxto(xdim;ydim){psfilename}: you specify the dimensions and
%    TeX uniformly scales to fit the largest one. If xdim=0pt, the
%    scale is fully determined by ydim and vice versa.
%    Notice: psboxes are a real vboxes; couldn't take hbox otherwise all
%    indentation and all cr's would be interpreted as spaces (hugh!).
%
\def\psboxto(#1;#2)#3{\vbox{%
   \ReadPSize{#3}%
   \advance\pswdincr by \drawingwd
   \advance\pshtincr by \drawinght
   \divide\pswdincr by 1000
   \divide\pshtincr by 1000
   \d@mx=#1
   \ifdim\d@mx=0pt\xscale=1000
         \else \xscale=\d@mx \divide \xscale by \pswdincr\fi
   \d@my=#2
   \ifdim\d@my=0pt\yscale=1000
         \else \yscale=\d@my \divide \yscale by \pshtincr\fi
   \ifnum\yscale=1000
         \else\ifnum\xscale=1000\xscale=\yscale
                    \else\ifnum\yscale<\xscale\xscale=\yscale\fi
              \fi
   \fi
   \divide\drawingwd by1000 \multiply\drawingwd by\xscale
   \divide\drawinght by1000 \multiply\drawinght by\xscale
   \divide\psxoffset by1000 \multiply\psxoffset by\xscale
   \divide\psyoffset by1000 \multiply\psyoffset by\xscale
   \global\divide\pscm by 1000
   \global\multiply\pscm by\xscale
   \multiply\pswdincr by\xscale \multiply\pshtincr by\xscale
   \ifdim\d@mx=0pt\d@mx=\pswdincr\fi
   \ifdim\d@my=0pt\d@my=\pshtincr\fi
   \message{scaled \the\xscale}%
 \hbox to\d@mx{\hss\vbox to\d@my{\vss
   \global\setbox\drawingBox=\hbox to 0pt{\kern\psxoffset\vbox to 0pt{%
      \kern-\psyoffset
      \PSspeci@l{\PSfilename}{\the\xscale}%
      \vss}\hss\ps@nnotation}%
   \global\wd\drawingBox=\the\pswdincr
   \global\ht\drawingBox=\the\pshtincr
   \global\drawingwd=\pswdincr
   \global\drawinght=\pshtincr
   \baselineskip=0pt
   \copy\drawingBox
 \vss}\hss}%
  \global\psxoffset=0pt
  \global\psyoffset=0pt
  \global\pswdincr=0pt
  \global\pshtincr=0pt % These are local to one figure
  \global\pscm=1cm %should not be necessary
}}%
%
% \psboxscaled{scalefactor*1000}{PSfilename} allows to bypass the
%   rounding errors of TeX integer divisions for situations where the
%   TeX box should fit the original BoundingBox with a precision
%   better
%   than 1/1000.
%
\def\psboxscaled#1#2{\vbox{%
  \ReadPSize{#2}%
  \xscale=#1
  \message{scaled \the\xscale}%
  \divide\pswdincr by 1000 \multiply\pswdincr by \xscale
  \divide\pshtincr by 1000 \multiply\pshtincr by \xscale
  \divide\psxoffset by1000 \multiply\psxoffset by\xscale
  \divide\psyoffset by1000 \multiply\psyoffset by\xscale
  \divide\drawingwd by1000 \multiply\drawingwd by\xscale
  \divide\drawinght by1000 \multiply\drawinght by\xscale
  \global\divide\pscm by 1000
  \global\multiply\pscm by\xscale
  \global\setbox\drawingBox=\hbox to 0pt{\kern\psxoffset\vbox to 0pt{%
     \kern-\psyoffset
     \PSspeci@l{\PSfilename}{\the\xscale}%
     \vss}\hss\ps@nnotation}%
  \advance\pswdincr by \drawingwd
  \advance\pshtincr by \drawinght
  \global\wd\drawingBox=\the\pswdincr
  \global\ht\drawingBox=\the\pshtincr
  \global\drawingwd=\pswdincr
  \global\drawinght=\pshtincr
  \baselineskip=0pt
  \copy\drawingBox
  \global\psxoffset=0pt
  \global\psyoffset=0pt
  \global\pswdincr=0pt
  \global\pshtincr=0pt % These are local to one figure
  \global\pscm=1cm
}}%
%
%  \psbox{PSfilename} makes a TeX box having the minimal size to
%      enclose the picture
\def\psbox#1{\psboxscaled{1000}{#1}}%
%------------------------------------------------------
%  \joinfiles file1, file2, ...n \into joinedfilename .
%     makes one file out of many
%  \splitfile joinedfilename
%     the opposite
\newif\ifn@teof\n@teoftrue
\newif\ifc@ntrolline
\newif\ifmatch
\newread\j@insplitin
\newwrite\j@insplitout
\newwrite\psbj@inaux
\immediate\openout\psbj@inaux=psbjoin.aux
\immediate\write\psbj@inaux{\string\joinfiles}%
\immediate\write\psbj@inaux{\jobname,}%
%
% INPUT REDEFINITION
%
% works if #1 is a single character
\def\toother#1{\ifcat\relax#1\else\expandafter%
  \toother@ux\meaning#1\endtoother@ux\fi}%
\def\toother@ux#1 #2#3\endtoother@ux{\def\tmp{#3}%
  \ifx\tmp\@mpty\def\tmp{#2}\let\next=\relax%
  \else\def\next{\toother@ux#2#3\endtoother@ux}\fi%
\next}%
%
% \readfilename defs:
%
\let\readfilenamehook=\relax
\def\re@d{\expandafter\re@daux}% spares typing 10 \expandafter's...
\def\re@daux{\futurelet\nextchar\stopre@dtest}%
\def\re@dnext{\xdef\lastreadfilename{\lastreadfilename\nextchar}%
  \afterassignment\re@d\let\nextchar}%
\def\stopre@d{\egroup\readfilenamehook}%
\def\stopre@dtest{%
  \ifcat\nextchar\relax\let\nextread\stopre@d
  \else
    \ifcat\nextchar\space\def\nextread{%
      \afterassignment\stopre@d\chardef\nextchar=`}%
    \else\let\nextread=\re@dnext
      \toother\nextchar
      \edef\nextchar{\tmp}%
    \fi
  \fi\nextread}%
\def\readfilename{\bgroup%
  \let\\=\backslashother \let\%=\percentother \let\~=\tildeother
  \let\#=\sharpother \xdef\lastreadfilename{}%
  \re@d}%
%
% redefines \input using \readfilename
%
\xdef\GlobalInputList{\jobname}%
\def\psnewinput{%
  \def\readfilenamehook{% each entry in \GlobalInputList should be unique
    \if\matchexpin{\GlobalInputList}{, \lastreadfilename}%
    \else\xdef\GlobalInputList{\GlobalInputList, \lastreadfilename}%
      \immediate\write\psbj@inaux{\lastreadfilename,}%
    \fi%
    \let\readfilenamehook=\relax%
    \ps@ldinput\lastreadfilename\relax%
  }\readfilename%
}%
\expandafter\ifx\csname @@input\endcsname\relax    % then Plain
  \immediate\let\ps@ldinput=\input\def\input{\psnewinput}%
\else
  \immediate\let\ps@ldinput=\@@input
  \def\@@input{\psnewinput}%
\fi%
%
\def\nowarnopenout{%
 \def\warnopenout##1##2{%
   \readfilename##2\relax
   \message{\lastreadfilename}%
   \immediate\openout##1=\lastreadfilename\relax}}%
\def\warnopenout#1#2{%
 \readfilename#2\relax
 \def\t@mp{psbox,psbox.texTrashMe,psbjoin.aux,psbjoint.tex,}%
 \uncatcode\t@mp
 \if\matchexpin{\t@mp}{\lastreadfilename,}%
 \else
   \immediate\openin\pst@mpin=\lastreadfilename\relax
   \ifeof\pst@mpin
     \else
     \edef\tmp{{If the content of this file is precious to you, this
is your last chance to abort (ie press x or e) and rename it before
retexing (\jobname). If you're sure there's no file
(\lastreadfilename) in the directory of (\jobname), then go on: I'm
simply worried because you have another (\lastreadfilename) in some
directory I'm looking in for inputs...}}%
     \errhelp=\tmp
     \errmessage{I may be about to replace your file named \lastreadfilename}%
   \fi
   \immediate\closein\pst@mpin
 \fi
 \message{\lastreadfilename}%
 \immediate\openout#1=\lastreadfilename\relax}%
% % will have an unusual catcode below; use * instead
{\catcode`\%=12\catcode`\*=14
\gdef\splitfile#1{*
 \readfilename#1\relax
 \immediate\openin\j@insplitin=\lastreadfilename\relax
 \ifeof\j@insplitin
   \message{! I couldn't find and split \lastreadfilename!}*
 \else
   \immediate\openout\j@insplitout=TrashMe
   \message{< Splitting \lastreadfilename\space into}*
   \loop
     \ifeof\j@insplitin
       \immediate\closein\j@insplitin\n@teoffalse
     \else
       \n@teoftrue
       \executeinspecs{\global\read\j@insplitin to\spl@tinline\expandafter
         \ch@ckbeginnewfile\spl@tinline%Beginning-Of-File-Named:%\endcheck}*
       \ifc@ntrolline
       \else
         \toks0=\expandafter{\spl@tinline}*
         \immediate\write\j@insplitout{\the\toks0}*
       \fi
     \fi
   \ifn@teof\repeat
   \immediate\closeout\j@insplitout
 \fi\message{>}*
}*
\gdef\ch@ckbeginnewfile#1%Beginning-Of-File-Named:#2%#3\endcheck{*
 \def\t@mp{#1}*
 \ifx\@mpty\t@mp
   \def\t@mp{#3}*
   \ifx\@mpty\t@mp
     \global\c@ntrollinefalse
   \else
     \immediate\closeout\j@insplitout
     \warnopenout\j@insplitout{#2}*
     \global\c@ntrollinetrue
   \fi
 \else
   \global\c@ntrollinefalse
 \fi}*
\gdef\joinfiles#1\into#2{*
 \message{< Joining following files into}*
 \warnopenout\j@insplitout{#2}*
 \message{:}*
 {*
 \edef\w@##1{\immediate\write\j@insplitout{##1}}*
\w@{% This collection of files was produced with CERN psbox package}*
\w@{% To decompose and tex it:}*
\w@{%-save this with a filename CONTAINING ONLY LETTERS and a .TEX}*
\w@{% extension (say, JOINTFIL.TEX), in some uncrowded directory;}*
\w@{%-make sure you can \string\input\space psbox.tex (version>=1.3);}*
\w@{%  (else ftp cs.nyu.edu(=128.122.140.24):pub/TeX/psbox/, then get}*
\w@{%  and tex the file psboxall.tex; more info in psbREAD.ME)}*
\w@{%-tex JOINTFIL.TEX using Plain, or LaTeX, or whatever is needed by}*
\w@{%  the first file in the joining (after splitting JOINTFIL.TEX into}*
\w@{%  it's constituents, TeX will try to process it as it stands).}*
\w@{\string\input\space psbox.tex}*
\w@{\string\splitfile{\string\jobname}}*
\w@{\string\let\string\autojoin=\string\relax}*
}*
 \expandafter\tre@tfilelist#1, \endtre@t
 \immediate\closeout\j@insplitout
 \message{>}*
}*
\gdef\tre@tfilelist#1, #2\endtre@t{*
 \readfilename#1\relax
 \ifx\@mpty\lastreadfilename
 \else
   \immediate\openin\j@insplitin=\lastreadfilename\relax
   \ifeof\j@insplitin
     \errmessage{I couldn't find file \lastreadfilename}*
   \else
     \message{\lastreadfilename}*
     \immediate\write\j@insplitout{%Beginning-Of-File-Named:\lastreadfilename}*
     \executeinspecs{\global\read\j@insplitin to\oldj@ininline}*
     \loop
       \ifeof\j@insplitin\immediate\closein\j@insplitin\n@teoffalse
       \else\n@teoftrue
         \executeinspecs{\global\read\j@insplitin to\j@ininline}*
         \toks0=\expandafter{\oldj@ininline}*
         \let\oldj@ininline=\j@ininline
         \immediate\write\j@insplitout{\the\toks0}*
       \fi
     \ifn@teof
     \repeat
   \immediate\closein\j@insplitin
   \fi
   \tre@tfilelist#2, \endtre@t
 \fi}*
}%
% To be put at the end of a file, for making a tar-like file containing
%   everything it used.
\def\autojoin{%
 \immediate\write\psbj@inaux{\string\into{psbjoint.tex}}%
 \immediate\closeout\psbj@inaux
 \expandafter\joinfiles\GlobalInputList\into{psbjoint.tex}%
}%
%----------------------------------------------------------------
%  Annotations & Captions etc...
%
%
% \centinsert{anybox} is just a centered \midinsert, but is included as
%    people barely use the original inserts from TeX.
%
\def\centinsert#1{\midinsert\line{\hss#1\hss}\endinsert}%
\def\psannotate#1#2{\vbox{%
  \def\ps@nnotation{#2\global\let\ps@nnotation=\relax}#1}}%
\def\pscaption#1#2{\vbox{%
   \setbox\drawingBox=#1
   \copy\drawingBox
   \vskip\baselineskip
   \vbox{\hsize=\wd\drawingBox\setbox0=\hbox{#2}%
     \ifdim\wd0>\hsize
       \noindent\unhbox0\tolerance=5000
    \else\centerline{\box0}%
    \fi
}}}%
% for compatibility with older versions, but \psfig is a bad name!
%\def\psfig#1#2#3{\pscaption{\psannotate{#1}{#2}}{#3}}
%\def\psfigurebox#1#2#3{\pscaption{\psannotate{\psbox{#1}}{#2}}{#3}}
%
% \at(#1;#2)#3 puts #3 at #1-higher and #2-right of the current
%    position without moving it (to be used in annotations).
\def\at(#1;#2)#3{\setbox0=\hbox{#3}\ht0=0pt\dp0=0pt
  \rlap{\kern#1\vbox to0pt{\kern-#2\box0\vss}}}%
%
% \gridfill(ht;wd) makes a 1cm*1cm grid of ht by wd whose lower-left
%   corner is the current point
\newdimen\gridht \newdimen\gridwd
\def\gridfill(#1;#2){%
  \setbox0=\hbox to 1\pscm
  {\vrule height1\pscm width.4pt\leaders\hrule\hfill}%
  \gridht=#1
  \divide\gridht by \ht0
  \multiply\gridht by \ht0
  \gridwd=#2
  \divide\gridwd by \wd0
  \multiply\gridwd by \wd0
  \advance \gridwd by \wd0
  \vbox to \gridht{\leaders\hbox to\gridwd{\leaders\box0\hfill}\vfill}}%
%
% Useful to measure where to put annotations
\def\fillinggrid{\at(0cm;0cm){\vbox{%
  \gridfill(\drawinght;\drawingwd)}}}%
%
% \textleftof\anybox: Sample text\endtext
%   inserts "Sample text" on the left of \anybox ie \vbox, \psbox.
%   \textrightof is the symmetric (not documented, too uggly)
% Welcome any suggestion about clean wraparound macros from
%   TeXhackers reading this
%
\def\textleftof#1:{%
  \setbox1=#1
  \setbox0=\vbox\bgroup
    \advance\hsize by -\wd1 \advance\hsize by -2em}%
\def\textrightof#1:{%
  \setbox0=#1
  \setbox1=\vbox\bgroup
    \advance\hsize by -\wd0 \advance\hsize by -2em}%
\def\endtext{%
  \egroup
  \hbox to \hsize{\valign{\vfil##\vfil\cr%
\box0\cr%
\noalign{\hss}\box1\cr}}}%
%
% \frameit{\thick}{\skip}{\anybox}
%    draws with thickness \thick a box around \anybox, leaving \skip of
%    blank around it. eg \frameit{0.5pt}{1pt}{\hbox{hello}}
% \boxit{\anybox} is a shortcut.
\def\frameit#1#2#3{\hbox{\vrule width#1\vbox{%
  \hrule height#1\vskip#2\hbox{\hskip#2\vbox{#3}\hskip#2}%
        \vskip#2\hrule height#1}\vrule width#1}}%
\def\boxit#1{\frameit{0.4pt}{0pt}{#1}}%
%
%
\catcode`\@=12 % cs containing @ are unreachable
%
% CUSTOMIZE YOUR DEFAULT DRIVER:
%    Uncomment the line corresponding to your TeX system:
%\psfortextures%     For TeXtures on the Macintosh
%\psforoztex   %     For OzTeX shareware on the Macintosh
%\psfordvitops %     For the DVItoPS converter for TeX on IBM mainframes
 \psfordvips   %     For DVIPS converter on VAX and UNIX
%\psfordvitps  %     For dvitps from TeXPS package under UNIX
%\psfordvialw  %     For dvialw, UNIX public domain
%\psonlyboxes  %     Blank Boxes (when all else fails).
%
\splitfile{\jobname}
\let\autojoin=\relax

