Is there any way that I can change \parskip
to a d开发者_运维百科ifferent value inside certain environments, namely enumerate
and itemize
.
I want to have space between paragraphs (\setlength{\parskip}{1em plus 1pt minus 1pt}
), but not inside itemize or enumerate.
If you use the enumitem
package, you can say in your preamble
\setlist[itemize]{parsep=0pt}
\setlist[enumerate]{parsep=0pt}
to get what you want. enumitem
allows for doing much more list customization, see its documentation for details.
you can also use:
begin{itemize} \itemsep -5pt
\item foo
\item bar
\end{itemize}
and that will only affect the current list.
Yes you can; but you will have to alter either the enumerate
and itemize
environments from your class file (by copying them and adding your \parskip
), or by redefining \@listi
, which works for all lists:
\makeatletter
\def\@listi{%
% default settings for base LaTeX classes at 10pt:
\parsep 4pt plus 2pt minus 1pt
\topsep 8pt plus 2pt minus 4pt
\itemsep 4pt plus 2pt minus 1pt
% your settings:
\parskip 1em plus 1pt minus 1pt
}
\makeatother
If you want different settings at nested list levels, change \@listii
, \@listiii
etc.
The following addition to the preamble updates enumerate
to make the suggested change:
\let\oldenumerate\enumerate% Keep a copy of \enumerate (or \begin{enumerate})
\let\endoldenumerate\endenumerate% Keep a copy of \endenumerate (or \end{enumerate})
\renewenvironment{enumerate}
{\begin{oldenumerate}
\setlength{\parskip}{0pt}}% Adjust \parskip to suit your needs
{\end{oldenumerate}}
Here is a complete minimal example showing the adjustment when setting \parskip
to 0pt
:
\documentclass{article}
\begin{document}
\begin{enumerate}
\item First line
Second line
\end{enumerate}
\let\oldenumerate\enumerate
\let\endoldenumerate\endenumerate
\renewenvironment{enumerate}
{\begin{oldenumerate}
\setlength{\parskip}{0pt}}
{\end{oldenumerate}}
\begin{enumerate}
\item First line
Second line
\end{enumerate}
\end{document}
One would do exactly the same for itemize
.
精彩评论