0

I want my descriptive lists to look like...

enter image description here

The source for that is (source)...

\documentclass{article}
\usepackage{tcolorbox}
\tcbuselibrary{skins,hooks}

\newcommand\fancybox[3]{%
\tcbset{
    mybox/.style={
        enhanced,
        boxsep=0mm,
        opacityfill=0,
        overlay={
            \coordinate (X) at ([xshift=-1mm, yshift=-1.5mm]frame.north west);
            \node[align=right, text=#1, text width=2.5cm, anchor=north east] at (X) {#2};
            \draw[line width=0.5mm, color=#1] (frame.north west) -- (frame.south west); 
            }
        }
    }
\begin{tcolorbox}[mybox]
    #3
\end{tcolorbox}
}

\definecolor{MyPink}{HTML}{7F007F}
\definecolor{MyGrey}{HTML}{838383}
\definecolor{MyGreen}{HTML}{02856B}

\begin{document}

\fancybox{MyPink}{Define Situation}{
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley 
}

\end{document} 

Is there I way I can replace the default descriptive list item with this fancybox environment (or add a line separator some other way)?

I tried, \renewcommand{\descriptionlabel[1]{\fancybox{red}{#1}{}} and that set the label in the correct place, but I cannot figure out how to set the description properly.

EDIT!

I do not think that using this environment is the best approach. Instead, I tried adapting the code from this post to get something...

I ended up with....

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

\setlist[description]{style=multiline, leftmargin={\dimexpr 2.5cm+\labelwidth+\labelsep}}

\newcommand\desclist[2]{%
  \begin{tikzpicture}
    \node[align=right, anchor=east] (label) at (0,0) {#1};
    \node[anchor=west, text width=\dimexpr\linewidth-1.5em] at ($(label.east)+(1.5em,0)$) {#2};
    \draw[line width=1.5pt] ($(label.north east)+(-2pt,2pt)$) -- ($(label.south east)+(-2pt,-2pt)$);
  \end{tikzpicture}%
}

\renewcommand\descriptionlabel[1]{\desclist{#1}{}}


\begin{document}

%% Start of auto-generated code: can't edit this
\begin{description}
\item[Item One]
This is the text that goes with item one.
\end{description}
\end{document}

which looks almost right but not exactly...

1
  • It may seem something very fancy, but I'm sure there's a simpler Optex/Plain Tex solution for that: I bet @wipet or someone else will come with a clear answer.
    – user574859
    Aug 9, 2023 at 1:04

1 Answer 1

1

The following is more of a hack. It does not use description environment but a with enumitem patched itemize environment. You can use your newdefined command \fancybox for each item:

\documentclass[]{report}
\usepackage[T1]{fontenc}

\usepackage{blindtext}

\usepackage{tcolorbox}
\tcbuselibrary{skins,hooks}

\newcommand\fancybox[3]{%
    \tcbset{
        mybox/.style={
            enhanced,
            boxsep=0mm,
            opacityfill=0,
            overlay={
                \coordinate (X) at ([xshift=-1mm, yshift=-1.5mm]frame.north west);
                \node[align=right, text=#1, text width=2.5cm, anchor=north east] at (X) {#2};
                \draw[line width=0.5mm, color=#1] (frame.north west) -- (frame.south west); 
            }
        }
    }
    \begin{tcolorbox}[mybox]
        #3
    \end{tcolorbox}
}

\definecolor{MyPink}{HTML}{7F007F}
\definecolor{MyGrey}{HTML}{838383}
\definecolor{MyGreen}{HTML}{02856B}

\usepackage{enumitem}
\setlist[itemize,1]{label={},leftmargin={\dimexpr 2.5cm+\labelwidth+\labelsep}} % add width of descriptionlabel and needed widths for itemize indent of \items to the margin. Thus, the environment is correct indented

\begin{document}
\blindtext
\begin{itemize}
    \item \fancybox{MyPink}{Define Situation}{
        Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley 
    }
    \item \fancybox{MyGreen}{2nd Situation}{\blindtext}
\end{itemize}
\blindtext
\end{document}

It looks like that:

description

If you want this version only for one specific case of description-itemize environment, comment the \setlist... line out and add the options to the particular environment: \begin{itemize}[label={},leftmargin={\dimexpr 2.5cm+\labelwidth+\labelsep}] ...

This way, you can also use the regular itemize environment in the same document.

I hope this is a useful solution, although not perfect ;)

Edit:

You can wrap it in a new defined environment and even add optional arguments, like in the following case setting the length of leftmargin. Additionally I defined a new length \descrboxlabelwidth to have the ability of changing the width of the labelbox:

\documentclass[10pt]{report}
\usepackage[T1]{fontenc}

\usepackage{blindtext}

\usepackage{tcolorbox}
\tcbuselibrary{skins,hooks}

\definecolor{MyPink}{HTML}{7F007F}
\definecolor{MyGrey}{HTML}{838383}
\definecolor{MyGreen}{HTML}{02856B}

\usepackage{enumitem}
\newlength{\descrboxlabelwidth}
\setlength\descrboxlabelwidth{2,5cm}
\NewDocumentEnvironment{descrlist}{O{+\labelwidth+\labelsep}}{
    \begin{itemize}[label={},leftmargin={\dimexpr \descrboxlabelwidth#1}]
    }
    {\end{itemize}}
\newcommand\fancybox[3]{%
    \tcbset{
        mybox/.style={
            enhanced,
            boxsep=0mm,
            opacityfill=0,
            overlay={
                \coordinate (X) at ([xshift=-1mm, yshift=-1.5mm]frame.north west);
                \node[align=right, text=#1, text width=\descrboxlabelwidth, anchor=north east] at (X) {#2};
                \draw[line width=0.5mm, color=#1] (frame.north west) -- (frame.south west); 
            }
        }
    }
    \begin{tcolorbox}[mybox]
        #3
    \end{tcolorbox}
}
\begin{document}
    \blindtext
    \begin{descrlist}
        \item \fancybox{MyGreen}{2nd Situation}{Lorem Ipsum is simply dummy text of the printing and typesetting industry.}
        \item \fancybox{MyPink}{Define Situation}{
            Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley 
        }
    \end{descrlist}
    \blindtext
    \begin{descrlist}[+.4\linewidth]
        \item \fancybox{MyGreen}{2nd Situation}{Lorem Ipsum is simply dummy text of the printing and typesetting industry.}
        \item \fancybox{MyPink}{Define Situation}{
            Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley 
        }
        \item \fancybox{MyPink}{Define Situation}{
            Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley 
        }
        \item \fancybox{MyPink}{Define Situation}{
            Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley 
        }
        \item \fancybox{MyPink}{Define Situation}{
            Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley 
        }
    \end{descrlist}
\end{document}

Plus this is page breakable which seemed to be an unsolved problem of your mentioned post.

2
  • Thank you for for your reply. I like the look of your response, but I'd really like to see if I can get this to work with just the description list. I have updated my question with a different approach.
    – user41177
    Aug 8, 2023 at 23:26
  • You could also wrap the edited itemizein a new environment: \NewDocumentEnvironment{descrlist}{}{\begin{itemize}[label={},leftmargin={\dimexpr 2.5cm+\labelwidth+\labelsep}]}{\end{itemize}}. Then you would have a new separate environment.
    – lukeflo
    Aug 9, 2023 at 5:31

You must log in to answer this question.

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