ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Wolfgang Schuster <schuster.wolfgang@gmail.com>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Using *fleurons*
Date: Sun, 10 Nov 2013 19:56:56 +0100	[thread overview]
Message-ID: <527FD6F8.4010504@gmail.com> (raw)
In-Reply-To: <CACiybx7WVsQdLarHujdyDURQHtavN7AA5LKqCpGPFby1EvJDwQ@mail.gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 12838 bytes --]



> Francisco Gracia <mailto:fgragu023@gmail.com>
> 10. November 2013 16:12
> *Fleurons* are small decorative pieces that were often used in the 
> past for filling big blank spaces in books. They are seldom used 
> nowdays. As besides they will not appear more than a few times in any 
> book (mainly at the end of chapters), the easiest thing to do if one 
> insists in using them (for instance for simulating an old edition of 
> some past work) is to arrange its presence manually in the source 
> document in the way one would do for any other figure or piece of text.
>
> I subscribe to this, which is without doubt the way to proceed if the 
> original document will allways be typesett in the same way. But if it 
> were an extensive work and one foresees different layouts for its 
> appearence as different *products*, then one would have one more 
> source of worries after every run of the work through *Context*, as 
> you can bet that sooner than later one page will have been included 
> somewhere whose only content will be the damned *fleuron*, something 
> that obviously should not happen.
>
> This is the problem that I tackled, because I did not find any 
> previous reference or solution to it. My reasoning, my explanations 
> and the working code are all contained in the rest of this message.
>
> It is conceived as being composed of two parts, but it can also be 
> saved and dealt as one piece. If one saves it as two independent files 
> (as should be done if one intends to use it for any other thing that 
> running the tests samples) the content of the first file will be the 
> one delimited as *Fleuron.tex* and that of the second 
> (*Fleuron_test.tex*) would be the rest of the message. The line of 
> this second file
>
>     % \input {Fleuron}
>
> should be uncommented if one intends to run it as such. The one file 
> version runs as it is.
>
> The script creates the new command *\Fleuron{\<motive name>}*, which 
> is the one to include at the place intended in the source document for 
> the *fleuron* to appear (of course after having incorporated the 
> contents of *Fleuron.tex* in its preamble with *\input{Fleuron}*). The 
> argument *<motive name>* allows the selection of a specific motive 
> among the several of them that could be available; the user can create 
> and organize all this according to his wishes. For instance 
> *\Fleuron{\MotiveFive}* would use the example labelled *\MotiveFive* 
> in the group of examples provided. The comments in *Fleuron.tex* 
> explain how to handle all this.
>
> Enjoy and critizice
>
> Francisco
>
> %%%%%%%%%%%%%%%%%%%%%%%
> %
> % Fleuron.tex
> % Script that explains and implements in *ConTeXt* Mk-IV the kind of 
> small ornaments
> % traditionally used by printers for filling big blank spaces in books 
> and printed works.
>
> %*Fleuron*: subst. masc. 2b) Élément décoratif de fantaisie ornant le 
> titre ou les blancs des principales divisions d'un ouvrage [livre] 
> (Trésor de la langue française informatisé).
> %
> %%%%%%%%%%%%%%%%%%%%%%%%%%%
>
> % Creation of the ornament as an entity (in the form of a box)
>
> % Typesetting true *fleurons* requires the use of *TeX*'s special *box 
> registers* as arguments;
> % here box register number *0* has been arbitrarily selected for the 
> proceedings.
> % The essential steps in the construction are:
> %    - (typo)graphical composition of the motive (as for instance 
> *\midaligned{Finis}* in the first example)
> %        or designation of the source file of an image,
> %    - enclosure of it in a vertical box (*\vbox{\midaligned{Finis}}*) and
> %     - finally association of the boxed motive with boxregister *0* 
> (*\setbox0= ...*), all of which happens
> %          in reverse order, from right to left, in the code.
> % Here are several examples of this:
> %\setbox0=\vbox{\midaligned{Finis}}
> %\setbox0=\vbox{\midaligned{Finis\\coronat\\opus}}
> %\setbox0=\vbox{\midaligned{*****} \Inter \midaligned{***} \Inter 
> \midaligned{*}}
>
> % In order to get in *TeX* something remotely similar to a normal 
> variable,
> % called *Motivo*, the following machinery has to be implemented
> \def\Motivo{\copy0}        % get a copy of register's *0* content
>
> % the graphic parts of several (typographical) test motives follow:
> \def\MotOne{{\midaligned{\em Finis}}}
> \def\MotTwo{{\midaligned{\em Finis\\\em coronat\\\em opus}}}
> \def\MotThree{{\midaligned{*****} \Inter \midaligned{***} \Inter 
> \midaligned{*}}}
> \def\MotFour{{\midaligned{___________}}}
> \def\MotFive{{\bf \midaligned{\hl[1]} \Inter \midaligned{\hl[5]} 
> \Inter \midaligned{\hl[1]}}}
>
> %%%%%%%%%%%%%%%%%%%%%%%%%
> %
> % THINGS THAT DO NOT WORK
> %
> %\setbox0=\vbox{\midaligned{\switchtobodyfont[20pt]*}}    % executing 
> these corrupt the whole script
> %\setbox0=\vbox{\switchtobodyfont[20pt] \midaligned{*****\\***\\*}}
> %\def\Grande{\midaligned{\switchtobodyfont[50pt]*}}        % in any 
> form it is tried
> %\setbox0=\vbox{\Grande}
> %
> %%%%%%%%%%%%%%%%%%%%%%%%%
>
> %%%%%%%%%%%%%%%%%%%%%%%%%
> %
> % USING FIGURES AS MOTIVES
> %
> % Most *fleurons* will be based on figures (usually images of 
> schematic line drawings)
> % rather than on elements of the alphabetical character set.
> % So it is important to insure that also this alternative works as it 
> should.
> % *Contextref* says that just giving the name of the figure's file is 
> enough,
> %\useexternalfigure [cow] [cow.pdf] [scale=300]
> % but this usually does not work, so better give the whole path to the 
> figure in your machine
> \useexternalfigure [cow] 
> [L:/ConTeXt/context/tex/texmf-context/tex/context/sample/cow.pdf] 
> [hfactor=20]
> %\setbox0=\vbox{\externalfigure [cow] }
> \def\MotCow{{\externalfigure [cow] }}
> %
> %%%%%%%%%%%%%%%%%%%%%%%%%
>
> %%%%%%%%%%%%%%%%%%%%%%%%%
> %
> % This is the algorithmically interesting part of the whole business. 
> It rests upon one instruction,
> % *pagespace*, which gets and handles some of *TeX*'s internal 
> magnitudes of the page.
> % Its code was devised, implemented and very well explained by D. Salomon
> % in *Output Routines: Examples and Techniques.
> % Part I: Introduction and Examples.* Tugboat 11 nº 1: 71.), from 
> where the following extract originates:
> %
> % "As an example, the two variables [*pagetotal*, *t*, and *pagegoal*, 
> *g*] will be used
> % to determine how much space is left on the current page.
> % If *t* is zero, the space left on the page is the entire page 
> (*\vsize*).
> % Otherwise, it is the difference *g - t*. Macro *\pagespace* 
> calculates that difference".
>
> % The interpretations and comments that follow are on the contrary mine;
> % so be careful: they can be wrong!
> % Determination of the space available in *TeX*'s *current page*
> \newdimen\Spaceleft            % the result will be stored under this name
> % computation of the datum
> \def\pagespace{%
>    \ifdim\pagetotal=0pt        % if the page is empty (i.e. if it is a 
> new page)
>       \Spaceleft=\vsize            % the available space is the full 
> design page
>    \else                    % otherwise
>       \Spaceleft=\pagegoal        % the required amount is the design 
> maximum size
>       \advance\Spaceleft -\pagetotal    % less the already used space
>    \fi}
>
> % We also need for our purposes certain numerical information about 
> the ornament,
> % mainly its height; so let's get it algorithmically
> %\def\Talla{100pt}
> \newdimen\Orn                % the height of the ornament in points
> \newdimen\Talla                % the space requested from the page 
> (with some *air* around)
> \newdimen\Respiro            % the blank space between text and *fleuron*
>
> % let us construct the selected *fleuron*
> \def\Instance#1{%            % we get the (typo)graphical content as 
> argument,
>    \setbox0=\vbox{#1}        % put it in a box and assign the box to 
> register *0*
>    \Orn=\ht0                % after which we can get the required 
> values through this register
>    \Talla=\ht0                % (getting as an aside a little sample 
> of the daunting *texan* arithmetic)
>    %\advance \Talla by 0.5\Talla    % compute half the height of the 
> ornament
>    \advance \Talla by \Talla        % twice the height of the ornament
> %   \Respiro=0.5\ht0            % half the height of the ornament
> }
>
> % and the operative command can be finally issued
> \def\Fleuron#1{%
>    \Instance{#1}                % assemble the object
>    \pagespace                % get from *TeX* the relevant magnitudes 
> about the *current page*
>
> % (transitory debug information
> %   Available: \the\Spaceleft\par  % this shows the information on the 
> document itself
> %   Required: \the\Talla\par
> %   Ornament: \the\Orn\par
> %   Disponible: \show\Spaceleft\par  % and this shows it in the terminal
> %   Requerido: \show\Talla\par
> %   Ornamento: \show\Orn\par     % )
>
>    \ifdim\Spaceleft>4\Orn        % if there are lots of space available
> %    \Respiro=\ht0            % insert a bigger separation
>       \Respiro=\Orn            % insert a bigger separation
>    \else
>       \Respiro=0.5\Orn        % insert a smaller separation
>    \fi
>
>    \ifdim\Spaceleft<\vsize        % only when the page has already 
> some previous content
>       \ifdim\Spaceleft>\Talla        % but keeps also enough space for 
> the ornament,
>          \vskip\Respiro            % add a reasonable separation from 
> the text
> %       \vskip 0.5\Orn             % (as could be half the size of the 
> ornament)
>          \midaligned{\Motivo}        % and typeset the ornament centered
>       \fi
>    \fi
> }
>
>
> \def\Inter{\vskip 0.1pt}        % small downward displacement
>
> %%%%%%%%%%%%%%%%%%%%%
> %
> %End of *Fleuron.tex*
> %
> %%%%%%%%%%%%%%%%%%%%%
>
> %%%%%%%%%%%%%%%%%%%%%
> %
> % *Fleuron_test.tex*
> % Test script for the *Fleuron* instruction
>
> %\input {Fleuron}            % incorporate the contents of *Fleuron.tex*
>
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> %
> % some layout provisions for the test document
>
> \setuplayout[lines=10]    % size of the output page in lines
> \preloadtypescripts
> \usetypescript[latinmodern]
> \setupbodyfont[9pt]
>
> %\tracingpages=1        % show some internal typrographical magnitudes 
> in the *.log* file
>
>
> %%%%%%%%%%%%%%%%%%%%%
> %
> % Typesetting and display
> %
>
> \starttext
>
> Test script for the \em Fleuron \em complement.\par
>
> %\placefigure [none] {}{\externalfigure[cow]}    % testing if figure 
> reproduction works by itself
>
> \dorecurse{2}{Line \recurselevel\par}        % fill the page with some 
> lines and show the *fleuron*
> %\dorecurse{6}{Line \recurselevel\par}        % (more lines could 
> exclude the *fleuron*)
>
> % *\MotOne*, *\MotTwo*, *\MotThree*, *\MotFour*, *\MotFive*
> %  y *\MotCow* are available as example arguments
> \Fleuron{\MotTwo}            % passed argument allows selection among 
> available motives
>
> \stoptext

