ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* syntax
@ 1999-05-16 12:36 Siep Kroonenberg
  1999-05-17 21:59 ` syntax Hans Hagen
  1999-05-18  8:37 ` syntax Siep Kroonenberg
  0 siblings, 2 replies; 5+ messages in thread
From: Siep Kroonenberg @ 1999-05-16 12:36 UTC (permalink / raw)


A number of questions:

- Does Context provide for styles as in Word: a set of typographic
specifications (font, leading, h&j, space before and after) separate
from any sectioning hierarchy, or is it necessary to write those from
scratch as macros?

- Is the following syntax safe:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \some_context_macro
% comment
    [parameter]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

- I am trying to define typography for a header:

\setuphead[subject]
  [before=\blank,
   after=\blank[small],
   style={\switchtobodyfont[sans,16pt]\bf}]

This only seems to compile if I replace `after' with `\c!after', and
even then I get a full instead of half a blank line.

If I try C-style indentation:

\setuphead[subject]
  [before=\blank,
   after=\blank[small],
   style={\switchtobodyfont[sans,16pt]\bf
   }
  ]

then the style parameter seems to be ignored.

Siep Kroonenberg


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

* Re: syntax
  1999-05-16 12:36 syntax Siep Kroonenberg
@ 1999-05-17 21:59 ` Hans Hagen
  1999-05-18  8:37 ` syntax Siep Kroonenberg
  1 sibling, 0 replies; 5+ messages in thread
From: Hans Hagen @ 1999-05-17 21:59 UTC (permalink / raw)
  Cc: ntg-context

Siep Kroonenberg wrote:

> - Does Context provide for styles as in Word: a set of typographic
> specifications (font, leading, h&j, space before and after) separate
> from any sectioning hierarchy, or is it necessary to write those from
> scratch as macros?

Most commands have some before/after (voor/na) hooks. These are normally
used for spacing: voor={\blanko[groot]}, but you can use them for other
things too. Font switches normally take place with the style (letter)
parameter. In some occasions there is 'afstand', 'korps', 'binnen',
'links', 'rechts', etc. 

> - Is the following syntax safe:
> 
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>   \some_context_macro
> % comment
>     [parameter]

Yes. Try for instance 

\setuphead
  % comment 
  [chapter]
  % comment 
  [style=bold]

TeX ignores spaces atthe beginningof the line, so the comment becomes
one space, and the context argument handler takes care of such spaces.   

> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> 
> - I am trying to define typography for a header:
> 
> \setuphead[subject]
>   [before=\blank,
>    after=\blank[small],
>    style={\switchtobodyfont[sans,16pt]\bf}]

Use switched around {\blank[small]}. Unfortunately TeX's normal argument
handling capabilities are not able to handle nested things (in this case
nested []). Technically, everything between a pair of [] is picked up,
and in your case 
the after small ends the parameter list.  

> This only seems to compile if I replace `after' with `\c!after', and
> even then I get a full instead of half a blank line.

I suppose you run the english context. \c!after is illegal (at least
untill context is english low level), but \c!na should work, that is,
when the set up commands are surrounded by \unprotect \protect (makes !
? @ letter). But such rather low level dirty settings (c! and v!) are
only needed for international setups. 

> If I try C-style indentation:
> 
> \setuphead[subject]
>   [before=\blank,
>    after=\blank[small],
>    style={\switchtobodyfont[sans,16pt]\bf
>    }
>   ]

Spaces after the first [ and after commas are gobbled, but everything
between = and the next , or final ] makes up the value. 

% context style indentation: -)

\setuphead
  [subject]
  [before=\blank,
   after={\blank[small]},
   style={\switchtobodyfont[sans,16pt]\bf}]

> then the style parameter seems to be ignored.

Some bonus tips:

  \definealternativestyle [siep] [{\switchtobodyfont[sans,16pt]\bf}] []

  \defineblank [alsosiep] [2*big]

  \setuphead[chapter][style=siep,before={\blank[alsosiep]}]

Especially the logical blank's can enforce consistency. 

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


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

* Re: syntax
  1999-05-16 12:36 syntax Siep Kroonenberg
  1999-05-17 21:59 ` syntax Hans Hagen
@ 1999-05-18  8:37 ` Siep Kroonenberg
  1999-05-18 10:14   ` syntax Hans Hagen
  1999-05-18 10:27   ` syntax Hans Hagen
  1 sibling, 2 replies; 5+ messages in thread
From: Siep Kroonenberg @ 1999-05-18  8:37 UTC (permalink / raw)


