2

I am new to LaTeX and I am having trouble with \text and line breaks.

My code is as such

$$\text{if} y^{(t)} \neq h(x; \theta, \theta_{0}) \text{then} \\ 
\theta^{(k+1)} = \theta^{k}+ y^{(t)}*x^{(t)}\\ 
\theta_{0} = \theta_{0}^{(k+1)}  + y^{(t)}$$

When I try to compile in TexWorks I get an error, then when I take out the \text parts it compiles but without the line breaks.

If any one could explain these two occurrences it would be greatly appreciated,

Thanks.

1
  • 4
    $$ should not be used in latex, for single line equations use \[ \] or multiline use amsmath package and one of its environments such as align Jun 30, 2014 at 19:18

1 Answer 1

4

You need amsmath package. gather is only an example of splitting. Choosing the proper one depends on the desired effect, in particular, the starred version omits equation numbering.

\documentclass{article}

\usepackage{amsmath}
\begin{document}

%$$
\begin{gather}
\text{if } y^{(t)} \neq h(x; \theta, \theta_{0}) \text{ then} \\ 
\theta^{(k+1)} = \theta^{k}+ y^{(t)}*x^{(t)}\\ 
\theta_{0} = \theta_{0}^{(k+1)}  + y^{(t)}
\end{gather}
%$$
\end{document}

enter image description here

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .