algorithm2e コンパクト \tcc コメント

algorithm2e コンパクト \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} 

出力:

ここに画像の説明を入力してください

関連情報