在同一行的单词后缩进段落

在同一行的单词后缩进段落

我想做这个:

Term        This is the definition of the word. No matter how much is typed
            here it should always line up like this. How do I do this? I am
            not sure since there is another word on the first line.

Next Term   Not to mention, the alignment should be consistent for multiple
            entries as well. The entries may span multiple pages as well.

我正在使用 LuaLaTeX。

答案1

使用enumitem包:

\documentclass{article}
\usepackage{calc}
\usepackage{enumitem}

\newlength\widest

\begin{document}

red yellow blue, red yellow blue, red yellow blue, 
red yellow blue, red yellow blue, red yellow blue, 

\settowidth\widest{\textbf{word}}
\begin{description}[leftmargin=\dimexpr\widest+\labelsep\relax,labelindent=0pt,
    labelwidth=\widest]
\item[word]
red yellow blue, red yellow blue, red yellow blue, 
red yellow blue, red yellow blue, red yellow blue, 
\item[that]
one two three four, one two three four, one two three four, 
one two three four, one two three four, one two three four, 
one two three four, one two three four, one two three four, 
\end{description}

\end{document}

在此处输入图片描述

对于最宽标签的自动计算,您可以看到我的答案根据最宽的标签自动设置描述列表“标签宽度”?

答案2

\documentclass{article}


\begin{document}


\begin{description}
\item[word]
red yellow blue, red yellow blue, red yellow blue, 
red yellow blue, red yellow blue, red yellow blue, 
\item[that]
one two three four, one two three four, one two three four, 
one two three four, one two three four, one two three four, 
one two three four, one two three four, one two three four, 
\end{description}

\end{document}

答案3

另一种选择是仅使用表格,但根据您真正想要在右列中放置的内容,这可能会受到限制:

\documentclass{article}
\usepackage{tabularx}

\begin{document}
    \begin{tabularx}{\linewidth}{@{}lX}
         Term & This is the definition of the word. No matter how much is typed here it should always line up like this. How do I do this? I am not sure since there is another word on the first line. \\
         Next Term & Not to mention, the alignment should be consistent for multiple
         entries as well. The entries may span multiple pages as well.
    \end{tabularx}
\end{document}

相关内容