5

I am using enumerate together with the enumitem package. I have set up my code as per the MWE below. This puts the label and number to the left of the text. I am wondering it there a way to adapt this so as that the label and number appear above the text (with a line break) instead of to the left.

For example I would like it to look like this;

                                       Article 1

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus
elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dic-
tum gravida mauris. Nam arcu libero, ...

This is my MWE;

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{lipsum} % just for dummy text
\usepackage{enumitem} 

\begin{document}

\begin{enumerate}[label=Article \arabic*:]
\item \lipsum[1].

\item \lipsum[1]

\item \lipsum[1]
\end{enumerate}
\end{document}

4 Answers 4

2

Here is a simple way, with the stackengine package. You can set the distance beteen label and body with before=\setstackgap[S]{…}:

\documentclass[12pt,a4paper]{article}

\usepackage[utf8]{inputenc}
\usepackage{lipsum} % just for dummy text
\usepackage{enumitem}
\usepackage{stackengine}

\begin{document}


\begin{enumerate}[label=\hfill\stackon{}{Article \arabic*}\hfill, wide=0pt, labelwidth=\textwidth, itemsep=1.25\baselineskip, before=\setstackgap{S}{2.5ex}]
\item \lipsum[1]

\item \lipsum[1]

\item \lipsum[1]
\end{enumerate}

\end{document} 

enter image description here

5

Define a new list and a new align:

\documentclass{article}
\usepackage{lipsum,showframe}   %% showframe for demo
\usepackage{enumitem}
\SetLabelAlign{mycenter}{\strut\smash{\parbox[t]{\textwidth}
                            {\centering#1}}%
                        }
\newlist{mylist}{enumerate}{1}
\setlist[mylist]{label=\bfseries Article~\arabic*,align=mycenter,
                    leftmargin=0cm,itemindent=\labelwidth}

\begin{document}
\begin{mylist}
\item \lipsum[1]
\item \lipsum[1]
\end{mylist}
\end{document}

enter image description here

3

How about this (you can obviously tweak the vertical space in the definition):

\documentclass{article}
\usepackage{lipsum}
\usepackage[inline]{enumitem}
\newenvironment{mylist}{%
  \begin{enumerate*}[%
    before={\\[12pt]},%
    label=\centerline{Article \arabic*:},%
    afterlabel={\\[12pt]},%
    itemjoin={\\[12pt]},%
    itemjoin*={\\[12pt]},%
    ]%
    }{\end{enumerate*}}
\begin{document}
\begin{mylist}
\item \lipsum[1]
\item \lipsum[1]
\end{mylist}
\end{document}
2
  • May be a little better would be not to use \centerline and use \par\addvspace{..} rather than \\[..].
    – Manuel
    Oct 11, 2014 at 12:33
  • I can not get your idea to work right now Manuel, maybe you can post a full answer.
    – Lucas
    Oct 11, 2014 at 12:46
2

I didn't see an easy way to use enumitem to make enumerate work this way (but Lucas was smarter!), so I thought that you had only two options:

  • Use existing formatting. For example, it wouldn't be that hard to do what you want using \section or \subsection commands, either by choosing a class that centres these or by using titlesec to get the formatting that you want.

  • Build you own custom environment.

Here is one way that you could build your own environment so that it produces:

enter image description here

and here is the code:

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{lipsum} % just for dummy text
\usepackage{enumitem}

\begin{document}

\newcounter{centereditem}%  a counter for the article numbers
\renewcommand\thecentereditem{Article~\arabic{centereditem}}
\newcommand\centereditem{% this will become the \item command in the environment
  \refstepcounter{centereditem}
  \centerline{\thecentereditem}
}
% Usage:
%   - \begin{centeredlist}...\end{centeredlist}
%   - \begin{centeredlist}[num]...\end{centeredlist}, to make numbering start a num+1
\newenvironment{centeredlist}[1][0]
  {\let\item=\centereditem%
   \setcounter{centereditem}{#1}
  }{}

\begin{centeredlist}
\item \lipsum[1].

\item \lipsum[1]

\item \lipsum[1]
\end{centeredlist}

\end{document}
2
  • You can see a way to make enumitem do the job in my answer below, but what magic in your code makes the item labels appear on a line by themselves?
    – Lucas
    Oct 11, 2014 at 12:36
  • @Lucas I do it the same way that you do: inside the centeredlist environment \item=\centereditem and, in turn, \centereditem uses \centerline. I like your solution better: I tried using label=\hfill Article~\arabic*\hfill but when this didn't work I took the route above. As the centeredlist environment is inside a group \item reverts to its normal meaning after the end of the environment.
    – user30471
    Oct 11, 2014 at 12:41

You must log in to answer this question.

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