0

I'd like to globally add a character to the front of any item that is part of a description list embedded within another description list.

Hardcoded Example

Character U+21B3 is the closest thing I could find to the character I'd like to add. The arrow head is too low. Unfortunately, there is no rightwards equivalent of U+21B5 DOWNWARDS ARROW WITH CORNER LEFTWARDS.

\documentclass{article}
\usepackage{xcolor}
\usepackage{tikz}
\def\defineCMYKcolor(#1,#2,#3,#4)#5{% Just here for item colors
    \pgfmathsetmacro{\myc}{#1/255}%
    \pgfmathsetmacro{\mym}{#2/255}%
    \pgfmathsetmacro{\myy}{#3/255}%
    \pgfmathsetmacro{\myk}{#4/255}%
    \definecolor{#5}{cmyk}{\myc,\mym,\myy,\myk}%
}
\defineCMYKcolor(100,91,7,32){myblue}
\usepackage{fontspec}

\newfontfamily\dejavu[%
  Extension = .ttf
]{DejaVuSerif}

\usepackage{enumitem} % Adds functionality to lists
\setlist[description]{style=nextline,labelwidth=0pt,leftmargin=15pt,font=\normalfont\color{myblue},itemindent=\dimexpr-5pt-\labelsep\relax} % Global Setup Description List

% When a description list is embedded, each item should be prefixed with the character U+21B3
% Unfortunately, there is no right equivalent of U+21B5 DOWNWARDS ARROW WITH CORNER LEFTWARDS, because U+21B3 is actually too low.
% DOWNWARDS ARROW WITH TIP RIGHTWARDS U+21B3
\newcommand\elbowarrowright{\bgroup\dejavu\selectfont \char"21B3\egroup}


\begin{document}
\begin{description}
  \item [apples]
    Really good in apple strudel. Apples come in different varieties:
    \begin{description}
      \item [\elbowarrowright\ Macintosh]% hardcoded
        tart, baking, eating, aromatic
      \item [\elbowarrowright\ Melrose]% hardcoded 
        crisp, sweet, baking, eating
      \item [\elbowarrowright\ Jonathan]% hardcoded
        tart, baking, eating
    \end{description}
  \item [bananas]
    Good with ice cream.
  \item [oranges]
    Sweet delicious fruit.
\end{description}
\end{document}

Output (MikTex)

enter image description here

2 Answers 2

2

You can define options that affect only the second level:

\documentclass{article}

\usepackage{xcolor,enumitem} % Adds functionality to lists
\setlist[description]{style=nextline,labelwidth=0pt,leftmargin=15pt,font=\normalfont\color{blue},itemindent=\dimexpr-5pt-\labelsep\relax} %
\setlist[description,2]{font=\normalfont\color{red}\elbowarrowright\ }

\newcommand\elbowarrowright{see~}
\begin{document}
\begin{description}
  \item [apples]
    Really good in apple strudel. Apples come in different varieties:
    \begin{description}
      \item [Macintosh]% hardcoded
        tart, baking, eating, aromatic
      \item [Melrose]% hardcoded
        crisp, sweet, baking, eating
      \item [Jonathan]% hardcoded
        tart, baking, eating
    \end{description}
  \item [bananas]
    Good with ice cream.
  \item [oranges]
    Sweet delicious fruit.
\end{description}
\end{document}

enter image description here

0
0

As an addendum to Ulrike Fischer's answer, you can define all levels greater than 2 with a loop:

TeX Loop

% Loop Sublevels 2 thru 4
\newcount\descriptionlistlevel
\descriptionlistlevel=4
\loop
  \ifnum\descriptionlistlevel>1
    \setlist[description,\descriptionlistlevel]{font=\normalfont\color{blue}\elbowarrowright\ }% Inherit level 1 and override/append to global levels ≥ 2
\advance\descriptionlistlevel by -1
\repeat

Code

The enumitem package provides the following loop syntax: \value{somecounter}+1, but that is not terribly helpful if you do not know how to make loops, so here is an example.

\documentclass{article}
\usepackage{fontspec}
\usepackage{xcolor,enumitem} % Adds functionality to lists
\usepackage{tikz}
% Setup Level 1
\setlist[description]{style=nextline,labelwidth=0pt,leftmargin=15pt,font=\normalfont\color{red},itemindent=\dimexpr-5pt-\labelsep\relax}%Global Level 1
\DeclareRobustCommand\elbowarrowright{\tikz [baseline=-.5ex]\draw [->] (0,1mm) -- (0,0) -- (2mm,0);}
% Loop Sublevels 2 thru 4
\newcount\descriptionlistlevel
\descriptionlistlevel=4
\loop
  \ifnum\descriptionlistlevel>1
    \setlist[description,\descriptionlistlevel]{font=\normalfont\color{blue}\elbowarrowright\ }% Inherit level 1 and override/append to global levels ≥ 2
\advance\descriptionlistlevel by -1
\repeat

\begin{document}
\begin{description}
  \item [apples (Level 1)]
    Really good in apple strudel. Apples come in different varieties:
    \begin{description}
      \item [Macintosh (Level 2)]% hardcoded
        tart, baking, eating, aromatic
        \begin{description}
           \item [Comment (Level 3)]
             This is my favorite apple.
             \begin{description}
               \item [Level 4]
                 For good measure.
                 \begin{description}
                   \item [Level 5]
                     Because I like to know what happens when things do not go as planned. This level inherits only from level 1.
                 \end{description}
             \end{description}
        \end{description}
      \item [Melrose]% hardcoded
        crisp, sweet, baking, eating
      \item [Jonathan]% hardcoded
        tart, baking, eating
    \end{description}
  \item [bananas]
    Good with ice cream.
  \item [oranges]
    Sweet delicious fruit.
\end{description}
\end{document}

Output

enter image description here

You must log in to answer this question.

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