5

I know there are lots of questions out there about "left align using alignat". But so far I haven't figured out a solution to this. I am using \begin{alignat}{2} and want to make a piece of \text{..} left-aligned (i.e. flush with the left hand margin) but keep the rest of the equation centered. How can I achieve this?

enter image description here

MWE

\documentclass[12pt]{report}
\usepackage[margin=4cm,showframe]{geometry}
\usepackage{mathtools}
\usepackage{newtxtext}

\begin{document}

\begin{alignat}{2}
a_1 &= b_1 &&= c_1 
\\
\text{and} a_{111} &= b_{111} &&= c_{111}.
\end{alignat}

\end{document}

UPDATE

I understand that using either \intertext or \shortintertext are options, but, I have lots of other equations written using flalign for which I am able to get "and" on the same line. So I was hoping I could keep the formatting consistent.

Milo
  • 9,440

3 Answers3

4

with flalign and some manual tweaking using \hphantom:

\documentclass[12pt]{report}
\usepackage[margin=4cm,showframe]{geometry}
\usepackage{mathtools}
\usepackage{newtxtext}

\begin{document}
\begin{flalign}
            && a_1       &= b_{1\hphantom{11}} = c_1      &    \\
\text{and}  && a_{111}   &= b_{111}            = c_{111}. &
\end{flalign}
\end{document}

enter image description here

Zarko
  • 296,517
  • I'm upvoting because your answer is clearly superior to my own. Bravo! – Steven B. Segletes Jun 13 '18 at 16:55
  • @StevenB.Segletes, thank you very much. i liked your second example (+1). – Zarko Jun 13 '18 at 17:04
  • @Zarko Thanks, this is indeed a very neat solution to this specific problem. But... unfortunately, the equations I am dealing with on the two different lines are very unrelated to each other. b_1 and b_{111} are conveniently very similar to each other. Maybe my mistake for choosing a very simple MWE ;) – Milo Jun 13 '18 at 18:33
4

Three other possibilities, with flalign + alignedat, or with fleqn (from nccmath) + align + \makebox* (from makebox):

\documentclass[12pt]{report}
\usepackage[margin=4cm,showframe]{geometry}
\usepackage{mathtools, nccmath}
\usepackage{makebox}
\usepackage{newtxtext}

\begin{document}

\begin{flalign}
 & \text{and} &&\begin{alignedat}[b]{2} a_1 &= b_{1} & & = c_1 \\
 a_{111} &= b_{111} & & = c_{111}.
\end{alignedat} & &
\end{flalign}
\vskip 3ex
\begin{fleqn}
\begin{align}
&& a_1 &= \makebox*{$b_{111}$}[l]{$ b_{1} $} = c_1 \\
 & \text{and} & a_{111} &= b_{111} = c_{111}.
\end{align}
\end{fleqn}
\vskip 3ex
\begin{fleqn}
\begin{align}
&& a_1 &= \makebox*{$b_{111}$}[l]{$ b_{1} $} = c_1 & & \\
 & \text{and} & a_{111} &= b_{111} = c_{111}. & &
\end{align}
\end{fleqn}

\end{document} 

enter image description here

Bernard
  • 271,350
3

The problem is that this approach needs to be manually tuned. It uses added negative space with the \\[-33pt] and then applies a \smashed version of \intertext which itself has been lowered.

EDITED to put the shenanigans in a \vbox, so that it becomes immune to vertical compression based on page density. Note, however, that the \vbox will now cause spacing before and after the equations to be different, as well, though perhaps one can find a compromise.

\documentclass[12pt]{report}
\usepackage[margin=4cm,showframe]{geometry}
\usepackage{mathtools}
\usepackage{newtxtext}
\begin{document}
Leading text
\\\vbox{\begin{alignat}{2}
a_1 &= b_1 &&= c_1 
\\[-33pt]
\intertext{\smash{\raisebox{-27pt}{and}}} 
a_{111} &= b_{111} &&= c_{111}.
\end{alignat}}
trailing text
\end{document}

enter image description here

Here is a stackengine alternative that only makes you guess a single number to match the line:

\documentclass[12pt]{report}
\usepackage[margin=4cm,showframe]{geometry}
\usepackage{mathtools}
\usepackage{newtxtext}
\usepackage{stackengine}
\begin{document}
Leading text\\
\setbox0=\vbox{\begin{alignat}{2}
a_1 &= b_1 &&= c_1 
\\
a_{111} &= b_{111} &&= c_{111}.
\end{alignat}}
\noindent\stackengine{17pt}{\box0}{\makebox[\textwidth][l]{and}}{O}{c}{F}{F}{L}
trailing text
\end{document}

Of course, the more probable advice you will get is to just use \intertext in the normally prescribed way:

\documentclass[12pt]{report}
\usepackage[margin=4cm,showframe]{geometry}
\usepackage{mathtools}
\usepackage{newtxtext}

\begin{document}

\begin{alignat}{2}
a_1 &= b_1 &&= c_1 
\\
\intertext{and}
a_{111} &= b_{111} &&= c_{111}.
\end{alignat}

\end{document}

enter image description here

  • Thanks. The manual method does work I guess, but it doesn't play well when the linespacing is adjusted. Maybe I will have to compromise. – Milo Jun 13 '18 at 15:39
  • 1
    @Milo You can preclude the linespacing change by putting the alignat in a \vbox, though this will naturally change other things. See my edit. – Steven B. Segletes Jun 13 '18 at 16:44