# code for NLP formula in latex

how to write the following conditional equation by latex , I tried the following code but it not work

\begin{align}
T_{P_i} = \begin{cases} 1 & \text{,T $\leq$ 1} \\
1+ \beta T & \text{,T$>$ 1} \end{cases}
in which T_{P_i} = \begin{cases} T_{now}-T_{last} & \text{,T_{last} $\neq$ NULL} \\
T_{now}-T_{update} & \text{,T_{last} = NULL}  \end{cases}
\end{align}


There are some errors that I see in your code. Mainly, the use of subscripts inside \text{}. And also some things that might look better written in a different way. This code produces something similar to your image.

\begin{equation*}
T_{i} = \begin{cases}
1, & \text{T $\leq$ 1}\\
1+ \beta T, & \text{T$>$ 1} \end{cases},
\text{ in which } T =
\begin{cases}
T_{now}-T_{last}, & T_{last} \neq NULL \\
T_{now}-T_{update}, & T_{last} = NULL
\end{cases}
\end{equation*}


If you need it inside the align environment, you can change of course, the \begin{equation*} and \end{equation*} to \begin{align} and \end{align}.

If you want to know a bit more why your code does or doesn't work, or about my code, just let me know.

The following code produces the result you're after. I find it best not to try to make the various components line up in your tex editor as they would on the page because adjusting the zoom ruins it anyway.

\begin{document}
$$T(i) = \begin{cases} 1, T \geq 1\\1 + \beta T, T > 1 \end{cases}\emph{, in which } T = \begin{cases}T_{now}- T_{last}, T_{last} \neq NULL\\T_{now}-T_{update}, T_{last} \neq NULL\end{cases}$$
\end{document}


I more prefer the following result:

which is produced by

\documentclass{article}
\usepackage{amsmath}

\begin{document}
$T_{i} = \begin{cases} 1 , & T \leq 1\\ 1+ \beta T, & T > 1 \end{cases}, \text{ in which } T = \begin{cases} T_{\mathrm{now}}-T_{\mathrm{last}}, & T_{\mathrm{last}} \neq \mathrm{NULL} \\ T_{\mathrm{now}}-T_{\mathrm{update}}, & T_{\mathrm{last}} = \mathrm{NULL} \end{cases}$
\end{document}