1

Here is my algorithm:algorithm:

As can be seen the comment is aligned to the right end of the line. I would like to align the comment to the end of the same line. At the exact place where the line ends I would like the comment to appear. Here is the code:

\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{graphicx}
\usepackage{algpseudocode}
\usepackage{algorithm}
\usepackage{authblk}
\usepackage{textcomp}
\usepackage{mathtools}
\usepackage{filecontents}
\usepackage{microtype}
\usepackage{float}
\usepackage{adjustbox}
\usepackage{booktabs,makecell,tabularx}
\usepackage{url}
\usepackage{booktabs}
\usepackage{subfigure}

\begin{document}   
\begin{algorithm} 
            \caption{Bla Bla}
            \label{alg:ALG1}
            \begin{flushleft}
                \textbf{INPUT:} $N$ = no.   \\
                \textbf{OUTPUT:} Prediction of $W_{t_c}$    
            \end{flushleft}
            \begin{algorithmic}

            \\ BLALAAALALAdskjhfdsjk    \Comment{This is done as part}

            \end{algorithmic}
        \end{algorithm} 
\end{document}
1

The comment can be changed via the macro \algrenewcommand{\algorithmiccomment}[1]{...}

\documentclass{article}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{graphicx}
\usepackage{algpseudocode}
\usepackage{algorithm}
\usepackage{authblk}
\usepackage{textcomp}
\usepackage{mathtools}
\usepackage{filecontents}
\usepackage{microtype}
\usepackage{float}
\usepackage{adjustbox}
\usepackage{booktabs,makecell,tabularx}
\usepackage{url}
\usepackage{booktabs}
\usepackage{subfigure}

\algrenewcommand{\algorithmiccomment}[1]{\hspace{1em}$\triangleright$ #1}

\begin{document}   
\begin{algorithm} 
            \caption{Bla Bla}
            \label{alg:ALG1}
            \begin{flushleft}
                \textbf{INPUT:} $N$ = no.   \\
                \textbf{OUTPUT:} Prediction of $W_{t_c}$    
            \end{flushleft}
            \begin{algorithmic}

            \\ BLALAAALALAdskjhfdsjk    \Comment{This is done as part}

            \end{algorithmic}
        \end{algorithm} 
\end{document}

enter image description here

| improve this answer | |

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.