当我在算法的 if 子句前插入多个新行;或者在算法部分的两个 if 子句之间插入新行时,出现以下错误:[]
! LaTeX Error: There's no line here to end.
以下是我的代码的摘录:
\usepackage{algorithm2e}
\begin{algorithm}[h]
(..)
\\
\If{ $currentFecUnit$ > $HIGHEST\_FEC\_UNIT\_NR\_DECODED\_GLOBAL$ OR
( $currentFecUnit$ == 0 AND $nrOfPacketsReceived$ == 1 ) }
{
ExtractPktHeaderAndPutIntoGlobalFecUnitHeaderValues ()
}
如何在 if 子句前添加一行而不出现语法错误?
答案1
您可以使用\BlankLine
:
\documentclass{article}
\usepackage{algorithm2e}
\begin{document}
\begin{algorithm}[H]
\SetAlgoLined
\KwData{this text}
\KwResult{how to write algorithm with \LaTeX2e }
initialization\;
\While{not at end of this document}{
read current\;
\BlankLine
\eIf{understand}{
go to next section\;
current section becomes this one\;
}{
go back to the beginning of current section\;
}
}
\caption{How to write algorithms}
\end{algorithm}
\end{document}