From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/29839 Path: news.gmane.org!not-for-mail From: Hans Hagen Newsgroups: gmane.comp.tex.context Subject: Re: Rule under length of last line Date: Mon, 31 Jul 2006 20:56:24 +0200 Message-ID: <44CE5258.8070806@wxs.nl> References: <44CE370F.8030202@capdm.com> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1154372330 1589 80.91.229.2 (31 Jul 2006 18:58:50 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 31 Jul 2006 18:58:50 +0000 (UTC) Original-X-From: ntg-context-bounces@ntg.nl Mon Jul 31 20:58:42 2006 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 ciao.gmane.org with esmtp (Exim 4.43) id 1G7cyF-00072r-TM for gctc-ntg-context-518@m.gmane.org; Mon, 31 Jul 2006 20:58:32 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 7B0761FDC8; Mon, 31 Jul 2006 20:58:30 +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 20800-03; Mon, 31 Jul 2006 20:58:29 +0200 (CEST) Original-Received: from ronja.vet.uu.nl (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 801681FDD1; Mon, 31 Jul 2006 20:56:30 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 15B0A1FDCF for ; Mon, 31 Jul 2006 20:56:27 +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 20800-02 for ; Mon, 31 Jul 2006 20:56:22 +0200 (CEST) Original-Received: from mail.pragma-ade.net (dsl-083-247-100-017.solcon.nl [83.247.100.17]) by ronja.ntg.nl (Postfix) with SMTP id 1C7141FDC8 for ; Mon, 31 Jul 2006 20:56:21 +0200 (CEST) Original-Received: from [10.100.1.102] (unverified [10.100.1.102]) by controller-1 (SurgeMail 3.5b3) with ESMTP id 30252 for ; Mon, 31 Jul 2006 20:56:20 +0200 User-Agent: Thunderbird 1.5.0.5 (Windows/20060719) Original-To: mailing list for ConTeXt users In-Reply-To: <44CE370F.8030202@capdm.com> X-Server: High Performance Mail Server - http://surgemail.com r=-274017400 X-Authenticated-User: hagen@controller-1 X-Virus-Scanned: amavisd-new at ntg.nl X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.7 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:29839 Archived-At: Duncan Hothersall wrote: > I've had a last-minute impossible request for a typesetting style, and > having already told the person it can't be done in the time available, > wondered whether it can actually be done at all. > depends on the amount of time, and it the case of customers what they are willing to pay -) many things can be done, esp because designers are not that accustomed to thinking on programmable designs > The request is for a subsection heading to have a continuous horizontal > rule under both its number and title, at a distance of about 6pt from > the baseline (i.e. not underlining), extending just the length of the > heading. I can do that by setting both number and title in a TABLE, > setting the offsets and specifying the bottom frame to be on - no problem. > > However, the tricky part is that where a longer title runs beyond one > line, the line should only appear under the last line, and only to the > length of the last line of text. > > In other words, for viewers with fixed width fonts: > > 1.1.1 Short title > ----------------- > > 1.1.2 Longer title which wraps onto a > second line like this > --------------------------- > > We generate the ConTeXt code from XML, so ideally a solution wouldn't > require the last line to be set separately, but would just work whether > the heading was single or multiple line. What I'm really looking for is > a subsection setup that will automatically do this whatever length of title. > > I have to say I think it's quite ugly, but can anyone give me a pointer > you don't wanna know hwo much time i've spent in programming ugly stuff -) > as to how it could be done? Is there a box left at the end of a par > which shows the width of the last line? > > As I say, I've already said no, so this is just out of interest, no > urgency. > anyhow, it's doable; the first solution took me 30 minutes, the second one 15 minutes \def\FirstSolution#1#2% {\vbox\bgroup \setbox0\hbox{#1} \hsize.4\textwidth \beginshapebox#2\endshapebox \gdef\SetLastLineWidth{\xdef\LastLineWidth{\the\wd\scratchbox}}% \reshapebox {\setbox\scratchbox\hbox{\unhbox\shapebox}% \SetLastLineWidth \globallet\SetLastLineWidth\relax \box\scratchbox}% \scratchdimen\dimexpr\wd0+.25em+\LastLineWidth\relax % \setbox2\ruledvbox {\innerflushshapebox} % why is correction needed \setbox2\vbox {\vskip-\lineskip\innerflushshapebox} \setbox0\vbox to \ht2{\box0} \hbox{\box0\hskip.25em\box2} \offinterlineskip \vskip.25ex \blackrule[width=\scratchdimen,height=2pt] \egroup} \doglobal\newcounter\NextLinePos \def\SecondSolution#1#2% {\vbox\bgroup \hsize.4\textwidth \doglobal\increment\NextLinePos \setbox\scratchbox\hbox{#1} \hbox{\vtop{\copy\scratchbox}\hskip.25em\vtop{#2}}% \offinterlineskip \scratchdimen\dimexpr\wd\scratchbox+.25em+ \MPx{e:npl:\NextLinePos}-\MPx{b:npl:\NextLinePos}\relax \vskip.25ex \blackrule[width=\scratchdimen,height=2pt] \egroup} \def\DoSecondSolution#1% {\bpos{npl:\NextLinePos}#1\epos{npl:\NextLinePos}} % \showstruts \setuphead[section][command=\FirstSolution] \starttext \section{is this nice or not} \section{is this nice or not nice, that's the question} \setuphead[section][command=\SecondSolution,deeptextcommand=\DoSecondSolution] \section{is this nice or not} \section{is this nice or not nice, that's the question} \stoptext Now it's your turn to wikify this ... 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 -----------------------------------------------------------------