在 LaTeX 中编写算法时不显示 {Begin End}

在 LaTeX 中编写算法时不显示 {Begin End}

我正在使用 LaTeX 编写算法

\usepackage[ruled,vlined]{algorithm2e}

运行代码时,生成的文件不会显示在使用时应该自动出现的单词“end”

\Begin{ %my Code}

生成的文本仅显示“开始”

代码:

%&latex
\documentclass[onecolumn]{IEEEtran}
%\usepackage{subfigure}

\ifCLASSINFOpdf
 \usepackage[pdftex]{graphicx}
  \DeclareGraphicsExtensions{.pdf,.jpeg,.png,.eps}
\else
 \usepackage[dvips]{graphicx}
 \DeclareGraphicsExtensions{.eps}
\fi

\setlength{\pdfpagewidth}{8in}
\setlength{\pdfpageheight}{11in}

%\usepackage{graphicx}
\usepackage{pifont}
\usepackage{cite}
\usepackage{caption}
%\usepackage{subcaption}
\usepackage{url}
\usepackage{multirow}
\usepackage[cmex10]{amsmath}
\usepackage{amsmath,amssymb}
%\usepackage{algorithmic}
\usepackage{mdwmath} 
\usepackage{float}
\usepackage{amsmath}
\usepackage[T1]{fontenc} 

\usepackage{varwidth,xcolor}

%\usepackage[ruled,noresetcount,noend]{algorithm2e}
%\usepackage{algorithm}% http://ctan.org/pkg/algorithms
\usepackage{algpseudocode}


\usepackage{float}
\usepackage[caption = false]{subfig}


%\usepackage[titlenumbered,ruled]{algorithm2e}
\usepackage[ruled,vlined]{algorithm2e}

%today 
%\usepackage{algcompatible}
%\usepackage[table,xcdraw]{xcolor}
%\SetKwIF{If}{ElseIf}{Else}{if}{then}{else if}{else}{endif} 


\hyphenation{op-tical net-works semi- conduc-tor}
%phases
\newcommand{\var}[1]{\text{\texttt{#1}}}
\newcommand{\func}[1]{\text{\textsl{#1}}}

\begin{document}
\begin{algorithm}
\caption{Arabic reCAPTCHA Control Word Classification}
        \SetKwInOut{Input}{input}
        \SetKwInOut{Output}{output}
        \Input{User inputs: control text, suspicious text}
        \Output{Update database tables}
\SetKwBlock{Beginn}{beginn}{ende}
\Begin{

}
    \end{algorithm}


\end{document}

什么地方出了错?

谢谢

答案1

您只需要在加载时使用该选项lined而不是。vlinedalgorithm2e

梅威瑟:

%&latex
\documentclass[onecolumn]{IEEEtran}
%\usepackage{subfigure}

\ifCLASSINFOpdf
 \usepackage[pdftex]{graphicx}
  \DeclareGraphicsExtensions{.pdf,.jpeg,.png,.eps}
\else
 \usepackage[dvips]{graphicx}
 \DeclareGraphicsExtensions{.eps}
\fi

\setlength{\pdfpagewidth}{8in}
\setlength{\pdfpageheight}{11in}

%\usepackage{graphicx}
\usepackage{pifont}
\usepackage{cite}
\usepackage{caption}
%\usepackage{subcaption}
\usepackage{url}
\usepackage{multirow}
\usepackage[cmex10]{amsmath}
\usepackage{amsmath,amssymb}
%\usepackage{algorithmic}
\usepackage{mdwmath}
\usepackage{float}
\usepackage{amsmath}
\usepackage[T1]{fontenc}

\usepackage{varwidth,xcolor}

%\usepackage[ruled,noresetcount,noend]{algorithm2e}
%\usepackage{algorithm}% http://ctan.org/pkg/algorithms
\usepackage{algpseudocode}


\usepackage{float}
\usepackage[caption = false]{subfig}


%\usepackage[titlenumbered,ruled]{algorithm2e}
\usepackage[ruled,lined]{algorithm2e}

%today
%\usepackage{algcompatible}
%\usepackage[table,xcdraw]{xcolor}
%\SetKwIF{If}{ElseIf}{Else}{if}{then}{else if}{else}{endif}


\hyphenation{op-tical net-works semi- conduc-tor}
%phases
\newcommand{\var}[1]{\text{\texttt{#1}}}
\newcommand{\func}[1]{\text{\textsl{#1}}}

\begin{document}
\begin{algorithm}
\caption{Arabic reCAPTCHA Control Word Classification}
        \SetKwInOut{Input}{input}
        \SetKwInOut{Output}{output}
        \Input{User inputs: control text, suspicious text}
        \Output{Update database tables}
\SetKwBlock{Beginn}{beginn}{ende}
\Begin{

}% end for begin
    \end{algorithm}


\end{document} 

输出:

在此处输入图片描述

如果您只希望此算法有此行为,请保留vlined选项并发出

\SetAlgoLined

在算法的开始处。

相关内容