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 have an odd problem, I tried already all possible things, align, eqnarray, $, \[ \] and so on, but the following stays the same: I have a formula inside text and it is not broken, so it goes into the right margin, how can I say LaTeX it should do a linebreak?

Here's the code:

\documentclass{book}
\usepackage{geometry}
\geometry{left=4cm,right=3cm, top=2cm, bottom=2cm} 
\usepackage[pagestyles]{titlesec}
\titlespacing*{\chapter}{0pt}{-30pt}{20pt}
\titleformat{\chapter}[display]{\color{headercolor}\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter}{20pt}{\Huge}


\usepackage[ngerman]{babel}
\usepackage{mathptmx}
\usepackage{helvet}
\usepackage{wallpaper}
\usepackage{color}
\usepackage[final]{pdfpages} 
%,bookmarksopenlevel={1}
%\usepackage[hidelinks,bookmarks=true,bookmarksopen=true,bookmarksnumbered=true,colorlinks=true,linkcolor=black,]{hyperref}
\usepackage[hidelinks,bookmarksopen=false,
hypertexnames=TRUE,pdfpagelabels=true]{hyperref}[2011/02/05]%colorlinks,linkcolor=black,
\hypersetup{ 
  pdftitle={},
%  pdfauthor={\textcopyright },
  pdfsubject={statistics Buch}, 
  pdfkeywords={}, 
  }

\usepackage{xcolor,bookmark}
\usepackage{scrextend}
\usepackage{titlepic}
\usepackage{shorttoc}
\usepackage{courier}
\usepackage{type1cm}         
\usepackage{zref-abspage}
\usepackage{graphicx}                       
\usepackage{multicol}        
\usepackage[bottom]{footmisc}
\usepackage{tocstyle}
\usetocstyle{allwithdot} 
%\usepackage{thmbox}
\usepackage{shadethm}
\usepackage{amsthm}
\usepackage{amsmath}
\usepackage{marginnote}
%\usetocstyle{KOMAlike}
\usepackage{wrapfig}
\usepackage{paralist}
\usepackage{amssymb}
\usepackage[framemethod=tikz]{mdframed}
\usepackage{ulem}
\usepackage{fancyhdr}


\begin{document}

\pagenumbering{arabic}  
%

%\pagestyle{mystyle}
\mainmatter
\section{text text}
text\\text a lot of text\\ and then the problem with the formula:\\
Die $x_i$ sind die Zuwachsraten, ingesamt haben wir 4 Jahre, es ergibt sich also \begin{eqnarray*}\bar{x}_{Geom}=\sqrt[4]{\prod \limits_{i=1}^{4} x_i}=\sqrt[4]{1,01*1,024*0,987*1,034 }=(1,01*1,024*0,987*1,034 )^{\frac{1}{4}}=1,0135957\end{eqnarray*} Wir machen die Probe: \\ and so on\\
\end{document}

Heres a screenshot:

enter image description here

Any ideas?

share|improve this question
add comment

2 Answers

(La)TeX does not break lines automatically within math mode like it does in text mode for paragraphs. You need to introduce this line break manually, or provide support for this line-breaking via something like breqn.

In the example below, I've used amsmath's align* which allows the introduction of a line-break via \\:

enter image description here

\documentclass{article}
\usepackage{amsmath}% http://ctan.org/pkg/amsmath
\begin{document}
\section{text text}
Die~$x_i$ sind die Zuwachsraten, ingesamt haben wir 4 Jahre, es ergibt sich also
\begin{align*}
  \bar{x}_{\text{Geom}} &= \sqrt[4]{\prod_{i=1}^{4} x_i} \\
    &= \sqrt[4]{1.01 \times 1.024 \times 0.987 \times 1,034} \\
    &= (1.01 \times 1.024 \times 0.987 \times 1.034)^{\frac{1}{4}} \\
    &= 1.0135957
\end{align*}
Wir machen die Probe: \ldots
\end{document}

Also note the use of . as a decimal separator, which provides a different spacing than that of ,. If you wish to use the latter, you need to introduce some way of compensating for the different notation. Either icomma or siunitx may be of help here.

share|improve this answer
    
ok, thanks a lot, but do I have to use \times or is * also ok? I want to use the comma, because I have the dot as a marker for "thousand" –  Heronimious Sep 5 '12 at 12:47
    
how I can I implement this? Just say \usepackage{icomma} in the preamble or do I have to write also something else? Thanks a lot! –  Heronimious Sep 5 '12 at 12:49
    
I would use siunitx and its \num command, it can be told to use comma as the decimal marker and it can separate numbers in thousands such that you don't need to. And yes I would write \times or \cdot, it looks a lot more professionel. –  daleif Sep 5 '12 at 12:54
add comment

LaTeX does not do automatic line breaking of displayed formuals (as it is very hard to teach a computer that is good practice in this case, there are other rules at play here than what applies to text-mode math). You need to introduce a manual line break via \\

An please forget you ever head of eqnarray it is a broken construction, see http://tug.org/TUGboat/tb33-1/tb103madsen.pdf

and stop using \\ in the text, that road does not lead to anywhere pleasant.

share|improve this answer
add comment

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.