我正在写一篇论文,其中有三个文件,一个是主要文件,一个是章节文件,最后一个是 a.tex。
- main.tex 用于调用该章节。
- 我在 a.tex 中编写了主算法。因此我在 chapter.tex 中调用该文件。但它显示错误?
错误
! Missing \endcsname inserted.<to be read again>\ALG@currentblock@0 \State
! Extra \endcsname.\ALG@makebeginrepeat ...\ALG@thisblock \endcsname\relax \def \ALG@thisblock... \State
! LaTeX Error: Lonely \item--perhaps a missing list environment.See the LaTeX manual or LaTeX Companion for explanation.Type H <return> for immediate help.... \State
! Missing \endcsname inserted.<to be read again>\ALG@currentblock@0 \State
! Extra \endcsname.\ALG@makebeginrepeat ...\ALG@thisblock \endcsname\relax \def \ALG@thisblock... \State
! LaTeX Error: Lonely \item--perhaps a missing list environment.See the LaTeX manual or LaTeX Companion for explanation.Type H <return> for immediate help.... \State
! Missing \endcsname inserted.<to be read again>\ALG@currentblock@0 \State
! Extra \endcsname.\ALG@makebeginrepeat ...\ALG@thisblock \endcsname\relax \def \ALG@thisblock... \State
! LaTeX Error: Lonely \item--perhaps a missing list environment.See the LaTeX manual or LaTeX Companion for explanation.Type H <return> for immediate help.... \State
! Missing \endcsname inserted.<to be read again>\ALG@currentblock@0 \State
! Extra \endcsname.\ALG@makebeginrepeat ...\ALG@thisblock \endcsname\relax \def \ALG@thisblock... \State
! LaTeX Error: Lonely \item--perhaps a missing list environment.See the LaTeX manual or LaTeX Companion for explanation.Type H <return> for immediate help.... \State
! Missing \endcsname inserted.<to be read again>\ALG@currentblock@0 \State
! Extra \endcsname.\ALG@makebeginrepeat ...\ALG@thisblock \endcsname\relax \def \ALG@thisblock... \State
! Missing \endcsname inserted.<to be read again>\ALG@currentblock@0 \Procedure
包裹:
\documentclass[
11pt, % The default document font size, options: 10pt, 11pt, 12pt
%oneside, % Two side (alternating margins) for binding by default, uncomment to switch to one side
english, % ngerman for German
singlespacing, % Single line spacing, alternatives: onehalfspacing or doublespacing
%draft, % Uncomment to enable draft mode (no pictures, no links, overfull hboxes indicated)
%nolistspacing, % If the document is onehalfspacing or doublespacing, uncomment this to set spacing in lists to single
%liststotoc, % Uncomment to add the list of figures/tables/etc to the table of contents
%toctotoc, % Uncomment to add the main table of contents to the table of contents
%parskip, % Uncomment to add space between paragraphs
%nohyperref, % Uncomment to not load the hyperref package
headsepline, % Uncomment to get a line under the header
%chapterinoneline, % Uncomment to place the chapter title next to the number on one line
%consistentlayout, % Uncomment to change the layout of the declaration, abstract and acknowledgements pages to match the default layout
]{MastersDoctoralThesis}
\usepackage{algorithm}
\usepackage{algpseudocode}
特克斯 (代码文件)
\usepackage{algorithm}
\usepackage{algpseudocode}
%\begin{filecontents}{a.tex}
\begin{algorithm}[H]
%\SetAlgoLined
%\KwResult{Write here the result }
\State $a$ is BAC , $T$ is trignotmatric, $R\textsubscript{Data}$ is my symbolic data\;
\State RS \textsubscript{Data} is textual data\;
\begin{algorithmic}[1]
\State $R\textsubscript{Data} \gets hi$ w.r.t $j$ \Comment{ABC} \;
\State $L_i \gets $ FSC \Comment(i=1,2,3)\;
\State Remove ABC\;
\State $T_{0}\gets R_{Data}$.$T$($start$)\;
$T_{new}$}
\Procedure {multi} {$ab\textsubscript{Data}$, $g\textsubscript{i}$}
\For {$s\gets RS_{dd}(1)$ \TO $RS_{aa}(end)$}
\State $ff_{sw}\gets S_{ddd} \times W_{L}$
\If{vvvv }
\State np such
\Else
\State $dd_{ss}\gets sss_{ffff} \times aada_{sadada} \times \frac{O_{LP}}{100}$
\EndIf
\For {$F_{S}\gets 1 \leq 6$}
\State $E_{feature}\gets F(T_{sw}
\EndFor
\EndFor
\EndProcedure
\Procedure {myz}{$sa_{aa}$}
\For {each value}
\State Not something
\EndFor
\EndProcedure
\caption{MYALGORIHTM}
\end{algorithmic}
\end{algorithm}
%\end{filecontents}
请帮我解决这个问题吗?
答案1
抱歉,但您的问题与您之前问的几乎相同,我已经给了您答案:老问题与我的答案
在这个答案中我已经告诉过你——例如——改变$ \TO $
以纠正\to
等等。
我没有你用过的课程 MastersDoctoralThesis
,但我知道据说它很成问题。所以如果你不能自己测试,请在你的问题中添加你用过的课程的链接。
对于这个答案我简单地使用article
。
请查看此更正后的代码
\documentclass{article}
\usepackage{algorithm}
\usepackage{algpseudocode}
\begin{document}
\begin{algorithm}[H]
\begin{algorithmic}[1]
\State $a$ is BAC , $T$ is trignotmatric, $R\textsubscript{Data}$ is my symbolic data%\;
\State RS \textsubscript{Data} is textual data%\;
\State $R\textsubscript{Data} \gets hi$ w.r.t $j$ \Comment{ABC} %\;
\State $L_i \gets $ FSC \Comment(i=1,2,3)%\;
\State Remove ABC%\;
\State $T_{0}\gets R_{Data}$.$T$($start$)%\;
%$T_{new}$}
\Procedure {multi} {$ab\textsubscript{Data}$, $g\textsubscript{i}$}
\For {$s\gets RS_{dd}(1) \to RS_{aa}(end)$} % <============= \TO -> \to inside $ $
\State $ff_{sw}\gets S_{ddd} \times W_{L}$
\If{vvvv }
\State np such
\Else
\State $dd_{ss}\gets sss_{ffff} \times aada_{sadada} \times \frac{O_{LP}}{100}$
\EndIf
\For {$F_{S}\gets 1 \leq 6$}
\State $E_{feature}\gets F(T_{sw}$ % <==============
\EndFor
\EndFor
\EndProcedure
\Procedure {myz}{$sa_{aa}$}
\For {each value}
\State Not something
\EndFor
\EndProcedure
\caption{MYALGORIHTM}
\end{algorithmic}
\end{algorithm}
\end{document}
及其结果:
请注意,我再次\;
在文章开头最后评论了你的错误\State
。我已经在你的旧问题中这样做了。
请研究给出的答案并从中学习!