Does anyone know how to put an equation tag in $$ line?

  • Thread starter Thread starter guv
  • Start date Start date
  • Tags Tags
    solution
AI Thread Summary
The discussion centers on how to add a right-aligned equation tag in the $$ environment, which is commonly used for rendering math equations. Users express frustration that the \tag command works in the equation environment but not with $$, leading to issues with automatic numbering. A solution is proposed using \tag* to create custom tags, allowing for right-aligned labels like [1]. However, some users report that their specific tools, particularly those using the Overleaf API, do not support this functionality. The conversation highlights the limitations of certain math rendering tools and the need for specific packages to achieve desired formatting.
guv
Messages
122
Reaction score
22
This has bothered me for a while and I have not found a good solution, it's convenient to write math equations using the \$\$ on the fly and occasionally we want to put a tag for an equation. tag works for the equation environment but not for \$\$. For example I would like to have [1] displayed all the way on the right. Is there a way to do this? Thanks,

$$v = v_0 + a t [1]$$
 
Physics news on Phys.org
Code:
\begin{align}
v&=v_0+at \\
s&=s_0+v_0t+\dfrac{1}{2}at^2
\end{align}
is a possibility, but the numbering is not an absolute one. It changes sometimes. I haven't figured out yet what the conditions are. F5 (refresh) sets it back to 1.

\begin{align}
v&=v_0+at \\
s&=s_0+v_0t+\dfrac{1}{2}at^2
\end{align}
 
  • Like
  • Informative
Likes pinball1970, Greg Bernhardt, berkeman and 2 others
fresh_42 said:
Code:
\begin{align}
v=v_0+at
\end{align}
is a possibility, but the numbering is not an absolute one. It changes sometimes. I haven't figured out yet on which conditions.

\begin{align}
v=v_0+at
\end{align}
Thanks, I know the proper math mode works. There is a tool I am using that only supports the \$ and \$$ environment to render equations. That's where I need the right-aligned equation tag.
 
guv said:
For example I would like to have [1] displayed all the way on the right.
Just to be clear, do you want your equation numbers to be displayed in brackets ##[1]## instead of in parentheses ##(1)##?
 
You can use \tag to set the text to whatever you want. If you don't, the automatic counter is not reset and continues from one post to another. (The reason why it is set to ##3## in post #3 's quote.)
Code:
$$
\begin{equation}\tag{1}
v=v_0+at
\end{equation}
$$
Result:
$$
\begin{equation}\tag{1}
v=v_0+at
\end{equation}
$$
If you do not want the added parenthesis, use \tag*. You can then add your brackets.
Code:
$$
\begin{equation}\tag*{[1]}
v=v_0+at
\end{equation}
$$
Result:
$$
\begin{equation}\tag*{[1]}
v=v_0+at
\end{equation}
$$
 
  • Like
  • Informative
Likes dextercioby, Bandersnatch, DaveE and 3 others
jack action said:
You can use \tag to set the text to whatever you want. If you don't, the automatic counter is not reset and continues from one post to another. (The reason why it is set to ##3## in post #3 's quote.)
Code:
$$
\begin{equation}\tag{1}
v=v_0+at
\end{equation}
$$
Result:
$$
\begin{equation}\tag{1}
v=v_0+at
\end{equation}
$$
If you do not want the added parenthesis, use \tag*. You can then add your brackets.
Code:
$$
\begin{equation}\tag*{[1]}
v=v_0+at
\end{equation}
$$
Result:
$$
\begin{equation}\tag*{[1]}
v=v_0+at
\end{equation}
$$
I'm always confused by the fact that 'align' automatically generates math mode and 'equation' does not.
 
jack action said:
You can use \tag to set the text to whatever you want. If you don't, the automatic counter is not reset and continues from one post to another. (The reason why it is set to ##3## in post #3 's quote.)
Code:
$$
\begin{equation}\tag{1}
v=v_0+at
\end{equation}
$$
Result:
$$
\begin{equation}\tag{1}
v=v_0+at
\end{equation}
$$
If you do not want the added parenthesis, use \tag*. You can then add your brackets.
Code:
$$
\begin{equation}\tag*{[1]}
v=v_0+at
\end{equation}
$$
Result:
$$
\begin{equation}\tag*{[1]}
v=v_0+at
\end{equation}
$$
This would be a good addition to the LaTeX Guide.
 
I combined all that has been said here and finally got the ultimate equation alignment with manually set numbers for only the chosen lines:
\begin{align*}
\ddot{s}&=a_0\\
s&=s_0+v_0t+\dfrac{1}{2}at^2 \tag*{[17]} \\
v&=v_0+at \\[20pt]
a&=a_0 \tag{18}
\end{align*}

Code:
\begin{align*}
\ddot{s}&=a_0\\
s&=s_0+v_0t+\dfrac{1}{2}at^2 \tag*{[17]} \\
v&=v_0+at \\[20pt]
a&=a_0 \tag{18}
\end{align*}
 
