Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust alignment for comments #16

Open
rosshjb opened this issue Jan 18, 2024 · 4 comments · May be fixed by #18
Open

Adjust alignment for comments #16

rosshjb opened this issue Jan 18, 2024 · 4 comments · May be fixed by #18

Comments

@rosshjb
Copy link

rosshjb commented Jan 18, 2024

Could you support an option to align comments?

Sample:
image

\begin{algorithm}
	\caption{Merge Sort}
	\begin{algorithmic}
	    \Procedure{Merge-Sort}{$A,p,q,r$}
			\If{$p\ge r$} \Comment{zero or one element?}
				\State \Return\Comment{early return}
			\EndIf
			\State $q \gets \lfloor(p+r)/2\rfloor$
			\State \Call{Merge-Sort}{$A,p,q$}
			\State \Call{Merge-Sort}{$A,q+1,r$}
			\State \Call{Merge}{$A,p,q,r$}
	    \EndProcedure
	\end{algorithmic}
\end{algorithm}
@ytliu74
Copy link
Owner

ytliu74 commented Jan 19, 2024

Hi, well, the comment now indeed looks bad. How about let them align to the right side like below:
image
If you are okay with this, I can try to implement.

@rosshjb
Copy link
Author

rosshjb commented Jan 19, 2024

@ytliu74
Awesome!
If the comment is on a separate line, it would be better to display it as before:

image

\begin{algorithm}
	\caption{Merge Sort}
	\begin{algorithmic}
	    \Procedure{Merge-Sort}{$A,p,q,r$}
		        \State \Comment{zero or one element?}
			\If{$p\ge r$}
				\State \Return
			\EndIf
			\State $q \gets \lfloor(p+r)/2\rfloor$
			\State \Call{Merge-Sort}{$A,p,q$}
			\State \Call{Merge-Sort}{$A,q+1,r$}
			\State \Call{Merge}{$A,p,q,r$}
	    \EndProcedure
	\end{algorithmic}
\end{algorithm}

@dzx-dzx dzx-dzx linked a pull request May 13, 2024 that will close this issue
@ytliu74
Copy link
Owner

ytliu74 commented Jun 1, 2024

Hi @rosshjb, you can refer to this pull request #18 for a possible solution. But it's not perfect. But you can use it as a workaround, thanks.

@dzx-dzx
Copy link

dzx-dzx commented Jun 2, 2024

Example here:
image
image
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants