# Applying different formatting to different description lists

I'm using description lists for several different purposes in something I'm writing. I would like to somehow define these lists differently so that I could apply different formatting or style to the different types. In HTML/CSS I would use the "class" attribute to do this. Is there something similar that can be done in LaTeX? The only thing I could think of was to make sort of a wrapper \NewDocumentCommand or environment that would get the list passed to it as an argument.

EDIT:I meant the description environment. So sometimes I might want the descriptions on the same line as the items, other times offset on the next line. I know how to do this, but I don't want to have to do it individually for each list. The project may have as many as 240 description lists of three different types.

I wanted to keep things flexible in case I had different ideas, but maybe I'm applying too much of an HTML/CSS mindset -- there I would use class attributes even if I had no specific plans to style things differently, just in case I wanted to do it later.

• By "description" do you mean that you are really using the description environment? – campa Aug 7 '20 at 14:50
• Could you include some examples of the different styles you have in mind. If you are referring to the description environment, you might want to have a look at the enumitem package and its various list customization options. – leandriis Aug 7 '20 at 14:53
• Yes, let me edit the original post. – Chris Kern Aug 7 '20 at 14:56

The package enumitem offers the possibility of adapting the description environment and to define custom lists, e.g.

\documentclass{article}

\usepackage{enumitem}

% Define small caps description-like environment
\newlist{scdesc}{description}{1}
\setlist[scdesc]{font=\mdseries\scshape,noitemsep}

\begin{document}

\begin{description}
\item[Foo] explanation for foo
\item[Bar] explanation for baz
\item[Baz] explanation for baz
\end{description}

\begin{description}[font=\slshape]
\item[Foo] explanation for foo
\item[Bar] explanation for baz
\item[Baz] explanation for baz
\end{description}

\begin{description}[font=\mdseries\scshape]
\item[Foo] explanation for foo
\item[Bar] explanation for baz
\item[Baz] explanation for baz
\end{description}

\begin{scdesc}
\item[Foo] explanation for foo
\item[Bar] explanation for baz
\item[Baz] explanation for baz
\end{scdesc}

\end{document}


EDIT With the macro \SetEnumitemKey you can define a shorthand for a (more or less arbitrary) list of keys:

\documentclass{article}

\usepackage{enumitem}
\SetEnumitemKey{myclassA}{font=\slshape,noitemsep}
\SetEnumitemKey{myclassB}{font=\mdseries\scshape,noitemsep}

\begin{document}

\begin{description}[myclassA]
\item[Foo] explanation for foo
\item[Bar] explanation for bar
\item[Baz] explanation for baz
\end{description}

\begin{description}[myclassB]
\item[Foo] explanation for foo
\item[Bar] explanation for bar
\item[Baz] explanation for baz
\end{description}

\end{document}


• @ChrisKern Well, you just define three types of description with \newlist like I did with the scdesc in the example. – campa Aug 7 '20 at 15:04
• @ChrisKern Are you saying you would like to have a \begin{description}[myclass] type of solution? – ivankokan Aug 18 '20 at 9:58
• That sounds promising. – Chris Kern Aug 19 '20 at 13:26
• @ChrisKern See edit. – campa Aug 19 '20 at 13:36
• Thank you! I appreciate it. – Chris Kern Aug 19 '20 at 15:39