我想使用 enumitem 全局创建这个垂直空间。该键会style=nextline
按我的意愿将项目内容推送到其自己的行,但我想添加一些我选择的垂直空间。这是我的 MWE:
\documentclass{article}
\usepackage{enumitem}
\setlist[description]{%
labelindent=0em,
leftmargin=1.5em,
font={\large\bfseries},
style=nextline
}
\begin{document}
\begin{description}
\item[Backgammon] One of the oldest known games, Backgammon was played
by the ancient Mesopotamians.
\end{description}
\end{document}
答案1
最终代码:
\documentclass{article}
\usepackage{enumitem}
\def\myitem[#1]{\item[#1\vspace{8pt}]}
\setlist[description]{%
labelindent=0em,
leftmargin=1.5em,
font={\large\bfseries},
style=nextline,
}
\begin{document}
test
\begin{description}
\myitem[Backgammon] One of the oldest known games, Backgammon was played
by the ancient Mesopotamians.
\myitem[Chess]
\begin{itemize}\myitem[] %%%IF THE FIRST DESCRIPTION ITEM HAS A LIST AS A BODY WE NEED TO START LIKE THIS TO TRIGGER THE NEW LINE
\item First inside
\item Second inside
\end{itemize}
Newer than Backgammon with subtracted the factor of luck (as possible)
\begin{itemize}
\item First inside
\item Second inside
\end{itemize}
\begin{enumerate}
\item Numbered 1
\item Numbered two
\end{enumerate}
\begin{description}
\myitem[Nested In chess] test text body od description
\begin{enumerate}
\item Numbered 1
\item Numbered two
\end{enumerate}
\myitem[More description in Chess] test description body after enumeration
\end{description}
\end{description}
Next paragraph and test if itemize and enumerate is ok:
\begin{itemize}
\item first
\item second
\end{itemize}
\begin{enumerate}
\item a
\item b
\end{enumerate}
\end{document}
接受 OP 和他的新请求后进行编辑:
关于编辑的评论:在新列表中重新定义项目之后,在定义的环境中又添加了新列表。这导致在我们定义的环境中插入新列表或其他内容时出现问题。
作为一个解决方案,我重新定义了 \begin 命令,以包含对 \item 的重新定义,就像更改之前一样……这样,需要旧项目的新环境就会发现它原来的样子……嵌套将“在重新定义之后重新定义重新定义”-> 有趣但真实……而且它会起作用。不使用 \item 的环境不会有问题(但这只是猜测,因为我无法知道每个环境的代码以及与我的 hack 可能存在的冲突)……
结果:不得不在这里做,但我不能保证这种黑客行为没有危险,我可以理解任何不接受良好编程实践的人...我希望他明白这种做法可以以尽可能少的努力解决非乳胶专家的许多问题...(仍然不推荐给专业人士:P)
如果列表遵循我们的环境,它将重新定义项目为原始项目,因此我们创建的新列表将不会使用项目的重新定义命令,也不会中断行。在这种情况下,\begin
在我们的描述中遵循列表之后,我们可以添加一个空的\myitem[]
,但如果描述列表有多个项目,我们可能仍会发现问题……(未经测试)因此,上述方法更简单、更好。
\documentclass{article}
\usepackage{enumitem}
\let\olditem=\item
\def\myitem[#1]{\olditem[#1\vspace{8pt}]}
\let\oldbegin\begin
\def\begin{\let\item\olditem\oldbegin}
\setlist[description]{%
before=\let\item\myitem,
labelindent=0em,
leftmargin=1.5em,
font={\large\bfseries},
style=nextline,
}
\begin{document}
test
\begin{description}
\item[Backgammon] One of the oldest known games, Backgammon was played
by the ancient Mesopotamians.
\item[Chess]
\begin{itemize}\myitem[]
\item First inside
\item Second inside
\end{itemize}
Newer than Backgammon with subtracted the factor of luck (as possible)
\begin{itemize}
\item First inside
\item Second inside
\end{itemize}
\begin{enumerate}
\item Numbered 1
\item Numbered two
\end{enumerate}
\begin{description}
\item[Nested In chess] test text
\begin{enumerate}
\item Numbered 1
\item Numbered two
\end{enumerate}
\end{description}
\end{description}
Next paragraph and test if itemize and enumerate is ok:
\begin{itemize}
\item first
\item second
\end{itemize}
\begin{enumerate}
\item a
\item b
\end{enumerate}
\end{document}
输出:
旧答案:
这是一个解决方案:
\documentclass{article}
\usepackage{enumitem}
\let\olditem=\item
\def\myitem[#1]{\olditem[#1\vspace{8pt}]}
\setlist[description]{%
before=\let\item\myitem,
labelindent=0em,
leftmargin=1.5em,
font={\large\bfseries},
style=nextline,
}
\begin{document}
test
\begin{description}
\item[Backgammon] One of the oldest known games, Backgammon was played
by the ancient Mesopotamians.
\item[Chess] Newer than Backgammon with subtracted the factor of luck (as possible)
\end{description}
Next paragraph and test if itemize and enumerate is ok:
\begin{itemize}
\item first
\item second
\end{itemize}
\begin{enumerate}
\item a
\item b
\end{enumerate}
\end{document}
输出: