I want to use \tag
in my LaTex file at https://www.sharelatex.com/.
For example, I want to do:
If $x \equiv x' \pmod{N}$ and $y \equiv y' \pmod{N}$, then: $xy \equiv x'y' \pmod{N}\tag{Substitution rule}$.
I look at a previous question on this website, \numcases with \tag, and found the answer insufficient for my problem.
I still get the ! Package amsmath Error: \tag not allowed here.
error even though I am only importing the following:
\usepackage{textcomp,geometry,graphicx,hyperref,empheq}
I have two questions:
(1) Why does the amsmath
package cause an error when \tag
is used?
(2) How do I add customized tags to my equations without causing errors?
Thank you for any help you can provide on this!
EDIT:
This is a made-up example as requested:
Now solve for $E[X]$:\newline
\hspace{30pt} $E[X] = 1 + E[X] - p \cdot E[X]$\newline
\hspace{30pt} $0 = 1 - p \cdot E[X]\tag{"xyz"}$\newline
\hspace{30pt} $p \cdot E[X] = 1\tag{"xyy"}$\newline
\hspace{30pt} $E[X] = \frac{1}{p}\tag{"xzy"}$\newline\newline
Note the \tag
parts were added in afterwards because they caused errors.
Then I want to say, based on "xyz" and "xyy", I can prove "abc".
Best Answer
You're still using inline math. (La)TeX distinguishes between math that is supposed be written on a line of text, delimited by
$ ... $
or\( ... \)
, and displayed math, which is placed on its own paragraph.For a single unnumbered, displayed equation you can use
\[ ... \]
, for a numberered equation there is\begin{equation} ... \end{equation}
. For sets of equations, or multiline equations,amsmath
provides several environment, includingalign
andgather
, as well as the starred formsalign*
andgather*
that are unnumbered.Displayed equations are by default centered, to make them left-aligned add
fleqn
as an option toamsmath
or the document class, e.g.\usepackage[fleqn]{amsmath}
.For more information about
amsmath
, read the manual. For math typesetting in general, you could take a look at Herbert Voss' Mathmode.A demonstration with your example: