# Some text lines are italicized with no spaces between words

Some lines in my document are italicized, with no spaces between words, and continue after the edge of the document. The rest of the document is fine. Here is the beginning:

\documentclass[runningheads]{llncs}
\usepackage{graphicx}
\usepackage{float}
\usepackage{tikz}
\usetikzlibrary{arrows}
\usepackage[explicit]{titlesec}
\usepackage{amsmath,amssymb} % define this before the line numbering.
\usepackage[width=122mm,left=12mm,paperwidth=146mm,height=193mm,top=12mm,paperheight=217mm]{geometry}
\begin{document}


And then, for example:

 \subsection{b)}\\
\\
Given that h(n) is admissible, the algorithm will be optimal for:\\
f(n)=(2-w)[g(n) + w/(2-w)h(n)]
\\
when w/(2-w) \leq 1, that is when w \leq 1 the algorithm is optimal.\\ It
behaves like an A* algorithm following the heuristic:
f(n) = g(n) + w/(2-w) h(n)


And below is the result:

Any help is appreciated!

• Welcome to the site. As a little side note, I'm actually kinda surprised you got away with all the explicit \\s! These should never come after a sectioning command and they should rarely appear in the running text, being used only in certain environments (such as tabular for tables) and as a last resort to help TeX break lines. Use them sparingly. I really recommend you check out a starter guide tex.stackexchange.com/questions/11/… – Au101 Nov 11 '15 at 2:18
• There are a lot of mistakes here which aren't your fault, you can't be expected to know any different without learning a little bit about how LaTeX works. You're using it how anybody would coming to it fresh. But the longer you wait to get a proper introduction to LaTeX, the more unpleasant your life with it is gonna be! – Au101 Nov 11 '15 at 2:20

In LaTeX, text and math are treated differently, so you need to indicate that you're using math. Specifically, surround your math by $ signs. If you want display math, meaning that the formula should be on its own line, then you should indicate it like this: $ (math goes here) $. This adds the new line automatically, so you don't need to break it with \\. In your document, the compiler can't tell when you're using math except that certain symbols, such as \leq, can only be used in mathmode. Thus, it assumes everything afterwards is in mathmode until it reaches a $ (or \], etc.), and in mathmode variables are italicized. Look at the error log: there are probably some significant errors hiding in there.
Given that $h(n)$ is admissible, the algorithm will be optimal for:
$f(n)=(2-w)[g(n) + w/(2-w)h(n)]$

• Thank you! I followed your suggestion and it worked. I see that \leq causes the problem. But what if I want to have a shorter formula within the text? Should I use $? – Nottolina Nov 11 '15 at 2:06 • Yes, use $ for short formulas that shouldn't be on a new line, and $...$ for longer formulas that should be on a new line. – Arun Debray Nov 11 '15 at 2:07