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

5
  • And \item Item 2 should produce what?
    – Bernard
    Sep 26, 2019 at 11:19
  • \item keeps its standard behavior without adding anything.
    – projetmbc
    Sep 26, 2019 at 11:23
  • So it is a \bulletitem, no more, no less?
    – Bernard
    Sep 26, 2019 at 11:25
  • No it does nothing special contrary to \squareitem and \bulletitem.
    – projetmbc
    Sep 26, 2019 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, 2019 at 12:08

1 Answer 1

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

2
  • Thanks for this ! LaTeX and its community are great. ;-)
    – projetmbc
    Sep 26, 2019 at 18:20
  • @projetmbc It is my pleasure to assist. Sep 26, 2019 at 18:34

You must log in to answer this question.

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