演算法2e緊湊\tcc註釋

演算法2e緊湊\tcc註釋

這裡,該命令,在和\tcc{iterate over all training examples}之間產生很大的差距。左對齊就好了。但如何縮小間隙,使其緊湊呢?examples*/

答案1

\SetNoFillComment在環境中本機使用該命令或在載入時algorithm使用全域選項。nofillcommentalgorithm2e

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} 

輸出:

在此輸入影像描述

相關內容