# Customising description lists

Ok folks, I have a slightly bizarre set up and I'm hoping that someone can help.

I have an auto-generated .tex file (made by pandoc from markdown) which has a description list as so:

\begin{description}
\item[Item One]
This is the text that goes with item one
\item[Item Two]
This one is much nicer
\item[Item Three]
The third item is by far my favourite though.
\end{description}


This chunk is auto-generated, so I cannot edit it.

I'm trying to get the output to visually match a different file format, which looks like this:

I'm getting pretty close by using the enumitem package. I can edit the preamble, and I have this so far:

\usepackage{enumitem}
\setlist[description]{style=multiline,leftmargin=5.5cm, itemsep=0cm}
\renewcommand{\descriptionlabel}[1]{
\hspace{\labelsep}
\colorbox{lightgrey}{
\parbox{4.8cm}{
\textbf{#1}
}\par
}
}


This gives me output that looks like this:

I'm fairly new to LaTeX and this is as far as I've been able to get. Does anyone know if I can add a border around the item descriptions? Also if I can join up the item headers and increase the padding around the text.

Thanks!

-- UPDATE --

Let me redefine my question to make it clearer. How can I get the description items (not labels) to have a border? Based on this minimal example:

\documentclass[12pt]{article}

\usepackage{enumitem}
\setlist[description]{style=multiline, leftmargin=5.5cm, itemsep=0cm}

\begin{document}

%% Start of auto-generated code: can't edit this
\begin{description}
\itemsep1pt\parskip0pt\parsep0pt
\item[Item One]
This is the text that goes with item one
\item[Item Two]
This one is much nicer
\item[Item Three]
The third item is by far my favourite though.
\end{description}
%% end of auto-generated code

\end{document}

• Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. – DG' Nov 21 '14 at 10:34
• Yeah of course, sorry, it's just that it's part of a much bigger document. I'll add a minimal example. – ewels Nov 21 '14 at 11:46

Here's one option using the tikzmark library from TikZ and the etoolbox to automatically add the colorized region for the description labels and the frames for the descriptions; the code needs three runs to stabilize:

The code:

\documentclass[12pt]{article}
\usepackage{enumitem}
\usepackage{etoolbox}
\usepackage{tikzpagenodes}
\usetikzlibrary{tikzmark,calc}

\newcounter{colordesc}
\newlength\longestlabel
\setlength\longestlabel{5.5cm}

\setlist[description]{style=multiline, leftmargin=\longestlabel, itemsep=0cm}

\AtBeginEnvironment{description}{%
\stepcounter{colordesc}%
\begin{tikzpicture}[overlay,remember picture]
\fill[gray!60]
( $(pic cs:start-\thecolordesc) + (-25pt,-1.2\topsep)$ )
rectangle
( $({pic cs:start-\thecolordesc}|-{pic cs:end-\thecolordesc}) + (\longestlabel-25pt,-.5\topsep)$ );
\draw[gray!60]
( $(current page text area.east|-{pic cs:start-\thecolordesc}) + (0,-1.2\topsep)$ )
--
( $(current page text area.east|-{pic cs:end-\thecolordesc}) + (0,-0.45\topsep)$ );
\end{tikzpicture}%
\tikzmark{start-\thecolordesc}%
}
\AtEndEnvironment{description}{%
\tikzmark{end-\thecolordesc}%
}
\AtEndEnvironment{description}{%
\tikz[overlay,remember picture]\draw[gray!60]
( $(current page text area.west|-{pic cs:end-\thecolordesc}) + (0,-.45\topsep)$ )
-- ++(\textwidth,0);%
}

\renewcommand*\descriptionlabel[1]{%
\tikz\draw[overlay,gray!60]
(0,.8\baselineskip) --
(\textwidth,.8\baselineskip);%
\hspace\labelsep\normalfont\bfseries #1%
}

\begin{document}

%% Start of auto-generated code: can't edit this
\begin{description}
\itemsep1pt\parskip0pt\parsep0pt
\item[Item One]
This is the text that goes with item one.
\item[Item Two]
This one is much nicer. This one is much nicer. This one is much nicer. This one is much nicer. This one is much nicer. This one is much nicer.
\item[Item Three]
The third item is by far my favourite though.
\item[Item Four]
The fourth item is by far my less favourite.
\end{description}
%% end of auto-generated code

%% Start of auto-generated code: can't edit this
\begin{description}
\itemsep1pt\parskip0pt\parsep0pt
\item[Item One]
This is the text that goes with item one. This is the text that goes with item one. This is the text that goes with item one. This is the text that goes with item one.
\item[Item Two]
This one is much nicer.
\item[Item Three]
The third item is by far my favourite though.
\item[Item Four]
The fourth item is by far my less favourite.
\item[Item Fifth]
I don't really care about the fifth item.
\end{description}
%% end of auto-generated code

%% Start of auto-generated code: can't edit this
\begin{description}
\itemsep1pt\parskip0pt\parsep0pt
\item[Item One]
This is the text that goes with item one
\item[Item Two]
I don't really care about the second item.
\end{description}
%% end of auto-generated code

\end{document}


## Remark

In its present form, this solution doesn't handle page breaks; the necessary modification to admit page breaks is not specially difficult, and as soon as I have the time (perhaps after this weekend) I'll provide it.

• Brilliant! This is much further than I managed to get.. I wait with baited breath :) – ewels Nov 21 '14 at 13:57
• @tallphil Thanks. I've updated my answer. This new version will produce the desired result, but it still doesn't handle page breaks; as I mentioned in the answer, I'll handle page breaks as soon as I have the time. – Gonzalo Medina Nov 21 '14 at 19:05
• Fantastic! :D As you say, it breaks when the list goes over a page, looks great for the smaller lists though.. Exactly what I was going for. Thanks again! Looking forward to the final fix :) – ewels Nov 23 '14 at 14:38
• Hi @gonzalo-medina - do you have any pointers for where I could get started with fixing the page break problem? I've played with your code in my production setting and it looks great now, so this is the last thing I need. I don't really know where to start though :) Thanks again for your help! – ewels Nov 28 '14 at 13:18
• @tallphil Hi! I am working on it; there's a problem with page breaks and the labels (the colorized background overlaps the labels), and I haven't had enough time to develop a full solution. Perhaps later (tomorrow) I'll add my preliminary code to the answer, so you can take a look at iy. – Gonzalo Medina Nov 28 '14 at 13:21