Your question is more a general question about labeling and referencing equations.
I think one great introduction is the mathmode of Herbert Voss. It's available at CTAN.
mathmode at CTAN
In the linked document you will find an extra sub section about Labels. It is introduced by:
Every numbered equation can have a label to which a reference is
possible.
- There is one restriction for the label names, they cannot include one of
LaTeX’s 8 command characters.
- The label names are replaced by the equation number.
Update
The following point was mentioned by Mico:
It may be useful to note that in addition to the eight "basic" special
characters that can't be used inside labels, users should also refrain
from using
- commas if the plan on using the cleveref package or
- any characters that have special meanings for various languages
supported by the babel package (such as : in babel/French).
The environment equation
doesn't allow any line breaks. So the syntax will be:
\begin{equation}
a^2+b^2=c^2\label{eq:1}
\end{equation}
The environment align
allows line breaks and so every line can get a label.
\begin{align}
x^2+y^2&=2r^2 \label{eq:1} \\
d^2+h^2&=4r^2 \label{eq:2}
\end{align}
To reference to a given label you can use the standard command \ref
or any other reference command provided by some packages. I like to use \eqref
to reference to equations.
Here a complete example:
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation}
a^2+b^2=c^2\label{eq:1}
\end{equation}
Text \eqref{eq:1}
\end{document}
You wrote:
However, when I use it along with \begin{step}
, \begin{claim}
, or \begin{myclaim}
, there two additional round parentheses appear.
Is there a way to get rid of those round braces?
Don't surround the corresponding \hypertarget{...}{}
statements with square brackets ([
and ]
). Otherwise, amsthm
will interpret the material as indicating the optional "title" of the corresponding theorem-like environments. Expressed differently, only use square brackets if the second argument of \hypertarget
is nonempty.
Another way to understand this better is to consider the two cases in your code where the second argument of \hypertarget
is nonempty:
\begin{proof}[\hypertarget{proof:1}{Proof.}]
and
\begin{namedtheorem}[\hypertarget{thm:mystery}{Mystery theorem}]
In these cases, the square brackets indicate to LaTeX that "Proof." and "Mystery theorem", respectively, should be used as the titles of the corresponding environments. That's not the case with
\begin{step}\hypertarget{step1}{}
\begin{claim}\hypertarget{claim1}{}
\begin{myclaim}\hypertarget{myclaim}{}
and that's why you shouldn't provide square brackets.
You also wrote:
Below there is a MWE, where I used \clearpage
extensively, because I noticed that when \hypertarget
does not work properly, it links to the first page of the document.
When that happens, try inserting \phantomsection
directives immediately ahead of the environments or other items being cross-referenced via \hypertarget
and \hyperlink
.
Best Answer
For this you need to use the
gathered
environment fromamsmath
and place the\label
outside that environment. Another quick-and-dirty way to achieve this, without usingamsmath
, would be to use anarray
:Also consider using
\eqref
instead of\ref
for equations, since this is fully supported byamsmath
to duplicate the behaviour of the equation number, even in other fonts.