From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/22365 Path: news.gmane.org!not-for-mail From: Hans Hagen Newsgroups: gmane.comp.tex.context Subject: Re: cropping with \limitatefirstline Date: Thu, 08 Sep 2005 17:28:45 +0200 Message-ID: <432058AD.1040900@wxs.nl> References: <431EFA3B.8090706@gmx.net> <431F0D7F.9020005@wxs.nl> <4320499B.5050002@gmx.net> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1126193691 30638 80.91.229.2 (8 Sep 2005 15:34:51 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 8 Sep 2005 15:34:51 +0000 (UTC) Original-X-From: ntg-context-bounces@ntg.nl Thu Sep 08 17:34:47 2005 Return-path: Original-Received: from ronja.vet.uu.nl ([131.211.172.88] helo=ronja.ntg.nl) by ciao.gmane.org with esmtp (Exim 4.43) id 1EDOMM-0002Co-BP for gctc-ntg-context-518@m.gmane.org; Thu, 08 Sep 2005 17:30:42 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 20A1E12801; Thu, 8 Sep 2005 17:30:42 +0200 (CEST) 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 20643-01; Thu, 8 Sep 2005 17:30:41 +0200 (CEST) Original-Received: from ronja.vet.uu.nl (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 9F10F127F8; Thu, 8 Sep 2005 17:28:42 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 3FB2D127F8 for ; Thu, 8 Sep 2005 17:28:41 +0200 (CEST) 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 20527-10 for ; Thu, 8 Sep 2005 17:28:40 +0200 (CEST) Original-Received: from mailrelay01.solcon.nl (maillb.solcon.nl [212.45.32.200]) by ronja.ntg.nl (Postfix) with ESMTP id 4204D127E1 for ; Thu, 8 Sep 2005 17:28:40 +0200 (CEST) Original-Received: from server-1.pragma-net.nl (dsl-212-84-128-085.solcon.nl [212.84.128.85]) by mailrelay01.solcon.nl (8.12.11/SQL-8.12.11-5/8.12.11) with ESMTP id j88FSaMq020224 for ; Thu, 8 Sep 2005 17:28:36 +0200 Original-Received: by server-1.pragma-net.nl (Postfix, from userid 65534) id C7EC52DC48; Thu, 8 Sep 2005 16:36:05 +0200 (CEST) Original-Received: from [10.100.1.15] (unknown [10.100.1.15]) by server-1.pragma-net.nl (Postfix) with ESMTP id 83D0B193B3 for ; Thu, 8 Sep 2005 14:36:04 +0000 (UTC) User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) X-Accept-Language: en-us, en Original-To: mailing list for ConTeXt users In-Reply-To: <4320499B.5050002@gmx.net> X-Virus-Scanned: ClamAV version 0.86.2, clamav-milter version 0.86 on mailrelay01 X-Virus-Status: Clean X-Virus-Scanned: amavisd-new at ntg.nl X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.5 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-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on smtp.ntg.nl X-Virus-Scanned: amavisd-new at ntg.nl Xref: news.gmane.org gmane.comp.tex.context:22365 Archived-At: Peter Rolf wrote: >Hi, > >Hans Hagen wrote: > > >>Peter Rolf wrote: >> >> >> >>>Sorry to bother you Hans, but the macro is not working as expected... >>> >>>I can see the cropped text (\underbar + special symbols) and there is an >>>hyphen symbol in the text only example. >>> >>>I've added the example code I used for tests with \limitatetext and >>>\doboundtext. >>> >>> >>> >>> >>\def\limitatefirstline#1#2#3% >> {\hbox\bgroup\strut >> \setbox\scratchbox\hbox{#1}% >> \ifdim\wd\scratchbox>#2\relax >> \setbox\scratchbox\hbox{#3}% >> \hsize#2\relax >> \advance\hsize-\wd\scratchbox >> \setbox\scratchbox\vbox{\forgetall\veryraggedright#1}% >> \setbox\scratchbox\vsplit\scratchbox to \lineheight >> \vbox >> {\unvbox\scratchbox >> \global\setbox\plusone\lastbox >> \global\setbox\plusone\hbox{\unhbox\plusone}}% >> >> >^^^^ > > > >> \box\plusone\removeunwantedspaces#3% >> \else >> #1% >> \fi >> \egroup} >> >>of course there must be something to break (not possible with the non >>letters, so there you either need to add \hskip0pt's or do real clipping >>Hans >> >> > >So it fails in any case of nonbreakable text. > >How about adding a failsafe test ala > >\ifdim\dimexpr\wd\plusone+\wd of sentinel\relax>#2\relax > \clip[width=\wd\plusone,...]{...#1...}\removeunwantedspaced#3% >\else > \box\plusone\removeunwantedspaces#3% >\fi > >One (ugly looking) partial character is still better than a bunch of >characters, that cross the width border. > >I have played around with \clip, but it acts a little wild (vertical >position and height). Can't subdue it myself... > > \unprotect \def\limitatefirstline#1#2#3% {\hbox\bgroup\strut \setbox\scratchbox\hbox{#1}% \ifdim\wd\scratchbox>#2\relax \setbox\scratchbox\hbox{#3}% \hsize#2\relax \advance\hsize-\wd\scratchbox \setbox\scratchbox\vbox{\forgetall\veryraggedright#1}% \setbox\scratchbox\vsplit\scratchbox to \lineheight \vbox {\unvbox\scratchbox \global\setbox\plusone\lastbox \global\setbox\plusone\hbox{\unhbox\plusone}% \ifx\clip\undefined \box\plusone\removeunwantedspaces#3% \else\ifdim\wd\plusone>\hsize \hbox{\clip[\c!width=\hsize]{\box\plusone}#3}% \else \box\plusone\removeunwantedspaces#3% \fi\fi}% \else #1% \fi \egroup} \protect \ruledhbox{\limitatefirstline{xxxxxxxxxxxxxxxxxxxx}{3cm}{...}} now you owe this list at least three wiki pages -) Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------