
這裡,該命令,在和\tcc{iterate over all training examples}
之間產生很大的差距。左對齊就好了。但如何縮小間隙,使其緊湊呢?examples
*/
答案1
\SetNoFillComment
在環境中本機使用該命令或在載入時algorithm
使用全域選項。nofillcomment
algorithm2e
MWE(借連結答案):
\documentclass{article}
\usepackage{xcolor}
\usepackage[linesnumbered,ruled,vlined]{algorithm2e}
\newcommand\mycommfont[1]{\footnotesize\ttfamily\textcolor{blue}{#1}}
\SetCommentSty{mycommfont}
\begin{document}
\begin{algorithm}[H]
\DontPrintSemicolon
\SetNoFillComment % <---------------------------
\KwData{Training set $x$}
$\Delta_{ji}^l := 0$ \tcp*{will be used to compute $\partial x$}
\tcc{iterate over all training examples}
\caption{Example code}
\end{algorithm}
\end{document}
輸出: