# flush text on the left and centre equation of the same line (not working!)

I want to have the "Mass" and "Momentum" text part aligned to the left side of the page (where you see 'steady' and 'version' from the previous paragraph), while keeping the equations on the same line and centered. I have tried using {align}, \llap, {aligned}, {flalign}, and none have worked properly. I want to label each equation within the {subequations} command to reference them so is used within each subequation.

\llap has managed to help me get the text to not interfere with the centering of the equations, but using \begin{flushleft}, \begin{flushright}, etc only give me errors. Here is my code:

\documentclass[a4paper,12pt,default,numbered,print,index]{article}
\usepackage{lipsum}
\usepackage{enumitem}
\usepackage{graphicx} % Required for the inclusion of images
\usepackage{setspace}        % for use of \singlespacing and \doublespacing
\usepackage{pdfpages}
\usepackage{cite}
\usepackage[section]{placeins}
\usepackage{comment}
\usepackage{hyperref}
\usepackage{siunitx}
\usepackage{color}
\usepackage{ragged2e}
\usepackage{esvect}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{lscape}
\usepackage{tabularx}
\usepackage{multirow}
\usepackage{array}
\usepackage{soul}
\usepackage{bm}
\usepackage{url}
\usepackage{xparse}

\begin{document}

We can simplify our analysis by assuming the flow is inviscid ($\tau_{i,j}$ = 0), an ideal gas ($p = \rho RT$), and calorically perfect ($c_p$, $c_v$ = constant). Thus, for a homogeneous, steady, uniform gas flow in a straight duct without heat conduction, the linearised governing equations can be written as:

