# Fill indentation with dashes

When doing nested itemize, I have a very long list and want to make clear that the items lower on the list are still nested within (dependent on) earlier items.

For this reason, I would like to indent with dashes, i.e.

---If I am Bob,

--------- If it is Saturday,

--------------- If work with Sally,

--------------------------- We both wear suits.

--------------- If tennis is on TV,

--------------------------- I root for Serena Williams.

Sample current code:

\usepackage{enumitem}
\begin{itemize}
\item If I am Bob,
\begin{itemize}[leftmargin=*,labelindent= 1cm]
\item If it is Saturday
\begin{itemize}[leftmargin=*,labelindent= 2cm]
\item If I work with Sally
\begin{itemize}[leftmargin=*,labelindent= 3cm]
\item We both wear suits.
\end{itemize}
\item If tennis is on TV,
\begin{itemize}[leftmargin=*,labelindent= 3cm]
\item I root for Serena Williams.
\end{itemize}
\end{itemize}
\end{itemize}
\end{itemize}


How do I tell latex to fill the indentation space with dashes?

• TeX has a "leaders" features which seems suited for this sort of thing. Unfortunately I don't know enough about LaTeX's itemize environment to know if and how it can be customized to use leaders in place of the normal indentation (assuming you want to keep your input the same). – ShreevatsaR May 1 '17 at 11:20
• do you just want the dashes, or the normal itemize bullets etc as well? – David Carlisle May 1 '17 at 11:48
• Or maybe you want continuous lines of variable length? – Bernard May 1 '17 at 12:13
• alternatively, draw a tree – Marijn May 1 '17 at 14:12

You can keep track of the margins with a length of your own and use to draw an appropriate line. Following you comments, you just want a rule rather than dashes, and you want the standard itemize to be unchanged. So I suggest you introduce a new list, e.g. ditemize, for the particular style.

\documentclass{article}

\usepackage{enumitem}

\newlength{\myindent}
\setlength{\myindent}{0pt}
\newlist{ditemize}{itemize}{4}
\setlist[ditemize]{before={\setlength{\myindent}{\dimexpr\myindent+\leftmargin}},
label=\mbox{\hss\rule[.5ex]{\dimexpr\myindent-\labelsep}{.4pt}}}
\setlist[ditemize,2]{labelindent=1cm}
\setlist[ditemize,3]{labelindent=2cm}
\setlist[ditemize,4]{labelindent=3cm}

\begin{document}

\noindent
Some text that is not indented to show the left margin.

\begin{ditemize}
\item If I am Bob,
\begin{ditemize}
\item If it is Saturday
\begin{ditemize}
\item If I work with Sally
\begin{ditemize}
\item We both wear suits.
\end{ditemize}
\item If tennis is on TV,
\begin{ditemize}
\item I root for Serena Williams.
\end{ditemize}
\end{ditemize}
\end{ditemize}
\end{ditemize}

\end{document}


The code works as follows. Introduce a new variable \myindent to store the current indentation. At the start of each ditemize, using before= code, we add the current margin to \myindent. The mechainism of before means this is done inside a group local to the list, so when a sublist is finished, we recover the old value. Now set the label, to be a rule of an appropriate length, but in a box of zero width and sticking out to the left.

Had you wanted dashes instead of a line, I suggest using the dashrule package, which provides a near drop in replacement for the \rule above. You can then write the label specification as:

label=\mbox{\hss\hdashrule[.5ex]{\dimexpr\myindent-\labelsep}{.4pt}{3pt}}


after issuing \usepackage{dashrule}. With labelsep=.1em this produces:

• Thanks. I do use itemize elsewhere where I don't want dashes. How do I amend only this itemize? Rather than changing all itemize's in the document. – user341502 May 1 '17 at 21:05
• Additionally, I want to change the depth of indentation as described in the foundational post to be 0cm, then 1 cm, then 2cm, etc., where the $i$th nested list has indentation depth $(i-1)$cm. – user341502 May 1 '17 at 21:07
• Thanks. I have updated my answer to reflect these comments. – Andrew Swann May 2 '17 at 7:01