ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Using command in section
@ 2003-03-04 16:16 Martin Kolařík
  2003-03-04 22:12 ` Hans Hagen
  2003-03-05  7:29 ` Guy Worthington
  0 siblings, 2 replies; 6+ messages in thread
From: Martin Kolařík @ 2003-03-04 16:16 UTC (permalink / raw)


Hi all,

I'm using private macro for title of section:

\setuphead[section][command=\doTitle]

and if I typeset inside this \doTitle#1#2 something like (test code):

\vbox to 0pt{
  \hsize=3cm
  \hbox{\vtop{#1}\vtop{#2}}
  \hbox{\vtop{X} \vtop{The quick brown fox jumped over the lazy dog.}}
  \vss
}

I get two boxes -- the first (made from #1 and #2) NOT aligning the first
lines of vtop's (#1 is higher) and the second, which is aligned as I
expect -- both "X" and "The quick..." in the one "line".

So I traced data coming into #2 and content of \vtop filled with it and I
saw the #2 contains some vertical glue at the beginning.

What should I do to avoid this behaviour? (excluding splitting of the
resulting box using low level TeX primitives :-),

have a nice day and thanks,

Martin

--------
Martin Kolarik
Moravske Pristroje, a.s., Masarykova 1148, Zlin 76302
tel. +420 603 498 498, fax +420 577 107 171
web: http://www.mii.cz
--------
e-mail: kolarik@mii.cz
e-mail: kolarik@click.cz
tel. +420 603 535 593

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

* Re: Using command in section
  2003-03-04 16:16 Using command in section Martin Kolařík
@ 2003-03-04 22:12 ` Hans Hagen
  2003-03-05  9:19   ` Martin Kolarík
  2003-03-05  7:29 ` Guy Worthington
  1 sibling, 1 reply; 6+ messages in thread
From: Hans Hagen @ 2003-03-04 22:12 UTC (permalink / raw)


At 05:16 PM 3/4/2003 +0100, you wrote:
>Hi all,
>
>I'm using private macro for title of section:
>
>\setuphead[section][command=\doTitle]
>
>and if I typeset inside this \doTitle#1#2 something like (test code):
>
>\vbox to 0pt{
>   \hsize=3cm
>   \hbox{\vtop{#1}\vtop{#2}}
>   \hbox{\vtop{X} \vtop{The quick brown fox jumped over the lazy dog.}}
>   \vss
>}
>
>I get two boxes -- the first (made from #1 and #2) NOT aligning the first
>lines of vtop's (#1 is higher) and the second, which is aligned as I
>expect -- both "X" and "The quick..." in the one "line".
>
>So I traced data coming into #2 and content of \vtop filled with it and I
>saw the #2 contains some vertical glue at the beginning.
>
>What should I do to avoid this behaviour? (excluding splitting of the
>resulting box using low level TeX primitives :-),
>
>have a nice day and thanks,

\showstruts

\def\doTitle#1#2%
   {\ruledvbox
      {\forgetall \hsize=4cm
       \ruledhbox{\ruledvtop{#1}\ruledvtop{\noindent#2}}}}

try this with and without \noindent

The interfering factor is (are) a couple of write nodes needed for the 
list. I'll see if i can make a workaround (quite dangerous to path such 
code; has to do with timing, so i've now made \chardef\headtimingmode=1 for 
testing purposes)

Hans
-------------------------------------------------------------------------
                                   Hans Hagen | PRAGMA ADE | pragma@wxs.nl
                       Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
  tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com
-------------------------------------------------------------------------
                        information: http://www.pragma-ade.com/roadmap.pdf
                     documentation: http://www.pragma-ade.com/showcase.pdf
-------------------------------------------------------------------------

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

* Re: Using command in section
  2003-03-04 16:16 Using command in section Martin Kolařík
  2003-03-04 22:12 ` Hans Hagen
@ 2003-03-05  7:29 ` Guy Worthington
  2003-03-05  7:40   ` Martin Kolarík
  2003-03-05  8:52   ` Hans Hagen
  1 sibling, 2 replies; 6+ messages in thread
From: Guy Worthington @ 2003-03-05  7:29 UTC (permalink / raw)


Martin Kolaøík wrote:

> I'm using private macro for title of section:

Sometimes I get so cross with ConTeXt, and that's because, like you,
when stuck, I run to "The TeXbook" and not to "ConTeXt the manual".

Only a fortnight ago, I was facing your exact problem and wasted
several hours making a solution for a non-existant problem.  So, in
the hope that you can profit from my bitter experience, here's what I
advice:

  1) Go to the ConTeXt manual, 

  2) Look up '\setuphead' in the index, 

  3) Encapsulated within the handful of pages, following the index
     reference, is the solution to your exact problem laid out, step
     by step.  (It's also a good introduction into the methodology
     used in the ConTeXt interface.)

I'm only guessing that you want your section header looking like:

   X     The Quick Brown 
         Fox Jumped Over 
         The Lazy Dog

and using that assumption, I had a go at translating that into ConTeXt

-----

\setuphead[section]
	  [command=\doTitle]

%% \def\doTitle#1#2{%
%%   \vbox to 0pt{
%%     \hsize=3cm
%%     \hbox{\vtop{#1}\raise\lineheight\vtop{#2}}
%%     \vss}}

\def\doTitle#1#2{%
  \hbox to 3cm \bgroup
    \hfill
    \setupframed [offset=.5em, frame=off]
    \tbox{\framed [width=1.5cm, align=right]{#1}}%
    \tbox{\framed [width=3cm, align=right]{#2}}%
  \egroup}

\starttext

\section A Day in the Life of the Quick Brown Fox

\stoptext

------

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

* RE: Re: Using command in section
  2003-03-05  7:29 ` Guy Worthington
@ 2003-03-05  7:40   ` Martin Kolarík
  2003-03-05  8:52   ` Hans Hagen
  1 sibling, 0 replies; 6+ messages in thread
From: Martin Kolarík @ 2003-03-05  7:40 UTC (permalink / raw)


Thank you,

I will test it and I suppose your solution will work. But I think that
simple TeX-only solution should work too. Maybe I am a bit foolish :-) if I
try to do things as simple as possible and if I try to use thing with
understanding them...

The behaviour surprised me and as I did not expect it, I discussed it here.
And sure, if it is a feature, I really should use \tbox :-)

Have a nice day,

Martin

> -----Original Message-----
> From: ntg-context-admin@ntg.nl [mailto:ntg-context-admin@ntg.nl]On
> Behalf Of Guy Worthington
> Sent: Wednesday, March 05, 2003 8:29 AM
> To: ntg-context@ref.ntg.nl
> Subject: [NTG-context] Re: Using command in section
>
>
> Martin Kolarík wrote:
>
> > I'm using private macro for title of section:
>
> Sometimes I get so cross with ConTeXt, and that's because, like you,
> when stuck, I run to "The TeXbook" and not to "ConTeXt the manual".
>
> Only a fortnight ago, I was facing your exact problem and wasted
> several hours making a solution for a non-existant problem.  So, in
> the hope that you can profit from my bitter experience, here's what I
> advice:
>
>   1) Go to the ConTeXt manual,
>
>   2) Look up '\setuphead' in the index,
>
>   3) Encapsulated within the handful of pages, following the index
>      reference, is the solution to your exact problem laid out, step
>      by step.  (It's also a good introduction into the methodology
>      used in the ConTeXt interface.)
>
> I'm only guessing that you want your section header looking like:
>
>    X     The Quick Brown
>          Fox Jumped Over
>          The Lazy Dog
>
> and using that assumption, I had a go at translating that into ConTeXt
>
> -----
>
> \setuphead[section]
> 	  [command=\doTitle]
>
> %% \def\doTitle#1#2{%
> %%   \vbox to 0pt{
> %%     \hsize=3cm
> %%     \hbox{\vtop{#1}\raise\lineheight\vtop{#2}}
> %%     \vss}}
>
> \def\doTitle#1#2{%
>   \hbox to 3cm \bgroup
>     \hfill
>     \setupframed [offset=.5em, frame=off]
>     \tbox{\framed [width=1.5cm, align=right]{#1}}%
>     \tbox{\framed [width=3cm, align=right]{#2}}%
>   \egroup}
>
> \starttext
>
> \section A Day in the Life of the Quick Brown Fox
>
> \stoptext
>
> ------
>
> _______________________________________________
> ntg-context mailing list
> ntg-context@ntg.nl
> http://www.ntg.nl/mailman/listinfo/ntg-context
>

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

* Re: Re: Using command in section
  2003-03-05  7:29 ` Guy Worthington
  2003-03-05  7:40   ` Martin Kolarík
@ 2003-03-05  8:52   ` Hans Hagen
  1 sibling, 0 replies; 6+ messages in thread
From: Hans Hagen @ 2003-03-05  8:52 UTC (permalink / raw)


At 03:29 PM 3/5/2003 +0800, you wrote:
>Martin Kolaøík wrote:
>
> > I'm using private macro for title of section:
>
>Sometimes I get so cross with ConTeXt, and that's because, like you,
>when stuck, I run to "The TeXbook" and not to "ConTeXt the manual".

in general, when constructing your own alternatives, it helps to use 
\framed and nested \framed's; the main thing there is to set the offset's 
right (overlay, none, etc); in the final version one can always turn off 
the frame

Hans
-------------------------------------------------------------------------
                                   Hans Hagen | PRAGMA ADE | pragma@wxs.nl
                       Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
  tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com
-------------------------------------------------------------------------
                        information: http://www.pragma-ade.com/roadmap.pdf
                     documentation: http://www.pragma-ade.com/showcase.pdf
-------------------------------------------------------------------------

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

* RE: Using command in section
  2003-03-04 22:12 ` Hans Hagen
@ 2003-03-05  9:19   ` Martin Kolarík
  0 siblings, 0 replies; 6+ messages in thread
From: Martin Kolarík @ 2003-03-05  9:19 UTC (permalink / raw)


> try this with and without \noindent
>
> The interfering factor is (are) a couple of write nodes needed for the
> list. I'll see if i can make a workaround (quite dangerous to path such

aha, with \noindent it works. The document has no paragraph indenting, so
leaving vertical mode/entering par mode did not come to my mind.

See http:\\www.mii.cz\~martin\noindent.jpg for result (but be warned, as I'm
in tests, the document is really ugly :-), the first "A" is without
\noindent, the second "A" is with \noindent.

Thanks,

Martin

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

end of thread, other threads:[~2003-03-05  9:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-04 16:16 Using command in section Martin Kolařík
2003-03-04 22:12 ` Hans Hagen
2003-03-05  9:19   ` Martin Kolarík
2003-03-05  7:29 ` Guy Worthington
2003-03-05  7:40   ` Martin Kolarík
2003-03-05  8:52   ` Hans Hagen

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).