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.]

JQK
  • 13
  • 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 Nov 06 '22 at 08:57
  • When you say "item", do you mean \item? It doesn't show in your code. – Miyase Nov 06 '22 at 09:01
  • Thanks I will try to improve the description. – JQK Nov 06 '22 at 10:13
  • https://tex.stackexchange.com/questions/267952/bolding-a-single-number-in-a-enumerated-list This seems to be a useful method. – JQK Nov 07 '22 at 04:57
  • Another helpful solution with etaremune: https://tex.stackexchange.com/questions/286730/how-to-modify-labels-on-some-not-all-etaremune-items – JQK Nov 07 '22 at 05:07

1 Answers1

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}

Miyase
  • 2,544
  • 2
  • 12
  • 26
  • 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 06 '22 at 09:56
  • @JQK OK, I understand. Please edit your question with this additional information, then I'll see to updating my answer. – Miyase Nov 06 '22 at 10:05
  • Maybe, one macro managing the formatting of the label would be more useful. – projetmbc Nov 06 '22 at 10:17