Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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 ?

share|improve this question

migrated from stackoverflow.com Jul 21 '11 at 17:03

This question came from our site for professional and enthusiast programmers.

    
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 '11 at 16:59

3 Answers 3

up vote 13 down vote accepted

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}
share|improve this answer
    
The solution \def\boenumerate is in my opinion bad. You should use something like: \newenvironment{boenumerate}{\begin{enumerate}\renewcommand*\labelenumi{..... –  Marco Daniel Jul 21 '11 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. –  Gonzalo Medina Jul 21 '11 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 ;-) –  Marco Daniel Jul 21 '11 at 18:08
    
@Marco: agreed. I've added a note to my answer. –  Gonzalo Medina Jul 21 '11 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 :-) –  Marco Daniel Jul 21 '11 at 19:37

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

share|improve this answer
    
This doesn't address the question, I'm afraid. –  egreg Jul 22 '11 at 8:27

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}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.