2

In the following code I would like to define special items that add content just before the item that follow use.

\documentclass[12pt]{article}

\usepackage{amssymb}


\newcommand\squareitem{\item}
\newcommand\bulletitem{\item}

\begin{document}

What I want to type using special items.

\begin{itemize}
    \squareitem Item 1
    \item Item 2
    \bulletitem Item 3
\end{itemize}

What I would like to do without typing all the code.

\begin{itemize}
    \item Item 1 

          \hfill $\square$

    \item Item 2

    \item Item 3

          \hfill \textbullet
\end{itemize}

\end{document}

enter image description here

  • And \item Item 2 should produce what? – Bernard Sep 26 '19 at 11:19
  • \item keeps its standard behavior without adding anything. – projetmbc Sep 26 '19 at 11:23
  • So it is a \bulletitem, no more, no less? – Bernard Sep 26 '19 at 11:25
  • No it does nothing special contrary to \squareitem and \bulletitem. – projetmbc Sep 26 '19 at 11:42
  • I hadn't noticed how they behave, sorry. Should the square and textbullet be at the right margin of the first line of the item, in case it has several? – Bernard Sep 26 '19 at 12:08
2
\documentclass[12pt]{article}
\usepackage{amssymb}
\let\svitem\item
\let\itemtag\relax
\newcommand\squareitem{\let\nextitemtag S\item}
\newcommand\bulletitem{\let\nextitemtag B\item}
\newenvironment{tagitemize}{
  \renewcommand\item{%
    \ifx S\itemtag\par\hfill$\square$\par\fi
    \ifx B\itemtag\par\hfill$\bullet$\par\fi
    \let\itemtag\nextitemtag\let\nextitemtag\relax
    \svitem 
  }
  \itemize
}{%
  \ifx S\itemtag\par\hfill$\square$\par\fi
  \ifx B\itemtag\par\hfill$\bullet$\par\fi
\enditemize}
\begin{document}
\begin{tagitemize}
    \squareitem Item 1
    \item Item 2
    \bulletitem Item 3
\end{tagitemize}
\end{document}

enter image description here

|improve this answer|||||
  • Thanks for this ! LaTeX and its community are great. ;-) – projetmbc Sep 26 '19 at 18:20
  • @projetmbc It is my pleasure to assist. – Steven B. Segletes Sep 26 '19 at 18:34

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.