From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/37571 Path: news.gmane.org!not-for-mail From: Taco Hoekwater Newsgroups: gmane.comp.tex.context Subject: Re: line breaking hints? Date: Tue, 27 Nov 2007 09:40:04 +0100 Message-ID: <474BD7E4.7050100@elvenkind.com> References: <6703815B292B664DBAEC55EE3192386A20BCD0@poseidon.in.dynetics.com> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1196152850 13265 80.91.229.12 (27 Nov 2007 08:40:50 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 27 Nov 2007 08:40:50 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Tue Nov 27 09:40:57 2007 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from ronja.vet.uu.nl ([131.211.172.88] helo=ronja.ntg.nl) by lo.gmane.org with esmtp (Exim 4.50) id 1Iww01-0007fg-Pd for gctc-ntg-context-518@m.gmane.org; Tue, 27 Nov 2007 09:40:57 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 317911FDF7; Tue, 27 Nov 2007 09:40:25 +0100 (CET) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 07225-01; Tue, 27 Nov 2007 09:40:15 +0100 (CET) Original-Received: from ronja.vet.uu.nl (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 0EF311FD1D; Tue, 27 Nov 2007 09:40:15 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id AF2A21FD1D for ; Tue, 27 Nov 2007 09:40:13 +0100 (CET) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 08892-01-4 for ; Tue, 27 Nov 2007 09:40:09 +0100 (CET) Original-Received: from www.bittext.nl (unknown [195.86.58.132]) by ronja.ntg.nl (Postfix) with ESMTP id 126DE1FD06 for ; Tue, 27 Nov 2007 09:40:08 +0100 (CET) Original-Received: from localhost (vz3.aanhet.net [127.0.0.1]) by www.bittext.nl (Postfix) with ESMTP id A0A471E8C2B4 for ; Tue, 27 Nov 2007 09:40:07 +0100 (CET) X-Virus-Scanned: amavisd-new at bittext.nl Original-Received: from www.bittext.nl ([127.0.0.1]) by localhost (vz3.aanhet.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id bqQ0TALQn+KV for ; Tue, 27 Nov 2007 09:40:03 +0100 (CET) Original-Received: from [10.10.0.6] (boo.demon.nl [82.161.175.147]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by www.bittext.nl (Postfix) with ESMTP id 5CA171E8C2B3 for ; Tue, 27 Nov 2007 09:40:03 +0100 (CET) User-Agent: Thunderbird 1.5.0.10 (X11/20070305) In-Reply-To: <6703815B292B664DBAEC55EE3192386A20BCD0@poseidon.in.dynetics.com> X-Virus-Scanned: amavisd-new at ntg.nl X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.9 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: ntg-context-bounces@ntg.nl Errors-To: ntg-context-bounces@ntg.nl X-Virus-Scanned: amavisd-new at ntg.nl Xref: news.gmane.org gmane.comp.tex.context:37571 Archived-At: 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 ___________________________________________________________________________________