# Spacing in flalign affected by mathpazo

I got the following (partly shorted) equation:

I would like to get rid of the space left of the equation (left of Q') so that the label (0.2) fits on the right side.

\documentclass[
a4paper,
12pt,
parskip=half
]{scrbook}
\usepackage[showframe]{geometry}
\usepackage{amsmath}

\newcommand*{\op}[1]{\mathrm{#1}}

\begin{document}
\begin{align}
Q'&(s,x) \nonumber\\
&\mid s=(f,r)() \wedge x=\mathcal{E}(r) &&= [\mathcal{E}(f())]\\
&\mid s=(f,r)(q_1,...,q_z) &&= \left[\mathcal{E}(f(p_1,...,p_z)) \middle\vert
\begin{aligned}
&x' = \op{split}(x,r(q_1,...,q_z)),\\
&(x_1,...,x_z) \in x',\\
&p_i \in Q'(q_i,x_i),1 \leq i \leq z
\end{aligned}
\right]
\end{align}
\end{document}


Using flalign:

Using flalign and \usepackage{mathpazo}:

\documentclass[
a4paper,
12pt,
parskip=half,
]{scrbook}
\usepackage[showframe]{geometry}
\usepackage{amsmath}
\usepackage{mathpazo}

\newcommand*{\op}[1]{\mathrm{#1}}

\begin{document}
\begin{flalign}
Q'&(s,x) \nonumber\\
&\mid s=(f,r)() \wedge x=\mathcal{E}(r) &&= [\mathcal{E}(f())]\\
&\mid s=(f,r)(q_1,...,q_z) &&= \left[\mathcal{E}(f(p_1,...,p_z)) \middle\vert
\begin{aligned}
&x' = \op{split}(x,r(q_1,...,q_z)),\\
&(x_1,...,x_z) \in x',\\
&p_i \in Q'(q_i,x_i),1 \leq i \leq z
\end{aligned}
\right] \label{eq:q'_fr}
\end{flalign}
\end{document}


While flalign solves the problem, mathpazo seems to distort the alignment in the middle of the equation. Why is that?

-
Using flalign environment should do what you desire. –  Peter Grill Mar 6 '13 at 21:12
Consider reading section 25 align environments (p 43 onward) of Herbert's mathmode document. It has a number of examples of use of align and friends environments. –  Werner Mar 6 '13 at 21:24
Hmm, flalign really worked :) Thanks both of you! –  neo Mar 6 '13 at 21:26
You mention in a deleted comment "And I don't really want to get rid of the space left of the aligned =s." Why is that? To be blunt, "it don't look nice." –  Werner Mar 6 '13 at 21:26
Because this should model the guard notation of programming languages like Haskell and the right = has a different meaning then the left. It's basically a case environment in reverse. –  neo Mar 6 '13 at 21:27

You can do it by trial and error like this:

\documentclass[
a4paper,
12pt,
]{scrbook}
\usepackage[showframe]{geometry}
\usepackage{amsmath,mathtools}
\usepackage{mleftright}
%\usepackage{mathpazo}

\newcommand*{\op}[1]{\operatorname{#1}}

\begin{document}
\begin{alignat}{2}
\mathmakebox[.5em][r]{Q'}
&(s,x) \nonumber\\
&{\mid}\; s=(f,r)() \wedge x=\mathcal{E}(r)
&&= [\mathcal{E}(f())]
\\
&{\mid}\; s=(f,r)(q_1,\dots,q_z)
&&=
\mleft[
\mathcal{E}(f(p_1,\dots,p_z))
\middle\vert
\begin{aligned}
&x' = \op{split}(x,r(q_1,\dots,q_z)),\\
&(x_1,\dots,x_z) \in x',\\
&p_i \in Q'(q_i,x_i),1 \leq i \leq z
\end{aligned}
\mright]
\end{alignat}
\end{document}


However, this will probably break badly when you either change fonts or page parameters. For instance, the normal page parameters you get without calling geometry will not pose unsurmountable problems, because the text width would be larger. On the contrary, with mathpazo the average width of the glyphs is bigger than Computer Modern's, so the trick won't work and the display simply won't fit.

Here's the example. In such tough cases some manual adjusting is almost always needed.

The very same code with mathpazo; if you look at the result you'll see that the material won't fit no matter how you push left the first "Q".

Again, the same code (but with simply Q' instead of \mathmakebox[.5em][r]{Q'}, without leaving control to geometry:

Just to show how page parameters can influence the final result, here's what I get without leaving control to geometry with your original input:

-
Hmm, to be honest, it's not really satisfying to do stuff like that... I mean, in my eyes, the real problem is: Why isn't align clever enough to make the middle space before the equal signs smaller so that everything fits? –  neo Mar 7 '13 at 20:11