如何在 ConTeXt 中的段落枚举中的数字前允许换行?

如何在 ConTeXt 中的段落枚举中的数字前允许换行?

我以段落形式列举了一些项目,如下所示:

\setuppapersize[A5]
\showgrid

\setupitemize[text, r]

\starttext
    \startcolumns[n=2]
        \startitemize
            \item This is a sentence.
            \item This is another sentence.
            \item This is yet another sentence.
            \item This sentences comes after the one before.
        \stopitemize
    \stopcolumns
\stoptext

这应该会形成两个不同的列,但是,左列的文本最终会变得很长并与第二列重叠。

ConTeXt 似乎不允许在 之前\item或 和\item之后的第一个单词之间出现断行\item,所以我经常发现内容被推到相邻的列中,例如:

                                  |
(i.) This is some text. (ii.) This|
is some more text. (iii.) This is |
yet some more text in a sentence. (iv.) This
is the last sentence.             |

我怎样才能允许在之前出现分隔符\item,以便文本不会流入相邻的列?例如:

                                  |
(i.) This is some text. (ii.) This|
is some more text. (iii.) This is |
yet some more text in a sentence. |
(iv.) This is the last sentence.  |

答案1

正如我在评论中所述,已经有一个有效的断点,TeX 在换行期间会考虑它。如果您愿意,下面的示例向您展示了一种(非常 hack 的)方法来调整此时的惩罚,而无需修改strc-itm.mkvi

另一点,允许休息插入项目标记会稍微复杂一些。因此,我定义了一个宏,用于恢复此时将插入的一系列非中断元素,并将其分配给参数command。这将是定义您自己的项目命令(这是我更喜欢的解决方案)的强力解决方案。

干得好:

\setuppapersize[A5]
\showgrid

\unprotect

%% This undos a sequence of spaces made by \strc_itemgroups_start_item
\def\correct_penalty{%
  \ifnum\lastnodetype=\penaltynodecode
    \unpenalty
    \removeunwantedspaces
    \unpenalty
    \removehboxes
    \unpenalty
    \removehboxes
    \removeunwantedspaces
    \space
    \penalty0
  \fi%
}

\defineitemgroup[myitemize]
\setupitemgroup [myitemize][
  lefttext=(, righttext=),
  symbol=r,   option=text,
  %% <hacks>
  command=\correct_penalty,   %% allow a break after the symbol
  textdistance=1em\penalty-42,%% There already *is* a breakpoint
                              %% before the item; adjust its penalty
                              %% here.
  %% </hacks>
]

\protect

\starttext
  \startcolumns[n=2]
    % \setuptolerance[horizontal,stretch] %% turn this on for less hassle
    \startmyitemize
      \item This is a sentence.
      \item This is another sentence.
      \item This is yet another nice sentence.
      \item This sentences comes after the one before.
    \stopmyitemize
  \stopcolumns
\stoptext

结果相当糟糕:你用不够满的箱子来交换过满的箱子。 修改了文内条目

相关内容