Last edited:
  • Like
  • Love
Likes dextercioby, jack action and pinball1970
fresh_42 said:
I combined all that has been said here and finally got the ultimate equation alignment with manually set numbers for only the chosen lines:
\begin{align*}
\ddot{s}&=a_0\\
s&=s_0+v_0t+\dfrac{1}{2}at^2 \tag*{[17]} \\
v&=v_0+at \\
a&=a_0 \tag{18}
\end{align*}

Code:
\begin{align*}
\ddot{s}&=a_0\\
s&=s_0+v_0t+\dfrac{1}{2}at^2 \tag*{[17]} \\
v&=v_0+at \\
a&=a_0 \tag{18}
\end{align*}
fresh_42 said:
I'm always confused by the fact that 'align' automatically generates math mode and 'equation' does not.
Sorry guys, again the problem is not with proper math environment like align etc. The problem is with \$ or \$$ math mode.
 
  • #10
guv said:
Sorry guys, again the problem is not with proper math environment like align etc. The problem is with \$ or \$$ math mode.
If you can type a formula like ##v=v_0+at## then why can't you type \begin{align}? However, we also solved your specific problem:
$$
v=v_0+at\tag*{[5]}
$$
came from
Code:
$$
v=v_0+at\tag*{[5]}
$$
 
  • #11
fresh_42 said:
I combined all that has been said here and finally got the ultimate equation alignment with manually set numbers for only the chosen lines:
\begin{align*}
\ddot{s}&=a_0\\
s&=s_0+v_0t+\dfrac{1}{2}at^2 \tag*{[17]} \\
v&=v_0+at \\
a&=a_0 \tag{18}
\end{align*}

Code:
\begin{align*}
\ddot{s}&=a_0\\
s&=s_0+v_0t+\dfrac{1}{2}at^2 \tag*{[17]} \\
v&=v_0+at \\
a&=a_0 \tag{18}
\end{align*}
fresh_42 said:
If you can type a formula like ##v=v_0+at## then why can't you type \begin{align}?
For reasons I stated in post #3:
Thanks, I know the proper math mode works. There is a tool I am using that only supports the $ and $$ environment to render equations. That's where I need the right-aligned equation tag.
 
  • #12
guv said:
For reasons I stated in post #3:
Thanks, I know the proper math mode works. There is a tool I am using that only supports the $ and $$ environment to render equations. That's where I need the right-aligned equation tag.
See my edit.
 
  • #13
guv said:
Thanks, I know the proper math mode works. There is a too
guv said:
Thanks, I know the proper math mode works. There is a tool I am using that only supports the \$ and \$$ environment to render equations. That's where I need the right-aligned equation tag.
fresh_42 said:
See my edit.

l I am using that only supports the \$ and \$$ environment to render equations. That's where I need the right-aligned equation tag.
Unfortunately I can't see your edit through reply, I am not sure if you are still using align there.
 
  • #14
$$
v=v_0+at\tag*{[71]}
$$
came from
Code:
$$
v=v_0+at\tag*{[71]}
$$
Inline tags here are ## so ##
v=v_0+at\tag{[5]}
## resulted from
Code:
##
v=v_0+at\tag*{[5]}
##
which means that the tag command does not work for inline equations, which makes sense.
 
  • #15
fresh_42 said:
$$
v=v_0+at\tag*{[71]}
$$
came from
Code:
$$
v=v_0+at\tag*{[71]}
$$
Inline tags here are ## so ##
v=v_0+at\tag{[5]}
## resulted from
Code:
##
v=v_0+at\tag*{[5]}
##
hmm, just tried what you wrote in the tool, unfortunately it's not compiled correctly. It also didn't work on overleaf.

$$
v=v_0+at\tag*{[1]}
$$

I am guessing this is a pretty special thing about physics forums that coded around the \$\$ math mode. Thanks for your help though.
 
  • #16
guv said:
hmm, just tried what you wrote in the tool, unfortunately it's not compiled correctly. It also didn't work on overleaf.

$$
v=v_0+at\tag*{[1]}
$$

I am guessing this is a pretty special thing about physics forums that coded around the \$\$ math mode. Thanks for your help though.
In that case, you are left with quads.
 
  • #17
guv said:
There is a tool I am using
guv said:
just tried what you wrote in the tool
What tool is that?
 
  • #18
it's a tool using overleaf api, not public. Not working on overleaf is obviously the problem.
 
  • #19
First time use with overleaf, but it does work:

overleaf-test.png

But I had to specify \usepackage{amsmath}. It works with align and equation alike.

Without using additional packages, I achieve it with \hspace*{\fill} x= 2+y \hspace*{\fill} [1]:

overleaf-test-2.png

Edit: Actually you have to use \hspace*{\fill} $x= 2+y$ \hspace*{\fill} [1] to get it written as an equation. (In my example it is pure text.)
 
  • Like
Likes guv and fresh_42
Back
Top