Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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 occurences it would be greatly appreciated,

Thanks.

share|improve this question
3  
$$ 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 at 19:18

1 Answer 1

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

share|improve this answer
    
Thanks, this fixed the problem!! –  Aaron B Jun 30 at 21:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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