15

How to change the font in the description environment, for the term word (e.g. First, Second...) and for its definition (The first item, The second item...)? How to restore the paragraph indentation after environment in the whole document? How to change the distance between items inside environment? How to change the distance between environment and paragraphs (after and before)?

\documentclass{article}
\usepackage{lipsum}

\begin{document}
\lipsum
\begin{description}
    \item[First] The first item
    \item[Second] The second item
    \item[Third] The third etc \ldots
\end{description}
\lipsum[1-3]
\end{document}

Can you help me? And sorry for my bad English

4 Answers 4

17

The package enumitem is your friend here:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{lipsum}
\usepackage{enumitem}
\usepackage{xcolor}          % if colour is needed
\setlist[description]{%
  topsep=30pt,               % space before start / after end of list
  itemsep=5pt,               % space between items
  font={\bfseries\sffamily}, % set the label font
%  font={\bfseries\sffamily\color{red}}, % if colour is needed
}

% macro to effect changes to the 'text' part of the description env.
\newcommand{\myitem}[2]{\item[#1] \textcolor{blue}{\emph{#2}}}

\begin{document}
\lipsum[1]
\begin{description}
  \item[First] The first item
  \item[Second] The second item
  \item[Third] The third etc \ldots
% use \myitem{<desc>}{<text>} if you want special formatting in both parts:     
  \myitem{Fourth}{The fourth item}
  \myitem{Fifth}{The fifth item, etc.\ldots} 
\end{description}

% restore paragraph indentation: add a blank line after \end{description}
\lipsum[3]
\end{document}
2
  • Is it possible to do it without using new command \myitem? And how to make own environments like description? I saw en.wikibooks.org/wiki/LaTeX/Macros#New_Environments but It only add some code before and after. While environments like itemize are more complicated, they add some code before and after every element and also before and after whole environments. How to do it, how to make similar macro? But the best would be to set all parameters (fonts, spaces, colors...) for standard environments(itemize, enumerate...)
    – novice
    Oct 10, 2013 at 8:36
  • The package enumitem can set all parameters all at once, but your original question only mentioned the description environment so I only modified that one (try changing \setlist[description] to \setlist to see the difference). You can still use enumitem for the regular environments along with @Herbert's Description environments: everything will be set in the preamble.
    – jon
    Oct 10, 2013 at 14:32
4

Define your own environment Description:

\documentclass{article}
\usepackage{xcolor}
\newenvironment{Description}
               {\list{}{\labelwidth=0pt \itemindent-\leftmargin
                        \let\makelabel\Descriptionlabel
                        \itshape% or whatever
               }}
               {\endlist}
\newcommand*\Descriptionlabel[1]{%
  \hspace\labelsep
  \normalfont%  reset current font setting
  \color{blue}\bfseries\sffamily% or whatever 
  #1}

\begin{document}

\begin{Description}
  \item[First] The first item
  \item[Second] The second item
  \item[Third] The third etc \ldots
  \item[Fourth]{The fourth item}
  \item[Fifth]{The fifth item, etc.\ldots} 
\end{Description}

\end{document}
1
4

As Jon showed, enumitem offers significant power and flexibility for list configuration of all kinds. It allows customisation for all description/itemise/enumerate-type lists, lists of particular types, default lists, custom lists, lists at particular hierarchical levels, lists at all levels etc. etc.

Here's a slightly more extended example. Note that the result is pretty ugly because the purpose is to illustrate the possibilities and not to demonstrate good typography or aesthetic adequacy.

\documentclass{article}
\usepackage{enumitem,xcolor}

Since you asked about vertical spacing, let's demonstrate the settings for this.

\setlist{% configure vertical spacing for all affected lists
  topsep=2ex,
  partopsep=2ex,
  parsep=.75ex,
  itemsep=1ex,

Add a options for the font used in the labels and the font used for the list of a whole which, in effect, means the item bodies since the font for the labels overrides the list-wide settings.

  font=\normalfont\bfseries\color{blue},

So labels will be bold blue.

  before={\color{blue!50!red}\itshape}

And the rest will be purple italics.

}

Since we didn't use the optional argument for \setlist, this will refer to all description, itemize and enumerate environments, including custom environments.

For example,

\begin{description}
  \item[First] The first item
  \item[Second] The second item

  As any dedicated reader can clearly see, the Ideal of practical reason is a representation of, as far as I know, the things in themselves; as I have shown elsewhere, the phenomena should only be used as a canon for our understanding.
  \item[Third] The third etc \ldots
\end{description}

produces

description

while

\begin{enumerate}
  \item The first item
  \item The second item

  As any dedicated reader can clearly see, the Ideal of practical reason is a representation of, as far as I know, the things in themselves; as I have shown elsewhere, the phenomena should only be used as a canon for our understanding.
  \item The third etc \ldots
\end{enumerate}

results in

enumeration

and the corresponding itemize gives

itemisation

These defaults also apply to customised list environments.

For example, let's set up a custom ordered list, myenumerate.

\newlist{myenumerate}{enumerate}{4}

The list can have at most 4 levels.

\setlist[myenumerate]{label=(\Alph*), ref=\Alph*, before={\color{red}\scshape}}

These settings add to, possibly overriding the default custom settings above. This particular list will use labels of the form (A), (B) etc., but references to items will be set without the surrounding brackets. For the list as a whole, we set a red colour and small-caps shape. However, the customised label format and spacing still applies, so the labels will still be bold blue.

So the myenumerate version of the ordered list above is rendered as

custom enumeration

Again, suppose we create a custom mydescription environment.

\newlist{mydescription}{description}{1}
\setlist[mydescription]{font=\normalfont\normalcolor\sffamily, before*={\scshape}}

This list is of type description. The font for the labels will be in the default document sans-serif font and default colour, while the entire list will be set in small-caps (unless overridden locally), in addition to the custom settings declared earlier.

This means that setting our first list using mydescription produces

custom description

The item bodies are still set in purple because the code triggered at the start of the list environment is effectively

\color{blue!50!red}\itshape\scshape

which means that the italic shape is overridden by the small-caps, but the purple colour is untouched.

If we had used

before={\scshape}

rather than

before*={\scshape}

then the code would have replaced rather than adding to the default we set earlier and the result would instead have been

tweaked custom description

Complete Code:

\documentclass{article}
\usepackage{enumitem,xcolor}
\setlist{% configure vertical spacing for all affected lists
  topsep=2ex,
  partopsep=2ex,
  parsep=.75ex,
  itemsep=1ex,
  font=\normalfont\bfseries\color{blue},
  before={\color{blue!50!red}\itshape}
}
\newlist{myenumerate}{enumerate}{4}
\setlist[myenumerate]{label=(\Alph*), ref=\Alph*, before={\color{red}\scshape}}
\newlist{mydescription}{description}{1}
\setlist[mydescription]{font=\normalfont\normalcolor\sffamily, before*={\scshape}}
\begin{document}
As any dedicated reader can clearly see, the Ideal of practical reason is a representation of, as far as I know, the things in themselves; as I have shown elsewhere, the phenomena should only be used as a canon for our understanding.
\begin{description}
  \item[First] The first item
  \item[Second] The second item

  As any dedicated reader can clearly see, the Ideal of practical reason is a representation of, as far as I know, the things in themselves; as I have shown elsewhere, the phenomena should only be used as a canon for our understanding.
  \item[Third] The third etc \ldots
\end{description}
As any dedicated reader can clearly see, the Ideal of practical reason is a representation of, as far as I know, the things in themselves; as I have shown elsewhere, the phenomena should only be used as a canon for our understanding.
\begin{mydescription}
  \item[First] The first item
  \item[Second] The second item

  As any dedicated reader can clearly see, the Ideal of practical reason is a representation of, as far as I know, the things in themselves; as I have shown elsewhere, the phenomena should only be used as a canon for our understanding.
  \item[Third] The third etc \ldots
\end{mydescription}
As any dedicated reader can clearly see, the Ideal of practical reason is a representation of, as far as I know, the things in themselves; as I have shown elsewhere, the phenomena should only be used as a canon for our understanding.
\begin{enumerate}
  \item The first item
  \item The second item

  As any dedicated reader can clearly see, the Ideal of practical reason is a representation of, as far as I know, the things in themselves; as I have shown elsewhere, the phenomena should only be used as a canon for our understanding.
  \item The third etc \ldots
\end{enumerate}
As any dedicated reader can clearly see, the Ideal of practical reason is a representation of, as far as I know, the things in themselves; as I have shown elsewhere, the phenomena should only be used as a canon for our understanding.
\begin{itemize}
  \item The first item
  \item The second item

  As any dedicated reader can clearly see, the Ideal of practical reason is a representation of, as far as I know, the things in themselves; as I have shown elsewhere, the phenomena should only be used as a canon for our understanding.

  \item The third etc \ldots
\end{itemize}
As any dedicated reader can clearly see, the Ideal of practical reason is a representation of, as far as I know, the things in themselves; as I have shown elsewhere, the phenomena should only be used as a canon for our understanding.
\begin{myenumerate}
  \item The first item
  \item The second item

  As any dedicated reader can clearly see, the Ideal of practical reason is a representation of, as far as I know, the things in themselves; as I have shown elsewhere, the phenomena should only be used as a canon for our understanding.
  \item The third etc \ldots
\end{myenumerate}
As any dedicated reader can clearly see, the Ideal of practical reason is a representation of, as far as I know, the things in themselves; as I have shown elsewhere, the phenomena should only be used as a canon for our understanding.
\end{document}
3

With scrartcl document class from KOMA-Script, you can among many other things adjust font used to typeset labels with \addtokomafont.

\documentclass{scrartcl}

\begin{document}
  \begin{description}
    \item[foo] is like bar,
  \end{description}

  \addtokomafont{descriptionlabel}{\itshape}

  \begin{description}
    \item[bar] is like a pub
  \end{description}
\end{document}

modified description label font

You must log in to answer this question.

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