You can split the long condition into three lines.
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation}
r(b_{i,t}^C,p_{\mathrm{market},t})=
\begin{cases}
-(b_{i,t}^C - p_{\mathrm{market},t})^2,
& \text{if } b_{i,t}^C > p_{\mathrm{market},t} \\[2ex]
-(b_{i,t}^C - p_{\mathrm{grid}})^2,
& \text{if } b_{i,t}^C < p_{\mathrm{market},t} \\[2ex]
\frac{p_{\mathrm{market},t}}{100} + \theta,
& \text{if } b_{i,t}^C = p_{\mathrm{market},t} \\[2ex]
\frac{p_{\mathrm{market},t}}{100} + 2\theta,
& \begin{aligned}[t]
&\text{if } b_{i,t}^C = p_{\mathrm{market},t} \text{ and} \\
&b_{i,t}^C < \min(b_{i,t-j}^C,\dots, b_{i,t-1}^C) \\
&\mid b_{i,t-j}^C=p_{\mathrm{market},t-j}
\end{aligned}
\end{cases}
\end{equation}
\end{document}
Note \mathrm{market}
, \mathrm{grid}
, \dots
and \min
.
Best Answer
You should never use
$$
in LaTeX. Well, there are rare situations in which$$...$$
can be useful, but they're very special.Why do you get the error?
When TeX is typesetting a horizontal box, which is part of the work of
\resizebox
, display math mode is not allowed and therefore$$
just denotes an empty math formula. Hence, in your case,aligned
is found outside of math mode, which is illegal and the error message tells you exactly this.You should use
$...$
instead. Well, assuming you really want to do that.Is
aligned
necessary?Not at all: you need
aligned
to make multiline displays, but you have just one (very long) line. The only thingaligned
does is to add additional space between the second and third formulas.Why
0.999\columnwidth
? Because the various roundings lead to a width of 229.50241pt, whereas the column width is just 229.5pt, so you get two lines. Here's the output:Can you see the difference in the spaces? If you remove
\begin{aligned}
and&
, you getWhy? Because
aligned
adds space after even numbered columns.Why not doing a full display?