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,


  • 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 – David Carlisle Jun 30 '14 at 19:18

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.



\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)}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.