# Problem with compiling code on Sharelatex

Here is the rather complicated input that will not compile for me in Sharelatex. ShareLatex simply will not compile it within my project. I am looking for help with restructuring the code and appreciate any advice you can offer.

 F_{\bar{X}_i}(x) = \left.

\begin{cases}
0,          & \text{if } x<0,\\
1+e^{rT}\frac{C_i[K_{i,j+1}]-C_i[K_{i,j}{K_{i,j+1}-K_{i,j}},  & \text{if } K_{i,j} \leq x \leq K_{i,j+1}, j=-l_i,\dots,h_{i}+1\\
1,              & \text{if } x \geq K_{i,h_{i}+1}.
\end{cases}
\right.
\end{displaystyle}

F_{\bar{X}_i}(x) =
$\begin{cases} 0, & \text{if } x<0,\\ 1+e^{rT}\frac{C_i[K_{i,j+1}]-C_i[K_{i,j}{K_{i,j+1}-K_{i,j}}, & \text{if } K_{i,j} \leq x \leq K_{i,j+1}, j=-l_i,\dots,h_{i}+1\\ 1, & \text{if } x \geq K_{i,h_{i}+1}. \end{cases}$

• i don't know about sharelatex, but the $...$ within the equation environment are not valid, and would result in error messages in a non-sharelatex compilation. also, blank lines within any math environment are illegal. there are some other suspicious elements, but your example contains incomplete environments, so it's difficult to say more. – barbara beeton May 27 '16 at 15:12
• Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. – Holene May 27 '16 at 16:05
• Thank you Holene! I should have really researched the guidelines before I submitted my first post. – Barry Coleman May 30 '16 at 9:07

Looks like you had the same equation twice, so I only included one below. There are several things that were wrong, some mentioned by Barbara in the comment above:

• You were missing one closing brace in the \frac, that is you had \frac{...{...}, where it should have been \frac{...}{...}
• The \left. and \right. in the first should be removed. I guess it's a remnant from having used an array or something with \left\{ instead of cases.
• There is no in the first case, but you have both \end{displaymath} and . You only need one display math environment, so use either displaymath if you want an unnumbered equation (or the short form $...$), or equation if you want a numbered equation.
• There is no in the second case.
• Empty lines are not allowed in displayed math environments.
• When you are inside a math environment like $$..$$, don't use other math environments such as $..$.
• Looks like there was also a ] missing in the fraction in the second case, but that wouldn't produce any errors.
• The equation is a bit too wide for a standard article, but as I don't know what kind of page setup you have, I haven't tried doing anything about it.

\documentclass{article}
\usepackage{amsmath}
\begin{document}

$$F_{\bar{X}_i}(x) = \begin{cases} 0, & \text{if } x<0,\\ 1+e^{rT} \frac{ C_i[K_{i,j+1}]-C_i[K_{i,j}] }{ K_{i,j+1}-K_{i,j} }, & \text{if } K_{i,j} \leq x \leq K_{i,j+1}, j=-l_i,\dots,h_{i}+1\\ 1, & \text{if } x \geq K_{i,h_{i}+1}. \end{cases}$$
\end{document}

• Thank you so much @torbjørn-t. Great answer to a poorly structured question. – Barry Coleman May 30 '16 at 9:21