![縮排描述](https://rvso.com/image/286347/%E7%B8%AE%E6%8E%92%E6%8F%8F%E8%BF%B0.png)
我在縮排描述標籤時遇到問題。嘗試定義一個新環境,並將 leftmargin 設定為任何值,但標籤保持不變。我怎樣才能實現我想要的?
這就是我所做的:
\newenvironment{owndesc}
{\begin{description}
\setlength{\leftmargin}{3cm}
\setlength{\labelsep}{5cm}}
{\end{description}}
我對 LaTeX 很陌生,非常感謝您的幫助,謝謝!
答案1
在這種情況下,我相信加載列舉項打包並使用該套件的\newlist
和\setlist
命令來 (i) “克隆”基本列表類型之一(此處:description
)並建立新的列表類型(此處:owndesc
)以及 (ii) 設定新列表類型的參數。
在下面的範例中,頂部的水平線只是為了說明文字區塊的寬度。 Lipsum 用於填充文字。
\documentclass{article}
\usepackage{enumitem,lipsum} % lipsum for filler text
\newlist{owndesc}{description}{1} % clone an existing list type
\setlist[owndesc]{leftmargin=3cm,labelsep=4cm} % set parameters of cloned list
\begin{document}
\hrule % demonstrate width of text block
\begin{owndesc}
\item[firstlabel] \lipsum*[1]
\item[secondlabel] \lipsum*[2]
\end{owndesc}
\end{document}
答案2
另一個解決方案,始終使用enumitem
,讓body
專案的 始終從同一位置開始。首先,顯示 enumitem 給出的參數:
\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{enumitem}
\usepackage[showframe, nomarginpar]{geometry}
\newenvironment{owndesc}%
{\begin{description}[leftmargin = 3cm, labelsep = 5cm]}
{\end{description}}
\newenvironment{mydesc}%
{\begin{description}[ style =sameline, leftmargin = 3cm, itemindent = 2cm]}%,
{\end{description}}
\begin{document}
\begin{owndesc}
\item[Title of the first item] Anything will do. \\New line for this item
\item[Title of the second item] Second item. \\ Another line for this one.
\end{owndesc}
\vspace{2ex}
\begin{mydesc}
\item[Title of the first item] Anything will do. \\New line for this item
\item[Title of the second item] Second item. \\ Another line for this one.
\item[A third item with a longer title] Third item. \\ Another line for this one.
\end{mydesc}
\end{document}