\begin{subequations}
$$\label{eq:linear_EOM_vector_mass} \llap{\text{Mass}}\frac{\bar{D}\rho'}{Dt} + \bar{\rho}\nabla\cdot\boldsymbol{u}' = \mathbf{0}$$
$$\label{eq:linear_EOM_vector_mom} \llap{\text{Momentum}}\frac{\bar{D}\mathbf{u}'}{Dt} + \frac{1}{\bar{\rho}} \nabla p' = \mathbf{0}$$
\end{subequations}

\end{document}


I have also tried using \llap and adding on space myself (as seen below) but it's messy because each equation requires different spacings and it will never properly align:

\llap{\text{Momentum}\qquad\qquad\qquad\qquad\qquad\qquad\enspace}


Please let me know what to do! Thanks so much in advance.

EDIT #2: image for the two different alternatives given by helpful comments:

\documentclass[a4paper,12pt,default,numbered,print,index]{article}
\usepackage{lipsum}
\usepackage{enumitem}
\usepackage{graphicx} % Required for the inclusion of images
\usepackage{setspace}        % for use of \singlespacing and \doublespacing
\usepackage{pdfpages}
\usepackage{cite}
\usepackage[section]{placeins}
\usepackage{comment}
\usepackage{hyperref}
\usepackage{siunitx}
\usepackage{color}
\usepackage{ragged2e}
\usepackage{esvect}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{lscape}
\usepackage{tabularx}
\usepackage{multirow}
\usepackage{array}
\usepackage{soul}
\usepackage{bm}
\usepackage{url}
\usepackage{xparse}

\begin{document}

We can simplify our analysis by assuming the flow is inviscid ($\tau_{i,j}$ = 0), an ideal gas ($p = \rho RT$), and calorically perfect ($c_p$, $c_v$ = constant). Thus, for a homogeneous, steady, uniform gas flow in a straight duct without heat conduction, the linearised governing equations can be written as:

\begin{subequations}
\begin{flalign}
&    \rlap{Mass}     &
\frac{\bar{D}\rho'}{Dt} + \bar{\rho}\nabla\cdot\boldsymbol{u}'
& = \mathbf{0}  &   \label{eq:linear_EOM_vector_mass}\\
&    \rlap{Momentum} &
\frac{\bar{D}\mathbf{u}'}{Dt} + \frac{1}{\bar{\rho}} \nabla p'
& = \mathbf{0}  &   \label{eq:linear_EOM_vector_mom}\\
&    \rlap{Energy}     &
c_p\frac{\bar{D}}{Dt}(\bar{\rho}T' + \rho'\bar{T}) + \nabla \cdot     (\boldsymbol{u'}\bar{p} + \bar{\boldsymbol{u}}p')
& = \dot{q}'\bar{\rho} + \bar{\dot{q}}\rho'   &       \label{eq:linear_EOM_vector_energy}\\
&    \rlap{Entropy}     &
\frac{\bar{D}s'}{Dt}
& = \frac{\dot{q}'}{\bar{\rho}\bar{T}}  &       \label{eq:linear_EOM_vector_entropy}\\
&    \rlap{Vorticity}     &
\frac{\bar{D}\boldsymbol{\xi}'}{Dt}
& = \mathbf{0}  &   \label{eq:linear_EOM_vector_vorticity}
\end{flalign}
\end{subequations}

\begin{subequations}
\begin{flalign}
& \rlap{Mass} & & \frac{\bar{D}\rho'}{Dt} +     \bar{\rho}\nabla\cdot\boldsymbol{u}' = \mathbf{0} &     \label{eq:linear_EOM_vector_mass}\\
& \rlap{Momentum} & & \frac{\bar{D}\mathbf{u}'}{Dt} + \frac{1}{\bar{\rho}}     \nabla p' = \mathbf{0} & \label{eq:linear_EOM_vector_mom}\\
& \rlap{Energy} & & c_p\frac{\bar{D}}{Dt}(\bar{\rho}T' + \rho'\bar{T}) +     \nabla \cdot (\boldsymbol{u'}\bar{p} +\bar{\boldsymbol{u}}p') =     \dot{q}'\bar{\rho} + \bar{\dot{q}}\rho' & \label{eq:linear_EOM_vector_energy}\\
& \rlap{Entropy} & & \frac{\bar{D}s'}{Dt} = \frac{\dot{q}'}    {\bar{\rho}\bar{T}} & \label{eq:linear_EOM_vector_entropy}\\
& \rlap{Vorticity} & & \frac{\bar{D}\boldsymbol{\xi}'}{Dt} = \mathbf{0} &     \label{eq:linear_EOM_vector_vorticity}
\end{flalign}
\end{subequations}

\end{document}

• perhaps this helps: How can I add left aligned text to an equation? (possible duplicate) – barbara beeton Aug 15 '17 at 21:01
• Hi @barbara beeton, unfortunately this is not a duplicate. I saw that post, but I want the equations to be centered as well as have text aligned to the left, all in the same line. This hasn't been dealt with before unfortunately (at least according to my findings). – jrjrjr Aug 15 '17 at 21:58

Here are three possibilities; the first two are variants based on the flalign environment, with a different positioning of the equations w.r.t.the left margin text. The third possibility paves the texts aligned w.r.t. each other, at some distance from the equations. It's based on alignat:

\documentclass[a4paper, 12pt, default, numbered, print, index]{article}
\usepackage{mathtools}


\usepackage{eqparbox} \newcommand{\eqmathbox}2[M]{\eqmakebox[#1]{$\displaystyle#2$}}

\DeclareFontFamily{U}{mathx}{\hyphenchar\font45}
\DeclareFontShape{U}{mathx}{m}{n}{
<5><6><7><8><9><10>
<10.95><12><14.4><17.28><20.74><24.88>
mathx10
}{}
\DeclareSymbolFont{mathx}{U}{mathx}{m}{n}
\DeclareFontSubstitution{U}{mathx}{m}{n}
\DeclareMathAccent{\widebar}{0}{mathx}{"73}

\begin{document}

We can simplify our analysis by assuming the flow is inviscid ($\tau_{i,j}$ = 0), an ideal gas ($p = ρRT$), and calorically perfect ($c_p$, $c_v$ = constant). Thus, for a homogeneous, steady, uniform gas flow in a straight duct without heat conduction, the linearised governing equations can be written as:

\begin{subequations}
\begin{flalign}
\label{eq:linear_EOM_vector_mass}
& \rlap{Mass} & &\eqmathbox{\frac{\widebar{D}\rho'}{Dt} + \bar{ρ}∇ · \boldsymbol{u}' = \mathbf{0}} & \\[0.8ex]
\label{eq:linear_EOM_vector_mom}
& \rlap{Momentum} & &\eqmathbox{\frac{\widebar{D}\mathbf{u}'}{Dt} + \frac{1}{\bar{ρ}}
∇ p' = \mathbf{0}}
\end{flalign}
\end{subequations}

\begin{subequations}
\begin{flalign}
\label{eq:linear_EOM_vector_mass}
& \text{Mass} & & \frac{\widebar{D}\rho'}{Dt} + \bar{ρ}∇ · \boldsymbol{u}' = \mathbf{0} &\hspace{12em} \\[0.8ex]
\label{eq:linear_EOM_vector_mom}
& \text{Momentum} & & \frac{\widebar{D}\mathbf{u}'}{Dt} + \frac{1}{\bar{ρ}}
∇ p' = \mathbf{0}&&
\end{flalign}
\end{subequations}

\begin{subequations}
\begin{alignat}{2}
\label{eq:linear_EOM_vector_mass}
& \text{Mass} &\hspace{3em} &\frac{\widebar{D}\rho'}{Dt} + \bar{ρ}∇ · \boldsymbol{u}' = \mathbf{0} \\[0.8ex]
\label{eq:linear_EOM_vector_mom}
& \text{Momentum} & & \frac{\widebar{D}\mathbf{u}'}{Dt} + \frac{1}{\bar{ρ}}
∇ p' = \mathbf{0}
\end{alignat}
\end{subequations}

\end{document}


Edit: Here is how to adapt the first solution to the last version of the O.P.'s code (two variants):

\documentclass[a4paper,12pt,default,numbered,print,index]{article}
\usepackage{lipsum}
\usepackage{enumitem}
\usepackage{graphicx} % Required for the inclusion of images
\usepackage{setspace} % for use of \singlespacing and \doublespacing
\usepackage{pdfpages}
\usepackage{cite}
\usepackage[section]{placeins}
\usepackage{comment}
\usepackage{siunitx}
\usepackage{color}
\usepackage{ragged2e}
\usepackage{esvect}
\usepackage{mathtools}
\usepackage{lscape}
\usepackage{tabularx}
\usepackage{multirow}
\usepackage{array}
\usepackage{soul}
\usepackage{bm}
\usepackage{url}
\usepackage{xparse}
\usepackage{hyperref}
\newcommand{\myeqlabel}[1]{\rlap{\bfseries#1}}
\usepackage{eqparbox}
\newcommand{\eqmathbox}[2][M]{\eqmakebox[#1]{$\displaystyle#2$}}

\DeclareFontFamily{U}{mathx}{\hyphenchar\font45}
\DeclareFontShape{U}{mathx}{m}{n}{
<5><6><7><8><9><10>
<10.95><12><14.4><17.28><20.74><24.88>
mathx10
}{}
\DeclareSymbolFont{mathx}{U}{mathx}{m}{n}
\DeclareFontSubstitution{U}{mathx}{m}{n}
\DeclareMathAccent{\widebar}{0}{mathx}{"73}

\begin{document}

We can simplify our analysis by assuming the flow is inviscid ($\tau_{i,j} = 0$), an ideal gas ($p = \rho RT$), and calorically perfect ($c_p$, $c_v$ = constant). Thus, for a homogeneous, steady, uniform gas flow in a straight duct without heat conduction, the linearised governing equations can be written as:
\begin{subequations}
\begin{flalign}
& \myeqlabel{Mass} &&
\eqmathbox{\frac{\widebar{D}\rho'}{Dt} + \bar{\rho}\,\nabla\cdot\boldsymbol{u}'
= \mathbf{0}} & \label{eq:linear_EOM_vector_mass}\\
& \myeqlabel{Momentum} &&
\eqmathbox{\frac{\widebar{D}\mathbf{u}'}{Dt} + \frac{1}{\bar{\rho}} \nabla p'
= \mathbf{0}} & \label{eq:linear_EOM_vector_mom}\\
& \myeqlabel{Energy} &&
\eqmathbox{c_p\frac{\widebar{D}}{Dt}(\bar{\rho}\,T' + \rho'\widebar{T}) + \nabla \cdot (\boldsymbol{u'}\bar{p} + \bar{\boldsymbol{u}}p')
= \dot{q}'\bar{\rho} + \bar{\dot{q}}\rho' }& \label{eq:linear_EOM_vector_energy}\\
& \myeqlabel{Entropy} &&
\eqmathbox{\frac{\widebar{D}s'}{Dt}
= \frac{\dot{q}'}{\bar{\rho}\,\bar{T}}} & \label{eq:linear_EOM_vector_entropy}\\
& \myeqlabel{Vorticity} &&
\eqmathbox{\frac{\widebar{D}\boldsymbol{\xi}'}{Dt}
= \mathbf{0}} & \label{eq:linear_EOM_vector_vorticity}
\end{flalign}
\end{subequations}
\begin{subequations}
\begin{flalign}
& \myeqlabel{Mass} &&
\eqmathbox{\frac{\widebar{D}\rho'}{Dt} + \bar{\rho}\,\nabla\cdot\boldsymbol{u}'
= \mathbf{0}} & \label{eq:linear_EOM_vector_mass}\\
& \textbf{Momen\rlap{tum}} &&
\eqmathbox{\frac{\widebar{D}\mathbf{u}'}{Dt} + \frac{1}{\bar{\rho}} \nabla p'
= \mathbf{0}} & \label{eq:linear_EOM_vector_mom}\\
& \myeqlabel{Energy} &&
\eqmathbox{c_p\frac{\widebar{D}}{Dt}(\bar{\rho}\,T' + \rho'\widebar{T}) + \nabla \cdot (\boldsymbol{u'}\bar{p} + \bar{\boldsymbol{u}}p')
= \dot{q}'\bar{\rho} + \bar{\dot{q}}\rho' }& \label{eq:linear_EOM_vector_energy}\\
& \myeqlabel{Entropy} &&
\eqmathbox{\frac{\widebar{D}s'}{Dt}
= \frac{\dot{q}'}{\bar{\rho}\,\bar{T}}} & \label{eq:linear_EOM_vector_entropy}\\
& \myeqlabel{Vorticity} &&
\eqmathbox{\frac{\widebar{D}\boldsymbol{\xi}'}{Dt}
= \mathbf{0}} & \label{eq:linear_EOM_vector_vorticity}
\end{flalign}
\end{subequations}

\end{document}


• Thanks for your suggestions! I have removed amsmath and changed the location of hyperref. All your suggestion are nice, however, what I want is closer to your first, but where the equations are centered (i.e. they are not flushed with eachother at the start of the equation). Thanks again for your help! – jrjrjr Aug 15 '17 at 21:35
• Please see my edited code - would you know how to center the equations? Thanks! – jrjrjr Aug 15 '17 at 21:43
• I've modified the code: the first possibility uses the eqparbox package. I defined an \eqmathbox command with an optional argument (a tag, M by default) ; its contents is typeset in mathmode, centred in the box, and all boxes with the same tag have the width of the largest contents. In addition, I defined an extensible \widebar command, stolen from mathabx, which looks better than bar with capital letters. – Bernard Aug 15 '17 at 22:08
• Hi @Bernard. Thanks again for your efforts. As mentioned to Zarko a few minutes ago, my issue right now is centering the equations with respect to the text above. They are centered with respect to the box they are in, but not with the text (i.e. shifted to the right of the page a bit). If you know how to solve that, please let me know! – jrjrjr Aug 15 '17 at 22:12
• I think replacing \text{...} with \rlap{...} does the trick: it makes the first column have 0 width. See the updated answer (I only touched upon the first solution) – Bernard Aug 15 '17 at 22:32

Like this?

with use of flalign:

\documentclass[a4paper,12pt,default,numbered,print,index]{article}
\usepackage{lipsum}
\usepackage{mathtools}

\begin{document}

\lipsum[11]

\begin{subequations}
\begin{flalign}
&    \text{Mass}     &
\frac{\bar{D}\rho'}{Dt} + \bar{\rho}\nabla\cdot\boldsymbol{u}'
& = \mathbf{0}  &   \label{eq:linear_EOM_vector_mass}\\
&    \text{Momentum} &
\frac{\bar{D}\mathbf{u}'}{Dt} + \frac{1}{\bar{\rho}} \nabla p'
& = \mathbf{0}  &   \label{eq:linear_EOM_vector_mom}
\end{flalign}
\end{subequations}

\end{document}


Note: mathtools load amsmath therefore is sufficient to load only it.

\documentclass[a4paper,12pt,default,numbered,print,index]{article}
\usepackage{lipsum}
\usepackage{mathtools}
\usepackage{tabularx}
\renewcommand\tabularxcolumn[1]{m{#1}}

\begin{document}

\lipsum[11]

\begin{subequations}
\begin{center}
\begin{tabularx}{\linewidth}{lX}
Mass            &
$$\label{eq:linear_EOM_vector_mass} \frac{\bar{D}\rho'}{Dt} + \bar{\rho}\nabla\cdot\boldsymbol{u}' = \mathbf{0}$$          \\
Momentum        &
$$\label{eq:linear_EOM_vector_mom} \frac{\bar{D}\mathbf{u}'}{Dt} + \frac{1}{\bar{\rho}} \nabla p' = \mathbf{0}$$          \\
Energy          &
$$\label{eq:linear_EOM_vector_energy} c_p\frac{\bar{D}}{Dt}(\bar{\rho}T' + \rho'\bar{T}) + \nabla \cdot (\boldsymbol{u'}\bar{p} + \bar{\boldsymbol{u}}p') = \dot{q}'\bar{\rho} + \bar{\dot{q}}\rho'$$
\end{tabularx}
\end{center}
\end{subequations}

\end{document}


• Thanks, Zarko for your comment! Very close to what I want! I want the beginning of the text to start flushed left. The Momentum line seems to do it (?) but not the Mass line... – jrjrjr Aug 15 '17 at 21:08
• Also, you removed the equation labels - how can I reference each equation individually via this method? – jrjrjr Aug 15 '17 at 21:08
• sorry, i overlooked the desired position. now corrected. i didn't remove labels, only place them to right place. – Zarko Aug 15 '17 at 21:11
• sorry, clearly I just breezed through your code and missed the label. Will try this now and get back to you in a minute. Thanks! – jrjrjr Aug 15 '17 at 21:12
• Please see the edit! Worked ok when I had the two initial equations, but when I added the longer one it messed things up and none of the 5 seems correctly centered? How can this be fixed? – jrjrjr Aug 15 '17 at 21:32

You may want to use flalign. In the example I removed all unnecessary packages (add the ones you need, but take note that hyperref should be loaded last). There should be no blank line between the text and the display.

\documentclass[a4paper,12pt]{article}
\usepackage{amsmath}

\begin{document}

We can simplify our analysis by assuming the flow is
inviscid ($\tau_{i,j}$ = 0), an ideal gas ($p = \rho RT$),
and calorically perfect ($c_p$, $c_v$ = constant). Thus,
for a homogeneous, steady, uniform gas flow in a straight
duct without heat conduction, the linearised governing
equations can be written as:
\begin{subequations}
\begin{flalign}
\label{eq:linear_EOM_vector_mass}
&\text{Mass}
&&\frac{\bar{D}\rho'}{Dt} + \bar{\rho}\nabla\cdot\boldsymbol{u}' = \mathbf{0}
&
\\[1ex]
\label{eq:linear_EOM_vector_mom}
&\text{Momentum}
&&\frac{\bar{D}\mathbf{u}'}{Dt} + \frac{1}{\bar{\rho}} \nabla p' = \mathbf{0}
&
\end{flalign}
\end{subequations}

\end{document}


On the other hand, I see no reason for the labels to be flush left:

\documentclass[a4paper,12pt]{article}
\usepackage{amsmath}
\usepackage{calc}

\begin{document}

We can simplify our analysis by assuming the flow is
inviscid ($\tau_{i,j}$ = 0), an ideal gas ($p = \rho RT$),
and calorically perfect ($c_p$, $c_v$ = constant). Thus,
for a homogeneous, steady, uniform gas flow in a straight
duct without heat conduction, the linearised governing
equations can be written as:
\begin{subequations}
\begin{alignat}{2}
\label{eq:linear_EOM_vector_mass}
&\makebox[0pt][r]{\makebox[\widthof{Momentum}][l]{Mass}}