4

How can I define a list environment using a package like enumitem such that it reproduces the same output as the following code but with the syntax of an enumerated list:

\documentclass[a4paper,12pt]{article}

\usepackage{lipsum}

\begin{document}

\subsubsection*{Item 1}
\lipsum[1]

\subsubsection*{Item 2}
\lipsum[2]

\subsubsection*{Item 3}
\lipsum[3]

%% The following syntax should produce the same as above.

% \begin{mylist}
%   \item 
%     \lipsum[1]
%   \item 
%     \lipsum[2]
%   \item 
%     \lipsum[3]
% \end{mylist}

\end{document}

Desired output:

enter image description here

  • Shall Item 1 etc. be printed as well? – user31729 Aug 21 '16 at 11:18
  • Yes, exactly as in the output of the posted example. – student Aug 21 '16 at 11:22
  • Using \subsubsection* is easier then, in my point of view – user31729 Aug 21 '16 at 11:34
  • 2
    @ChristianHupfer You mean something like this: tex.stackexchange.com/a/176265/4011 – student Aug 21 '16 at 11:57
  • Yes, pretty much like that. – user31729 Aug 21 '16 at 11:59
4

Here is a possibility

\documentclass[a4paper,12pt]{article}
\usepackage{lipsum}
\usepackage{calc}
\usepackage[inline]{enumitem}
\newlist{mylist}{enumerate}{1}
\setlist[mylist]{
    label=\bfseries Item \arabic*,
    labelwidth=\widthof{last-item},
    leftmargin=!,
    align=left,
    itemindent=1.8cm,
    itemsep=10pt
}

\newcommand{\myitem}{\item~\\[6pt]}
\begin{document}
\subsubsection*{Item 1}
\lipsum[1]

\subsubsection*{Item 2}
\lipsum[2]

\subsubsection*{Item 3}
\lipsum[3]

%% The following syntax should produce the same as above.


 \begin{mylist}
   \myitem
     \lipsum[1]
   \myitem 
     \lipsum[2]
   \myitem 
     \lipsum[3]
 \end{mylist}

\end{document}

enter image description here

I had to redefine \item too so to send the item text to a new line.

labelwidth=\widthof{last-item},
leftmargin=!,
align=left,

are for setting the label next to the margin. To automatically calculate the largest label width the package calc is needed.

itemindent=1.8cm,

is for removing the indent of the item text (this is the only value I wasn't able to compute automatically but should be fixed, so not a big deal)

itemsep=10pt

sets the vertical space between items

\newcommand{\myitem}{\item~\\[6pt]}

sends the item text to a newline with a vertical space of 6pt from the label.

  • 2
    Actually you did not redefine \item, you wrapped in another macro ;-) Hopefully \myitem[...] is never requested ;-) – user31729 Aug 21 '16 at 11:42
  • 1
    @ChristianHupfer oh yes, you are absolutely right! – Nico Boni Aug 21 '16 at 11:45
2

A very simple code, which lets you use the usual \item command:

\documentclass[a4paper,12pt]{article}
\usepackage{lipsum}
\usepackage{enumitem}
\newlist{mylist}{enumerate}{1}

\setlist[mylist]{label=\raisebox{0pt}[4ex][3ex]{\makebox[\textwidth][l]{\bfseries Item \arabic*}}, wide = 0pt}

\begin{document}

 \begin{mylist}
   \item
     \lipsum[1]
   \item
     \lipsum[2]
   \item
     \lipsum[3]
 \end{mylist}

\end{document} 

enter image description here

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.