如何更改描述环境中术语词(例如 First、Second...)及其定义(第一项、第二项...)的字体?如何在整个文档中恢复环境后的段落缩进?如何更改环境内项之间的距离?如何更改环境与段落之间的距离(之后和之前)?
\documentclass{article}
\usepackage{lipsum}
\begin{document}
\lipsum
\begin{description}
\item[First] The first item
\item[Second] The second item
\item[Third] The third etc \ldots
\end{description}
\lipsum[1-3]
\end{document}
你能帮助我吗?抱歉我的英语不好
答案1
这里的包enumitem
是你的朋友:
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{lipsum}
\usepackage{enumitem}
\usepackage{xcolor} % if colour is needed
\setlist[description]{%
topsep=30pt, % space before start / after end of list
itemsep=5pt, % space between items
font={\bfseries\sffamily}, % set the label font
% font={\bfseries\sffamily\color{red}}, % if colour is needed
}
% macro to effect changes to the 'text' part of the description env.
\newcommand{\myitem}[2]{\item[#1] \textcolor{blue}{\emph{#2}}}
\begin{document}
\lipsum[1]
\begin{description}
\item[First] The first item
\item[Second] The second item
\item[Third] The third etc \ldots
% use \myitem{<desc>}{<text>} if you want special formatting in both parts:
\myitem{Fourth}{The fourth item}
\myitem{Fifth}{The fifth item, etc.\ldots}
\end{description}
% restore paragraph indentation: add a blank line after \end{description}
\lipsum[3]
\end{document}
答案2
定义您自己的环境Description
:
\documentclass{article}
\usepackage{xcolor}
\newenvironment{Description}
{\list{}{\labelwidth=0pt \itemindent-\leftmargin
\let\makelabel\Descriptionlabel
\itshape% or whatever
}}
{\endlist}
\newcommand*\Descriptionlabel[1]{%
\hspace\labelsep
\normalfont% reset current font setting
\color{blue}\bfseries\sffamily% or whatever
#1}
\begin{document}
\begin{Description}
\item[First] The first item
\item[Second] The second item
\item[Third] The third etc \ldots
\item[Fourth]{The fourth item}
\item[Fifth]{The fifth item, etc.\ldots}
\end{Description}
\end{document}
答案3
作为乔恩展示,枚举项为各种列表配置提供了强大的功能和灵活性。它允许自定义所有描述/条目/枚举类型列表、特定类型的列表、默认列表、自定义列表、特定层次级别的列表、所有级别的列表等。
这是一个稍微扩展的例子。请注意,结果相当丑陋,因为其目的是说明可能性,而不是展示良好的排版或美观性。
\documentclass{article}
\usepackage{enumitem,xcolor}
既然您询问了垂直间距,让我们演示一下它的设置。
\setlist{% configure vertical spacing for all affected lists
topsep=2ex,
partopsep=2ex,
parsep=.75ex,
itemsep=1ex,
添加标签中使用的字体和整个列表使用的字体的选项,实际上,这意味着项目主体,因为标签的字体覆盖了列表范围的设置。
font=\normalfont\bfseries\color{blue},
因此标签将采用粗体蓝色。
before={\color{blue!50!red}\itshape}
其余部分将以紫色斜体显示。
}
由于我们没有使用可选参数\setlist
,因此这将指所有description
、itemize
和enumerate
环境,包括自定义环境。
例如,
\begin{description}
\item[First] The first item
\item[Second] The second item
As any dedicated reader can clearly see, the Ideal of practical reason is a representation of, as far as I know, the things in themselves; as I have shown elsewhere, the phenomena should only be used as a canon for our understanding.
\item[Third] The third etc \ldots
\end{description}
生产
尽管
\begin{enumerate}
\item The first item
\item The second item
As any dedicated reader can clearly see, the Ideal of practical reason is a representation of, as far as I know, the things in themselves; as I have shown elsewhere, the phenomena should only be used as a canon for our understanding.
\item The third etc \ldots
\end{enumerate}
结果是
相应的itemize
给出
这些默认值也适用于自定义列表环境。
例如,让我们设置一个自定义排序列表myenumerate
。
\newlist{myenumerate}{enumerate}{4}
该列表最多可以有 4 个级别。
\setlist[myenumerate]{label=(\Alph*), ref=\Alph*, before={\color{red}\scshape}}
这些设置可能会覆盖上面的默认自定义设置。此特定列表将使用 等形式的标签(A)
,(B)
但对项目的引用将设置为不带括号。对于整个列表,我们设置了红色和小型大写字母形状。但是,自定义标签格式和间距仍然适用,因此标签仍为粗体蓝色。
因此,myenumerate
上述有序列表的版本呈现为
再次假设我们创建一个自定义mydescription
环境。
\newlist{mydescription}{description}{1}
\setlist[mydescription]{font=\normalfont\normalcolor\sffamily, before*={\scshape}}
此列表为 类型description
。标签的字体将采用默认文档无衬线字体和默认颜色,而整个列表将设置为小型大写字母(除非在本地被覆盖),此外,还需加上先前声明的自定义设置。
这意味着使用mydescription
produce设置我们的第一个列表
项目主体仍设置为紫色,因为在列表环境开始时触发的代码实际上是
\color{blue!50!red}\itshape\scshape
这意味着斜体形状被小型大写字母覆盖,但紫色保持不变。
如果我们使用了
before={\scshape}
而不是
before*={\scshape}
那么代码将会有被取代而不是添加我们之前设置的默认值,结果应该是
完整代码:
\documentclass{article}
\usepackage{enumitem,xcolor}
\setlist{% configure vertical spacing for all affected lists
topsep=2ex,
partopsep=2ex,
parsep=.75ex,
itemsep=1ex,
font=\normalfont\bfseries\color{blue},
before={\color{blue!50!red}\itshape}
}
\newlist{myenumerate}{enumerate}{4}
\setlist[myenumerate]{label=(\Alph*), ref=\Alph*, before={\color{red}\scshape}}
\newlist{mydescription}{description}{1}
\setlist[mydescription]{font=\normalfont\normalcolor\sffamily, before*={\scshape}}
\begin{document}
As any dedicated reader can clearly see, the Ideal of practical reason is a representation of, as far as I know, the things in themselves; as I have shown elsewhere, the phenomena should only be used as a canon for our understanding.
\begin{description}
\item[First] The first item
\item[Second] The second item
As any dedicated reader can clearly see, the Ideal of practical reason is a representation of, as far as I know, the things in themselves; as I have shown elsewhere, the phenomena should only be used as a canon for our understanding.
\item[Third] The third etc \ldots
\end{description}
As any dedicated reader can clearly see, the Ideal of practical reason is a representation of, as far as I know, the things in themselves; as I have shown elsewhere, the phenomena should only be used as a canon for our understanding.
\begin{mydescription}
\item[First] The first item
\item[Second] The second item
As any dedicated reader can clearly see, the Ideal of practical reason is a representation of, as far as I know, the things in themselves; as I have shown elsewhere, the phenomena should only be used as a canon for our understanding.
\item[Third] The third etc \ldots
\end{mydescription}
As any dedicated reader can clearly see, the Ideal of practical reason is a representation of, as far as I know, the things in themselves; as I have shown elsewhere, the phenomena should only be used as a canon for our understanding.
\begin{enumerate}
\item The first item
\item The second item
As any dedicated reader can clearly see, the Ideal of practical reason is a representation of, as far as I know, the things in themselves; as I have shown elsewhere, the phenomena should only be used as a canon for our understanding.
\item The third etc \ldots
\end{enumerate}
As any dedicated reader can clearly see, the Ideal of practical reason is a representation of, as far as I know, the things in themselves; as I have shown elsewhere, the phenomena should only be used as a canon for our understanding.
\begin{itemize}
\item The first item
\item The second item
As any dedicated reader can clearly see, the Ideal of practical reason is a representation of, as far as I know, the things in themselves; as I have shown elsewhere, the phenomena should only be used as a canon for our understanding.
\item The third etc \ldots
\end{itemize}
As any dedicated reader can clearly see, the Ideal of practical reason is a representation of, as far as I know, the things in themselves; as I have shown elsewhere, the phenomena should only be used as a canon for our understanding.
\begin{myenumerate}
\item The first item
\item The second item
As any dedicated reader can clearly see, the Ideal of practical reason is a representation of, as far as I know, the things in themselves; as I have shown elsewhere, the phenomena should only be used as a canon for our understanding.
\item The third etc \ldots
\end{myenumerate}
As any dedicated reader can clearly see, the Ideal of practical reason is a representation of, as far as I know, the things in themselves; as I have shown elsewhere, the phenomena should only be used as a canon for our understanding.
\end{document}
答案4
使用scrartcl
来自的文档类别KOMA 脚本,除其他外,您还可以使用 调整用于排版标签的字体\addtokomafont
。
\documentclass{scrartcl}
\begin{document}
\begin{description}
\item[foo] is like bar,
\end{description}
\addtokomafont{descriptionlabel}{\itshape}
\begin{description}
\item[bar] is like a pub
\end{description}
\end{document}