From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/4661 Path: main.gmane.org!not-for-mail From: Berend de Boer Newsgroups: gmane.comp.tex.context Subject: Vertical alignment of arbitrary text Date: 12 May 2001 16:35:19 +0200 Sender: owner-ntg-context@let.uu.nl Message-ID: <87itj6skig.fsf@dellius.nederware.nl> NNTP-Posting-Host: coloc-standby.netfonds.no Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1035395307 27577 80.91.224.250 (23 Oct 2002 17:48:27 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Wed, 23 Oct 2002 17:48:27 +0000 (UTC) Original-To: ntg-context@ntg.nl Xref: main.gmane.org gmane.comp.tex.context:4661 X-Report-Spam: http://spam.gmane.org/gmane.comp.tex.context:4661 Hello Hans, Is there a construct in ConTeXt to align two arbitrary pieces of text? For example I wanted a chapter number and the contents of that chapter to be aligned. After much blood, sweat and tears I came up with this: ------------------------------- \def\SimpleHead#1% {\vtop{\rightaligned{{\switchtobodyfont[36pt]\ }}\par \rightaligned{\startnarrower[3*left] #1\stopnarrower}}} \def\myContents#1#2#3% {\sym{$\bullet$} {\bs #2}\par} \newdimen\myheight \newdimen\mydepth \newbox\myboxA \newbox\myboxB \def\ContentsHead#1#2% {\setbox\myboxA=\vbox{\hsize=5cm \startframedtext [frame=off,background=screen,width=5cm]% In this chapter:\par \startalignment[right] \placelist [section] [criterium=chapter, alternative=command, command=\myContents, style=boldslanted, align=left, interaction=all, before=,after=]% \stopalignment \stopframedtext}% \myheight=\ht\myboxA \mydepth=\dp\myboxA \ht\myboxA=0pt \advance\mydepth by \myheight \dp\myboxA=\mydepth \setbox\myboxB=\vbox {\hsize=8cm \rightaligned{{\switchtobodyfont[36pt]#1}}\par \startalignment[left,broad] #2\stopalignment}% \myheight=\ht\myboxB \mydepth=\dp\myboxB \ht\myboxB=0pt \advance\mydepth by \myheight \dp\myboxB=\mydepth \box\myboxA\hfill\box\myboxB} \def\myhead#1#2% {\doifemptyelse{#1}{\SimpleHead{#2}}{\ContentsHead{#1}{#2}}} \setuphead [chapter] [header=empty, style=\bsd, command=\myhead, page=right, after={\blank[2*big]}] ------------------------------- But is there a better way? This took me surprisingly long and I had to use the visual debugger to get a clue what was going on. With the height of both boxes to 0 I've more or less alignment them I think. (I attempt to emulate the O'Reilly format) Groetjes, Berend. (-: