
웹사이트에 있는 템플릿을 사용하여 IEEE Access 논문을 작성하려고 합니다. 하지만 템플릿에 의사코드 예제가 없기 때문에 의사코드를 작성하는 데 문제가 있습니다. ieeeaccess 템플릿을 사용할 때 다음과 같은 오류 메시지가 나타납니다.
"추가 \endcsname.\상태",
"정의되지 않은 제어 시퀀스. \doWhile",
"\endcsname이 누락되었습니다. \State".
또한 결과가 예상대로 나오지 않습니다. 예를 들어 의사 코드에서는 모든 줄 번호가 0입니다. 또한 .tex 파일을 컴파일한 후 "input" 및 "output" 대신 "require" 및 "ensure"가 표시되었습니다.
일부 사용자 패키지가 누락되었습니까?(많은 조합을 시도했지만 여전히 결과가 없습니다.) 필요한 사용자 패키지와 함께 ieeeaccess 의사 코드의 예를 알려주실 수 있습니까?
\documentclass{ieeeaccess}
\usepackage{cite}
\usepackage{amsmath,amssymb,amsfonts}
\usepackage{graphicx}
\usepackage{textcomp}
\usepackage[section]{placeins}
\usepackage{algorithm}
\usepackage{algpseudocode}
\usepackage{algorithmicx}
\algdef{SE}[DOWHILE]{Do}{doWhile}{\algorithmicdo}[1]{\algorithmicwhile\ #1}%
\begin{document}
\begin{algorithm}[H]
\caption{Algorithm 1}\label{Alg-Decap}
\begin{algorithmic}[1]
\Require{$(C,S_k)$}
\Ensure{ HashSession$(1,\underbar r,C)$ or HashSession$(0,\rho,C))$ }
\State $c\leftarrow$ Decode$(\underbar c)$
\State $c.(3f)\in\mathcal{R}/q$
\State $e\leftarrow $ (Rounded$(c.(3f))$ mod 3) $\in \mathcal{R}/3$
\State $e.(1/g)\in\mathcal{R}/3$
\State $r'\leftarrow$ Lift($e.(1/g)$) $\in\mathcal{R}/q$
\State $h.r'\in\mathcal{R}/q$
\State $c'\leftarrow$ Round$(h.r')$
\State $\underbar c'\leftarrow$ Encode$(c')$
\State $C'\leftarrow(\underbar c',$ HashConfirm$(\underbar r',\underbar h))$
\If{$C'==C$}
\State \textbf{return} HashSession$(1,\underbar r,C)$
\Else
\State \textbf{ return} HashSession$(0,\rho,C))$
\EndIf
\end{algorithmic}
\end{algorithm}
\end{document}
답변1
algorithmic
및 를 모두 로드하면 안 됩니다 algpseudocode
. 후자의 구문을 사용하고 있으므로 전자를 삭제하십시오.
네가 원한다면입력그리고산출, 이를 위한 인프라를 정의합니다.
또한 수학 모드에 들어가거나 나오지 말고 \underbar
, 를 사용하지 마세요 \underline
.
\documentclass{ieeeaccess}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{algorithm}
\usepackage{algpseudocode}
\algdef{SE}[DOWHILE]{Do}{doWhile}{\algorithmicdo}[1]{\algorithmicwhile\ #1}%
\algnewcommand\algorithmicinput{\textbf{Input:}}
\algnewcommand\algorithmicoutput{\textbf{Output:}}
\algnewcommand\Input{\item[\algorithmicinput]}
\algnewcommand\Output{\item[\algorithmicoutput]}
% no in and out of math mode!
\newcommand{\Fun}[1]{\mathrm{#1}}
\begin{document}
\begin{algorithm}[htp]
\caption{Algorithm 1}\label{Alg-Decap}
\begin{algorithmic}[1]
\Input{$(C,S_k)$}
\Output{$\Fun{HashSession}(1,\underbar r,C)$ or $\Fun{HashSession}(0,\rho,C))$}
\State $c\leftarrow \Fun{Decode}(\underbar c)$
\State $c.(3f)\in\mathcal{R}/q$
\State $e\leftarrow (\Fun{Rounded}(c.(3f))\bmod 3)\in \mathcal{R}/3$
\State $e.(1/g)\in\mathcal{R}/3$
\State $r'\leftarrow \Fun{Lift}(e.(1/g)) \in\mathcal{R}/q$
\State $h.r'\in\mathcal{R}/q$
\State $c'\leftarrow \Fun{Round}(h.r')$
\State $\underline{c}'\leftarrow \Fun{Encode}(c')$
\State $C'\leftarrow(\underline{c}', \Fun{HashConfirm}(\underline{r}',\underline{h}))$
\If{$C'==C$}
\State \textbf{return} $\Fun{HashSession}(1,\underline{r},C)$
\Else
\State \textbf{return} $\Fun{HashSession}(0,\rho,C))$
\EndIf
\end{algorithmic}
\end{algorithm}
\EOD
\end{document}