3

The following example illustrates the incompatibility of nccmath/fleqn and hyperref

\documentclass{article}
\usepackage{nccmath}
\numberwithin{equation}{section}
\setlength{\parindent}{0.0ex}

% comment out hyperref to see proper equation references
\usepackage[colorlinks=true]{hyperref}

\begin{document}

\section{First section}
Hello world
\begin{fleqn}
\begin{equation}\label{eqnA}
    \qquad\text{equation A:}\quad x + 3y = 7
\end{equation}
\end{fleqn}

\vspace{5in}
Goodby world
\begin{fleqn}
\begin{equation}\label{eqnB}
    \qquad\text{equation B:}\quad 5x + 2y = 3
\end{equation}
\end{fleqn}

\newpage
\section{Second section}
reference to equation B: \eqref{eqnB}\\
reference to equation A: \eqref{eqnA}

\end{document}
  • 1
    It would be very helpful if you could create (and post) a small self-contained example (so-called minimum working example, MWE), starting with \documentclass and ending with \end{document} that demonstrates this behavior. Often times, it is the packages that are loaded with the document that affect the result. Welcome to the site. – Steven B. Segletes Apr 08 '14 at 14:08
  • \documentclass{article} \usepackage{nccmath} – user3249581 Apr 08 '14 at 21:05
  • Unfortunately I don't know how to write code in a comment. The problem described seems to stem from a conflict between nccmath/fleqn and hyperref. Without hyperref the numbering works fine. – user3249581 Apr 08 '14 at 21:22
  • You don't have to write code in your comment. As the originator of the question, you can edit the question (there is an "edit" button below your question), and add whatever supporting code is needed to your question itself. – Steven B. Segletes Apr 09 '14 at 01:22
  • The question is now an answer. Perhaps I should have left the original question. In any case it would be nice to be able to use the fleqn environment of the nccmath package to produce a pdf document with hot links. – user3249581 Apr 09 '14 at 13:37
  • FFYI, I used to use the nccmath package package but ran into numerous issues that I decided to drop it. See Is there a replacement for nccmath? and the problems listed in the question. If all you want is the felqn environment, you can use Stefan Kottwitz's solution from nccmath affecting minipage widths. – Peter Grill Apr 09 '14 at 16:35

1 Answers1

4

Load nccmath after hyperref:

\documentclass{article}

\usepackage[colorlinks=true]{hyperref}

\usepackage{nccmath}
\numberwithin{equation}{section}

\begin{document}

\section{First section}
Hello world
\begin{fleqn}
\begin{equation}\label{eqnA}
    \qquad\text{equation A:}\quad x + 3y = 7
\end{equation}
\end{fleqn}

\vspace{5in}
Goodby world
\begin{fleqn}
\begin{equation}\label{eqnB}
    \qquad\text{equation B:}\quad 5x + 2y = 3
\end{equation}
\end{fleqn}

\newpage
\section{Second section}
reference to equation B: \eqref{eqnB}\\
reference to equation A: \eqref{eqnA}

\end{document}

enter image description here

egreg
  • 1,121,712
  • Perfect! I guess I was paying too much attention to hyperref's advice to load hyperref last. Perhaps the nccmath package is the example that proves the rule. – user3249581 Apr 09 '14 at 18:30
  • @user3249581 There are some other packages that must be loaded after hyperref, notably bookmark and cleveref. – egreg Apr 09 '14 at 19:47