[-- Attachment #1: message body and .signature --]
[-- Type: text/plain, Size: 2928 bytes --]

Hans Hagen writes:
 > Siep Kroonenberg wrote:
 > 
 > > - Does Context provide for styles as in Word: a set of typographic
 > > specifications (font, leading, h&j, space before and after) separate
 > > from any sectioning hierarchy, or is it necessary to write those from
 > > scratch as macros?
 > 
 > Most commands have some before/after (voor/na) hooks. These are normally
 > used for spacing: voor={\blanko[groot]}, but you can use them for other
 > things too. Font switches normally take place with the style (letter)
 > parameter. In some occasions there is 'afstand', 'korps', 'binnen',
 > 'links', 'rechts', etc. 

So what would be a natural choice as a basis for defining Word styles
(as an environment)? I need to define several variations on ordinary
text, not some kind of sectioning command. Can you give me a
template, or should I do something like start/stopWhatever from
s-map-01.tex?

 >  
 > > - Is the following syntax safe:
 > > 
 > > %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 > >   \some_context_macro
 > > % comment
 > >     [parameter]
 > 
 > Yes. Try for instance 
 > 
 > \setuphead
 >   % comment 
 >   [chapter]
 >   % comment 
 >   [style=bold]
 > 
 > TeX ignores spaces atthe beginningof the line, so the comment becomes
 > one space, and the context argument handler takes care of such
spaces.   

Glad to learn this. Some non-reproducible mysterious behaviour must
probably be ascribed to other causes.

 > > %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 > > 
 > > - I am trying to define typography for a header:
 > > 
 > > \setuphead[subject]
 > >   [before=\blank,
 > >    after=\blank[small],
 > >    style={\switchtobodyfont[sans,16pt]\bf}]
 > 
 > Use switched around {\blank[small]}. Unfortunately TeX's normal argument
 > handling capabilities are not able to handle nested things (in this case
 > nested []). Technically, everything between a pair of [] is picked up,
 > and in your case 
 > the after small ends the parameter list.  

This turns out to work in one example but not in another; attached the
one where it doesn't work.

 > > If I try C-style indentation:
 > > 
 > > \setuphead[subject]
 > >   [before=\blank,
 > >    after=\blank[small],
 > >    style={\switchtobodyfont[sans,16pt]\bf
 > >    }
 > >   ]
 > 
 > Spaces after the first [ and after commas are gobbled, but everything
 > between = and the next , or final ] makes up the value. 

A `%' after `}' fixes it, too. Sanity restored.

 > Some bonus tips:
 > 
 >   \definealternativestyle [siep] [{\switchtobodyfont[sans,16pt]\bf}] []
 > 
 >   \defineblank [alsosiep] [2*big]
 > 
 >   \setuphead[chapter][style=siep,before={\blank[alsosiep]}]
 > 
 > Especially the logical blank's can enforce consistency. 
 > 
 > Hans

Ah! More indirection! But I see where I would want to use this.

Siep

-- 
Siep Kroonenberg, TeX helpdesk
Siep.Kroonenberg@wkap.nl

Kluwer Academic Publishers
Prepress Department
Achterom 119
3311 KB Dordrecht
The Netherlands

[-- Attachment #2: typograf.tex --]
[-- Type: application/octet-stream, Size: 3351 bytes --]

% This example shows commands for defining typographic parameters.
% You can define these parameters in units such as in, mm or pt,
% but if you define them in terms of font dimensions, then they will
% adapt themselves to changes in font size.
% 1em = width of `m'; 1ex = height of `x'

% \blank adds vertical whitespace; define what we mean by
% \blank[normal]
\defineblank[normal][3.5ex]
%\defineblank[small][1.75ex]
\defineblank[small][7pt]

% conventional paragraph marking:
% 1 em indentation
\indenting[yes]
\setupindenting[1em]
% no whitespace between paragraphs
\setupwhitespace[none]
% 3.5ex distance between baselines
\setupinterlinespace[line=3.5ex]

% we want raggedright, which is called rightaligned in Context
\setupalign[right]

% typography for `\title' head
\setuphead[title]
  [style={\ss \tfc},
   after=\blank]

% typography for `\subject' heads
\setuphead[subject]
  [before=\blank,
   after={\blank[small]},
   style={\switchtobodyfont[sans,16pt]\bf}]

\setuplayout[grid=no]

\starttext

\title{What is TeX?}

\subject{Introduction}

A text in TeX format is a plain ascii file, such as can be read and
written by any wordprocessor or ascii editor. Formatting is done by
inserting ascii formatting codes (voorbeeld).

Printing is done in two steps: first a dvi (DeVice Independent) file
is generated, and in a separated step this dvi file is printed or
converted to PostScript and then to pdf.\blank

% Change typography locally. Leading and indentation adjust
% themselves automatically since they are defined in terms of font
% dimensions.

\start[bigger] % `bigger' is an arbitrary label
\switchtobodyfont[16pt]
TeX is built by Donald Knuth, a mathematician who was dissatisfied
with the quality of the typesetting of his books. What was meant to
be a quick hack took him seven years. He made TeX freely available
to anybody, and versions are now available for virtually any
computer platform.

TeX is a full-fledged programming language. This distinguishes it
from older markup-based typesetting systems such as troff. It is
especially popular among scientists: modern wysiwyg wordprocessors
become increasingly impractical as the amount of math and the size
and complexity of a document increases.

\stop[bigger]

\subject{LaTeX}

Most users of TeX use a macro package on top of TeX, and by far the
most popular macro package is LaTeX.

LaTeX allows one to specify structure rather than exact typographic
details, just as in HTML and SGML/XML. Examples of structural
elements in LaTeX are the sectioning commands and the
cross-referencing engine. It also takes care of automatic generation
of tables of contents.  Modern wordprocessors provide these
facilities too, but can't touch TeX in terms of speed, reliability
or flexibility.

LaTeX has its share of problems, too: a culture has come into
existence of mutually incompatible packages, and it is difficult to
tailor LaTeX's typography to one's own tastes or requirements.

\subject{Context}

Context provides an interesting alternative. Centralized development
guaratees internal consistency, and it is suitable for a much
broader range of layout requirements, including screen-based,
interactive applications.

Context has a nice keyword-value syntax. However, it may cost
seasoned (La)TeX users a lot of time finding out how to do things
the Context way.

\stoptext

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

* Re: syntax
  1999-05-18  8:37 ` syntax Siep Kroonenberg
@ 1999-05-18 10:14   ` Hans Hagen
  1999-05-18 10:27   ` syntax Hans Hagen
  1 sibling, 0 replies; 5+ messages in thread
From: Hans Hagen @ 1999-05-18 10:14 UTC (permalink / raw)
  Cc: ntg-context

Siep Kroonenberg wrote:

>  > TeX ignores spaces atthe beginningof the line, so the comment becomes
>  > one space, and the context argument handler takes care of such
> spaces.
> 
> Glad to learn this. Some non-reproducible mysterious behaviour must
> probably be ascribed to other causes.

I spent a lot of time making things as robust as possible within the
concept of tex. Some of the things I encountered are described in the
syst-* files. The biggest problem (unsolvable) is the error messages.
There is no way to hook error recovery in tex. High on the NTS agenda. 

>  > Especially the logical blank's can enforce consistency.
>  >
>  > Hans
> 
> Ah! More indirection! But I see where I would want to use this.

The nice thing about indirection is that you can change it halfway
without redefining all kind of things. There is also indirection in
references. 

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


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

* Re: syntax
  1999-05-18  8:37 ` syntax Siep Kroonenberg
  1999-05-18 10:14   ` syntax Hans Hagen
@ 1999-05-18 10:27   ` Hans Hagen
  1 sibling, 0 replies; 5+ messages in thread
From: Hans Hagen @ 1999-05-18 10:27 UTC (permalink / raw)
  Cc: ntg-context

Siep Kroonenberg wrote:

>  > > \setuphead[subject]
>  > >   [before=\blank,
>  > >    after=\blank[small],
>  > >    style={\switchtobodyfont[sans,16pt]\bf}]

> This turns out to work in one example but not in another; attached the
> one where it doesn't work.

The \blank macro adds up whitespace, so when natural whitespace is
added, the small one is simply not seen. Just say: [nowhite,small] and
you get a smaller one. Watch out, in head's spacing adapts itself to the
font! You can say \showstruts (\toonstruts) to get an impression on how
white space is also influenced by strut placement. (When in despair, you
can always use \vskip in head setups). 

So, watch out: \blank \blank[2*big] \blank \blank[middle] results in a
2*big skip! 

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


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

end of thread, other threads:[~1999-05-18 10:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-05-16 12:36 syntax Siep Kroonenberg
1999-05-17 21:59 ` syntax Hans Hagen
1999-05-18  8:37 ` syntax Siep Kroonenberg
1999-05-18 10:14   ` syntax Hans Hagen
1999-05-18 10:27   ` syntax 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).