如何控制项目末尾的间距?

如何控制项目末尾的间距?

这涉及到我之前的问题

如何减少 itemize 开头但不减少结尾的空间

现在我需要控制 itemize 末尾的间距,就像上一个问题建议的那样,我可以控制开头的间距。我该如何控制它?

答案1

以下地址两个都问题 - 如何调整itemize环境上方和下方的分离。这是使用键值方法完成的(感谢 [ keyval](ht,它允许您设置beforeskipafterskip(默认值为0pt)。

在此处输入图片描述

\documentclass{article}
\usepackage{keyval}% http://ctan.org/pkg/keyval
\makeatletter
\newlength{\mylist@beforeskip}
\newlength{\mylist@afterskip}
\define@key{mylist}{beforeskip}{\setlength{\mylist@beforeskip}{#1}}
\define@key{mylist}{afterskip}{\setlength{\mylist@afterskip}{#1}}
\newenvironment{mylist}[1][,]
  {\setkeys{mylist}{beforeskip=0pt,afterskip=0pt,#1}%
   \par\vspace*{\mylist@beforeskip}%
   \begin{itemize}}
  {\end{itemize}%
   \vspace*{\mylist@afterskip}}
\makeatother
\begin{document}
\noindent Here is some text. Regular \verb|itemize|:
\begin{itemize}
  \item stuff \item stuff \item 
\end{itemize}
Here is some text. New \verb|mylist|:
\begin{mylist}
  \item stuff \item stuff \item
\end{mylist}
Here is some text. New \verb|mylist| with \verb|beforeskip=-\baselineskip|:
\begin{mylist}[beforeskip=-\baselineskip]
  \item stuff \item stuff \item
\end{mylist}
Here is some text. New \verb|mylist| with \verb|afterskip=-\baselineskip|:
\begin{mylist}[afterskip=-\baselineskip]
  \item stuff \item stuff \item
\end{mylist}
Here is some text. New \verb|mylist| with \verb|beforeskip=afterskip=-\baselineskip|:
\begin{mylist}[beforeskip=-\baselineskip,afterskip=-\baselineskip]
  \item stuff \item stuff \item
\end{mylist}
Here is some text.
\end{document}

相关内容