9

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.

5

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

5

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

4

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.

  • \begin{tabular}[t] would be more intuitive. – egreg May 7 '14 at 15:29
  • @egreg, indeed you are right. I did as you suggested. Thanks. – Pouya May 7 '14 at 15:41
  • how does one extend this to include \item[label]? – Debanjan Basu Aug 20 '15 at 17:02
  • @DebanjanBasu, as easy as \newcommand{\LinedItem}[1]{\item[label] \begin{tabular}[t]{|p{10cm}}#1\end{tabular}} – Pouya Aug 21 '15 at 8:42
  • no no. I mean I want to use \LinedItem[label] text ... - the label will not be the same all the times and hence wouldn't be mentioned in the macro definition. – Debanjan Basu Aug 21 '15 at 14:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.