1

Hello trying to writte pseudocode in Latex

I cant fix mistake in line 8

code:

\begin{algorithm} \caption{Učící mechanismus všech obcí}
\begin{algorithmic}[1]
\While {Obce ještě nedokonvergovaly}
\State t=t+1
\ForEach {KNIES_p $\in$ Population}
\For{$X_i$ $\in$ Zařazené body}
\State KNIES_p.\quad \textbf{Learn}($X_i$, $\beta_t = \frac{t\beta_T}{T}$)
\EndFor
\If{KNIES_p {$\qaq$} KNIES}
\State KNIES(t) = KNIES_p
\end{algorithmic}
\end{algorithm}

enter image description here

  • 3
    Welcome to TeX.SX! Could you please turn your code fragment into a compilabe minimal working example (MWE) by adding the documentclass and the relevant packages. Please also explain the connection to biblatex as you used this tag. – leandriis Mar 18 '19 at 19:01
  • 1
    Please do not shout on us (Change chapital letters in title of question)! How is this related to your last question tex.stackexchange.com/questions/479937/… ? Which error do you get and please make your code snippet compilable .... – Mensch Mar 18 '19 at 19:23
3

You have many errors, mostly due to improper treatment of math symbols.

There is no predefined \ForEach block, you have to define it yourself.

Supply a definition for \qaq, that's not a standard command.

\documentclass[a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[czech]{babel}

\usepackage{algorithm,algpseudocode}

\algblockx{ForEach}{EndForEach}{\textbf{foreach} }{\textbf{end foreach}}
\newcommand{\ivar}[1]{\mathit{#1}}
\newcommand{\tvar}[1]{\textrm{#1}}

\newcommand{\qaq}{???} % what's this?

\begin{document}

\begin{algorithm} \caption{Učící mechanismus všech obcí}
\begin{algorithmic}[1]
\While {Obce ještě nedokonvergovaly}
  \State $t=t+1$
  \ForEach {$\ivar{KNIES}_p \in \tvar{Population}$}
    \For{$X_i\in\tvar{Zařazené body}$}
      \State $\ivar{KNIES}_p$.\quad
             \textbf{Learn}($X_i$, $\beta_t = \frac{t\beta_T}{T}$)
    \EndFor
  \EndForEach
  \If{$\ivar{KNIES}_p \qaq \ivar{KNIES}$}
    \State $\ivar{KNIES}(t) = \ivar{KNIES}_p$
  \EndIf
\EndWhile
\end{algorithmic}
\end{algorithm}

\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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