# Aligning equation such that second line is more to the left than the first line

My goal is to reproduce the following math snippet:

As you can see, the equal sign in the second line comes before the first character (from left to right) in the first line. I am not able to reproduce this. I neglected the bold letter style and tried

\documentclass{article}

\usepackage{mathtools}
\usepackage{amsfonts}
\DeclareMathOperator{\ReLU}{ReLU}
\newcommand*{\R}{\mathbb{R}}
\begin{document}

\begin{align*}
\{(Wv)^T \ReLU(Wv \cdot - b): W \in \R^{p \times d}, b \in \R^p\} \\
= \left\{\sum_{i=1}^p  w_i\ReLU(w_i \cdot -b_i): w_i, b_i \in \R \right\}
\end{align*}

\end{document}


to derive

Any suggestions are welcomed!

• please post source that produces the output shown, not fragments with undefined commnds, but use & at start of line 1 and ={}& on line 2 Aug 20, 2023 at 16:21

You've forgotten to use &, e.g.

\documentclass{article}

\usepackage{mathtools}
\usepackage{amsfonts}
\DeclareMathOperator{\ReLU}{ReLU}
\newcommand*{\R}{\mathbb{R}}
\begin{document}
\begin{align*}
& \{(Wv)^T \ReLU(Wv \cdot - b): W \in \R^{p \times d}, b \in \R^p\} \\
= & \left\{\sum_{i=1}^p  w_i\ReLU(w_i \cdot -b_i): w_i, b_i \in \R \right\}
\end{align*}

\end{document}


or

\documentclass{article}

\usepackage{mathtools}
\usepackage{amsfonts}
\DeclareMathOperator{\ReLU}{ReLU}
\newcommand*{\R}{\mathbb{R}}
\begin{document}
\begin{align*}
& \; \{(Wv)^T \ReLU(Wv \cdot - b): W \in \R^{p \times d}, b \in \R^p\} \\
= & \left\{\sum_{i=1}^p  w_i\ReLU(w_i \cdot -b_i): w_i, b_i \in \R \right\}
\end{align*}

\end{document}


• ={}& for spacing Aug 20, 2023 at 16:22
• @DavidCarlisle Tested, but don't see a real difference to the first example. IMHO the second one is better. But this could depend on the used fonts. Aug 20, 2023 at 16:26
• To more accurately reproduce the OP's target screenshot, you may want to replace \left\{ and \right\} in row 2 with \biggl\{ and \biggr\}.
– Mico
Aug 20, 2023 at 16:38
• I prefer the second answer. Thanks!
– Pazu
Aug 20, 2023 at 16:39

I'd not do that way, but…

\documentclass{article}

\usepackage{mathtools}
\usepackage{amsfonts}

\DeclareMathOperator{\ReLU}{ReLU}
\newcommand*{\R}{\mathbb{R}}

\begin{document}

With the desired alignment
\begin{align*}
&    \{(Wv)^T \ReLU(Wv \cdot - b): W \in \R^{p \times d}, b \in \R^p\}
\\
={}& \biggl\{\,\sum_{i=1}^p  w_i\ReLU(w_i \cdot -b_i): w_i, b_i \in \R \biggr\}
\end{align*}
but it would be better to use \texttt{multline}
\begin{multline*}
\{(Wv)^T \ReLU(Wv \cdot - b): W \in \R^{p \times d}, b \in \R^p\}
\\
= \biggl\{\,\sum_{i=1}^p  w_i\ReLU(w_i \cdot -b_i): w_i, b_i \in \R \biggr\}
\end{multline*}
or a different version of \texttt{align}
\begin{align*}
& \{(Wv)^T \ReLU(Wv \cdot - b): W \in \R^{p \times d}, b \in \R^p\}
\\

Note \bigg instead of autosizing braces (they tend to be too big) and \, to avoid the clash with the subscript.