The package easyeqn

Enrico Bertolazzi Laboratorio di Matematica Applicata Dipartimento di Ingegneria Civile ed Ambientale Università degli Studi di Trento Mesiano, Trento, Italy

             bertolaz@ing.unitn.it

Abstract

The 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. A package option cases only those equations that were labeled and referenced to be numbered.

Contents

1 Some examples with easyeqn 1 2 Use of the EQ environment 2 3 Use of EQS environment 3 4 The \yesnumber command 3 5 The \eqlabel command 4 6 Use of EQA environment 5 7 Use of fleqn and leqno option 5 8 Cosmeting changes 6

1 Some examples with easyeqn

Load the package using the usual syntax:

   \documentclass{article}
   .
   .
   \usepackage[allnumber,warning,fleqn,leqno]{easyeqn}
   .
   .

The package introduces the EQ, EQS and EQA environments. The package options are:

allnumber means that all of the EQ, EQS and EQA environments are numbered. Without that option, only those EQ, EQS and EQA environment that are labeled and referenced are numbered.

warning causes equations that are labeled but not referenced to be flagged.

fleqn flushes equation on the left margin.

leqno writes equation number on the left.

2 Use of the EQ environment

The following input:

\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}.

produces the following output:

\frac{x}{y} = z  (1)

\frac{x}{y} = z

I will refer only to (1) or, in the old style, 1.

Note that the command \eqlabel is used instead of \label and the reference is done by \eqref or \refeq. The command \refeq produces the same output as \ref, while \eqref uses ( ) for the output.

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

3 Use of EQS environment

The following commands:

   \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}

produces

∇ · (ρ∇u) = f  on Ω
u = u_{0} on A ⊂ ∂Ω
(ρ∇u) · n = u_{1} on B ⊂ ∂Ω

Note that between [...] you can specify the column alignment in the same way as in the array or tabular environment. The permitted alignment are l for left alignment, r for right alignment and c for centering.

4 The \yesnumber command

If you want to number an equation without reference it, use the \yesnumber command as this example shows:

   \begin{EQ}\yesnumber
      \nabla\cdot(\rho\nabla u) = 0
   \end{EQ}

produces

∇ · (ρ∇u) = 0 (2)

5 The \eqlabel command

It is possible to use custom label by \eqlabel command. The syntax is the following

     \eqlabel`[*]'{labelname}
     or
     \eqlabel`(*)'{labelname}

where `[*]' is an optional argument. If `[*]' is defined, equation displays `*' instead of `("equation number")'. The equation counter is not advanced and `labelname' will refer to `*'. If we use `[*]' the result is similar but the equation number is substituted by `(*)' instead of `*'. Look at this example:

   \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}
   \end{EQA}
   I will refer to \eqref{eq:custom:a} and \eqref{eq:custom:b}

produces

∇ · (ρ∇u) = 0  (eq.1)
∇ · (ρ∇u) = 0  eq.2

I will refer to (eq.1) and (eq.2)

6 Use of EQA environment

The following commands:

\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}!!

produce

∇·(ρ∇u) = f  on Ω  (3)
u = u_{0} on A ⊂ ∂Ω
(ρ∇u)·n = u_{1} on B ⊂ ∂Ω  (∗)

it is referenced only (∗)!!

Note that only the referenced lines or the lines with \yesnumber are numbered.

7 Use of fleqn and leqno option

You can use fleqn to flux left the equations or leqno to number equations on the left. If for example we have used

\documentclass{article}
.
.
\usepackage[fleqn,leqno]{easyeqn}
.
.

the effect with this example:

\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}!!

is the following

(4) ∇ · (ρ∇u) = f  on Ω
(5)  u = u_{0} on A ⊂ ∂Ω
(6) (ρ∇u)·n = u_{1} on B ⊂ ∂Ω

it is referenced only (6)!!

The same effect can be obtained everywhere using the commands \equationleft and \numberleft before defining the equation. To restore the default use \equationcenter and \numberright after the equation.

8 Cosmeting changes

It is possible to modify a little the appearance of the equations. There are three parameter that it is possible to change

left indent When the equations are fluxed left, the left indent (default \leftmargini) can be changed by the command

     \eqleftmargin{new indent}
     for example
     \eqleftmargin{1cm}

equation spacing The spacing around a formula, (default 7pt) can be changed by the command

\eqspacing{new spacing}
for example
\eqspacing{4pt}

column spacing The spacing between column in multicolumn equations (default 4pt) can be changed by the command

\eqcolumnsep{new spacing}
for example
\eqcolumnsep{10pt}

row spacing The spacing between rows in multiple equations (default 7pt) can be changed by the command

\eqrowsep{new spacing}
for example
\eqrowsep{10pt}

for example

\eqrowsep{20pt}
\eqcolumnsep{10pt}
\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}

produces

∇ · (ρ∇u) = f  on Ω

u = u_{0}  on A ⊂ ∂Ω

(ρ∇u) · n = u_{1}  on B ⊂ ∂Ω