0

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??

Thanks in advance.

marked as duplicate by Schweinebacke, CarLaTeX, user36296, Mico math-mode Sep 2 '17 at 15:06

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    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
  • 1
    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
2

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$} 

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