Math & ScienceWeird behaviour of algorithmic package.

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
ppel123
Posts: 2
Joined: Sat May 30, 2020 12:26 pm

Weird behaviour of algorithmic package.

Post by ppel123 »

I am trying to write a simple algorithm, but I am getting errors and not corrected format all the time.
The "code" I am using is :

Code: Select all

\begin{algorithm}
\caption{Αλγόριθμος πρόβλεψης της γλώσσας επόμενης λέξης}\label{euclid}
\begin{algorithmic}[1]
\Procedure{PredictLanguageOfNextWord}{}
\State Initialize a queue of size 3
\State Initialize a list with 3 weights [0.45, 0.35, 0.20]
\State Append word of previous typed word to the queue
\If{Word typed exists in both dictionaries}
	\State Iterate through queue and calculate probabilities for the two languages 
	\State $prob\_of\_lang = prob\_of\_lang + weight_list$
	\State Compare final probabilities and return the language with the higher one
\EndIf
\EndProcedure
\end{algorithmic}
\end{algorithm}
The result I am taking is shown in the screenshot below:
Annotation 2020-06-03 092032.png
Annotation 2020-06-03 092032.png (45.56 KiB) Viewed 1815 times
Could someone please help me understand what is my problem here?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
Ijon Tichy
Posts: 640
Joined: Mon Dec 24, 2018 10:12 am

Weird behaviour of algorithmic package.

Post by Ijon Tichy »

Unfortunately you've given neither a Infominimal working example nor the error message you've got nor a description of what is wrong nor what is expected. So I cannot test your code and can only speculate: You've written weight_list instead of \mathit{weight\_list} or \verb|weight_list|. Note: The \mathit should be used for the other terms too, because otherwise they are printed as products of single-letter variables instead of printed as a multi-letter variable.

If this does not answer your question, please try to improve the question. And because I've already told you that it is waste of time, to ask questions without making the problem reproducible: Please always show a Infominimal working example, always quote error messages (copy&paste from the log-file), and always describe your problem and the expected result.
Sorry, but I can no longer participate here as the administrator is trampling on my wishes on one of his other platforms. :cry:
Post Reply