1. To use graphics from the TeX directory add 
\setupexternalfigures[location=default] (or better 
location={local,global,default}) to your document, avoid abolsute paths.

2. Add braces around the words where you want to change the font with 
\em, e.g. {\em this text is emphasized}.

3. Use context programming stuff when you want to write a command, e.g. 
\dowithnextboxcs. With \dimexpr you can also simplify calculations 
because you don't have to store dimension to multiply or add them

Below is a simpler version of your \Fleuron command but I haven't 
checked if everything works as expected.

\unprotect

\unexpanded\def\fleuron
   {\par
    \begingroup
    \setupalign[\v!middle]%
    \dowithnextboxcs\fleuron_direct\vbox}

\def\fleuron_direct
   {\ifzeropt\pagetotal
      % new page, don't place the fleuron
    \else
      \ifdim\dimexpr\pagegoal-\pagetotal-\htdp\nextbox\relax<\textheight
        
\ifdim\dimexpr\pagegoal-\pagetotal\relax<\dimexpr\htdp\nextbox*4\relax
          \vskip.5\htdp\nextbox
        \else
          \vskip\htdp\nextbox
        \fi
        \box\nextbox
      \fi
    \fi
    \endgroup}

\protect

\setuplayout[lines=10]

\setupexternalfigure[location=default] % use figures from the tex directory

\setupbodyfont[9pt]

\showframe

\starttext

Test script for the {\em Fleuron} complement.\par

\dorecurse{2}{Line \recurselevel\par}

\fleuron{\em Finis\\\em coronat\\\em opus}

\page

\dorecurse{2}{Line \recurselevel\par}

\fleuron{\dontleavehmode\externalfigure[cow][height=2cm]}

\stoptext

Wolfgang

[-- Attachment #1.2.1: Type: text/html, Size: 16704 bytes --]

[-- Attachment #1.2.2: compose-unknown-contact.jpg --]
[-- Type: image/jpeg, Size: 770 bytes --]

[-- Attachment #2: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

  reply	other threads:[~2013-11-10 18:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-10 15:12 Francisco Gracia
2013-11-10 18:56 ` Wolfgang Schuster [this message]
2013-11-11 17:51 ` Bill Meahan
2013-11-11 21:22   ` Wolfgang Schuster
2013-11-11 21:40 Francisco Gracia
2013-11-11 21:56 ` Wolfgang Schuster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=527FD6F8.4010504@gmail.com \
    --to=schuster.wolfgang@gmail.com \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).