# Missing $inserted in multiple lines [duplicate] This question already has an answer here: I m new for latex, When I try to create my document, I have following part. But its not functioning and giving$ missing

error.

\textbf{Algorithm 1}\\
\textit{ld  \Leftarrow (ld_1,ld_2,ld_3,...,ld_N)} \\
\textit{D \Leftarrow ld_1 + ld_2 + ld_3+...+ld_N } \\
\textit{P$_a$ \Leftarrow available power} \\
\textbf{for }  i $= 1$ to  N \textbf{ do}\\
\textit{la$_*i$ \Leftarrow P$_a$ \div D \times ld$_i$}\\
\textit{\textbf{end for}}\\
la$_*$ represents the allocated power to each load and its calculated using\\
\textit{la$_*$ = la$_*1$,la$_*2$,la$_*3$...,la$_*N$}\\
\textit{la$_*1$+la$_*2$+la$_*3$+ ...+la$_*N$}


What am I missing here??

## marked as duplicate by Schweinebacke, CarLaTeX, user36296, Mico math-mode StackExchange.ready(function() { if (StackExchange.options.isMobile) return; $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() { var$hover = $(this).addClass('hover-bound'),$msg = $hover.siblings('.dupe-hammer-message');$hover.hover( function() { $hover.showInfoMessage('', { messageElement:$msg.clone().show(), transient: false, position: { my: 'bottom left', at: 'top center', offsetTop: -7 }, dismissable: false, relativeToBody: true }); }, function() { StackExchange.helpers.removeMessages(); } ); }); }); Sep 2 '17 at 15:06

• You are using math commands like \Leftarrow and _ in text mode. I think the whole thing should be a math environment like align and the text in it should be \text. See the manual of the amsmath package for more information. – Schweinebacke Sep 2 '17 at 14:22
• Since you are new to LaTeX i suggest to read an introduction to get a grip how LaTeX works. – Johannes_B Sep 2 '17 at 14:46

It lacks $. \leftarrow must be surrounded by $, as well as _. You should use packages like algorithmicx to present your algorithms. \\ should not be used to change line. This works but is far from legible :

\textbf{Algorithm 1}\\
\textit{ld  $\Leftarrow (ld_1,ld_2,ld_3,...,ld_N)$} \\
\textit{D$\Leftarrow ld_1 + ld_2 + ld_3+...+ld_N$} \\
\textit{P$_a$ $\Leftarrow$ available power} \\
\textbf{for }  $i = 1$  to  N  \textbf{ do}\\
\textit{la$_*i$ $\Leftarrow P_a \div D \times ld_i$}\\
\textit{\textbf{end for}}\\
la$_*$ represents the allocated power to each load and its calculated using\\
\textit{la$_*$ = la$_*1$,la$_*2$,la$_*3$...,la$_*N$}\\
\textit{la$_*1$+la$_*2$+la$_*3$+ ...+la$_*N$}