1

I would like a command that takes two arguments, one a number and one an equation, and the command displays the equation (in displayed mode) and puts the number right justified centred on the equation. I want the position of the equation to be unaltered by the placing of the right justified number; so, if I just \begin{equation*}...\end{equation*} with the same equation it would put the equation in the exact same place, both horizontally and vertically. I have no clue where to start. Any suggestions would be appreciated. Thanks

6
  • 1
    Welcome to TeX.SE! I don't really understand where you want to have this extra number. Can you post a picture (hand-written or ascii-art) of what you want to achieve?
    – gernot
    Mar 9, 2017 at 21:55
  • 4
    why are you using equation* (which is for un-numbered equations) if you want an equation number? Mar 9, 2017 at 22:02
  • @ gernot: I want the number vertically centred on the equation like an equation number, and right justified. So this equation would go exactly where it would go without my modification, but there would be a number to the right of it right justified. @ David: I don't want an equation number. I want a number of my choosing, and then I want it right justified, likely in square brackets. I see that everyone is attaching tex produced code, but I don't know how. I can look this up. But I hope my description makes sense.
    – Hammar
    Mar 9, 2017 at 23:17
  • 1
    perhaps you are just looking for \tag{XXX} from amsmath Mar 10, 2017 at 0:08
  • read the documentation for amsmath (texdoc amsmath) and look for \tag. Mar 10, 2017 at 2:00

1 Answer 1

3

If I understand you correctly, you want \tag* as in the equation a=2.

enter image description here

\documentclass{article}

\usepackage{amsmath}

\begin{document}

zzz
\begin{equation}
  a= 1\tag{this}
\end{equation}

zzz
\begin{equation}
  a=2 \tag*{[this]}
\end{equation}

zzz
\begin{equation}
  a=3
\end{equation}

zzz
\begin{equation*}
  a=4
\end{equation*}

\end{document}
4
  • Yes! Simple and works! However..., is it possible to put this in a command that takes two arguments, one argument is the equation and the other argument is the \tag*? I can certainly live with the solution you provide, but I would prefer (for various complicated reasons) to have a command that does it with two arguments.
    – Hammar
    Mar 10, 2017 at 11:13
  • Ok. Figured it out. \newenvironment{myenv}[1]{\begin{equation*}\tag*{[#1]}}
    – Hammar
    Mar 10, 2017 at 12:05
  • Sorry, what I haven't figured out is how to comment properly. my code is \newenvironment{myenv}[1]{\begin{equation*}\tag{[#1]}}{\end{equation*}}. Interesting, if I put the \tag part of the code with the second argument of newenvironment it gives me an error. Sorry for making a mess of the comments here, I am just learning to comment.
    – Hammar
    Mar 10, 2017 at 12:16
  • @Hamar yes of course the arguments to newcommand only declare #1 etc for the begin code not for the end code. that is a general feature of latex environments nothing to do with equation Mar 10, 2017 at 12:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.