\usepackage[linesnumbered,ruled]{algorithm2e}
\usepackage[linesnumbered,ruled,vlined(去除end,竖线变为竖横线)]{algorithm2e}
\let\chapter\undefined ç 去除错误的不知道原因
\DontPrintSemicolon 行末尾的分号不显示
\SetKwBlock{Function}{function}{end} 设置子模块
\SetAlFnt{\normalsize} 算法正文
\SetAlCapFnt{\large} 算法帽
\SetAlCapNameFnt{\large} 算法名字
* 放在算法外面
There are two ways to do comments inalgorithm :
1. by using a comment macro defined by\SetKwComment{command}{right mark}{left mark}
(see below) like \tcc;
2. by using side comment, it means commentput in between ( ) after control command like
if-then-else, for, ... macros.
At section 9.3, you can see how \tcc isdefined and at section 9.4 you can look at some examples
how to use it with if then else likecommands and finally you can look at section 10.4 how to
define comments and explanations on thedifferent macros and ways of printing comments. Note
also that comments are not numbered bydefault when using linesnumbered option. You have to
set commentsnumbered to number them also.
The following macro control how comment aretypeseted.
\SetSideCommentLeft right justified sidecomments (side comments are flushed to the right),
equivalent to scleft option.
\SetSideCommentRight left justified sidecomments (side comments are put right after the code
line) , equivalent to scright option.
\SetFillComment end mark of comment isflushed to the right so comments fill all the width of
text, equivalent to fillcomment option.
\SetNoFillComment end mark of comment isput right after the comment, equivalent to nofillcomment
option.
预定义的
• \tcc{line(s) of comment}: comment “la” C
• \tcc*{right justified side comment}: comment “la” C
• \tcc*[r]{right justified side comment, ends the line (default)}: comment “la” C
• \tcc*[l]{left justified side comment, ends the line}: comment “la” C
• \tcc*[h]{left justified comment, without end line; useful with”if-then-else” macros for example}:
comment “ la” C
• \tcc*[f]{right justified comment, without end line; useful with”if-then-else” macros for example}:
comment “ la” C
• \tcp{line(s) of comment}: comment “la” C++
• \tcp*{right justified side comment}: comment “la” C++
• \tcp*[r]{right justified side comment, ends the line (default)}: comment “la” C++
• \tcp*[l]{left justified side comment, ends the line}: comment “la” C++
• \tcp*[h]{left justified comment, without end line; useful with”if-then-else” macros for example}:
comment“ la” C++
• \tcp*[f]{right justified comment, without end line; useful with”if-then-else” macros for
example}: comment “la” C++