0

I tried to add a hyperlink to an equation using information from this question, below is the MWE (the environments are there because there was more maths; I removed the unnecessary parts but kept the environments in case those are causing the issue. In the actual document, the align and the minipage are required.)

\documentclass[a4 paper, 12pt]{report}
\usepackage{amsmath}
\usepackage{hyperref}
\begin{document}
\begin{align*}
6x^4-8x^2-8&=0 \text{, with \((x^2-2)^4\neq0\), so \(x\not\in\{-\sqrt2,\sqrt2\}\)} \label{(1)}\\ %this is the line I want the link to go to
\end{align*}
\begin{minipage}{1\textwidth}
  \begin{align*}  
x&=\pm\sqrt2\\
\text{These two solutions are excluded in}&\text{ \eqref{(1)}, and hence are invalid. }\\
    \end{align*}
\end{minipage}
\end{document}

This gives the following output: enter image description here Neither the \label or the \eqref (I also tried \ref with the same result) worked.

Is there any way to label that line and add a hyperlink to it where the (??) are? I want it to look like this: enter image description here With the (1) at the bottom being a hyperlink to the equation numbered 1. I used the following to get the above image:

\documentclass[a4 paper, 12pt]{report}
\usepackage{amsmath}
\usepackage{hyperref}
\begin{document}
\begin{align*}
6x^4-8x^2-8&=0 \text{, with \((x^2-2)^4\neq0\), so \(x\not\in\{-\sqrt2,\sqrt2\}\)} \tag{1}\\ %this is the line I want the link to go to
\end{align*}
\begin{minipage}{1\textwidth}
  \begin{align*}  
x&=\pm\sqrt2\\
\text{These two solutions are excluded in}&\text{ (1), and hence are invalid. }\\
    \end{align*}
\end{minipage}
\end{document}

Thanks

3
  • 1
    Maybe the problem is the star in align. Try \begin{align}...\end{align} without the star Feb 4, 2021 at 3:30
  • @Luis But won't this cause all the equations to be numbered? I only want that one to be numbered. Feb 4, 2021 at 3:36
  • You can use \tag with align* or \notag with align, but you need a \label for \ref. This is assuming you put more than one equation into align or align*. Feb 4, 2021 at 5:13

2 Answers 2

1

A general remark up front: To create cross-references (to equations, or to any other object linked a counter variable) in a LaTeX document, one needs both a \label statement -- if you do things correctly, LaTeX will associate the argument of \label with the object's counter -- and a \ref (or \eqref, \autoref, \cref, etc) directive to generate the cross-referencing call-out. A \tag statement isn't a substitute for a \label statement.

Here's a variation on @DonHosek's answer. It attempts to streamline and simplify your somewhat complex code while (hopefully) also making the exposition of the argument easier to follow. Observe that by using \label{eq:quartic}, I try to provide a hint at the meaning of the object (here: an equation).

enter image description here

\documentclass[a4paper,12pt]{report}
\usepackage{amsmath}
\usepackage[colorlinks]{hyperref} % use 'colorlinks' option to make hyperlink visible in screenshot
\begin{document}
\begin{equation} \label{eq:quartic}
6x^4-8x^2-8=0 \text{, with \((x^2-2)^4\neq0\), so \(x\not\in\{-\sqrt2,\sqrt2\,\}\).}
\end{equation}
The two solutions 
\[
x=\sqrt2 \quad\text{and}\quad x=-\sqrt{2}
\]
are disallowed in \eqref{eq:quartic} and hence are invalid. 
\end{document}
2

There's a lot wrong here, but you can't do an \eqref to a non-numbered equation. Using an align instead of align* will fix that problem. But then, you're also not aligning anything so why use an align at all?

The minipage concerns me because it serves no purpose that I can see, and the use of \text inside the second align* is dubious at best and I would put the text outside the align. Overall, I think that the document would be better generated by writing:

\documentclass[a4 paper, 12pt]{report}
\usepackage{amsmath}
\usepackage{hyperref}
\begin{document}
\begin{equation}
6x^4-8x^2-8=0 \text{, with \((x^2-2)^4\neq0\), so \(x\not\in\{-\sqrt2,\sqrt2\}\)} \label{(1)}
\end{equation}

\[
x=\pm\sqrt2
\]
These two solutions are excluded in~\eqref{(1)}, and hence are invalid. 
\end{document}

Incidentally, if you want just one equation in an actual multi-line align environment to be numbered, you would accomplish this by putting \nonumber on the equations that should not be numbered.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .