1

I have the following code:

\begin{align*}
  \varphi = & \{ ... \} \\
       \cup & \{ ... \} 
\end{align*}

In the output, there is no whitespace between = and { as well as between \cup How can I fix this?

For now I just put \text{ } but I think this is not a good solution.

Edit: I want to align the lines at the "{" symbol.

  • The & should be on the left side of the alignment symbol, i.e. &=. – Torbjørn T. Jul 22 at 17:19
  • i want the lines to align at the "{" – T_01 Jul 22 at 17:20
  • 2
    Use ={}& in the first line and {}\cup{} in the second line. – egreg Jul 22 at 17:28
  • @egreg i think i did not understand exactly what you mean – T_01 Jul 22 at 17:29
3

Use ={} and {}\cup{} in order to get the right spacing.

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{equation*}
\begin{aligned}
  \varphi ={} & \{ ... \} \\
     {}\cup{} & \{ ... \}
\end{aligned}
\end{equation*}

\end{document}

I used aligned which is conceptually better, but also a single align* could go (there are some slight differences, though).

enter image description here

Where's the problem? TeX adds spacing around relation and operation symbols based on what they have in front and after. Each cell of an alignment forms a formula on its own. Thus you get

\varphi “thick space” =

in the first line, but no space around the \cup symbol in the second line, because it has nothing fore and aft. By adding empty objects, the correct spacing is restored.

Exception: in the even numbered columns of an align or aligned an initial {} is implicitly added. This is how x &= y gets the correct spacing.

  • okay that works, thank you. But why is it like this? Is the {}..{} a kind of hack? Why does latex fail to put the whitespaces whitout that? – T_01 Jul 22 at 17:50
  • 1
    @T_01 I added some comments. – egreg Jul 22 at 17:58
  • So this apply to equations that have and \implies (or \iff)? Because these symbols have space around. Or should we use its alternative, namely \Longrightarrow, \Longleftarrow etc? – manooooh Jul 23 at 5:24
  • @manooooh Simply don’t use those spaced symbols in such a context – egreg Jul 23 at 7:05
  • why we should not use them? how to write such things else? – T_01 Aug 26 at 19:00
1

I wondered whether you might be interested by this different layout (unless I misunderstand what you're after):

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

\begin{document}

\begin{align*}
  \varphi = {}&\eqmathbox{\{ ... \}} \\[-1ex]
 & \eqmathbox{\cup} \\[-1.5ex]
       & \{ ... \}
\end{align*}

\end{document} 

enter image description here

  • I was not, but this is good to know. Thank you. – T_01 Jul 22 at 18:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.