定义的最佳实践:描述与段落及其他

定义的最佳实践:描述与段落及其他

我想定义一些技术术语(例如精度、重复性、误差、准确度等)。我见过两种不同方式的教程:

\begin{description}
    \item[term] describing text
\end{description}

或者

\paragraph{term}
describing text

它们之间有什么区别、哪种方式适合哪种应用,以及是否还有更好的选择?

答案1

description环境在概念上是一个itemize类似环境,因此是一个“列表”,用于列出一些项目,增强其名称并显示其描述,以便它们与正常文本分开和缩进(从而增强),并且更清晰可见。

\paragraph是分段命令,表示文档中的分段,通常可用于插入一些注释或一些简短讨论特定主题的小段落。段落开头的单词(即括号之间的单词)之间的间距比 中使用的间距大。请注意,description对于较长的描述,这些描述会像普通文本一样流动,不会显示在缩进环境中。

我会选择description,它更紧凑并且增强了定义,并且通常从不使用环境paragraph,除非我想对上面的文本进行一些评论以吸引读者。

编辑

我正在添加一个例子

\documentclass{article}
\begin{document}

\begin{description}
 \item[item1:] a somewhat long long description about your item and all about it and look how pretty it is displayed like this
  \item[item2:] a somewhat long long description about your item and all about it and look how pretty it is displayed like this
  \end{description}

  \paragraph{item1} a somewhat long long description about your item and all about it and look how pretty it is displayed like this

  \paragraph{item2} a somewhat long long description about your item and all about it and look how pretty it is displayed like this
 \end{document}

在此处输入图片描述

答案2

我自己description也测试了paragraph一下,发现一般情况下description应该使用。下面是一个简单的比较:

  • 如图所示莫里安巴尔的回答description缩进所有尾随文本行,而paragraph仅缩进第一行。
  • description更适合放在前导文本和尾随文本之间。因为paragraph很难看出尾随文本是否是描述的一部分。(因此,如果整个部分都是关于定义的,那么您可以只使用段落。)
  • 的描述description符不能换行;paragraph标题可以。
  • paragraph条目可能(显然)最终出现在目录中(如果tocdepth相应设置)
  • 您不能引用描述符名称(据我所知),只能引用包含的页面或部分description;但您nameref可以引用paragraph

我曾经遇到过这种情况,所有description项目都拼命地填满页面,导致它们之间出现大片空白。这里无法重现此行为。


以下是 MWE:

\documentclass[a5paper]{article}
\usepackage[pass]{geometry}
\usepackage{hyperref}
\usepackage[nameinlink]{cleveref}
\usepackage[english]{babel}
\begin{document}
\setcounter{tocdepth}{5}
\tableofcontents\newpage
\section{Definitions with the \texttt{description} environment} \label{sec:sec1}
Here is just some text to fill up some space in the front, to make the document look like some common tex example. I need to continue to write senseless text, so the space will be taken from the page.

\begin{description}
\item[item 1:\label{des:item1}]Just a little short text here.
\item[super-duper-very-extra-mega-long item which doesn't line-break] Obviously \texttt{description}-descriptors can not line break... Very sad.
\item[s.i.:] Here comes a very short item, but it should also have a reasonably long describing text.
\item[item four] Just some random text, which should take up some space right behind the item-element.
\item Here one example without a descriptor.\\ Can we have manual line-breaks inside the description? Oh yes, we can!\\ I remember some case, were there was strange spacing between list-items, trying to fill up the page.

But apparently it does not occur in this case.
\item[last item] Let's see one more item in the list.
%\item[last last item] There is always a last \texttt{item}.
\end{description}

Juuuust a little more text to fill a line after all the describing stuff above. And another line allmost filled! The line is not filled yet, so I have to write some more. And more... AND MOOOORE!! So much text! This is an incredibly long text, where latex has no place to simply page-break it. Let's see how it performs.

\section{Definitions with the \texttt{paragraph} instruction}
Just an introductional text-line.

\paragraph[apparently paragraphed items may end up in the table of contents]{Paragraphed item 1}\label{par:item1}
I am tired of inventing text. \texttt{Blindtext}, help me out here! Ohh.... no blindtext... Damn. Now I have to fill the text again by myself! Ooooh byyyy myyyyy seeeeelft. Don't wanna be... Ah. Were you singing along?
%\blindtext

\paragraph{super-duper-extra-mega-very-very-extremely-long item which does line-break}
A somewhat very longer description.
\paragraph{} Lets have an empty one, just as we had before. Just to see how it looks. How about manual line-breaking?\\Mom, can I touch it? Only if you wash your hands afterwards!
\paragraph{s.o.:} or a short one!

Does this text belong to the last item? Who knows? Nobody does! You just can't really tell. Too bad. It almost looked good.
\section{Referencing (with \texttt{cleveref})}
\cref{des:item1} on \cpageref{des:item1}. Does not work properly... \texttt{nameref} crashes.\\
\cref{par:item1}, \nameref{par:item1} on \cpageref{par:item1}. Does also not work perfectly. But at least \texttt{nameref} works.
\end{document}

相关内容