1

Within an enumerated list, I would like some "meta"-level annotations: Mark a single, specific item in boldface, or another colour, or have an arrow point at it from the left margin, or surround it with a box. But the \item macro cannot be embedded within some other macro. Is there any way to accomplish this?

doncherry
  • 54,637
  • How do you want to markup the item itself? Would a macro like \specialitem be acceptable? Or do you want \item{\highlight ... }? – Alan Munn May 15 '15 at 20:04
  • 2
    Have a look at this question: http://tex.stackexchange.com/q/87564/10898 or http://tex.stackexchange.com/q/21004/10898 – azetina May 15 '15 at 20:07
  • Alan: \specialitem would be fine. – Mayer Goldberg May 15 '15 at 20:54
  • 1
    Can you please add a minimal working example to explain more clearly what you want. Comments such as "the \item macro cannot be embedded within some other macro" suggest that you may have serious constraints so you should spell out what you need in more detail. it would, for example, be possible to do something that fits your description by modifying the \item command except that this might violate your unexplained embedding requirement. –  May 16 '15 at 07:46

1 Answers1

1

Of course you can embed \item inside a macro. Below I define \specialitem to set an \item with the necessary non-argument formatting specified via \setspecialitem:

enter image description here

\documentclass{article}

\usepackage{xcolor}

\makeatletter
\newcommand{\setspecialitem}[1]{\def\specialitem@{#1}}
\newcommand{\specialitem}{%
  \begingroup
  \specialitem@
  \item\leavevmode
  \endgroup
}
\setspecialitem{}% Default
\begin{document}


\begin{enumerate}
  \item First

  \setspecialitem{\color{red}}
  \specialitem Second

  \setspecialitem{\itshape}
  \specialitem Third

  \item Last
\end{enumerate}

\end{document}

It would also be possible to do more complex things (like boxing a special number). Here's one showing a \boxeditem:

enter image description here

\documentclass{article}

\makeatletter
\newcommand{\boxeditem}{%
  \begingroup
  \expandafter\expandafter\expandafter
    \let\expandafter\expandafter\expandafter
      \oldlabelenum@\expandafter\csname labelenum\romannumeral\the\@enumdepth\endcsname
  \@namedef{labelenum\romannumeral\the\@enumdepth}{\fbox{\oldlabelenum@}}
  \item\leavevmode%
  \endgroup
}

\makeatother

\begin{document}

\begin{enumerate}
  \item First

  \boxeditem Second

  \boxeditem Third

  \boxeditem Fourth

  \item Last
\end{enumerate}

\end{document}
Werner
  • 603,163