[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Groff] A TeX-like macro package: I begin to write it, but need help

From: Thomas Baruchel
Subject: [Groff] A TeX-like macro package: I begin to write it, but need help
Date: Sun, 11 Mar 2001 11:49:50 +0100
User-agent: Mutt/1.2.5i

Brest, le dimanche 11 mars

Hi everybody, I begun to write my new .PP macro.
Use it in this way:
  .PP flush
The idea is that your paragraph must always be between to .PP requests. If
you don't want to begin another paragraph, put .PP flush instead
  .PP 0 means a paragraph without intial indentation
  .PP 1 means a paragraph with an initial indentation
  .PP means a paragraph with an initial indentation but you can change this
     default behaviour by setting the Pi register to 0 (default: 1)
You can for the moment play with these registers:
  PI (value of the indentation)
  VS (height of a line in the paragraph)
  PD (space before the paragraph)

OK, but what is new ?
For the moment, nothing except one thing: the paragraph is memorized in an
*unformatted* macro. You can then play with it, and then print it. My idea is
to use a line breaking algorithm in order to have a better output than with the
raw line breaking manner of troff. You can use wherever you want in your
paragraph: \\n(Pn to print the number of lines of this paragraph. New
registers will follow.

for the general algorithm. I know I will use the .ss request in a line by line
way to format correctly the paragraph, but any suggestion will be helpful
(remember that it is possible to try several diversions before choosing the
best one).

 - why is there a very little indentation (about 2pt) with .PP 0 ?
   (I think I must have forgotten an initial space somewhere)
 - why is there a big space between two paragraphs (much bigger then it should
   be with the PD register: even with PD set to 0, there is such a vertical

.\" ***********************************
.\" * Macro PP: début d'un paragraphe *
.\" ***********************************
.\" Registres modifiables par l'utilisateur :
.\" =========================================
.nr     PI 12p   \" indentation par défaut
.nr     Pi 1     \" par défaut: indentation de tous les paragraphes
.nr     PD 4p    \" espace précédant un paragraphe
.nr     PS 12    \" taille par défaut des caractères
.nr     VS 14.5p \" hauteur d'une ligne
.\" Registres en lecture seule
.\" ==========================
.nr     Pn 0 \" par défaut: aucun nombre de lignes
.\" Registres internes
.\" ==================
.nr Pz 0 \" par défaut: aucun paragraphe n'est ouvert
.\" Définition des macros
.\" =====================
.de PP
.if Pz \{ \\.. \" si un paragraphe est ouvert :
.    di PX \" PX est une diversion de travail
.    ad l
.    dt \\n(.du+\\n(.vu P1
.    P0
.    br
.    di
.    \" Affichage du paragraphe
.    \" =======================
.        sp \\n(PDu \" espace précédant le paragraphe
.        P0 \}
.\" indentation du paragraphe dans le registre P2
.    if '\\n(Pi'0' .nr P2 0
.    if '\\n(Pi'1' .nr P2 \\n(PI
.    if '\\$1'0'   .nr P2 0
.    if '\\$1'1'   .nr P2 \\n(PI
.ie !'\\$1'flush' \{ \" si un nouveau paragraphe doit commencer
.    nr Pn 0 \" remise à 0 du compteur de lignes
\\.  de P0 PP
.    ti \\n(P2u
.    ps \\n(PS
.    vs \\n(VSu
.el .nr Pz 0 \" fin d'un paragraphe
.\" Macro P1: ligne à ligne dans un paragraphe
.\" ==========================================
.de P1 \" cette macro est exécutée à chaque ligne d'un paragraphe
.dt \\n(.du+\\n(.vu P1
.nr Pn +1
.\" ********************************
.\" * End of the macros definition *
.\" ********************************
.\" Beginning of the document
.\" =========================
This is the first paragraph of this document. The most interesting thing about 
it is that it has been keeped in memory and handled without having been 
\fIformatted\fR before. The number of the lines in it have been counted and put 
in the register Pn. By doing this, you can know that this paragraph has 
\\n(Pn\~lines in it.
.PP 0
This is the second paragraph of this document. It is much shorter than the 
other one, since it only has \\n(Pn\~lines in it. I used the .PP macro with 0 
as argument in order to have ni initial indentation.
This paragraph of \\n(Pn\~lines is still shorter.
.PP flush

reply via email to

[Prev in Thread] Current Thread [Next in Thread]