11

I'm trying to customize the environment enumerate where the \item is bold but the text is not bold. What I've tried is (at the suggestion of one of the google-results):

\let\origitem\item
\renewcommand{\item}{\normalfont\origitem}
\newcommand{\bolditem}{\normalfont\bfseries\origitem}

and then use it with

\begin{enumerate}
    \bolditem[0] First item (whole line is bold)
    \bolditem[1] Second item (also bold)
    \item[2] Third item (not bold)
\end{enumerate}

But this makes the whole line bold. I only want the numbered part to be bold.

How can I achieve this ?

1
  • A quick work-around is using \normalfont{} around the text that should not be bold. If someone knows a way to do this in the \newcommand, that will still be very appreciated and I will mark that as accepted.
    – skari
    Jul 21, 2011 at 16:59

5 Answers 5

20

You can use the enumitem package. If you don't want to use additional packages, you can simply redefine \labelenumi:

\documentclass{article}
\usepackage{enumitem}

\begin{document}

\begin{enumerate}
    \renewcommand\labelenumi{\bfseries\theenumi}
    \item First item.
    \item Second item.
    \item Third item.
\end{enumerate}

% requires the enumitem package
\begin{enumerate}[label=\bfseries\arabic*]
    \item First item.
    \item Second item.
    \item Third item.
\end{enumerate}

\end{document}

EDIT: on a more programmatic level, you could define a new list-like environment that behaves like the standard enumerate, but with the desired format for the label. This can be done using something like this

\documentclass{article}

\newenvironment{boenumerate}
  {\begin{enumerate}\renewcommand\labelenumi{\textbf\theenumi}}
  {\end{enumerate}}

\begin{document}

\begin{boenumerate}
    \item First item.
    \item Second item.
    \item Third item.
\end{boenumerate}

\end{document}

or imitating the definition of the enumerate environment as given in source2e):

\documentclass{article}

\makeatletter
\def\boenumerate{%
\renewcommand\labelenumi{\textbf\theenumi}
  \ifnum \@enumdepth >\thr@@\@toodeep\else
    \advance\@enumdepth\@ne
    \edef\@enumctr{enum\romannumeral\the\@enumdepth}%
      \expandafter
      \list
        \csname label\@enumctr\endcsname
        {\usecounter\@enumctr\def\makelabel##1{\hss\llap{##1}}}%
  \fi}
\let\endboenumerate =\endlist
\makeatother

\begin{document}

\begin{boenumerate}
    \item First item.
    \item Second item.
    \item Third item.
\end{boenumerate}

\end{document}

Something similar, but now with the help of the enumitem package:

\documentclass{article}
\usepackage{enumitem}

\newlist{boenumerate}{enumerate}{4}
\setlist[boenumerate,1]{label=\bfseries\arabic*}

\begin{document}

\begin{boenumerate}
    \item First item.
    \item Second item.
    \item Third item.
\end{boenumerate}

\end{document}
6
  • The solution \def\boenumerate is in my opinion bad. You should use something like: \newenvironment{boenumerate}{\begin{enumerate}\renewcommand*\labelenumi{..... Jul 21, 2011 at 17:58
  • @Marco: why is it bad? I know that you can define boenumerate as you did, but I also wanted to show how the standard enumerate environment is defined in the kernel. Jul 21, 2011 at 18:02
  • I think the definition in the kernel is very strange to many users. So I think we should present a simple solution by LaTeX2e user commands. I doesn't mean that the solution is wrong ;-) Jul 21, 2011 at 18:08
  • @Marco: agreed. I've added a note to my answer. Jul 21, 2011 at 19:33
  • Now you have nearly every solution ;-) Few minutes ago I got an idea to complete this by creating a new environment by \list{}{} ....\endlist :-) Jul 21, 2011 at 19:37
13

You should use a package like enumitem. The package allows to modify the item by a key-value-syntax.

\documentclass{article}
\usepackage{enumitem}
\begin{document}
\begin{enumerate}[label=\textbf{\arabic*},start=0]
   \item First item
   \item Second item
   \item Third item
\end{enumerate}
\end{document}

enter image description here

1
  • 1
    This doesn't address the question, I'm afraid.
    – egreg
    Jul 22, 2011 at 8:27
2

It's not a good idea to redefine \item, as it's used in many parts of LaTeX. Here is a \benumerate environment in which you can use the \bolditem command alternating it to the normal one.

\documentclass[a4paper]{article}

\let\ifbolditem\iffalse
\def\bolditemtrue{\global\let\ifbolditem\iftrue}
\def\bolditemfalse{\global\let\ifbolditem\iffalse}

\newenvironment{benumerate}
  {\def\bolditem{\bolditemtrue\item}%
   \enumerate
   \renewcommand\makelabel[1]{\hss\llap{\ifbolditem\bfseries\fi##1\bolditemfalse}}}
  {\endenumerate}


\begin{document}
\begin{benumerate}
\item Normal
\bolditem Bold
\item Normal again
\bolditem[9] Bold
\end{benumerate}
\end{document}
2

This is almost the same answer I posted to a related (identical?) question here. I am re-posting most of it here for the sake of those finding these posts via Google search.

There are two different solutions, one local and one global, using the enumitem package.

The idea for both is to use the font= key for enumitem.

Local: Every time you want an individual enumerate environment with bold numbers/letters/numerals (whatever the setting is), just use:

\begin{enumerate}[font=\bfseries]
*your code here*
\end{enumerate}

Note that this solution is strictly local -- the font settings will be not be inherited by enumerate environments contained/nested within outer enumerate environments for which the setting does not hold -- see another of my related answers here.

Global: If you know in advance that you will want every enumerate environment to have bold numbers/letters/numerals (whatever the setting is), then put the following in the document's preamble:

\setlist[enumerate]{font=\bfseries}

Note: As a general rule of thumb, it is preferable to use the font= key for enumitem (as opposed to the label= key suggested in other answers) if all you want to do is to make the numbers/letters/etc. bold. label= completely overwrites the standard settings of enumerate, while font= just modifies them.


Source: I read the documentation for enumitem, and both of the above solutions worked for me using TeXstudio and XeLaTeX compiler.

1

By using enumerate package you can also use this command.

\documentclass{article}
\usepackage{enumerate}
\begin{document}
    \begin{enumerate}[\bfseries a.]
        \item one
        \item two
        \item three
    \end{enumerate}
\end{document}

You must log in to answer this question.

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