I'm trying to write an algorithm in latex, but after I put my if statement it gives me back an error and says that there's a missing number. What does that mean? Where is my flaw? This is what I've written (mind you I'm trying to write a generalized algorithm that doesn't necessarily examine things, hence the general statement in if):
\For{j = length($y_i$)}{
\If{$\{x_j$ and $\neg x_j\}$ in $y_i$}{
\State \text{$a_i$ = F}
}
Can I do that?
Best Answer
It seems you're mixing up the syntax of
algpseudocode
with that ofalgorithm2e
.With the former package, the syntax is like as follows
The latter package has no
\State
command, so I guess you're usingalgpseudocode
.Note the changes I made to your input to use math mode wherever it's needed.