4

I'm working on a project that requires a nested, enumerated list, the outer most items styled as shown below: a background color on the label, shading over the rest of the line containing the item label, and a line break following.

I seem to get as far as to develop the outer list with styling by making use of the inparaenum and tabularx packages, however when the nested list is an enumerate environment, I receive a 'missing item' error. I would continue using another inparaenum environment for the nested list, however I can't seem to force linebreaks for each item. This also seems to be poor semantically speaking since the environment should be used inline.

Anyone able to point me the right direction? I would love a solution that doesn't feel like a hack (like my attempted solution described above), but any solution at this point is welcomed. Thanks!

custom enumerated list

Minimal Working Example

\documentclass{article}
\usepackage{paralist,enumitem,tabularx, xcolor, colortbl}

\makeatletter
\def\myitem{%
   \@ifnextchar[ \@myitem{\@noitemargtrue\@myitem[\@itemlabel]}}
\def\@myitem[#1]{\renewcommand{\arraystretch}{1.5}\begin{tabularx}{\textwidth}{>{\columncolor{black}}l>{\columncolor{black!50}}X}\item[\color{white}#1]&\end{tabularx}\\}
\makeatother


\begin{document}
\begin{inparaenum}[1]
\myitem
\end{inparaenum}


\begin{enumerate}[label=\Alph*)]
\item NO CHANGE
\item were added to the bell.
\item were late additions to the bell.
\item were late additions to the bell, added after many years
\end{enumerate}
\end{document}

which produces

custom enumerated list

but will require that each top level item to be instantiated separately and the counter will need to be set every time.

1

1 Answer 1

4

Here is a solution with enumitem. I define fenum environments, with two levels, cloned from enumerate, with the relevant parameters.

\documentclass{article}
\usepackage[x11names]{xcolor}
\usepackage[showframe]{geometry}
\usepackage{enumitem}

\newlist{fenum}{enumerate}{2}
\setlist[fenum, 1]{label =\setlength\fboxsep{0pt}%
\raisebox{0.5ex}{\colorbox{LightSteelBlue3!30}{\makebox[\linewidth][l]{\setlength\fboxsep{3pt}%
\colorbox{RoyalBlue3!80}{\bfseries\color{white}\,\arabic*\,}}}}, wide= 0pt, labelsep = 0pt}%

\setlist[fenum, 2]{label =\Alph*), labelsep =0.25em, wide =1.5em, leftmargin = *, before =\leavevmode\vspace{-\topsep}}

\usepackage{lipsum}

\begin{document}

\lipsum[2]
\begin{fenum}
  \item \begin{fenum}[]
  \item NO CHANGE Test test test Test test test Test test test Test test test Test test test Test test test Test test test Test test test
  \item defeat
  \item outperform
  \item outweigh
\end{fenum}
\item Second item
\end{fenum}

\lipsum[3]
\end{document} 

enter image description here

You must log in to answer this question.

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