今晚我坐下来尝试定义一个如下所示的简单列表:
1:23
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean
commodo ligula eget dolor. Aenean massa. Cum sociis natoque
penatibus et magnis dis parturient montes, nascetur ridiculus
mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis,
sem.
Nulla consequat massa quis enim. Donec pede justo, fringilla vel,
aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut,
imperdiet a, venenatis vitae, justo.
所以你可以看到要求相当简单。项目标签根本不应该缩进,而应该精确地从左边距开始。它后面应该有一个换行符。换行符后面是项目主体。它应该缩进 - 整个段落 - 以及所有后续段落都应缩进相同的量。但是,不应该有任何段落开始缩进,所有段落都应该从空行开始。在示例中,缩进是两个空格,但我认为四个空格就足够了。
作为可能的复杂因素,我的文档整体上遵循上述段落样式,段落之间有空行,没有初始缩进。其次,我想用打字机文本格式化项目标签。
所以,显然,我认为,我需要一个list
环境。
\documentclass[12pt]{article}
\pagestyle{plain}
\usepackage[margin=1.8cm]{geometry}
\geometry{a4paper}
\usepackage[parfill]{parskip}
\begin{document}
\begin{list}{}{}
\item[1:23]
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean
commodo ligula eget dolor. Aenean massa. Cum sociis natoque
penatibus et magnis dis parturient montes, nascetur ridiculus
mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis,
sem.
Nulla consequat massa quis enim. Donec pede justo, fringilla vel,
aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut,
imperdiet a, venenatis vitae, justo.
\end{list}
\end{document}
但我完全搞不懂该把什么作为第二个参数,因为标签的实际缩进似乎本身并没有定义。相反,它\leftmargin
定义了,而项目标签则通过其他相关参数相对于它分流,而我不知道如何调整这些参数。
任何补充解释都将非常感激。
答案1
你做想要一份清单。
\documentclass[12pt]{article}
\pagestyle{plain}
\usepackage[margin=1.8cm]{geometry}
\geometry{a4paper,showframe} % showframe just for the example
\usepackage[parfill]{parskip}
\newenvironment{points}
{\begin{list}{}{\leftmargin=1em\labelwidth=\leftmargin\labelsep=0pt}%
\newcommand{\point}[1]{\item[##1]\mbox{}\\*\ignorespaces}}
{\end{list}}
\begin{document}
\begin{points}
\point{1:23}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean
commodo ligula eget dolor. Aenean massa. Cum sociis natoque
penatibus et magnis dis parturient montes, nascetur ridiculus
mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis,
sem.
Nulla consequat massa quis enim. Donec pede justo, fringilla vel,
aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut,
imperdiet a, venenatis vitae, justo.
\point{22:333}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean
commodo ligula eget dolor. Aenean massa. Cum sociis natoque
penatibus et magnis dis parturient montes, nascetur ridiculus
mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis,
sem.
\end{points}
\end{document}
答案2
这似乎非常接近你想要的:
\documentclass[12pt]{article}
\pagestyle{plain}
\usepackage[a4paper,margin=1.8cm]{geometry}
\usepackage{enumitem}
\usepackage{lipsum}
\usepackage{showframe}
\newlist{simple}{description}{1}
\setlist[simple]{leftmargin=4mm, % indentation of paragraphs
font=\texttt, % typewritter text for labels
style=nextline, % start new line for "wide" labels
labelindent=0pt, % the remaining settings make the
itemindent=-1.5mm,% width of the labels, with a small hack
% to drag the label back to the margin
listparindent=0pt,
labelwidth=0pt,
}
\begin{document}
\begin{simple}
\item[1:23]\lipsum[1-2]
\item[1:24]\lipsum[1-2]
\end{simple}
\end{document}
我用过展示架显示边距的位置。请注意,itemindent=-1.5mm
出于某种原因,需要使用一个小技巧来将标签放回到边距。
答案3
最后我放弃了使用list
环境,而是使用方框定义了一个新命令。这对我来说很管用,但感觉有点儿不方便。
\newlength{\currentparskip}
\setlength{\currentparskip}{\parskip}
\newcommand{\point}[2]{\texttt{#1} \\
\makebox[1em]{}\begin{minipage}[t]{\dimexpr\textwidth-1em}%
\setlength{\parskip}{\currentparskip}%
#2%
\end{minipage}%
}
我发现使用 1em 宽的盒子之前是minipage
必要的,因为\hfill
似乎没有做任何事情。
但它似乎能起到作用:
\documentclass[12pt]{article}
\pagestyle{plain}
\usepackage[margin=1.8cm]{geometry}
\geometry{a4paper}
\usepackage[parfill]{parskip}
\usepackage{showframe}
\newlength{\currentparskip}
\setlength{\currentparskip}{\parskip}
\newcommand{\point}[2]{\texttt{#1} \\
\makebox[1em]{}\begin{minipage}[t]{\dimexpr\textwidth-1em}%
\setlength{\parskip}{\currentparskip}%
#2%
\end{minipage}%
}
\begin{document}
\point{1:23}{%
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean
commodo ligula eget dolor. Aenean massa. Cum sociis natoque
penatibus et magnis dis parturient montes, nascetur ridiculus
mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis,
sem.
Nulla consequat massa quis enim. Donec pede justo, fringilla vel,
aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut,
imperdiet a, venenatis vitae, justo.
}
\point{1:24}{%
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean
commodo ligula eget dolor. Aenean massa. Cum sociis natoque
penatibus et magnis dis parturient montes, nascetur ridiculus
mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis,
sem.
Nulla consequat massa quis enim. Donec pede justo, fringilla vel,
aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut,
imperdiet a, venenatis vitae, justo.
}
\end{document}
请注意,我确实明白
Overfull \hbox (30.0pt too wide) in paragraph at lines 29--30
警告。