| 1 |
\documentclass{article} |
| 2 |
\usepackage{amsmath} |
| 3 |
\usepackage{mhequ} |
| 4 |
|
| 5 |
\def\eref#1{(\ref{#1})} |
| 6 |
|
| 7 |
\textwidth 13cm |
| 8 |
\textheight 22cm |
| 9 |
\oddsidemargin 0.2cm |
| 10 |
\topmargin 0.3cm |
| 11 |
\pagestyle{empty} |
| 12 |
|
| 13 |
\begin{document} |
| 14 |
|
| 15 |
\title{Using the \texttt{mhequ} package} |
| 16 |
\author{Martin Hairer} |
| 17 |
\date{Version 1.72, 9 November 2022} |
| 18 |
\maketitle |
| 19 |
\thispagestyle{empty} |
| 20 |
|
| 21 |
|
| 22 |
This package provides two environments: \texttt{equ} for single-line equations |
| 23 |
and \texttt{equs} for multi-line equations. They behave similarly to the built-in |
| 24 |
\texttt{equation} and \texttt{amsmath}'s \texttt{align} environments and can essentially |
| 25 |
be used as drop-in replacements. The main difference is that equation numbers are |
| 26 |
handled differently: equations are numbered if and only if they have a \verb|\label|, |
| 27 |
so there is no need for starred versions. This also applies to individual lines in |
| 28 |
a multiline equation. Also, the \texttt{equs} environment supports blocks of equation |
| 29 |
with more |
| 30 |
|
| 31 |
Since \texttt{mhequ} redefines the \verb|\tag| and \verb|\intertext| commands, it should |
| 32 |
always be loaded \textit{after} the \texttt{amsmath} package. However, these |
| 33 |
two commands should still behave correctly inside the \texttt{amsmath} environments. |
| 34 |
The rest of this document demonstrates the usage of the \texttt{mhequ} package, |
| 35 |
it is easiest to just read the source code of this document to see how it works. |
| 36 |
See also the description given at the start of the file \texttt{mhequ.sty}. |
| 37 |
|
| 38 |
Here is a simple labelled equation: |
| 39 |
\begin{equ}[onelab] |
| 40 |
e^{i\pi} + 1 = 0 \;. |
| 41 |
\end{equ} |
| 42 |
Removing or adding the label does not require a change of environment: |
| 43 |
\begin{equ} |
| 44 |
e^{i\pi} + 1 = 0 \;. |
| 45 |
\end{equ} |
| 46 |
However, if the option \texttt{numberall} is set, then every single |
| 47 |
equation is numbered. |
| 48 |
A simple list of equations can be displayed either with one number |
| 49 |
per equation |
| 50 |
\begin{align} |
| 51 |
f(x) &= \sin(x) + 1\;, \label{e:equ1}\\ |
| 52 |
h(x) &= f(x) + g(x) -3\;, \label{e:equ3} |
| 53 |
\end{align} |
| 54 |
\begin{equs} |
| 55 |
f(x) &= \sin(x) + 1\;, \label{e:equ1}\\ |
| 56 |
h(x) &= f(x) + g(x) -3\;, \label{e:equ3} |
| 57 |
\end{equs} |
| 58 |
or with one number for the whole list |
| 59 |
\begin{equs}[e:block] |
| 60 |
f(x) &= \sin(x) + 1\;, \\ |
| 61 |
h(x) &= f(x) + g(x) -3\;. |
| 62 |
\end{equs} |
| 63 |
Of course, it can also have no number at all: |
| 64 |
\begin{equs} |
| 65 |
f(x) &= \sin(x) + 1\;, \\ |
| 66 |
h(x) &= f(x) + g(x) -3\;. |
| 67 |
\end{equs} |
| 68 |
The command \verb|\minilab{label_name}| allows us to create a counter for the lines |
| 69 |
in a block of equations. |
| 70 |
\minilab{otherlabel} |
| 71 |
\begin{equs} |
| 72 |
f(x) &= \sin(x) + 1\;, \label{e:f}\\ |
| 73 |
g(x) &= \cos(x) - x^2 + 4\;,\label{e:g}\\[3mm] |
| 74 |
h(x) &= f(x) + g(x) -3\;. \label{e:h} |
| 75 |
\end{equs} |
| 76 |
One can refer to the whole block \eref{otherlabel} or to one |
| 77 |
line, like \eref{e:f} for example. |
| 78 |
It is possible to use any tag one likes with the \verb|\tag{displayed_tag}| |
| 79 |
command |
| 80 |
\begin{equ}[mylabel] |
| 81 |
x = y\;, \tag{$\star$} |
| 82 |
\end{equ} |
| 83 |
which in this case was used as \verb|\tag{$\star$}|. |
| 84 |
Such an equation can be referred to as usual: \eref{mylabel}. |
| 85 |
Of course, \texttt{mhequ} can be used in conjunction with the usual \texttt{equation} environment, |
| 86 |
but \texttt{mhequ} is great, so why would you want to do this? |
| 87 |
\begin{equation} |
| 88 |
x=y+z |
| 89 |
\end{equation} |
| 90 |
Typesetting several columns of equations is quite easy and doesn't require 10 different environments |
| 91 |
with awkward names: |
| 92 |
\begin{equs} |
| 93 |
x&=y+z &\qquad a&= b+c &\qquad x&= v \label{laba}\\ |
| 94 |
x&=y+z &\qquad a&= b+c &\qquad x&= u+1\tag{\ref{laba}'}\label{labtag}\\ |
| 95 |
\multicol{4}{\text{(multicol)}} &\qquad x&=y \\ |
| 96 |
a&= b &\multicol{4}{\qquad\text{(multicol)}} \\ |
| 97 |
x&=y+z &\qquad a^2&= (b-c)^3 +y \\ |
| 98 |
\intertext{and also (this is some \texttt{\string\intertext})} |
| 99 |
x&=y+z &\qquad a&= (b+c)^2 - 5 &\qquad \ell&= m\label{labb} |
| 100 |
\end{equs} |
| 101 |
We can even extend the block \eref{otherlabel} much later |
| 102 |
using the \verb|\minilab{label_name}| command: |
| 103 |
\minilab{otherlabel} |
| 104 |
\begin{equs} |
| 105 |
x&=y+z &\quad x&=y+z &\quad f(x)&= b\label{e:x1}\\ |
| 106 |
x&=y+z & x&=y+z &\quad g(x)&= b\label{e:x2} \\ |
| 107 |
\multicol{6}{\sin^2 x + \cos^2 x = 1} \label{e:x3} |
| 108 |
\end{equs} |
| 109 |
It is possible to change the type of subnumbering and to use the |
| 110 |
\texttt{\string\text} command without having to load \texttt{amstext}: |
| 111 |
\setlabtype{Alph} |
| 112 |
\minilab{alab} |
| 113 |
\begin{equs} |
| 114 |
I_1 &= \int_a^b g(x)\,dx\;,&\quad&\text{(First equation)} \label{e:1}\\ |
| 115 |
I_2 &= \int_a^b g(x^2-1)\,dx\;.&\quad&\text{(Second equation)} \label{e:2} |
| 116 |
\end{equs} |
| 117 |
|
| 118 |
\end{document} |