\documentclass[a4paper]{article}
% \usepackage{times}
\usepackage[warning,math]{easyeqn}
\usepackage[definevectors]{easyvector}
\usepackage{easytitle}

\let\package\texttt % so \package{foo} comes out in \tt
\let\envname\textsf % so \envname{foo} comes out as \sf

\newbox\tempbox

\def\BOX{\setbox\tempbox\hbox\bgroup\begin{minipage}{0.9\textwidth}}
\def\endBOX{\end{minipage}\egroup\par\bigskip%
\begin{center}\fboxsep=10pt\fbox{\box\tempbox}\end{center}\bigskip\par}

\title{The package \package{easyeqn}}
\author[E. Bertolazzi]{Enrico Bertolazzi}
\address{
  Laboratorio di Matematica Applicata e Meccanica Computazionale\\
  Dipartimento di Ingegneria Meccanica e Strutturale\\
  Universit\`a degli Studi di Trento\\
  Mesiano, Trento, Italy}

\mailto{enrico.bertolazzi@ing.unitn.it}

\begin{document}
\maketitle
\begin{abstract}
The package \package{easyeqn} introduces some equation
environments that simplify writing of equations.
It uses a syntax similar to the array environment to define
the column alignment. The label field is fully customizable.
A package option permits to number only those
equations that were \emph{labeled and referenced}.
Some additional macros are also included to facilitate typing of 
formulae. The option ``showkeys'' modifies the \verb+\eqlabel+,
\verb+\eqref+ and \verb+\refeq+ commands so that the `internal'
key is printed.
\end{abstract}

\tableofcontents
\vfill

\section{Some examples with \package{easyeqn}}
Load the package using the usual syntax:
\begin{BOX}
\begin{verbatim}
   \documentclass{article}
   .
   .
   \usepackage[allnumber,warning,fleqn,leqno,
               math,showkeys]{easyeqn}
   .
   .
\end{verbatim}
\end{BOX}
The package introduces the 
\envname{EQ}, \envname{EQS}~and \envname{EQA}~environments.
The package options are:
\begin{description}
\item[allnumber] Means that all of the
\envname{EQ}, \envname{EQS}~and \envname{EQA}~environments are numbered.
Without that option, only those \envname{EQ}, \envname{EQS}~and 
\envname{EQA}~environment that are \emph{labeled} and \emph{referenced}
are numbered.
\item[warning]  Causes equations that are labeled but
                \emph{not referenced} to be flagged.
\item[fleqn]    Flushes equation on the left margin.
\item[leqno]    Writes equation number on the left.
\item[math]     Define additional macros for mathematics.
\item[showkeys] Modifies the \verb+\eqlabel+, \verb+\eqref+ and
                \verb+\refeq+ commands so that the `internal'
                key is printed.
\end{description}
 


\section{Use of the \envname{EQ} environment}
The following input:
\begin{BOX}
\begin{verbatim}
\begin{EQ}\eqlabel{eq:1}
    \frac{x}{y} = z
\end{EQ}
\begin{EQ}\eqlabel{eq:2}
    \frac{x}{y} = z
\end{EQ}
I will refer only to \eqref{eq:1} or,
in the old style, \refeq{eq:1}.
\end{verbatim}
\end{BOX}
produces the following output:
\begin{BOX}
\begin{EQ}\eqlabel{eq:1}
    \frac{x}{y} = z
\end{EQ}
\begin{EQ}\eqlabel{eq:2}
    \frac{x}{y} = z
\end{EQ}
I will refer only to \eqref{eq:1} or,
in the old style, \refeq{eq:1}.
\end{BOX}
Note that the command \verb+\eqlabel+ is used instead of 
\verb+\label+ and the reference is done by \verb+\eqref+ 
or \verb+\refeq+. The command \verb+\refeq+ produces the same output
as \verb+\ref+, while \verb+\eqref+ uses \texttt{( )} for the output.

\textbf{Remark:} Due to the algorithm, in order to obtain the right
cross reference, you need to recompile the file 3~times.
The use \verb+\label+ is not permitted inside \envname{EQx} 
environments and if you use \verb+\ref+ for referencing
equations the results are unpredictable.

\section{Use of \envname{EQS} environment}
The following commands:
\begin{BOX}
\begin{verbatim}
\begin{EQS}[rcll]
   \nabla\cdot(\rho\nabla u)&=&f \qquad
      &\mbox{on $\Omega$} \\
   u&=&u_{0}&\mbox{on $A\subset\partial\Omega$} \\
   (\rho\nabla u)\cdot n&=&u_{1}
      &\mbox{on $B\subset\partial\Omega$}
\end{EQS}
\end{verbatim}
\end{BOX}
produces
\begin{BOX}
\begin{EQS}[rcll]
   \nabla\cdot(\rho\nabla u)&=&f \qquad
      &\mbox{on $\Omega$} \\
   u&=&u_{0}&\mbox{on $A\subset\partial\Omega$} \\
   (\rho\nabla u)\cdot n&=&u_{1}
      &\mbox{on $B\subset\partial\Omega$}
\end{EQS}
\end{BOX}
Note that between \verb+[...]+ you can specify the column alignment
in the same way as in the \envname{array} or \envname{tabular} environment.
The permitted alignment are \verb+l+ for left alignment,
\verb+r+ for right alignment and \verb+c+ for centering. There is also
the character ``\verb+.+'' that used between definition of two columns
disable the spacing between columns as in the following example taken 
from the documentation of \package{eqnarray} of Roland Winkler;


\begin{BOX}
\begin{verbatim}
\begin{EQS}[rcl.l]
    \phi & = & \sum \bigg( & \frac{xxxxxxxxxx}{\phi} \\
        & & & + \frac{yyyyyyyyyy}{\phi} \bigg) \\
        & = & \eqmulticol{2}{l}{\frac{zzzzzzzzzz}{\phi}}
\end{EQS}
\end{verbatim}
\begin{EQS}[rcl.l]
    \phi & = & \sum \bigg( & \frac{xxxxxxxxxx}{\phi} \\
        & & & + \frac{yyyyyyyyyy}{\phi} \bigg) \\
        & = & \eqmulticol{2}{l}{\frac{zzzzzzzzzz}{\phi}}
\end{EQS}
\end{BOX}

in this example we have used also the command \verb+\eqmulticol+ the 
sintax is the following
\begin{verbatim}
   \eqmulticol{ncol}{align}{body}
\end{verbatim}
where
\begin{description}
   \item[ncol] is the number of column to fuse.
   \item[aling] is the alignment, it can be \verb+l+,  \verb+r+,  \verb+c+.
   \item[body] is the thing to put across the column.
\end{description}

\section{The \texttt{\char`\\yesnumber} command}
If you want to number an equation without reference it, use the \verb+\yesnumber+
command as this example shows:
\begin{BOX}
\begin{verbatim}
\begin{EQS}[rcl]\yesnumber
     a & = & \frac{1}{23} \\
     b & = & \sqrt{\frac{1}{23}}
