-1

I have written an algorithm in latex like the following.

\usepackage{algorithm}
\usepackage{algpseudocode}
\begin{algorithm}
\caption{My algorithm}\label{euclid}
    ...
    \State $\vec{cle} \gets $\text{Mean($o1,o2$)}
                \If{$\vec{clh[t]}$ is empty}
                     \State $\vec{clh[t]} \gets $\vec{cle}$
                \Else
                     \State $\vec{$clh[t]} \gets \text{MeanCalc}($\vec{$cle}*0.1,clh[t]*0.5)$
                \EndIf
            \EndIf

My problem is, in the line after If statement, $\vec{cle}$ doesn't show up after arrow. Also after else, \State $\vec{$clh[t]} doesn't show up before arrow. I appreciate if anyone can help me with this

MinaMRM
  • 343
  • 4
  • 16

1 Answers1

1

The usage of the math environment $...$ in your snippet was inconsistent ...

\documentclass{article}
\usepackage{algorithm}
\usepackage{algpseudocode}
\begin{document}
\begin{algorithm}
\caption{My Algorithm}\label{alg:euclid}
\begin{algorithmic}

\State $\vec{cle} \gets $\text{Mean($o1,o2$)}
    \If{$\vec{clh[t]}$ is empty}
        \State $\vec{clh[t]} \gets \vec{cle}$
    \Else
        \State $\vec{clh[t]} \gets $\text{MeanCalc}($\vec{cle}*0.1,clh[t]*0.5)$  
    \EndIf
\end{algorithmic}
\end{algorithm}

\end{document}

With the result:
enter image description here

Hope this helps

sebo1234
  • 608
  • 5
  • 18