0

I have created an environment and I want to put a symbol ($\circ$) to the right of the last item of an itemize, which is inside the environment. However, using \hspace*{\fill}$\circ$ places $\circ$ at the end of the next line (after the last item). How can I fix this?

Here is the code of the environment:

\newenvironment{algoritmo}[3]
{
\setitemize     {labelindent=\parindent, leftmargin=*, labelsep=1em, itemindent=0em, rightmargin=0em, 
topsep=0em, parsep=0em, partopsep=0em, itemsep=0em}
\setenumerate   {labelindent=\parindent, leftmargin=*, labelsep=1em, itemindent=0em, rightmargin=0em, 
topsep=0em, parsep=0em, partopsep=0em, itemsep=0em}
\begin{Alg}[#2]
\label{#1}
\normalsize
\rmfamily
\itshape
``#3''
\vspace{1ex}
}
{ 
\hspace*{\fill}$\circ$
\end{Alg}
}

Thanks.

enter image description here

\documentclass {article} 
\usepackage {amssymb} 
\begin {document} 
\begin {itemize} \item nono nono nonon nono nono nono nono nono nono 
\item nono nono nono nono nono nono nono nono nono 
\item nono nono nono nono nono nono nono nono nono nono nono nono nono nono nono 
\end {itemize} 
\hspace{\fill}$\square$ 
\end {document}

This is a minimal working example. I would like the square to appear to the right of the last item, in the same line as it.

4
  • Where this square should appear, when the text in the last line reaches to the right edge pf text?
    – Zarko
    May 6, 2021 at 19:14
  • Could it be caused by the vspace right before? May 6, 2021 at 19:44
  • If your algoritmo environment could have occasions where there is a list at the end and sometimes there isn't, it's best to place the \circ manually as in the current proposed answer.
    – Werner
    May 6, 2021 at 23:02
  • I understand, however I would like my algoritmo environment to place \circ automatically at the very end of it, no mater if it finishes with an itemize or something else. For something else (for example plain text) it works, the problem is when it finishes with an itemize. Is that possible? How can it be achieved?
    – Marcus
    May 7, 2021 at 14:10

1 Answer 1

2

The square appears to the right of the last item, in the same line.

b

\documentclass {article} 

\usepackage {amssymb} 
\usepackage{enumitem} % added <<<<<<<<<<<<<
\usepackage{algorithm2e}% added <<<<<<<<<<<<<<
\setlength{\algomargin}{-0pt} % noindent

\newcommand{\fine}{\hfill~~$\square$} % added <<<<<<<<<<<<<

\begin {document} 

\setitemize{labelindent=\parindent, leftmargin=*, labelsep=1em, itemindent=0em, rightmargin=0em, 
topsep=0em, parsep=0em, partopsep=0em, itemsep=0em}

\setenumerate{labelindent=\parindent, leftmargin=*, labelsep=1em, itemindent=0em, rightmargin=0em, 
topsep=0em, parsep=0em, partopsep=0em, itemsep=0em}


\begin{algorithm}   
    \begin{itemize}
        \item nono nono nonon nono nono nono nono nono nono 
        \item nono nono nono nono nono nono nono nono nono 
        \item nono nono nono nono nono nono nono nono nono nono nono nono nono nono nono\fine
    \end{itemize}   
\end{algorithm}

\bigskip

\begin{algorithm}
    \begin{enumerate}
        \item nono nono nonon nono nono nono nono nono nono 
        \item nono nono nono nono nono nono nono nono nono 
        \item nono nono nono nono nono nono nono nono nono nono nono nono \fine
    \end{enumerate}
\end{algorithm}
    
\end {document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .