ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* line breaking hints?
@ 2007-11-26 21:08 Santy, Michael
  2007-11-27  8:40 ` Taco Hoekwater
  2007-11-27  8:50 ` luigi scarso
  0 siblings, 2 replies; 4+ messages in thread
From: Santy, Michael @ 2007-11-26 21:08 UTC (permalink / raw)
  To: ntg-context


[-- Attachment #1.1: Type: text/plain, Size: 1081 bytes --]


Hello,

I'm looking for a way to give ConTeXt's line breaking algorithm a hint on where it is allowed to break a line.  For example, I want ConTeXt to break lines, if necessary, when it encounters '//' in a string.  I don't want to force a line break there, but if context needs to break the line, I want it to be after a "//".  

A contrived example of some input text is:
THE QUICK BROWN FOX JUMPED OVER THE LAZY DOG//NOW IS THE TIME FOR ALL GOOD MEN TO COME TO THE AID OF THEIR COUNTRY.

When this text is rendered by ConTeXt, and it is too big to fit on a single line, I would like it to break like this:
THE QUICK BROWN FOX JUMPED OVER THE LAZY DOG//
NOW IS THE TIME FOR ALL GOOD MEN TO COME TO THE AID OF THEIR COUNTRY.

I can preprocess the source to change spaces into non-breaking spaces and can replace '//' with anything else that I need to, but don't know how to suggest where to break the line.  Also note that I do not want any words to be hyphenated nor broken on hyphens.

Does anyone have any ideas on how I might accomplish this?

Cheers,
Mike

[-- Attachment #1.2: Type: text/html, Size: 1539 bytes --]

[-- Attachment #2: Type: text/plain, Size: 487 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: line breaking hints?
  2007-11-26 21:08 line breaking hints? Santy, Michael
@ 2007-11-27  8:40 ` Taco Hoekwater
  2007-11-27 13:39   ` Santy, Michael
  2007-11-27  8:50 ` luigi scarso
  1 sibling, 1 reply; 4+ messages in thread
From: Taco Hoekwater @ 2007-11-27  8:40 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Santy, Michael wrote:
> Hello,
> 
> I'm looking for a way to give ConTeXt's line breaking algorithm a
> hint on where it is allowed to break a line.  For example, I want
> ConTeXt to break lines, if necessary, when it encounters '//' in a
> string.  I don't want to force a line break there, but if context
> needs to break the line, I want it to be after a "//".

I've been trying various things, but so far I have failed to find
a general solution to do this.

Normally you would say something like "\penalty-100" to hint that
some place is a good place to break a line, but such a hint is never
exclusive: TeX will happily use breakpoints elsewhere if those appear
to be better to the line breaking algorithm.

That's why you would need something like:

   \def\\{\hskip0pt plus .5\hsize \penalty-100 \hskip0pt plus -.5\hsize}

to make the break more attractive. The downside is that this actually
works by based on the 'break width' of the line, and because it will
not prevent other breaks, the break above will always be taken if the
current to-be-broken line is half-full or more already (so a line
that may actually fit on one line can be broken in two).

Anyway, as you don't mind ragged right typesetting, this should work
more or less:

   \def\specialpar#1%
     {\begingroup
      \rightskip=0pt plus \hsize
      \linepenalty100
      \clubpenalty0\widowpenalty0
      \hyphenpenalty10000\exhyphenpenalty10000
      \def\\{\penalty-50}%
      #1\endgraf
      \endgroup}

   \specialpar{HE QUICK BROWN FOX JUMPED OVER THE LAZY DOG//\\ NOW IS THE
    TIME FOR ALL GOOD MEN TO COME TO THE AID OF THEIR COUNTRY.}

Note I've added a special macro \\, instead of attemping to automate
breaking after //.

This 'solution' is far from perfect, but the problem is simply hard.

Best wishes,
Taco

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: line breaking hints?
  2007-11-26 21:08 line breaking hints? Santy, Michael
  2007-11-27  8:40 ` Taco Hoekwater
@ 2007-11-27  8:50 ` luigi scarso
  1 sibling, 0 replies; 4+ messages in thread
From: luigi scarso @ 2007-11-27  8:50 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Nov 26, 2007 10:08 PM, Santy, Michael <Michael.Santy@dynetics.com> wrote:
>
>
>
>
> Hello,
>
>  I'm looking for a way to give ConTeXt's line breaking algorithm a hint on
> where it is allowed to break a line.  For example, I want ConTeXt to break
> lines, if necessary, when it encounters '//' in a string.  I don't want to
> force a line break there, but if context needs to break the line, I want it
> to be after a "//".
>
>  A contrived example of some input text is:
>  THE QUICK BROWN FOX JUMPED OVER THE LAZY DOG//NOW IS THE TIME FOR ALL GOOD
> MEN TO COME TO THE AID OF THEIR COUNTRY.
>
>  When this text is rendered by ConTeXt, and it is too big to fit on a single
> line, I would like it to break like this:
>  THE QUICK BROWN FOX JUMPED OVER THE LAZY DOG//
>  NOW IS THE TIME FOR ALL GOOD MEN TO COME TO THE AID OF THEIR COUNTRY.
>
>  I can preprocess the source to change spaces into non-breaking spaces and
> can replace '//' with anything else that I need to, but don't know how to
> suggest where to break the line.  Also note that I do not want any words to
> be hyphenated nor broken on hyphens.
>
maybe this can give you more ideas
http://wiki.contextgarden.net/User:Luigi.scarso/autosize
-- 
luigi
...
it's new .
it's powerful .
it's luatex .
http://www.luatex.org
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: line breaking hints?
  2007-11-27  8:40 ` Taco Hoekwater
@ 2007-11-27 13:39   ` Santy, Michael
  0 siblings, 0 replies; 4+ messages in thread
From: Santy, Michael @ 2007-11-27 13:39 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 198 bytes --]


Taco,

Your solution definitely makes sense.  I wanted the content ragged right as you suggested.  I'll play around with these penalty settings until it comes out like I want.

Cheers,
Mike

[-- Attachment #1.2: Type: text/html, Size: 611 bytes --]

[-- Attachment #2: Type: text/plain, Size: 487 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-11-27 13:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-26 21:08 line breaking hints? Santy, Michael
2007-11-27  8:40 ` Taco Hoekwater
2007-11-27 13:39   ` Santy, Michael
2007-11-27  8:50 ` luigi scarso

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).