我想要实现的目标:
some list:
- some text
- Def.: Some long text which should both automatically wrap to a new line
and be tabbed as displayed here.
- some sublist
* with the new counter
* Def.: same as above, but note that the counter matches the list level
这答案最接近,但如果使用里面在其他一些列表中,计数器(我的意思是项目符号)不匹配,前后间距较大。此外,我不需要制表符来跨多个项目符号工作(与原始问题相反),这可能会简化事情。
我希望我的问题已经清楚了。如果不清楚,请告诉我!并不是因为我懒得使用 MWE,而是因为我无法接近我想要的(除了简单的itemize
)。谢谢!
(只是为了澄清:我不想自己指定任何项目符号样式,它们只是随着列表级别的增加而改变。)
答案1
我不确定您是否已指定所有要求,但这里有三种方法可以解决这个问题。第一种方法基于环境tabular
,不允许在缩进的文本中添加新段落。第二种使用minipage
缩进的文本现在可以分成段落。第三种是@egreg 的建议,使用 enumitem 包和描述列表;这将跨页面划分,但不会推广到其他制表位(如果您需要的话)。
首先是前两个解决方案:
\documentclass{article}
\newcommand*{\tabulardef}[3]{\begin{tabular}[t]{@{}lp{\dimexpr\linewidth-#1}@{}}
#2
\end{tabular}}
\newlength{\standardparindent}
\setlength{\standardparindent}{\parindent}
\newenvironment{minipdef}[2]{\makebox[#1]{#2\ \hfill}%
\begin{minipage}[t]{\dimexpr\linewidth-#1}%
\setlength{\parindent}{\standardparindent}\noindent\ignorespaces}%
{\end{minipage}}
\begin{document}
\subsection*{Tabular example}
Some list:
\begin{itemize}
\item Some text which is long and wraps on to the next line as usual
as this is demonstrating
\item \tabulardef{2cm}{Definition}{Some long text which should both
automatically wrap to a new line and be tabbed as displayed here.}
\item Some sublist
\begin{itemize}
\item with the new counter and some text which is long and wraps on
to the next line as usual as this is demonstrating
\item \tabulardef{2cm}{Definition}{Some long text which should both
automatically wrap to a new line and be tabbed as displayed here.}
\end{itemize}
\end{itemize}
\subsection*{Minipage example}
Some list:
\begin{itemize}
\item Some text which is long and wraps on to the next line as usual
as this is demonstrating
\item \begin{minipdef}{2cm}{Definition}
Some long text which should both automatically wrap to
a new line and be tabbed as displayed here.
This also contains new paragraphs with long text for demonstration
purposes.
\end{minipdef}
\item Some sublist
\begin{itemize}
\item with the new counter and some text which is long and wraps on
to the next line as usual as this is demonstrating.
\item \begin{minipdef}{2cm}{Definition}
Some long text which should both automatically wrap to
a new line and be tabbed as displayed here.
This also contains new paragraphs with long text for demonstration
purposes.
\end{minipdef}
\end{itemize}
\end{itemize}
\end{document}
在表格中,第一列左对齐,包含标题,后续文本位于一p
列中。第一列之前和最后一列之后的额外间距已根据@{}
规范删除。
迷你页面案例,首先在框中设置标题,然后开始迷你页面。我已经设置好了,以便后续段落具有正文的标准段落缩进;如果没有一些缩进,很难看到它们从哪里开始。
现在第三个解决方案是enumitem
:
\documentclass{article}
\usepackage{enumitem}
\newlist{deflist}{description}{2}
\setlist[deflist]{labelwidth=2cm,leftmargin=!,font=\normalfont}
\begin{document}
Some list:
\begin{itemize}
\item Some text which is long and wraps on to the next line as usual
as this is demonstrating
\item
\begin{deflist}
\item[Definition]Some long text which should both automatically wrap
to a new line and be tabbed as displayed here.
\end{deflist}
\item Some sublist
\begin{itemize}
\item with the new counter and some text which is long and wraps on
to the next line as usual as this is demonstrating
\item
\begin{deflist}
\item[Definition]Some long text which should both automatically
wrap to a new line and be tabbed as displayed here.
This also contains new paragraphs with long text for
demonstration purposes.
\end{deflist}
\end{itemize}
\end{itemize}
\end{document}