# (1), (2)… at the end of a line

Thank you very much, K. Paul and Ignasi ❤ You have provided me solutions that suit my document perfectly! However -- well -- which answer should I mark to be 'accepted' when both are correct?😂

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

What I have

I have the following code

\documentclass{article}
\begin{document}
We have $1+1=2$. (1)

Besides, we already have $3-1=2$. (2)

Since (1) and (2) we get $1+1=3-1$.
\end{document}


What I want

I want to have the result like this

where the black (1) and (2) are at the end of the line (like this question), but I can label them and then cite them in the next lines by the clickable red (1) and (2).

Thank you in advance!

Edit

A part of my document (in Vietnamese):

I want to change the position of the (3) (red arrow), but other equations (especially display equation as the blue arrow pointing) should not be affected.

• Can you point to a source where such typesetting is used? Commonly, equations to be referred to are displayed by themselves on a line. – egreg Nov 7 '18 at 7:52
• @egreg I use 1+1=2 for a short and simple MWE. However, I use it in geometry, like Since AB=BC, we get that ΔABC is isosceles (1). The way of writing ΔABC is isosceles in the center of a new line is not quite good to me. – user156344 Nov 7 '18 at 8:03

A command which increases equation counter and that can be placed where you want, could work:

\documentclass{article}
\usepackage{amsmath}

\usepackage{hyperref}
\newcommand{\myeq}[1]{\hfill{\refstepcounter{equation}(\theequation)\label{#1}}}

\begin{document}

We have $1+1=2$. \myeq{1}

Besides, we already have $3-1=2$. \myeq{2}

This is a nonnumbered equation
$$$x+y=z+d$$$

Another equation with number
$$x+y=z+d$$

Another inline expression $a+b=2$. \myeq{z}

Since \ref{1} and \ref{2} we get $1+1=3-1$. And with \ref{z} \dots
\end{document}


• It looks nice, but in my document there are still many equations which I put in a unique line (display equation). I don't want to ruin them :D See more in my image. – user156344 Nov 7 '18 at 8:54
• @joule_voo I've provided another solution, is it better? – Ignasi Nov 7 '18 at 10:01
• Thank you very much! That is exactly what I want to have! – user156344 Nov 7 '18 at 10:08

You'll need the amsmath and hyperref packages for this one:

\documentclass[10pt]{article}
\usepackage{amsmath}
\usepackage{hyperref}

\begin{document}
\begin{flalign}
\textrm{We have }1+1=2&&\label{eq:1}
\end{flalign}
\begin{flalign}
\textrm{Besides, we already have }3-1=2&&\label{eq:2}
\end{flalign}
Since \eqref{eq:1} and \eqref{eq:2} we get $1+1=3-1$
\end{document}


The flalign environment is provided by the amsmath package. Make sure to add the symbol && after each equation to make them flush left. Labeling is done by the \label{eq:n} command in every flalign environment. Referencing in-line is done by the \eqref{eq:n} command. (I used n in describing the equation number.)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The solution above was a partial solution that only works within displayed equations. Thw following presents a solution specifically for in-line equations:

\documentclass[10pt]{article}
\usepackage{amsmath}
\usepackage{hyperref}
\newcommand{\plusone}{\refstepcounter{equation}(\theequation)}

\begin{document}
\begin{flalign}
\textrm{We have }1+1=2&&\label{eq:1}
\end{flalign}
\noindent Writing an in-line math equation $$E=mc^2$$ and filling up some space so that
this sentence covers more than one line... \hfill $$\plusone \label{eq:2}$$
\begin{flalign}
\textrm{Besides, we already have }3-1=2&&\label{eq:3}
\end{flalign}
Since \eqref{eq:1} and \eqref{eq:3} we get $1+1=3-1$. \eqref{eq:2} is irrelevant but hey,
it was a good example.
\end{document}


\refstepcounter{equation}(\theequation) increments equation count, so every time you need to reference in-line equations, add this mark at the end of the paragraph. I've made a macro so no one needs to write that long code all the time. Always remember to label and eqref after every increment. \hfill was used so that the (n) is always flushed right after every paragraph. Use it after your last sentence to flush only the numbering part right. Compiling prints this:

• Thank you for your answer! It works perfectly for a line but for a paragraph (like in the last image I put in the question) I still don't really get what I want :( (see this image) – user156344 Nov 7 '18 at 9:25
• I've made a workaround for said problem. Seems as though the display mode was making margin problems, so I've made a workaround for said problem by implementing a similar solution for in-line math equations. I'm editing the answer now... – Paul Kim Nov 7 '18 at 9:43
• Thank you very much! That is exactly what I want to have!!! – user156344 Nov 7 '18 at 10:07
• Added a picture, just for good measure. – Paul Kim Nov 7 '18 at 15:24