10

Is it possible to have list environments (itemize, enumerate, ...) which have a vertical line between the label (i.e. the bullet/number) and the listing content?

Probably this is best explained using an image, I want to achieve something like this:

List

Edit: Some more info on the intended behaviour: If a pagebreak occurs, the line should naturally continue on the new page.

elemakil
  • 1,319

3 Answers3

6

A solution with mdframed, that also allows page breaks in the item. Not that I endorse this layout.

\documentclass{article}
\usepackage{lipsum,mdframed}

\mdfdefinestyle{litem}{
  skipabove=0pt,
  skipbelow=0pt,
  leftmargin=\dimexpr\leftmargini-\fboxrule-2pt\relax,
  rightmargin=0pt,
  innerleftmargin=2pt,
  innerrightmargin=0pt,
  innertopmargin=0pt,
  innerbottommargin=0pt,
  leftline=true,
  rightline=false,
  topline=false,
  bottomline=false,
}

\newenvironment{litemize}{\trivlist\item\relax}{\endtrivlist}
\newenvironment{litem}
  {%
   \par\addvspace{3\itemsep}
   \begin{mdframed}[style=litem]
   \makebox[0pt][r]{\textbullet\hspace{\dimexpr\labelsep+2pt+\fboxrule}}\ignorespaces
  }
  {%
   \end{mdframed}
  }

\begin{document}
\lipsum[2]
\begin{itemize}
\item a
\item b
\end{itemize}
Some text to separate the two environments
\begin{litemize}
  \begin{litem}
  \lipsum*[2]
  \end{litem}

  \begin{litem}
  \lipsum*[3]
  \end{litem}

  \begin{litem}
  A fairly small one!
  \end{litem}
\end{litemize}
\lipsum[4]
\end{document}

enter image description here

egreg
  • 1,121,712
6

A tcolorbox version which allows page breaks and is heavily customizable:

\documentclass{article}
\usepackage{tcolorbox}
\tcbuselibrary{skins,breakable}
\usepackage{lipsum}


\newtcolorbox{mybox}{
  freelance,
  breakable,
  colback=white,
  top=0pt,
  frame code={                          %%decoration code for unbreakable version
    \draw(frame.north west)--(frame.south west);
    \node[at=(frame.north west),anchor=north east,xshift=-5pt,circle,fill=black, inner sep=3pt]{};
  },
  extend freelancefirst={               %%decoration code for breakable version, first page
    frame code={
      \draw(frame.north west)--(frame.south west);
      \node[at=(frame.north west),anchor=north east,xshift=-5pt,circle,fill=black]{};
    },
  },
  extend freelancemiddle={              %%decoration code for breakable version, middle pages
    frame code={
      \draw(frame.north west)--(frame.south west);
    },
  },
  extend freelancelast={                %%decoration code for breakable version, last page
    frame code={
      \draw(frame.north west)--(frame.south west);
    },
  },
}

\newcommand{\myitem}[1]{\item\begin{mybox}#1\end{mybox}}
\begin{document}
\begin{itemize}
  \myitem{one line}
  \myitem{two

  lines}
  \myitem{\lipsum}
\end{itemize}

\end{document}

enter image description here

d-cmst
  • 23,095
5

Here is my not so elegant and very lame solution: using tabular within the itemize.

\documentclass{article}
\usepackage{lipsum}
\newcommand{\LinedItem}[1]{\item \begin{tabular}[t]{|p{10cm}}#1\end{tabular}}
\begin{document}
\lipsum[1]
\begin{itemize} 
    \LinedItem{\lipsum[2]}
    \LinedItem{\lipsum[3]}
    \LinedItem{A fairly small one!}
\end{itemize}
\lipsum[4]
\end{document}

enter image description here

Few possible updates that I leave to you to test are: Instead of p{10cm}, try something more general like p{\SomeInterestingWidth}. Secondly, you can try with other packages such as tabularx to change the behavior in the line break.

Pouya
  • 7,269