4

Currently the code below produces the following: enter image description here

The words on the left hand side are fine (i.e. I want them aligned to the left margin) and so are the equation numbers (i.e. I want them aligned to the right margin). However, I would like the terms in the middle $\xi$ and $\sigma$ to be centred relative to each other so the formulation looks neater.

How can I do this?

Thanks in advance!

\documentclass[a4paper,12pt,default]{amsart}
\usepackage{subeqnarray}

\begin{document}
\begin{flalign}\refstepcounter{equation}
\text{Gas injection:}    &&
    \xi = Y_i,  &&
    \sigma = \left( \dfrac{\bar{s}_{\textrm{air}}-\bar{s}_{i}}{\bar{c}_p} \right)\xi,      &&  \tag{\theequation $a$-$b$}
\end{flalign}
\begin{flalign}\refstepcounter{equation}
\text{Heat addition:}   && 
    \xi = 0,  &&
    \sigma = T^\prime/\bar{T},        &&\tag{\theequation $a$-$b$}
\end{flalign}
\end{document}

1
  • I suppose you want the equation numbers on the right side?
    – Bernard
    Oct 30, 2019 at 21:02

2 Answers 2

8

You can use my \Cen macro, see https://tex.stackexchange.com/a/209732/4427

\documentclass[a4paper,12pt,reqno]{amsart}

\makeatletter
\newcommand{\Cen}[2]{%
  \ifmeasuring@
    #2%
  \else
    \makebox[\ifcase\expandafter #1\maxcolumn@widths\fi]{$\displaystyle#2$}%
  \fi
}
\makeatother

\begin{document}

\begingroup\renewcommand{\theequation}{\arabic{equation}a-b}
\begin{flalign}
&\text{Gas injection:}    &
&\Cen{4}{\xi = Y_i,}  &
&\Cen{6}{\sigma = \left( \frac{\bar{s}_{\mathrm{air}}-\bar{s}_{i}}{\bar{c}_p} \right)\xi,} &&
\\[1ex]
&\text{Heat addition:}   &
&\Cen{4}{\xi = 0,}  &
&\Cen{6}{\sigma = T^\prime/\bar{T},} &&
\end{flalign}
\endgroup

\end{document}

enter image description here

I'd also consider a standard alignment:

\begingroup\renewcommand{\theequation}{\arabic{equation}a-b}
\begin{flalign}
&\text{Gas injection:}    &
\xi &= Y_i,  &
\sigma &= \left( \frac{\bar{s}_{\mathrm{air}}-\bar{s}_{i}}{\bar{c}_p} \right)\xi, &&
\\[1ex]
&\text{Heat addition:}   &
\xi &= 0,  &
\sigma &= T^\prime/\bar{T}, &&
\end{flalign}
\endgroup

enter image description here

You can label the equations separately, but you have to explicitly give the subequation letter. I also implemented math mode for the subequation letters (although I'd not use it myself).

\documentclass[a4paper,12pt,reqno]{amsart}

\makeatletter
\newcommand{\Cen}[2]{%
  \ifmeasuring@
    #2%
  \else
    \makebox[\ifcase\expandafter #1\maxcolumn@widths\fi]{$\displaystyle#2$}%
  \fi
}
\let\extra@label\label
\newcounter{equationtemp}
\newcommand{\extralabel}[2]{%
  \begingroup
  \setcounter{equationtemp}{\value{equation}}%
  \renewcommand{\theequationtemp}{\arabic{equationtemp}$#1$}%
  \refstepcounter{equationtemp}%
  \extra@label{#2}%
  \endgroup
}
\makeatother

\begin{document}

\begingroup\renewcommand{\theequation}{\arabic{equation}$a$-$b$}
\begin{flalign}
\label{first}
&\text{Gas injection:} &
&\Cen{4}{\xi = Y_i,}  \extralabel{a}{one} &
&\Cen{6}{\sigma = \left( \frac{\bar{s}_{\mathrm{air}}-\bar{s}_{i}}{\bar{c}_p} \right)\xi,}
  \extralabel{b}{two} &&
\\[1ex]
\label{second}
&\text{Heat addition:} &
&\Cen{4}{\xi = 0,} \extralabel{a}{three} &
&\Cen{6}{\sigma = T^\prime/\bar{T},} \extralabel{b}{four} &&
\end{flalign}
\endgroup

\ref{one} and \ref{two}; \ref{three} and \ref{four}; \ref{first} and \ref{second}.

\eqref{one} and \eqref{two}; \eqref{three} and \eqref{four}; \eqref{first} and \eqref{second}.

\end{document}

enter image description here

6
  • thanks for this! how can I keep the same formatting for the equations (i.e. lettering in italic)?
    – jrjrjr
    Oct 31, 2019 at 9:55
  • also forgot to mention this in my question - using your solution, how can I label each of the equations independently?
    – jrjrjr
    Oct 31, 2019 at 10:01
  • Thanks for the edits! One last query - any chance of being able to reference as well as individual eqtns 1a, 1b, reference (1a-b)?
    – jrjrjr
    Oct 31, 2019 at 23:47
  • @jrjrjr Just use the ordinary \label in addition to \extralabel. I edited the code to show the usage.
    – egreg
    Oct 31, 2019 at 23:53
  • that works - unfortunately the \extralabel macro isn't working in my other latex file. Probably not compatible with something I've loaded, the error says "Argument of \Hy@setref@link has an extra }"
    – jrjrjr
    Nov 1, 2019 at 0:05
6

I propose these solutions, based on a normal align environment, within a fleqn environment from nccmath which locally sets the fleqn option of amsmath, and a custom tag form with the help of mathtools.

There two variants: either the columns are aligned on the = sign, or the left column alone is so aligned, but the right column is centred (in the left column, the widths of each row are too close, and centring them doesn't look very nice, but you can do it if you prefer). Centring is obtained with the eqparbox package, which uses a system of tags, so that boxes sharing the same tag have the width of the largest natural width in the family.

\documentclass[a4paper,12pt,default, reqno]{amsart}
\usepackage{mathtools, nccmath}
\usepackage{eqparbox}
\newcommand{\eqmathbox}[2][M]{\eqmakebox[#1]{$\displaystyle#2$}}
\usepackage[showframe]{geometry}
\newtagform{a-b}{(}{a-b)}

\begin{document}

\begin{fleqn}
\usetagform{a-b}
\begin{align}%\
 & \text{Gas injection:} &
    \xi & = Y_i, & \sigma & = \left( \dfrac{\bar{s}_{\textrm{air}}-\bar{s}_{i}}{\bar{c}_p} \right)\xi, \\[0.5ex]
 & \text{Heat addition:} & \xi & = 0, & \sigma & = T^\prime/\bar{T},
\end{align}
\end{fleqn}
\bigskip

\begin{fleqn}
\usetagform{a-b}
\begin{align}%\
 & \text{Gas injection:} & \xi &= Y_i, & &
 \eqmathbox[R]{\sigma = \left( \dfrac{\bar{s}_{\textrm{air}}-\bar{s}_{i}}{\bar{c}_p} \right)\xi}, \\[0.5ex]
 & \text{Heat addition:} & \xi &= 0, & & \eqmathbox[R]{\sigma = T^\prime/\bar{T},}
\end{align}
\end{fleqn}

\end{document} 

enter image description here

1
  • thanks for this suggestion!
    – jrjrjr
    Nov 1, 2019 at 0:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .