2

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!

Leo Simon
  • 2,199

3 Answers3

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

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

idkfa
  • 461
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

John Kormylo
  • 79,712
  • 3
  • 50
  • 120