我有以下宏
\mainlanguage [de]
\definepapersize[MyBook][A5]
\setuppapersize[MyBook][A5]
\definestartstop[Test][commands=\setups{Test}]
\def\Test{\doTest}
\def\Test[#1]{
\placeongrid[top]{
{\startalignment [flushleft] #1 \stopalignment \startalignment [flushright] (\bf Test Message) \stopalignment}
\blank[big]
}
}
\starttext
\Test[Wrong]
\Test[This one is correct, correct, correct, correct, correct.]
This one is wrong, wrong, wrong, wrong, wrong.
\startalignment [flushright]
(\bf Test Message)
\stopalignment
\stoptext
举三个例子。我想要的是:
\Test[#1] 应该生成具有以下属性的 #1 和 #2:
- #1 应与左对齐,#2 应与右对齐
- #2 永远不应该分成两行
- 如果它们适合排成一行,那么它们就应该这样做,而不是像上面的第一个例子
怎么做?
答案1
我使用注释模块来获得更好的键值驱动语法(尽管您也可以使用\definestartstop
)。您可以使用\wordright{...}
将单词放在右侧。例如:
\usemodule[annotation]
\defineannotation
[Quote]
[
alternative=command,
spacebefore=big,
spaceafter=big,
command=\PlaceQuote,
]
\define[2]\PlaceQuote
{\startalignment[flushleft]
\placeannotationcontent
\stopalignment
\blank[samepage]
\wordright{\placeannotationtitle}}
\setuppapersize[A5]
\starttext
\input ward
\startQuote[title={Donald Knuth}]
\input knuth
\stopQuote
\input ward
\stoptext
给出