org.extex.unit.tex.typesetter.leaders
Class Leaders

java.lang.Object
  extended by org.extex.interpreter.type.AbstractCode
      extended by org.extex.unit.tex.typesetter.leaders.Leaders
All Implemented Interfaces:
java.io.Serializable, Code
Direct Known Subclasses:
Cleaders, Xleaders

public class Leaders
extends AbstractCode

This class provides an implementation for the primitive \leaders.

The Primitive \leaders

The primitive \leaders is a leaders construction which aligns the material on an imaginary grid on the page. The primitive takes as the first argument a box or rule. The second argument is a horizontal or vertical skip specification. The two arguments have to agree on the orientation; either both are horizontal or both are vertical.

The primitive behaves like a glue node with the given skip characteristics. This means it participates in the distribution of the space in the surrounding box. When the final dimensions of the leader element are determined then the empty space is filled with the given box or rule.

The simplest case is a rule which is adjusted to the actual size of the element. This means it either stretches horizontally or vertically according to its orientation.

If a box is given then the contents of the box is repeated within the free space until it is filled. The repeated boxes are aligned on an imaginary grid on the page which guarantees that the boxes fit together tightly. A box is only shown if it fits entirely into the space available. The leaders construction provides something like a window onto an infinite grid filled with the given boxes.

For a horizontal alignment nothing may appear unless the final width of the alignment is at least two times the width of the box to be inserted.

As a consequence of the alignment on the grid several invocations of \leaders with the same box will align those boxes. This can be used in a table of figures to align the dos connecting the title and the page number.

Note that there are also the primitives \cleaders and \xleaders which provide essentially the same functionality but adjust the material within the final space differently.

Syntax

The formal description of this primitive is the following:
    ⟨leaders⟩
      → \leaders ⟨Box or Rule⟩ ⟨Skip⟩

    ⟨Box or Rule⟩
      → ⟨Box⟩
       | ⟨Rule⟩        

Examples

    \leaders\hrule\hfill  

This example creates a horizontal rule which fills the space made up by the \hfill. The rule stretches horizontally and has its natural dimensions vertically.

    \leaders\vrule\vfil  

This example demonstrates the same in vertical direction. Since only \vil is used it may not appear at all when the other elements in the surrounding box overrule it.

    \leaders\hbox to 2em{\hss .\hss}\hfill  

This example shows a box of the width 2em which has a centered period in it. The contents of the box is repeated until it fills the space available.

Version:
$Revision:4431 $
Author:
Gerd Neugebauer
See Also:
AlignedLeadersNode, Serialized Form

Field Summary
protected static long serialVersionUID
          The constant serialVersionUID contains the id for serialization.
 
Constructor Summary
Leaders(CodeToken token)
          Creates a new object.
 
Method Summary
protected  void addNode(Typesetter typesetter, OrientedNode node, FixedGlue skip)
          Finally make an appropriate node and add it to the typesetter.
 void execute(Flags prefix, Context context, TokenSource source, Typesetter typesetter)
          This method takes the first token and executes it. The result is placed on the stack. This operation might have side effects. To execute a token it might be necessary to consume further tokens.
 
Methods inherited from class org.extex.interpreter.type.AbstractCode
getLocalizer, getName, getToken, isIf, isOuter, readResolve, toString, toText, toText
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

protected static final long serialVersionUID
The constant serialVersionUID contains the id for serialization.

See Also:
Constant Field Values
Constructor Detail

Leaders

public Leaders(CodeToken token)
Creates a new object.

Parameters:
token - the initial token for the primitive
Method Detail

execute

public void execute(Flags prefix,
                    Context context,
                    TokenSource source,
                    Typesetter typesetter)
             throws HelpingException,
                    TypesetterException
This method takes the first token and executes it. The result is placed on the stack. This operation might have side effects. To execute a token it might be necessary to consume further tokens.

Specified by:
execute in interface Code
Overrides:
execute in class AbstractCode
Parameters:
prefix - the prefix controlling the execution
context - the interpreter context
source - the token source
typesetter - the typesetter
Throws:
HelpingException - in case of an error
TypesetterException - in case of an error in the typesetter
See Also:
Code.execute( org.extex.interpreter.Flags, org.extex.interpreter.context.Context, org.extex.interpreter.TokenSource, org.extex.typesetter.Typesetter)

addNode

protected void addNode(Typesetter typesetter,
                       OrientedNode node,
                       FixedGlue skip)
                throws TypesetterException
Finally make an appropriate node and add it to the typesetter.

Parameters:
typesetter - the typesetter
node - the node
skip - the skip amount
Throws:
TypesetterException - in case of an error