1

Say I want to produce something with the effect like this:

[\textbf{1}] foo

[\textit{2}] bar

[\color{red} 3] foobar

and the numbers should be generated automatically by \item in \enumerate.

For example, the code should be something like

\begin{enumerate}
    \item[\bf] foo
    \item[\it] bar
    \item[\red] foobar
\end{enumerate}

Thanks.

Some edits: Both Bolding a single number in a enumerated list and How to modify labels on some (not all) etaremune items seem to provide some useful methods. For example, based on the suggestion in broken hyperlink to items in etaremune or revnum environment, I can implement the bold font with proper reference by

\providecommand*{\phantomsection}{}% for compatibility if hyperref not loaded
\newcommand{\lebal}{\phantomsection\label}


\begin{etaremune}
\newif\ifitembf
\renewcommand*\labelenumi{[\ifitembf\bfseries\fi\theenumi]}
{\itembftrue \item \lebal{bar} foo}
\end{etaremune}

to get a reference to foo, and in the enumerate the item number for is correctly bolded. However, when I use \ref{bar}, the caption in the link seems to be with the correct number but the font is not bolded automatically. Is there a proper solution? Thanks. [I do not have enough reputation to comment on the other questions so I cannot ask there.]

5
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
    – Community Bot
    Nov 6, 2022 at 8:57
  • When you say "item", do you mean \item? It doesn't show in your code.
    – Miyase
    Nov 6, 2022 at 9:01
  • Thanks I will try to improve the description.
    – JQK
    Nov 6, 2022 at 10:13
  • tex.stackexchange.com/questions/267952/… This seems to be a useful method.
    – JQK
    Nov 7, 2022 at 4:57
  • Another helpful solution with etaremune: tex.stackexchange.com/questions/286730/…
    – JQK
    Nov 7, 2022 at 5:07

1 Answer 1

1

I'll assume you forgot \item commands in your question.

Just use \textcolor:

\documentclass{article}
\usepackage{xcolor}

\begin{document}

\begin{itemize}
\item[\textbf{1}] foo
\item[\textit{2}] bar
\item[\textcolor{red}{3}] foobar
\end{itemize}

\end{document}
3
  • Hi @Miyase, thanks a lot for your reply. Sorry for the impreciseness. This can work but does not seem to help if I need to automatically generate the numbering. Say I have 100 items, this way need to set the values all by myself. But I know which one need to use red color or bold font. I am not sure if the question clearer and thanks again for your kind help.
    – JQK
    Nov 6, 2022 at 9:56
  • @JQK OK, I understand. Please edit your question with this additional information, then I'll see to updating my answer.
    – Miyase
    Nov 6, 2022 at 10:05
  • Maybe, one macro managing the formatting of the label would be more useful.
    – projetmbc
    Nov 6, 2022 at 10:17

You must log in to answer this question.

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