4

I am trying to reference a set of equations that are placed within a alignat and subequations environments. I would like to reference them as Eq. 1 together, rather than Eqs. 1a and 1b separately. The MWE below does exactly this, yet leaves a small indentation in the paragraph just below the equations. Is there a way to circumvent this or use a different environment?

\documentclass{article}
 \usepackage{mathtools}
 \usepackage{lipsum}
 \begin{document}
  \lipsum[1]
  \begin{subequations}
   \begin{alignat}{1}
    \dot{\mathbf{u}}_{i} &= \frac{\mathbf{u}_{i+1} - \mathbf{u}_{i-1}}{2\Delta t} + \mathcal{O}(\Delta t^2) \\
    \ddot{\mathbf{u}}_{i} &= \frac{\mathbf{u}_{i+1} - 2\mathbf{u}_{i} + \mathbf{u}_{i-1}}{\Delta t^2} + \mathcal{O}(\Delta t^2)
   \end{alignat}
   \label{eq}
  \end{subequations}
  \lipsum[2]

  I'm referencing the equation here: \ref{eq}
 \end{document}

2 Answers 2

6
   \label{eq}% you need a percent here
3
  • Ah, I see. How does the % change this? This goes beyond my understanding of latex.
    – Markus
    Mar 18, 2014 at 21:37
  • 2
    @Markus a newline (if not hidden by a comment) is a word space and word spaces typically make space in the output. (I'd have put money on it being a % just from your title, without needing to actually go in and read the question:-) I haven't looked at the source but it probably protects against one word space before the close environment (eg \unskip to remove a space) but a \label on a line of its own like that produces an extra one. Mar 18, 2014 at 21:40
  • 1
    @Markus: See What is the use of percent signs (%) at the end of lines?
    – Werner
    Mar 18, 2014 at 21:55
3

You're placing the label in the wrong line; the reference is set by \begin{subequations}, so the best location is just after it (on the same line or not, it's immaterial).

\documentclass{article}
\usepackage{mathtools}
\usepackage{lipsum}
\begin{document}

\lipsum*[1]% *, or a paragraph is started
\begin{subequations}\label{eq}
\begin{alignat}{1}
\dot{\mathbf{u}}_{i}  &=
  \frac{\mathbf{u}_{i+1} - \mathbf{u}_{i-1}}{2\Delta t} + \mathcal{O}(\Delta t^2) \\
\ddot{\mathbf{u}}_{i} &=
  \frac{\mathbf{u}_{i+1} - 2\mathbf{u}_{i} + 
  \mathbf{u}_{i-1}}{\Delta t^2} + \mathcal{O}(\Delta t^2)
\end{alignat}
\end{subequations}
\lipsum[2]

I'm referencing the equation here: \ref{eq}

\end{document}

enter image description here

You must log in to answer this question.

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