对于下面的算法,我得到了错误!Extra },或者忘记了$。 \egroup l.759 }
我认为 if 条件中再加一个 prantes 也是另一个问题,我不知道该如何处理。提前感谢您的建议。
\begin{algorithm}[H]
\SetAlgoLined
\KwData{x}
\KwResult{y}
\ForEach{Subject in Subjects}{
\If(G(Subject, rdf:type, d ) $\notin$ T) {
violation = true\;
BREAK\;
}
}
VIOLATION = false\;
\caption{Algorithm for checking}
\end{algorithm}
答案1
您的符号\If
不正确。您使用的是\If(..){...}
,而您应该使用\If{..}{...}
:
\documentclass{article}
\usepackage{algorithm2e}
\begin{document}
\begin{algorithm}[H]
\SetAlgoLined
\KwData{x}
\KwResult{y}
\ForEach{Subject in Subjects}{%
\If{G(Subject, rdf:type, d ) $\notin$ T}{%
violation = true\;
BREAK\;
}
}
VIOLATION = false\;
\caption{Algorithm for checking}
\end{algorithm}
\end{document}