1

This is a followup to this thread. I basically followed the construction offered by @egreg. The following construction throws an error when I have a & b in the line with \pushright. If I omit the b the code runs. Is there a way that I can use \pushright and have symbols to the right of the & sign?

\documentclass{article}
\usepackage{amsmath}
\makeatletter
\newcommand{\pushright}[1]{\ifmeasuring@#1\else\omit$\displaystyle#1$\ignorespaces\fi}
\makeatother

\begin{document}
\begin{align}
    a  &   b  \pushright{\hfill\text{(foo)}}
\end{align}
\end{document}

Ultimately, what I want to do is have lines like:

\begin{align}
    x_{t+1} = & x_t + f(x_t) - c_t  \pushright{\hfill\text{(eq of motion)}} \\
    x_0     = & \bar{x}       \pushright{\hfill\text{(initial condition)}}
\end{align}

and have the phrases eq of motion and initial condition right aligned just to the left of the equation numbers. Thanks!

2

Like that?

\begin{align}
    x_{t+1} = & x_t + f(x_t) - c_t  & \pushright{\hfill\text{(eq of motion)}} \\
    x_0     = & \bar{x}       & \pushright{\hfill\text{(initial condition)}}
\end{align}

enter image description here

5

I'm wondering if you are just looking for \tag.

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align}
    x_{t+1} = & x_t + f(x_t) - c_t  \tag{eq of motion} \\
    x_0     = & \bar{x}       \tag{initial condition}
\end{align}
\end{document}

enter image description here

  • Thanks, but I wanted to have the equation numbers as well as the text. – Leo Simon Dec 30 '17 at 8:54
  • as for the question and the answer it should be &= not =& – David Carlisle Dec 30 '17 at 10:16
2

There is always flalign: If you want the equations centered, replace \text with \llap.

\documentclass{article}
\usepackage{amsmath}
\usepackage{showframe}

\begin{document}
\begin{flalign}
&& x_{t+1} &= x_t + f(x_t) - c_t  &\text{(eq of motion)} \\
&&    x_0  &= \bar{x}       &\text{(initial condition)}
\end{flalign}
\end{document}

demo

  • It should be &= – egreg Dec 30 '17 at 9:31
  • @egreg - What's the point of copying an MWE if we have to fix ALL the mistakes? – John Kormylo Dec 30 '17 at 15:17

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.