0

I am trying to write new environment that would centre an itemised list, and here is the code for it:

\usepackage{varwidth}
\usepackage{enumitem}

\newenvironment{mitemize}{
     \begin{minipage}{1\textwidth}%
         \centering%
         \begin{varwidth}{\textwidth}%
             \begin{itemize}[rightmargin=1.3cm]%
             \setlength\itemsep{-0.2em}%
}{
             \end{itemize}%
         \end{varwidth}%
     \end{minipage}%
}

And the thing is that, when I am using this environment in my document, and it is a very time for list to break one page to continue on another one, list is completely carried over the new page.

Alas, I do not know why it is happening. Any ideas?

Minimal working example is below.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{varwidth}
\usepackage{enumitem}
\usepackage{lipsum}
\newenvironment{mitemize}{
     \begin{minipage}{1\textwidth}%
         \centering%
         \begin{varwidth}{\textwidth}%
             \begin{itemize}[rightmargin=1.3cm]%
             \setlength\itemsep{-0.2em}%
}{
             \end{itemize}%
         \end{varwidth}%
     \end{minipage}%
}

\newcommand{\phrase}{Withthelightsoutit'slessdangerousHerewearenow,entertainusI feelstupidandcontagiousHerewearenow,entertainusAmulatto,an AlbinoAmosquito,mylibido,yeah}

\begin{document}
\lipsum[1-4]

\vspace{7pt}
\begin{mitemize}
\item \phrase
\item \phrase
\item \phrase
\item \phrase
\end{mitemize}
\end{document}  
  • 2
    minipages do not break across page boundaries. They will always cram themselves on a single page. – Steven B. Segletes Jun 8 '17 at 18:06
  • So you are happy with your MWE. Pity, creating a breakable centered itemized list is a much more interesting problem. – John Kormylo Jun 10 '17 at 13:59
1

Use the varwidth box in a center environment.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{varwidth}
\usepackage{enumitem}
\usepackage{lipsum}
\newenvironment{mitemize}
 {\begin{center}
  \begin{varwidth}{\textwidth}
  \begin{itemize}[
    leftmargin=2cm,
    rightmargin=\dimexpr2cm-\labelwidth\relax,
    itemsep=-0.2em]
 }{\end{itemize}
   \end{varwidth}
   \end{center}}

\newcommand{\phrase}{With the lights out it's
  less dangerous Here we are now, entertainus I feel stupid
  andcontagious Here we are now, entertainus A mulatto, an 
  Albino A mosquito, mylibido, yeah}

\begin{document}
\lipsum[1]

\begin{mitemize}
\item \phrase
\item \phrase
\item \phrase
\item \phrase
\end{mitemize}

\lipsum[2]

\end{document}  

enter image description here

| improve this answer | |
0

You can tcolorboxify an itemize environment within a non-linewidth, centered and breakable tcolorbox.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[most]{tcolorbox}
\usepackage{enumitem}
\usepackage{lipsum}

\newcommand{\phrase}{With the lights out it's less dangerous Here we are now, entertain us I feel stupid and contagious Here we are now, entertain us A mulatto, an Albino Amosquito, my libido, yeah}

\newenvironment{myitemize}{%
\begin{itemize}}{\end{itemize}}

\tcolorboxenvironment{myitemize}{%
    blanker,
    center,
    breakable,
    width=.75\textwidth}

\begin{document}
\lipsum[1-4]
\begin{myitemize}
\item \phrase
\item \phrase
\item \phrase
\item \phrase
\end{myitemize}
\lipsum[1-4]
\end{document}  

enter image description here

| improve this answer | |

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.