1

I would like to change the default colour of the descriptive list terms in the preamble of my doc so as to save me doing it in-line on a case by case basis.

At the moment I am doing this to change the colour of descriptive list terms:

\begin{description}
\item[{\color{grey}{Term}}] Definition blah blah.
\end{description}

Can someone give me some code that will change the colour throughout the document of these parts of the text to save me doing it one by one. Find and replace doesn't work because each term is obviously unique. Thank you

1

2 Answers 2

2

Use the enumitem package:

\documentclass{article}
\usepackage{xcolor}
\usepackage{enumitem}
\setlist[description]{format=\textcolor{gray}} %\color{gray} works too
\begin{document}
Blah-blah
\begin{description}
\item[Term] Definition blah blah.
\end{description}
Blah-blah
\end{document}

enter image description here

0
1
\documentclass{article}
\usepackage{xcolor}
\let\svdescription\description
\let\svenddescription\enddescription
\renewenvironment{description}{%
  \svdescription%
  \let\svitem\item%
  \renewcommand\item[1][]{\svitem[\textcolor{gray}{##1}]}%
  }{
  \svenddescription%
  }
\begin{document}
Blah-blah
\begin{description}
\item[Term] Definition blah blah.
\end{description}
Blah-blah
\end{document}

enter image description here

If you want the color selectable, by way of \renewcommand\descriptioncolor{red}:

\documentclass{article}
\usepackage{xcolor}
\let\svdescription\description
\let\svenddescription\enddescription
\renewenvironment{description}{%
  \svdescription%
  \let\svitem\item%
  \renewcommand\item[1][]{\svitem[\textcolor{\descriptioncolor}{##1}]}%
  }{
  \svenddescription%
  }
\newcommand\descriptioncolor{gray}
\begin{document}
Blah-blah
\begin{description}
\item[Term] Definition blah blah.
\end{description}
Blah-blah
\renewcommand\descriptioncolor{red}
\begin{description}
\item[Term] Definition blah blah.
\end{description}
\end{document}

enter image description here

2
  • Thank you Steven for your efforts however this has leads to a compile error in ShareLaTeX. I am in book mode. Oct 23, 2017 at 10:28
  • @user63394 I do not do sharelatex, but the one thing of yours I changed was grey to gray, since the former is not recognized by xcolor. There is not much else I can offer...other than to use \documentclass{article} \usepackage{xcolor} \newenvironment{xdescription}{% \begin{description}% \let\svitem\item% \renewcommand\item[1][]{\svitem[\textcolor{gray}{##1}]}% }{ \end{description}% } \begin{document} \begin{xdescription} \item[Term] Definition blah blah. \end{xdescription} \end{document} Oct 23, 2017 at 10:31

You must log in to answer this question.

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