4

Here, the \tcc{iterate over all training examples} command, produces a large gap between examples and */. Left alignment is fine. But how to reduce the gap and make it compact?

3

Use the command \SetNoFillComment locally inside an algorithm environment or use the global option nofillcomment when loading algorithm2e.

MWE (borrowed from the linked answer):

\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} 

Output:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.