我有以下 tex 源:
Lorem ipsum dolor Lorem ipsum dolorLorem ipsum dolorLorem ipsum dolorLorem
ipsum dolorLorem ipsum dolorLorem ipsum dolorLorem ipsum dolorLorem ipsum
dolorLorem ipsum dolor
\begin{description}
\item[Google LG Nexus 4] \hfill \\
\begin{itemize}
\item Release date: November 2012,
\item CPU: Qualcomm Snapdragon\texttrademark~S4 Pro processor (ARMv7, 1.5GHz quad core),
\item GPU: Ardeno 320.
\end{itemize}
\item[Samsung Galaxy S III] \hfill \\
\begin{itemize}
\item Release date: May 2012,
\item CPU: Exynos 4 Quad 4412 (ARMv7, 1.4GHz quad core),
\item GPU: ARM Mali-400MP.
\end{itemize}
生成以下 pdf:
我需要删除描述标签(Google LG Nexus 4 和 Samsung Galaxy S III)后的间距并将其添加到嵌套列表后。
我尝试使用enumitem
和,\setlist{nolistsep}
但这只是使嵌套列表更紧凑:
我怎样才能做到这一点?
答案1
额外的空格 —— 实际上是一整行新行 —— 是由组标签后面的项目后的双反斜杠添加的。
在表格或多行数学显示模式之外,很少需要使用双反斜杠来结束一行。这些问题的答案中提出了一般原则:
答案2
如果希望itemize
以新行开始,只需输入\mbox{}
而不是\hfill\\
。要减少 周围的垂直间距itemize
,请将其设置\topsep
为零:
\documentclass{article}
\usepackage{enumitem}
\begin{document}
Lorem ipsum dolor Lorem ipsum dolorLorem ipsum dolorLorem ipsum dolorLorem
ipsum dolorLorem ipsum dolorLorem ipsum dolorLorem ipsum dolorLorem ipsum
dolorLorem ipsum dolor
\begin{description}
\item[Google LG Nexus 4] \mbox{}
\begin{itemize}[topsep=0pt]
\item Release date: November 2012,
\item CPU: Qualcomm Snapdragon\texttrademark~S4 Pro processor (ARMv7, 1.5GHz quad core),
\item GPU: Ardeno 320.
\end{itemize}
\item[Samsung Galaxy S III] \mbox{}
\begin{itemize}[topsep=0pt]
\item Release date: May 2012,
\item CPU: Exynos 4 Quad 4412 (ARMv7, 1.4GHz quad core),
\item GPU: ARM Mali-400MP.
\end{itemize}
\end{description}
\end{document}
您可能需要为这种描述提供另一种输入方式;这可确保在粗体标签后不会出现分页符。
\documentclass{article}
\usepackage{enumitem}
\makeatletter
\newenvironment{describephone}[1]
{\par\addvspace{\topsep}
\noindent\textbf{#1}\par\nobreak\vspace{1ex}%
\@afterheading
\begin{itemize}[topsep=0pt]}
{\end{itemize}\par\addvspace{\topsep}}
\makeatother
\begin{document}
Lorem ipsum dolor Lorem ipsum dolorLorem ipsum dolorLorem ipsum dolorLorem
ipsum dolorLorem ipsum dolorLorem ipsum dolorLorem ipsum dolorLorem ipsum
dolorLorem ipsum dolor
\begin{describephone}{Google LG Nexus 4}
\item Release date: November 2012,
\item CPU: Qualcomm Snapdragon\texttrademark~S4 Pro processor (ARMv7, 1.5GHz quad core),
\item GPU: Ardeno 320.
\end{describephone}
\begin{describephone}{Samsung Galaxy S III}
\item Release date: May 2012,
\item CPU: Exynos 4 Quad 4412 (ARMv7, 1.4GHz quad core),
\item GPU: ARM Mali-400MP.
\end{describephone}
Lorem ipsum dolor Lorem ipsum dolorLorem ipsum dolorLorem ipsum dolorLorem
ipsum dolorLorem ipsum dolorLorem ipsum dolorLorem ipsum dolorLorem ipsum
dolorLorem ipsum dolor
\end{document}