\end{EQS}
\end{verbatim}
\end{BOX}
produces
\begin{BOX}
\begin{EQS}[rcl]\yesnumber
     a & = & \frac{1}{23} \\
     b & = & \sqrt{\frac{1}{23}}
\end{EQS}
\end{BOX}



\section{Use of \envname{EQA} environment}
The following commands: 
\begin{BOX}
\begin{verbatim}
\begin{EQA}[rcll]
   \nabla\!\cdot\!(\rho\nabla u)&=&f \qquad
      &\mbox{on $\Omega$} 
   \yesnumber \\
   u&=&u_{0}&\mbox{on $A\subset\partial\Omega$}
          \eqlabel{eq:3} \\
   (\rho\nabla u)\!\cdot\!n&=&u_{1}
       &\mbox{on $B\subset\partial\Omega$}
          \eqlabel{eq:4}
\end{EQA}
it is referenced only \eqref{eq:4}!!
\end{verbatim}
\end{BOX}
produce
\begin{BOX}
\begin{EQA}[rcll]
   \nabla\!\cdot\!(\rho\nabla u)&=&f \qquad
      &\mbox{on $\Omega$} 
   \yesnumber \\
   u&=&u_{0}&\mbox{on $A\subset\partial\Omega$}
          \eqlabel{eq:3} \\
   (\rho\nabla u)\!\cdot\!n&=&u_{1}
       &\mbox{on $B\subset\partial\Omega$}
          \eqlabel{eq:4}
\end{EQA}
it is referenced only \eqref{eq:4}!!
\end{BOX}
Note that only the referenced lines or the lines with 
\verb+\yesnumber+ are numbered.







\section{The \texttt{\char`\\eqlabel} command}
It is possible to use custom label by \verb+\eqlabel+ command. 
The syntax is the following
\begin{verbatim}
     \eqlabel`[*]'{labelname}
     or
     \eqlabel`(*)'{labelname}
\end{verbatim}
where \verb+`[*]'+ is an optional argument.
If  \verb+`[*]'+ is defined, equation 
displays \verb+`*'+ instead of \verb+`("equation number")'+.
The equation counter is not advanced and 
\verb+`labelname'+ will refer to \verb+`*'+. If we use
\verb+`[*]'+ the result is similar but the equation number is 
substituted by \verb+`(*)'+ instead of \verb+`*'+.
Look at this example:
\begin{BOX}
\begin{verbatim}
\begin{EQA}[c]
   \nabla\cdot(\rho\nabla u) = 0
       \eqlabel(eq.1){eq:custom:a} \\
   \nabla\cdot(\rho\nabla u) = 0
       \eqlabel[eq.2]{eq:custom:b} \\
   \nabla\cdot(\rho\nabla u) = 0
       \eqlabel[(((1)))]{eq:custom:c}
\end{EQA}
I will refer to \eqref{eq:custom:a} and \eqref{eq:custom:b}
\end{verbatim}
\end{BOX}
produces
\begin{BOX}
\begin{EQA}[c]
   \nabla\cdot(\rho\nabla u) = 0
       \eqlabel(eq.1){eq:custom:a} \\
   \nabla\cdot(\rho\nabla u) = 0
       \eqlabel[eq.2]{eq:custom:b} \\
   \nabla\cdot(\rho\nabla u) = 0
       \eqlabel[(((1)))]{eq:custom:c}
\end{EQA}
I will refer to \eqref{eq:custom:a} and \eqref{eq:custom:b}
\end{BOX}
Notice that custom label are always displayed also if not referenced.



\section{Sub-numbering}
To sub-number equation instead of use something like
\begin{verbatim}
    \begin{subequations}
    \begin{EQS}...
    
    \end{EQS}
    \end{subequations}
\end{verbatim}
I prefer to use \verb+\eqlabel+ command with the character \verb+~+
as a shortcut for \verb+\theequation+. The following exmaple shows 
the use

\begin{BOX}
\begin{verbatim}
\begin{EQA}[c]\yesnumber
   \nabla\cdot(\rho\nabla u) = 0 \eqlabel(~.A){eq:sub:a} \\
   \nabla\cdot(\rho\nabla u) = 0 \eqlabel(~.B){eq:sub:b} \\
   \nabla\cdot(\rho\nabla u) = 0 \eqlabel(~.C){eq:sub:c}
\end{EQA}
\end{verbatim}
\begin{EQA}[c]\yesnumber
   \nabla\cdot(\rho\nabla u) = 0 \eqlabel(~.A){eq:sub:a} \\
   \nabla\cdot(\rho\nabla u) = 0 \eqlabel(~.B){eq:sub:b} \\
   \nabla\cdot(\rho\nabla u) = 0 \eqlabel(~.C){eq:sub:c}
\end{EQA}
\end{BOX}
the \verb+\yesnumber+ command is necessary to enforce advancing of 
equation counter.


\section{Use of \envname{fleqn} and \envname{leqno} option}
You can use \envname{fleqn} to flux left the equations or
\envname{leqno} to number equations on the left.
If for example we have used
\begin{BOX}
\begin{verbatim}
   \documentclass{article}
   .
   .
   \usepackage[fleqn,leqno]{easyeqn}
   .
   .
\end{verbatim}
\end{BOX}
the effect with this example:
\begin{BOX}
\begin{verbatim}
\begin{EQA}[rcll]
   \nabla\cdot(\rho\nabla u)&=&f \qquad
      &\mbox{on $\Omega$}\yesnumber \\
   u&=&u_{0}&\mbox{on $A\subset\partial\Omega$}
      \yesnumber\\
   (\rho\nabla u)\!\cdot\!n&=&u_{1}
      &\mbox{on $B\subset\partial\Omega$}
        \eqlabel{eq:5} 
\end{EQA}
it is referenced only \eqref{eq:5}!!
\end{verbatim}
\end{BOX}
is the following
\begin{BOX}
\equationleft\numberleft
\begin{EQA}[rcll]
   \nabla\cdot(\rho\nabla u)&=&f \qquad
      &\mbox{on $\Omega$}\yesnumber \\
   u&=&u_{0}&\mbox{on $A\subset\partial\Omega$}
      \yesnumber\\
   (\rho\nabla u)\!\cdot\!n&=&u_{1}
      &\mbox{on $B\subset\partial\Omega$}
        \eqlabel{eq:5} 
\end{EQA}
it is referenced only \eqref{eq:5}!!
\equationcenter\numberright
\end{BOX}
\sloppy
The same effect can be obtained everywhere using the commands
\verb+\equationleft+ and \verb+\numberleft+ before defining
the equation. To restore the default use
\verb+\equationcenter+ and \verb+\numberright+ after the equation.
%

\section{Cosmetic changes}
It is possible to modify a little the appearance of the equations.
There are three parameter that it is possible to change
\begin{description}
\item[left indent] When the equations are fluxed left, the left indent
(default \verb+\leftmargini+) can be changed by the command
\begin{verbatim}
    \eqleftmargin{new indent}
    
    for example
    
    \eqleftmargin{1cm}
\end{verbatim}
\item[equation spacing] The spacing around a formula,
(default \verb+7pt+) can be changed by the command
\begin{verbatim}
    \eqspacing{new spacing}
    
    for example
    
    \eqspacing{4pt}
\end{verbatim}
\item[column spacing] The spacing between column in multicolumn
equations (default \verb+4pt+) can be changed by the command
\begin{verbatim}
    \eqcolumnsep{new spacing}
    
    for example
    
    \eqcolumnsep{10pt}
\end{verbatim}
\item[row spacing] The spacing between rows in multiple
equations (default \verb+7pt+) can be changed by the command
\begin{verbatim}
    \eqrowsep{new spacing}
    
    for example
    
    \eqrowsep{10pt}
\end{verbatim}
\end{description}

for example
\begin{BOX}
\begin{verbatim}
\eqrowsep{20pt}
\eqcolumnsep{10pt}
\eqspacing{1cm}
bla bla bla bla bla bla bla bla bla bla bla bla
\begin{EQS}[rcll]
   \nabla\cdot(\rho\nabla u)&=&f \qquad
      &\mbox{on $\Omega$} \\
   u&=&u_{0}&\mbox{on $A\subset\partial\Omega$} \\
   (\rho\nabla u)\cdot n&=&u_{1}
      &\mbox{on $B\subset\partial\Omega$}
\end{EQS}
bla bla bla bla bla bla bla bla bla bla bla bla
\end{verbatim}
\end{BOX}
produces
\begin{BOX}
\eqrowsep{20pt}
\eqcolumnsep{10pt}
\eqspacing{1cm}
bla bla bla bla bla bla bla bla bla bla bla bla
\begin{EQS}[rcll]
   \nabla\cdot(\rho\nabla u)&=&f \qquad
      &\mbox{on $\Omega$} \\
   u&=&u_{0}&\mbox{on $A\subset\partial\Omega$} \\
   (\rho\nabla u)\cdot n&=&u_{1}
      &\mbox{on $B\subset\partial\Omega$}
\end{EQS}
bla bla bla bla bla bla bla bla bla bla bla bla
\end{BOX}



\section{Additional macros}
Using the package as follow
\begin{BOX}
\begin{verbatim}
   \documentclass{article}
   .
   .
   \usepackage[...,math]{easyeqn}
   .
   .
\end{verbatim}
\end{BOX}
we can use additional macros for typesetting mathematics, the 
following macros are defined  \verb+\frac+, \verb+\dfrac+,
\verb+\tfrac+, \verb+\binom+ and  \verb+\boxed+ which use is decribed 
in the following example:

\begin{BOX}
\begin{verbatim}
    \begin{EQS}[rclrcl]
        \frac[1pt]{\frac{1}{2}}{\frac{1}{2}}
        & = & \frac{\frac{1}{2}}{\frac{1}{2}} \qquad &
        \dfrac{\frac{1}{2}}{\frac{1}{2}}
        & = & \dfrac{\frac[0pt]{1}{2}}{\frac{1}{2}} \\
       \tfrac{1}{2} &=& \frac{1}{2}\qquad &
       \binom{n-1}{n-k} && \boxed{a+b}
    \end{EQS}
\end{verbatim}
    \begin{EQS}[rclrcl]
        \frac[1pt]{\frac{1}{2}}{\frac{1}{2}}
        & = & \frac{\frac{1}{2}}{\frac{1}{2}} \qquad &
        \dfrac{\frac{1}{2}}{\frac{1}{2}}
        & = & \dfrac{\frac[0pt]{1}{2}}{\frac{1}{2}} \\
       \tfrac{1}{2} &=& \frac{1}{2}\qquad &
       \binom{n-1}{n-k} && \boxed{a+b}
    \end{EQS}
\end{BOX}


The macro \verb+\eqbox+ is defined, the effect is the following
\begin{BOX}
\begin{verbatim}
    \[ \eqbox{1+\dfrac{1}{2}} \qquad
       \eqbox(1pt,20pt){1+\dfrac{1}{2}} \qquad
       \eqbox(5pt,5pt){1+\dfrac{1}{2}} \]
\end{verbatim}
    \[ \eqbox{1+\dfrac{1}{2}} \qquad
       \eqbox(1pt,20pt){1+\dfrac{1}{2}} \qquad
       \eqbox(5pt,5pt){1+\dfrac{1}{2}} \]
\end{BOX}


The macros \verb+\norm+ and \verb+\abs+ are defined, the effect is the following
\begin{BOX}
\begin{verbatim}
    \[ \norm{A}, \qquad \abs{A} \]
\end{verbatim}
    \[ \norm{A}, \qquad \abs{A} \]
\end{BOX}



The macro \verb+\ParDer+ is defined, the effect is the following
\begin{BOX}
\begin{verbatim}
    \[ \ParDer[xyyz]{f(x,y,z)} \]
    \[ \ParDer[{x^{2}}{x^{2}}{x^{2}}y\alpha]{f(x,y,z)} \]
\end{verbatim}
    \[ \ParDer[xyyz]{f(x,y,z)} \]
    \[ \ParDer[{x^{2}}{x^{2}}{x^{2}}y\alpha]{f(x,y,z)} \]
\end{BOX}
notice that single item of derivative must be a single letter (or a 
macro) or must be inside a group \verb+{ ... }+.
If you use \verb+\ParDer+ with package \package{easyvector}
remember to put macros in brace when use ``$[$ $]$'' as follows:
\begin{BOX}
\begin{verbatim}
    \usepackage[definevectors]{easyvector}
    .
    .
    .
    \[ \ParDer[\xx\xx{\xx[i,j]}\yy]{f(x,y,z)} \]
\end{verbatim}
    \[ \xx,\xx[i,j] = \ParDer[\xx\xx{\xx[i,j]}\yy]{f(x,y,z)} \]
\end{BOX}
otherwise you obtain strange think like the following
\begin{BOX}
\begin{verbatim}
    \[ \ParDer[\xx\xx\xx[i,j]\yy]{f(x,y,z)} \]
\end{verbatim}
    \[ \ParDer[\xx\xx\xx[i,j]\yy]{f(x,y,z)} \]
\end{BOX}


The macro \verb+\SUM+ is defined, the effect is the following
\begin{BOX}
\begin{verbatim}
    \[ \SUM{i=1}{100}a_{i},\quad \SUM[10]{i=1}{100}a_{i}\]
\end{verbatim}
    \[ \SUM{i=1}{100}a_{i},\quad \SUM[10]{i=1}{100}a_{i}\]
\end{BOX}


The macro \verb+\PROD+ is defined, the effect is the following
\begin{BOX}
\begin{verbatim}
    \[ \PROD{i=1}{100}a_{i},\quad \PROD[10]{i=1}{100}a_{i}\]
\end{verbatim}
    \[ \PROD{i=1}{100}a_{i},\quad \PROD[10]{i=1}{100}a_{i}\]
\end{BOX}

\end{document}