不可分页的居中列表

不可分页的居中列表

我正在尝试编写一个以逐项列表为中心的新环境,下面是它的代码:

\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}%
}

问题是,当我在文档中使用这个环境时,列表需要花很长时间才能打破一个页面并继续另一个页面,列表会完全延续到新页面上。

唉,我不知道为什么会这样。有什么想法吗?

最小工作示例如下。

\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}  

答案1

在环境中使用该varwidth盒子center

\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}  

在此处输入图片描述

答案2

您可以itemize在非线性、居中且可破坏的 tcolorbox 内对环境进行 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}  

在此处输入图片描述

相关内容