Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have some enumerated items, in paragraph form, like this:

\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

This should make two distinct columns, however, text from the left column ends up running long and overlapping the second column.

ConTeXt does not appear to allow a break to appear before an \item or between an \item and the first word following immediately after the \item, so I often find content is pushed into the neighboring column, e.g.:

                                  |
(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.             |

How can I allow breaks to appear before \item, so that the text will not flow into the neighboring column? E.g.:

                                  |
(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.  |
share|improve this question
2  
Adding \setuptolerance[horizontal,stretch] will show you that there actually is a breakpoint before the items. (Or replace the text of the first item with “This is the sentence” to see it appear without the emergency stretch.) –  phg May 1 '12 at 13:56
add comment

1 Answer 1

up vote 2 down vote accepted
+50

As I already stated in my comment, there already is a valid breakpoint and TeX does consider it during line break. If you would like, below example shows you a (very hackish) way to adjust the penalty at this point without having to modifiy strc-itm.mkvi.

The other point, allowing a break after an item marker is inserted, is a bit more complicated. Thus I defined a macro that reverts a sequence of non-breaking elements that will have been inserted at this point, and assigned it to the command parameter. This would be the brute force solution short of defining your own item commands (which is the solution I would prefer).

Here you go:

\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

The result is rather ugly: you traded overfull boxes by underfull ones. modified in-text itemization

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.