ConTeXt:如何获取多级描述?contextgarden 示例不起作用显示了如何获取嵌套描述,但每个描述都与其描述的标签在同一行开始。如何让描述从新行开始,以便标签单独占一行?
上述答案中描述的 ConTeXt 代码是
\setuppapersize[A5]
\definedescription
[descr]
[
headstyle=bold,
style=normal,
align=flushleft,
alternative=hanging,
width=broad,
margin=1cm,
]
\starttext
\startdescr{Para}
This is a shorter item label, and some text that talks about it.
The text is wrapped into a paragraph, with successive lines indented.
This is another paragraph under the "Para" item.
\startdescr{Sub Item}
This is a description of an item which is within the "Para" item.
\stopdescr
\startdescr{Sub Item}
Another Sub Item
\stopdescr
\stopdescr
\startdescr{Short}
A short item that's not part of that really long "Para" item.
\stopdescr
\stoptext
并产生格式如下的文本:
Para This is a shorter item label, and some text that
talks about it. The text is wrapped into a paragraph,
with successive lines indented.
This is another paragraph under the "Para" item.
Sub Item This is a description of an item which
is within the "Para" item.
Sub Item Another Sub Item.
Short A short item that's not part of that really long
"Para" item.
我所寻找的内容如下:
Para
This is a shorter item label, and some text that talks
about it. The text is wrapped into a paragraph, with
successive lines indented.
This is another paragraph under the "Para" item.
Sub Item
This is a description of an item which is within
the "Para" item.
Sub Item
Another Sub Item.
Short
A short item that's not part of that really long
"Para" item.
我尝试了各种各样的方法,使用 \definedescription 的 'command'、'before'、'inbetween'、'after'、'headcommand' 选项(参见http://wiki.contextgarden.net/Command/setupdescriptions), 以及 \crlf, \par, \vspace,但我尝试的任何方法都没有产生预期的效果。
答案1
要将描述的标题放在内容之前,您必须alternative=top
在设置中使用。由于使用键时标题的缩进量与内容的缩进量相同,因此您必须使用与键一起应用的margin
将其移动到左侧。\offset
headcommand
\define[1]\DescriptionHeadCommand
{\offset[leftoffset=-1cm]{#1}}
\definedescription
[descr]
[alternative=top,
margin=1cm,
headcommand=\DescriptionHeadCommand]
\showframe[text][text]
\starttext
\startdescr{Knuth}
\input knuth
\stopdescr
\stoptext