[Tex/LaTex] Numbering specific lines in align environment

alignnumbering

I want to number specific lines of an equation in the align environment. I've seen how to use gather instead of align here, but putting \usepackage[fleqn]{amsmath} in the preamble messes with the other equations in the document.

\documentclass[11pt,a4paper,openright]{book}
\usepackage[latin1]{inputenc}
\usepackage{amsmath,amsfonts,amssymb}
\usepackage[left=1.00in, right=1.00in, top=1.00in, bottom=1.20in]{geometry}
\usepackage[hidelinks]{hyperref}

\begin{document}

For any test function $\phi\in\mathcal{D}$,
\begin{align}
\langle f'(t),\phi(t) \rangle &= \int_{-\infty}^{\infty} f'(t)\phi(t) \mathrm{d}t \\ 
&= [f(t)\phi(t)]_{-\infty}^\infty - \int_{-\infty}^{\infty} f(t)\phi'(t) \mathrm{d}t \\ \nonumber
&= -\langle f(t),\phi'(t) \rangle
\end{align}

\end{document}

I want to number the first and third lines, not the first and second.

Best Answer

In each line of your align environment, \\ ends the equation. So, any actions you want to perform on that particular line need to go before the ending \\.

enter image description here

\documentclass{article}
\usepackage{amsmath}

\begin{document}

For any test function $\phi\in\mathcal{D}$,
\begin{align}
  \langle f'(t),\phi(t) \rangle &= \int_{-\infty}^{\infty} f'(t)\phi(t) \mathrm{d}t \\ 
    &= [f(t)\phi(t)]_{-\infty}^\infty 
         - \int_{-\infty}^{\infty} f(t)\phi'(t) \mathrm{d}t \nonumber \\ %%%%%%%%
    &= -\langle f(t),\phi'(t) \rangle
\end{align}

\end{document}