aboutsummaryrefslogblamecommitdiffstats
path: root/include/bsf
blob: 383d918c2be05bfbc25bdb251201b1ee14cea628 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12


                                                                               
                                                                               

                                                                               





                                                                               
















                                                                               

                                                                               


                                                                    



















                                                                               

                                                                           
                                                                           

                                                                           
 
                                                                         
 
 

                                                                           










                                                                           


                                                                           
 
 


































                                                 









                                                                               
                                                                             
                                                                       

                                                                  
                                         
                                                                           

                    

                                        


                                                               
 
                                     






                                                                            
                                                                        
                                                                              
                                                                           


                                                               



























































                                             
                  































































                                                                               
                                                                   


                                                                       
                                                                             

                                                                         
                                                               













                                                                               

                                                                     
                                                                           
                                                                            
                                                                                


                                                                          


                                                                             



                                                                               



















                                                                               



























                                                                                                         
                                                                                                               






                                                                               
                                                                               


                                                                               

                                                         
 





                                                                 


































































                                                                               

                                                                               














                                                                               

                                                     





























                                                     

                                                                            







































































































































































                                                                                 
                                                                               

















































                                                                               












                                            














































                                                                               




















                                                                               





























                                                                               




























                                                                               



                                                                               
                                                                               


                                                                               


                     




                                


                                                                         



                                
                                                                                          
                                                                      
                                            



                 





















                                                                   








                                                                               
                                            



                                        
                                                                               


                                 
                                                                                        






                                                           
                                            



                               
                                                                               


                        
                                                                                        







                                                            
                                            
                            
                                              




                                                                
                                                                             





                                                                          
                                                                           










                                                                          
                                            
                            
                                              





















                                                                   
                                                            




                                                         
                                                                                  
















                                                                          
                                            
                            
                                              







                                                         




                                                 





                                            




                                           












                                                                               




                                               













                                                                               






                                                  
























































                                                                                             





























                                                                              
                                                                              
                                                                              





                                                                              











                                                                              
                 
     
                                           


     














                                          
                                 



                       
                       




                      

                 
                                                                



                       
     
                                          


               
                 
     


                                      





                                         







                                                            

     









                                                               
















































































































































                                                                                
                               


                             
                            









                                                      
                                     

                 









                                                                                    



           
                                                                               



































                                                                               
                                     


                 

                                                                        













                                                 
                                     


                 

                                                                        





































































































                                                                                      
                                       












                                                  

                                                    
                                                  
                                                  



                                                  




                               







                                                                                                 


                                                                       
                                                                      
                                                                                
                 
                                                                             


                                                       


                                                                
                                                                                


                                                       














                                                  
                              











                                                            

                        

                                                                   



                          


                                                                            



                         



                                                                            



                         




                                                                            










                                      








                                                
            
                                                                            

     
















                                                                     





                                                   

















                                                         
                           













                                                                         
                                                                                 





































































                                                                                

###############################################################################
#                                                                             #
#  Lout @BasicSetup package                                                   #
#                                                                             #
#  Jeffrey H. Kingston                                                        #
#                                                                             #
#  This package contains basic symbols used widely throughout many            #
#  documents, for font changes, particular characters, standard words in      #
#  the current language, date and time, paragraphs, lists, colours,           #
#  rules, and boxes.                                                          #
#                                                                             #
#  This program is free software; you can redistribute it and/or modify       #
#  it under the terms of the GNU General Public License as published by       #
#  the Free Software Foundation; either Version 3, or (at your option)        #
#  any later version.                                                         #
#                                                                             #
#  This program is distributed in the hope that it will be useful,            #
#  but WITHOUT ANY WARRANTY; without even the implied warranty of             #
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              #
#  GNU General Public License for more details.                               #
#                                                                             #
#  You should have received a copy of the GNU General Public License          #
#  along with this program; if not, write to the Free Software                #
#  Foundation, Inc., 59 Temple Place, Suite 330, Boston MA 02111-1307 USA     #
#                                                                             #
#  As a special exception, when this file is read by Lout when processing     #
#  a Lout source document, you may use the result without restriction.        #
#                                                                             #
###############################################################################

@SysInclude { lengths }		# @PSLengths
@SysInclude { coltex }		# @ColourCommand and @TextureCommand
@SysPrependGraphic { bsf.lpg }	# rules, boxes, margin note setup


###############################################################################
#                                                                             #
#  The following symbols are defined outside @BasicSetup so that              #
#  they can be invoked when setting its parameters in the @Use clause.        #
#                                                                             #
###############################################################################

def @OrIfPlain
    precedence 80
    left x
    right y
{
    @BackEnd @Case {
	PlainText @Yield y
	else      @Yield x
    }
}

###########################################################################
#                                                                         #
#   @Colour, @Color                                                       #
#                                                                         #
###########################################################################

def @Colour @Color left col right y { {@ColourCommand col} @SetColour y }


###########################################################################
#                                                                         #
#  @ColouredUnderline, @ColoredUnderline                                  #
#                                                                         #
###########################################################################

def @ColouredUnderline @ColoredUnderline left col right y {
  {@ColourCommand col} @SetUnderlineColour @Underline y
}


###########################################################################
#                                                                         #
#   @Texture                                                              #
#                                                                         #
###########################################################################


def @Texture
    left type
                      named scale	{ 1	}
                      named hscale	{ 1	}
                      named vscale	{ 1	}
    import @PSLengths named angle	{ 0d	}
    import @PSLengths named hshift	{ 0i	}
    import @PSLengths named vshift	{ 0i	}
    import @PSLengths named width	{ "dft"	}
    import @PSLengths named height	{ "dft"	}
    import @PSLengths named gap		{ "dft"	}
    import @PSLengths named radius	{ "dft"	}
    import @PSLengths named linewidth	{ "dft"	}
                      named font	{ "dft"	}
    import @PSLengths named size	{ "dft"	}
                      named value	{ "dft"	}
    right x
{
    { type @TextureCommand
	scale		{ scale		}
	hscale		{ hscale	}
	vscale		{ vscale	}
	angle		{ angle		}
	hshift		{ hshift	}
	vshift		{ vshift	}
	width		{ width		}
	height		{ height	}
	gap		{ gap		}
	radius		{ radius	}
	linewidth	{ linewidth	}
	font		{ font		}
	size		{ size		}
	value		{ value	}
    } @SetTexture x
}


###############################################################################
#                                                                             #
#  Symbols exported by @BasicSetup.                                           #
#                                                                             #
###############################################################################

export

    @InitialFont @InitialBreak @InitialOutdent @InitialSpace @InitialLanguage
    @InitialColour @InitialBackgroundColour @OptimizePages @HeadingFont
    @ParaGap @ParaIndent @DisplayGap @DisplayIndent @DefaultIndent
    @DisplayNumStyle @WideIndent @VeryWideIndent
    @ListGap @ListIndent @ListRightIndent
    @ListLabelWidth @ListLabelRight @ListLabelRightGap @ListFont @ListBreak
    @NumberSeparator

    @Pipe @PipeVerbatim @PipeRawVerbatim

    @Word @Roman @UCRoman @Alpha @UCAlpha @FnBullets @FnSymbols
    @Months @ShortMonths @WeekDays @ShortWeekDays
    @TwelveHours @ShortHours @MeriDiems @ShortMeriDiems

    @Sym @Ding @R @I @B @BI @S @F @II
    "~" "~~" "``" "''" ",," "--" "---" "..."

    @Bullet @ParSym @SectSym @Dagger @DaggerDbl @CDot @Sterling @Yen @Florin
    @Star @Degree @Minute @Second @Multiply @Divide @Lozenge @Register
    @CopyRight @TradeMark @Euro

    @Date @Time @DateTimeFormat @DropCapTwo @DropCapThree @Centre @Right
    @NoDotSep @NoDotJoin @Join @Sep @DotSep @ColonSep @DotJoin @DashJoin
    @NumSep @VStrut @ZeroWidth @ZeroHeight @OverStrike @Sup @Sub @HClip @VClip
    @FullWidthRule @LocalWidthRule @Box @CurveBox @ShadowBox @BoundaryMarks
    @DocInfo @NumberMarker @NumberOf @TitleMarker @TitleOf
    @PageMarker @PageMark @NoLinkPageMark @PageOf @PageParityOf
    @CrossLink @ExternalLink

    @BeginDisplayCounter

    @Heading "^" "&-" @If @Not @And @Or @True
    @PP @LP @LLP @DP @LOP @NP @CNP

    @BeginAlignedDisplays
    @EndAlignedDisplays

    @Display
    @LeftDisplay
    @IndentedDisplay
    @QuotedDisplay
    @CentredDisplay
    @RightDisplay
    @AlignedDisplay
    @LeftAlignedDisplay
    @IndentedAlignedDisplay
    @QuotedAlignedDisplay
    @CentredAlignedDisplay
    @RightAlignedDisplay
    @NumberedDisplay
    @LeftNumberedDisplay
    @IndentedNumberedDisplay
    @QuotedNumberedDisplay
    @CentredNumberedDisplay
    @RightNumberedDisplay
    @AlignedNumberedDisplay
    @LeftAlignedNumberedDisplay
    @IndentedAlignedNumberedDisplay
    @QuotedAlignedNumberedDisplay
    @CentredAlignedNumberedDisplay
    @RightAlignedNumberedDisplay

    @RawDisplay
    @RawLeftDisplay
    @RawIndentedDisplay
    @RawQuotedDisplay
    @RawCentredDisplay
    @RawRightDisplay
    @RawAlignedDisplay
    @RawLeftAlignedDisplay
    @RawIndentedAlignedDisplay
    @RawQuotedAlignedDisplay
    @RawCentredAlignedDisplay
    @RawRightAlignedDisplay
    @RawNumberedDisplay
    @RawLeftNumberedDisplay
    @RawIndentedNumberedDisplay
    @RawQuotedNumberedDisplay
    @RawCentredNumberedDisplay
    @RawRightNumberedDisplay
    @RawAlignedNumberedDisplay
    @RawLeftAlignedNumberedDisplay
    @RawIndentedAlignedNumberedDisplay
    @RawQuotedAlignedNumberedDisplay
    @RawCentredAlignedNumberedDisplay
    @RawRightAlignedNumberedDisplay

    @ListItem
    @ParagraphItem
    @ListInterruptItem
    @ListNewPage
    @DropListItem
    @TagItem
    @DropTagItem

    @EndList
    @RawEndList

    @RawList
    @RawLeftList
    @RawIndentedList
    @RawQuotedList
    @RawCentredList @RawCenteredList
    @RawNumberedList
    @RawParenNumberedList
    @RawRomanList
    @RawParenRomanList
    @RawUCRomanList
    @RawParenUCRomanList
    @RawAlphaList
    @RawParenAlphaList
    @RawUCAlphaList
    @RawParenUCAlphaList
    @RawBulletList
    @RawStarList
    @RawDashList
    @RawTaggedList
    @RawWideTaggedList
    @RawVeryWideTaggedList

    @List
    @LeftList
    @IndentedList
    @QuotedList
    @CentredList @CenteredList
    @NumberedList 
    @ParenNumberedList
    @RomanList
    @ParenRomanList
    @UCRomanList
    @ParenUCRomanList
    @AlphaList
    @ParenAlphaList
    @UCAlphaList
    @ParenUCAlphaList
    @BulletList 
    @StarList 
    @DashList
    @TaggedList
    @WideTaggedList
    @VeryWideTaggedList


###############################################################################
#                                                                             #
#  The @BasicSetup package.                                                   #
#                                                                             #
###############################################################################

def @BasicSetup
    named @InitialFont	  { Times Base 12p	} # initial font
    named @InitialBreak	  { {adjust 1.20fx hyphen} @OrIfPlain
			    {ragged 1fx nohyphen} } # initial break
    named @InitialOutdent { 2f @OrIfPlain 4s	} # initial outdent
    named @InitialSpace	  { lout		} # initial space style
    named @InitialLanguage{ English		} # initial language
    named @InitialColour  { black		} # initial colour
    named @InitialBackgroundColour { white	} # initial background colour
    named @OptimizePages  { No			} # optimize page breaks?
    named @HeadingFont	  { Bold		} # font for @Heading
    named @FixedWidthFont { Courier Base -1p	} # font for @F
    named @ParaGap	  { 1.3vx @OrIfPlain 1f	} # gap between paragraphs
    named @ParaIndent	  { 2.0f @OrIfPlain 5s	} # first-line indent for @PP
    named @DisplayGap	  { 1.0v @OrIfPlain 1f	} # gap above, below displays
    named @DisplayIndent  { 2.0f @OrIfPlain 5s	} # @IndentedDisplay indent
    named @DefaultIndent  { 0.5rt		} # @Display indent
    named @DisplayNumStyle
	right num	  { (num)		} # display number style
    named @WideIndent	  { 4.0f @OrIfPlain 10s	} # @WideTaggedList indent
    named @VeryWideIndent { 8.0f @OrIfPlain 20s	} # @VeryWideTaggedList indent
    named @ListOuterGap	  { 1.0v @OrIfPlain 1f	} # gap before, after list
    named @ListGap	  { 1.0v @OrIfPlain 1f	} # gap between list items
    named @ListIndent	  { 0s			} # indent of list items
    named @ListRightIndent{ 0s			} # right indent of list items
    named @ListLabelWidth { 2.0f @OrIfPlain 5s	} # width allowed for list tags
    named @ListLabelRight { No			} # right align label
    named @ListLabelRightGap { 2s		} # right align gap
    named @ListFont       {                     } # font style of list item
    named @ListBreak      {                     } # break style of list item
    named @NumberSeparator{ .			} # separates numbers like 2.3.7
    import @BasicSetup
    named @CrossLinkFormat
	right @Body	  { @Body		} # format for cross links
    import @BasicSetup
    named @ExternalLinkFormat
	right @Body	  { @Body		} # format for external links
@Begin

    ###########################################################################
    #                                                                         #
    #  x @Dft y                                                               #
    #                                                                         #
    #  This returns x unless its value is "dft", in which case it returns y.  #
    #  Useful for defaulting the value of one parameter to another.           #
    #                                                                         #
    ###########################################################################

    def @Dft
	left x
	right y
    {
	x @Case {
	    dft  @Yield y
	    else @Yield x
	}
    }


    ###########################################################################
    #                                                                         #
    #   @Pipe, @PipeVerbatim, and @PipeRawVerbatim                            #
    #                                                                         #
    ###########################################################################

    def @Pipe
	left command
	right x
    {
	def @Filter { "cat" @FilterIn "|" command ">" @FilterOut }

	x
    }

    def @PipeVerbatim
	left command
	right x
    {
	def @Filter {
	  "(echo @Verbatim @Begin ; (cat" @FilterIn "|" command "); echo @End @Verbatim ) >" @FilterOut }

	x
    }

    def @PipeRawVerbatim
	left command
	right x
    {
	def @Filter {
	  "(echo @RawVerbatim @Begin ; (cat" @FilterIn "|" command "); echo @End @RawVerbatim ) >" @FilterOut }

	x
    }


    ###########################################################################
    #                                                                         #
    #   @Sym, @Ding font symbols, and miscellaneous special characters.       #
    #                                                                         #
    ###########################################################################

    def @Sym  right x { { Symbol Base } @Font @Char x	}
    def @Ding right x { { Dingbats Base } @Font @Char x	}

    def @R    right x { Base @Font x			}
    def @I    right x { Slope @Font x			}
    def @B    right x { Bold @Font x			}
    def @BI   right x { BoldSlope @Font x		}
    def @S    right x { smallcaps @Font x		}
    def @F    right x { @FixedWidthFont @Font x 		}

    def @II
	right x
    {
	{ @CurrFace @Case {
	    Bold @Yield BoldSlope
	    else @Yield Slope
	} } @Font x
    }

    def "~"  left x right y { x &1su y }
    def "~~" left x right y { x &2s y }

    def "``"       { @Char "quotedblleft"	@OrIfPlain "``"	}
    def "''"       { @Char "quotedblright"	@OrIfPlain "''"	}
    def ",,"       { @Char "quotedblbase"	@OrIfPlain ",,"	}
    def "--"       { @Char "endash"		@OrIfPlain "--"	}
    def "---"      { @Char "emdash"		@OrIfPlain "---"}
    def "..."      { @Char "ellipsis"		@OrIfPlain "..."}
    def @Bullet    { @Char "bullet"		@OrIfPlain "o"	}
    def @ParSym    { @Char "paragraph"		@OrIfPlain "P"	}
    def @SectSym   { @Char "section"		@OrIfPlain "$"	}
    def @Dagger    { @Char "dagger"		@OrIfPlain "+"	}
    def @DaggerDbl { @Char "daggerdbl"		@OrIfPlain "++"	}
    def @CDot      { @Char "periodcentered"	@OrIfPlain "."	}
    def @Sterling  { @Char "sterling"		@OrIfPlain "&"	}
    def @Yen       { @Char "yen"		@OrIfPlain "Y"	}
    def @Florin    { @Char "florin"		@OrIfPlain "f"	}

    def @Star      { @Sym  "asteriskmath"	@OrIfPlain "*"	}
    def @Degree    { @Sym  "degree"		@OrIfPlain "o"	}
    def @Minute    { @Sym  "minute"		@OrIfPlain "'"	}
    def @Second    { @Sym  "second"		@OrIfPlain "''"	}
    def @Multiply  { @Sym  "multiply"		@OrIfPlain "x"	}
    def @Divide    { @Sym  "divide"		@OrIfPlain "/"	}
    def @Lozenge   { @Sym  "lozenge"		@OrIfPlain "O"	}
    def @Register  { @Sym  "registersans"	@OrIfPlain "R"	}
    def @CopyRight { @Sym  "copyrightsans"	@OrIfPlain "C"	}
    def @TradeMark { @Sym  "trademarksans"	@OrIfPlain "TM"	}

    def @Euro
    {
	@BackEnd @Case {

	    PostScript @Yield {
		0.65w @VShift @VContract @HContract
		"xsize ysize ysize 0.07 mul louteuro" @Graphic {
		    0.7f @High 0.735f @Wide
		}
	    }

	    PDF @Yield { EUR }

	    PlainText @Yield { EUR }
	}
    }


    ###########################################################################
    #                                                                         #
    #  Symbols stored in the "standard" database                              #
    #                                                                         #
    #    @Word            language-spacific words such as Chapter, etc.       #
    #    @Roman           lower case Roman numerals i, ii, ... , cc           #
    #    @UCRoman         upper case Roman numerals I, II, ... , CC           #
    #    @Alpha           lower case Roman alphabet a, b,  ... , z            #
    #    @UCAlpha         upper case Roman alphabet A, B,  ... , Z            #
    #    @FnBullets       bullets as footnote markers                         #
    #    @FnSymbols       traditional footnote symbols asterisk, dagger, etc. #
    #    @Months          months of the year:  January, ... , December        #
    #    @ShortMonths     months of the year, abbreviated:  Jan, ..., Dec     #
    #    @WeekDays        days of the week:  Sunday, ... , Saturday           #
    #    @ShortWeekDays   days of the week, abbreviated:  Sun, ... , Sat      #
    #    @TwelveHours     hours, from 1 to 12                                 #
    #    @ShortHours      hours, from 0 to 23                                 #
    #    @DateTimeFormat  format of results of @Date and @Time                #
    #                                                                         #
    ###########################################################################

    def @Word		left @Tag right @Val { @Val }
    def @Roman		left @Tag right @Val { @Val }
    def @UCRoman	left @Tag right @Val { @Val }
    def @Alpha		left @Tag right @Val { @Val }
    def @UCAlpha	left @Tag right @Val { @Val }
    def @FnBullets	left @Tag right @Val { @Val }
    def @FnSymbols	left @Tag right @Val { @Val }
    def @Months		left @Tag right @Val { @Val }
    def @ShortMonths	left @Tag right @Val { @Val }
    def @WeekDays	left @Tag right @Val { @Val }
    def @ShortWeekDays	left @Tag right @Val { @Val }
    def @TwelveHours  	left @Tag right @Val { @Val }
    def @ShortHours  	left @Tag right @Val { @Val }
    def @MeriDiems  	left @Tag right @Val { @Val }
    def @ShortMeriDiems	left @Tag right @Val { @Val }

    export @Value
    def @DateTimeFormat	left @Tag
	named @Value
	    named @Year          {}
	    named @ShortYear     {}
	    named @Month         {}
	    named @ShortMonth    {}
	    named @MonthNum      {}
	    named @Day           {}
	    named @ShortDay      {}
	    named @DayNum        {}
	    named @MeriDiem      {}
	    named @ShortMeriDiem {}
	    named @Hour          {}
	    named @TwelveHour    {}
	    named @ShortHour     {}
	    named @Minute        {}
	    named @Second        {}
	{}
    {}

    @SysDatabase @Word @Roman @UCRoman @Alpha @UCAlpha @FnBullets @FnSymbols
		 @Months @ShortMonths @WeekDays @ShortWeekDays @TwelveHours
		 @ShortHours @MeriDiems @ShortMeriDiems @DateTimeFormat
    { standard  }


    ###########################################################################
    #                                                                         #
    #  @Date and @Time: the date and time now.                                #
    #                                                                         #
    ###########################################################################

    def @Date
	named @Format
	    named @Year         { @Moment&&now @Open { {@Century}@Year         }}
	    named @ShortYear    { @Moment&&now @Open { @Year                   }}
	    named @Month        { @Moment&&now @Open { @Months&&@Month         }}
	    named @ShortMonth   { @Moment&&now @Open { @ShortMonths&&@Month    }}
	    named @MonthNum     { @Moment&&now @Open { @Month                  }}
	    named @Day          { @Moment&&now @Open { @WeekDays&&@WeekDay     }}
	    named @ShortDay     { @Moment&&now @Open { @ShortWeekDays&&@WeekDay}}
	    named @DayNum       { @Moment&&now @Open { @Day                    }}
	    named @MeriDiem     { @Moment&&now @Open { @MeriDiems&&@Hour       }}
	    named @ShortMeriDiem{ @Moment&&now @Open { @ShortMeriDiems&&@Hour  }}
	    named @Hour         { @Moment&&now @Open { @Hour                   }}
	    named @TwelveHour   { @Moment&&now @Open { @TwelveHours&&@Hour     }}
	    named @ShortHour    { @Moment&&now @Open { @ShortHours&&@Hour      }}
	    named @Minute       { @Moment&&now @Open { @Minute                 }}
	    named @Second       { @Moment&&now @Open { @Second                 }}
	{
	    @DateTimeFormat&&date @Open { @Value
		@Year          { @Year }
		@ShortYear     { @ShortYear }
		@Month         { @Month }
		@ShortMonth    { @ShortMonth }
		@MonthNum      { @MonthNum }
		@Day           { @Day }
		@ShortDay      { @ShortDay }
		@DayNum        { @DayNum }
		@MeriDiem      { @MeriDiem }
		@ShortMeriDiem { @ShortMeriDiem }
		@Hour          { @Hour }
		@TwelveHour    { @TwelveHour }
		@ShortHour     { @ShortHour }
		@Minute        { @Minute }
		@Second        { @Second }
	    }
	}
    { @Format }

    def @Time
	named @Format
	    named @Year         { @Moment&&now @Open { {@Century}@Year         }}
	    named @ShortYear    { @Moment&&now @Open { @Year                   }}
	    named @Month        { @Moment&&now @Open { @Months&&@Month         }}
	    named @ShortMonth   { @Moment&&now @Open { @ShortMonths&&@Month    }}
	    named @MonthNum     { @Moment&&now @Open { @Month                  }}
	    named @Day          { @Moment&&now @Open { @WeekDays&&@WeekDay     }}
	    named @ShortDay     { @Moment&&now @Open { @ShortWeekDays&&@WeekDay}}
	    named @DayNum       { @Moment&&now @Open { @Day                    }}
	    named @MeriDiem     { @Moment&&now @Open { @MeriDiems&&@Hour       }}
	    named @ShortMeriDiem{ @Moment&&now @Open { @ShortMeriDiems&&@Hour  }}
	    named @Hour         { @Moment&&now @Open { @Hour                   }}
	    named @TwelveHour   { @Moment&&now @Open { @TwelveHours&&@Hour     }}
	    named @ShortHour    { @Moment&&now @Open { @ShortHours&&@Hour      }}
	    named @Minute       { @Moment&&now @Open { @Minute                 }}
	    named @Second       { @Moment&&now @Open { @Second                 }}
	{
	    @DateTimeFormat&&time @Open { @Value
		@Year          { @Year }
		@ShortYear     { @ShortYear }
		@Month         { @Month }
		@ShortMonth    { @ShortMonth }
		@MonthNum      { @MonthNum }
		@Day           { @Day }
		@ShortDay      { @ShortDay }
		@DayNum        { @DayNum }
		@MeriDiem      { @MeriDiem }
		@ShortMeriDiem { @ShortMeriDiem }
		@Hour          { @Hour }
		@TwelveHour    { @TwelveHour }
		@ShortHour     { @ShortHour }
		@Minute        { @Minute }
		@Second        { @Second }
	    }
	}
    { @Format }


    ###########################################################################
    #                                                                         #
    #  @DropCapTwo and @DropCapThree                                          #
    #                                                                         #
    ###########################################################################

    def @DropCapTwo
	left y
	named height { 1.5v }
	right x
    {
	def @ParPlace { @Galley }
	def @EndParPlace { @Galley }

	def @LineList
	{
	    @PAdjust @ParPlace
	    //1vx @LineList
	}

	def @ParGalley horizontally into { @ParPlace&&preceding }
	    right x
	{
	    x
	}

	def @EndPar force into { @EndParPlace&&following } { @Null }

	def @Cap
	{
	    -0.25f @VShift 1.0w @VShift {
		-90d @Rotate height @Wide @Scale 90d @Rotate y
	    }
	}

						  |1s @PAdjust @ParPlace 
	/1vo  @Cap @ParGalley {x & @EndPar &1rt } |   @PAdjust @ParPlace
	//1vx @LineList
	//    @EndParPlace
    }

    def @DropCapThree
	left y
	named height { 2.5v }
	right x
    {
	def @ParPlace { @Galley }
	def @EndParPlace { @Galley }

	def @LineList
	{
	    @PAdjust @ParPlace
	    //1vx @LineList
	}

	def @ParGalley force horizontally into { @ParPlace&&preceding }
	    right x
	{
	    x
	}

	def @EndPar force into { @EndParPlace&&following } { @Null }

	def @Cap
	{
	    -0.25f @VShift 1.0w @VShift {
		-90d @Rotate height @Wide @Scale 90d @Rotate y
	    }
	}

						|1s @PAdjust @ParPlace 
	/1vo  @ParGalley { x & @EndPar &1rt }	|   @PAdjust @ParPlace
	/1vo  @Cap				|   @PAdjust @ParPlace
	//1vx @LineList
	//    @EndParPlace
    }


    ###########################################################################
    #                                                                         #
    #  @Centre, @Center, @Right, @NoDotSep, @NoDotJoin, @DotSep,              #
    #  @ColonSep, @DotJoin, @DashJoin, @NumSep                                #
    #                                                                         #
    ###########################################################################

    macro @Centre @Center { |0.5rt @HContract }

    def @Right
	precedence 50
	left x
	right y
    { x |1.0rt @OneCol { 2f @Wide {} | y } }

    def @NoDotSep left x right y
    {
	x @Case {
	    {}   @Yield y
	    else @Yield {
		y @Case {
		    {}   @Yield x
		    else @Yield { x |2s y }
		}
	    }
	}
    }

    def @NoDotJoin left x right y
    {
	x @Case {
	    {}   @Yield y
	    else @Yield {
	        y @Case {
		    {}   @Yield x
		    else @Yield { x{y} }
	        }
	    }
	}
    }

    def @DotSep left x right y
    {
	x @Case {
	    {}   @Yield y
	    else @Yield {
		y @Case {
		    {}   @Yield x
		    else @Yield { x. |2s y }
		}
	    }
        }
    }

    def @ColonSep left x right y
    {
	x @Case {
	    {}   @Yield y
	    else @Yield {
		y @Case {
		    {}   @Yield x
		    else @Yield { x: |2s y }
		}
	    }
        }
    }

    def @DotJoin left x right y
    {
	x @Case {
	    {}   @Yield y
	    else @Yield {
		y @Case {
		    {}   @Yield x
		    else @Yield { x.y }
		}
	    }
	}
    }

    def @DashJoin left x right y
    {
	x @Case {
	    {}   @Yield y
	    else @Yield {
		y @Case {
		    {}   @Yield x
		    else @Yield { x--y }
		}
	    }
        }
    }

    def @NumSep left x right y
    {
	x @Case {
	    {}   @Yield y
	    else @Yield {
		y @Case {
		    {}   @Yield x
		    else @Yield {
			@CurrLang @Case {
			    Hungarian @Yield { y. x }
			    else      @Yield { x y }
			}
		    }
		}
	    }
        }
    }


    ###########################################################################
    #                                                                         #
    #   @VStrut, @ZeroWidth, @ZeroHeight                                      #
    #                                                                         #
    ###########################################################################


    def @VStrut
        named above { 0.5f }
        named below { 0.5f }
	right x
    {
	x &0iu @VContract { above @High ^/ below @High }
    }


    def @ZeroWidth right x { @HContract { |0io x |0io } }

    def @ZeroHeight right x { @VContract { /0io x /0io } }


    ###########################################################################
    #                                                                         #
    #   @OverStrike, @Sup and @Sub                                            #
    #                                                                         #
    ###########################################################################

    def @OverStrike left x right y
    {
	@OneRow { @HContract @VContract x /0io @HContract @VContract y }
    }

    def @Sup
	left x
	named gap { 0.40fk }
	right y
    {
	@HContract @VContract
	{
	    | 0.7f @Font y ^/gap x
	}
    }

    def @Sub
	left x
	named gap { 0.40fk }
	right y
    {
	@HContract @VContract
	{
	    x /gap | 0.7f @Font y
	}
    }


    ###########################################################################
    #                                                                         #
    #   @HClip and @VClip                                                     #
    #                                                                         #
    ###########################################################################

    def @HClip
	named shift { 0.0 }
	right x
    {
       { "newpath 0 0 moveto xsize 0 lineto xsize ysize lineto 0 ysize lineto"
	 "closepath clip gsave" // "grestore" } @Graphic
	 {
	   |{{shift}"rt"} @ZeroWidth {{shift}"w"} @HShift x |
	 }
    }

    def @VClip
	named shift { 0.0 }
	right x
    {
       { "newpath 0 0 moveto xsize 0 lineto xsize ysize lineto 0 ysize lineto"
	 "closepath clip gsave" // "grestore" } @Graphic
	 {
	   /{{shift}"rt"} @ZeroHeight {{shift}"w"} @VShift x /
	 }
    }


    ###########################################################################
    #                                                                         #
    #   @AddPaint, @StrokeCommand                                             #
    #                                                                         #
    ###########################################################################

    def @AddPaint
        left col
	right texture
    {
	col @Case {
	    none @Yield ""
	    nochange @Yield {
		@BackEnd @Case {
		    PostScript @Yield { "gsave" texture "fill grestore" }
		    PDF        @Yield { "q f Q" }
		    PlainText  @Yield { "" }
		}
	    }
	    else @Yield {
		@BackEnd @Case {
		    PostScript @Yield {"gsave" @ColourCommand col texture "fill grestore"}
		    PDF        @Yield { "q" @ColourCommand col "f Q" }
		    PlainText  @Yield { "" }
		}
	    }
	}
    }

    def @StrokeCommand right linewidth
    {
	@BackEnd @Case {
	    PostScript @Yield {
		linewidth @Case {
		    ""   @Yield { "stroke" }
		    none @Yield { }
		    else @Yield { linewidth "setlinewidth stroke" }
		}
	    }
	    PDF @Yield {
		linewidth @Case {
		    ""   @Yield { "S" }
		    none @Yield { }
		    else @Yield { linewidth "w S" }
		}
	    }
	    else @Yield ""
	}
    }



    ###########################################################################
    #                                                                         #
    #   @FullWidthRule, @Box, @CurveBox, and @ShadowBox                       #
    #                                                                         #
    ###########################################################################

    def @FullWidthRule
	import @PSLengths named linewidth {}
    {
	@BackEnd @Case {

	    PostScript @Yield @HExpand {
		{ "LoutRule" @StrokeCommand linewidth } @Graphic { 0.5p @High }
	    }

	    PDF @Yield @HExpand {
		{ "0 0 m __xsize 0 l" @StrokeCommand linewidth } @Graphic { 0.5p @High }
	    }

	    PlainText @Yield { "-" @PlainGraphic 1f @High }
	}
    }

    def @LocalWidthRule
	import @PSLengths named linewidth {}
    {
	@BackEnd @Case {

	    PostScript @Yield {
		{ "LoutRule" @StrokeCommand linewidth } @Graphic { 0.5p @High }
	    }

	    PDF @Yield {
		{ "0 0 m __xsize 0 l" @StrokeCommand linewidth } @Graphic { 0.5p @High }
	    }

	    PlainText  @Yield { "-" @PlainGraphic 1f @High }
	}
    }

    def @Box
	named margin { 0.3f }
	import @PSLengths named linewidth {}
	named paint { none }
	import @TextureImport named texture {}
	right x
    {
	@BackEnd @Case {

	    PostScript @Yield @VContract @HContract 0c @HShift {
		{"LoutBox" paint @AddPaint texture @StrokeCommand linewidth }
		@Graphic
		{ ^/margin ^|margin 0c @HShift @OneRow x |margin /margin }
	    }

	    PDF @Yield @VContract @HContract 0c @HShift {
		{ "0 0 m __xsize 0 l __xsize __ysize l 0 __ysize l h"
		paint @AddPaint texture @StrokeCommand linewidth } @Graphic
		{ ^/margin ^|margin 0c @HShift @OneRow x |margin /margin }
	    }

	    PlainText @Yield @VContract @HContract 0c @HShift {
		^/margin ^|margin 0c @HShift @OneRow x |margin /margin
	    }
	}
    }

    def @CurveBox
	named margin { 0.3f }
	import @PSLengths named linewidth {}
	named paint { none }
	import @TextureImport named texture {}
	right x
    {
	def @PDFStuff
	{
	    "__xmark 0 m"
	    "__sub(__xsize, __xmark) 0 l"
	    "__sub(__xsize, __div(__mul(11, __xmark), 24)) 0"
	    "__xsize __div(__mul(11, __xmark), 24)"
	    "__xsize __xmark c"
	    "__xsize __sub(__ysize, __xmark) l"
	    "__xsize __sub(__ysize, __div(__mul(11, __xmark), 24))"
	    "__sub(__xsize, __div(__mul(11, __xmark), 24)) __ysize"
	    "__sub(__xsize, __xmark) __ysize c"
	    "__xmark __ysize l"
	    "__div(__mul(11, __xmark), 24) __ysize"
	    "0 __sub(__ysize, __div(__mul(11, __xmark), 24))"
	    "0 __sub(__ysize, __xmark) c"
	    "0 __xmark l"
	    "0 __div(__mul(11, __xmark), 24)"
	    "__div(__mul(11, __xmark), 24) 0"
	    "__xmark 0 c"
	    "h"
	    paint @AddPaint texture @StrokeCommand linewidth
	}

	@VContract @HContract 0c @HShift @BackEnd @Case {

	    PostScript @Yield {
		{"LoutCurveBox" paint @AddPaint texture @StrokeCommand linewidth }
		@Graphic
		{ ^/margin ^|margin 0c @HShift @OneRow x |margin /margin }
	    }

	    PlainText @Yield {
		^/margin ^|margin 0c @HShift @OneRow x |margin /margin
	    }

	    PDF @Yield {
		@PDFStuff @Graphic
		{ ^/margin ^|margin 0c @HShift @OneRow x |margin /margin }
	    }
	}
    }

    def @ShadowBox
	named margin { 0.3f }
	import @PSLengths named linewidth {}
	named paint { none }
	import @TextureImport named texture {}
	named shadow { 0.2f }
	right x
    {
	@VContract @HContract 0c @HShift @BackEnd @Case {

	    PostScript @Yield {
		"LoutShadowBox fill" @Graphic
		{ ^/shadow ^|shadow 0c @HShift
		      @Box
			  margin {margin}
			  paint {paint}
			  texture { texture }
			  linewidth {linewidth} x
		      |shadow /shadow
		}
	    }

	    PlainText @Yield {
		^/shadow ^|shadow 0c @HShift
		@Box
		    margin { margin }
		    paint { paint }
		    texture { texture }
		    linewidth {linewidth} x
		|shadow /shadow
	    } 

	    PDF @Yield {
		{
		  "__mul(__xmark, 2) 0 m __xsize 0 l"
		  "__xsize __sub(__ysize, __mul(__xmark, 2)) l"
		  "__sub(__xsize, __xmark) __sub(__ysize, __mul(__xmark, 2)) l"
		  "__sub(__xsize, __xmark) __xmark l"
		  "__mul(__xmark, 2) __xmark l h f"
		}
		@Graphic
		{ ^/shadow ^|shadow 0c @HShift
		  @Box
		      margin { margin }
		      paint { paint }
		      texture { texture }
		      linewidth { linewidth } x
		  |shadow /shadow
		}
	    }
	}
    }


    ###########################################################################
    #                                                                         #
    #   @BoundaryMarks                                                        #
    #                                                                         #
    ###########################################################################

    def @BoundaryMarks
	import @PSLengths named linewidth { 0.2p }
	import @PSLengths named length { 0.5c }
	import @PSLengths named gap { 0.5c }
	import @PSLengths named lout { 0c }
	import @PSLengths named rout { 0c }
	import @PSLengths named uout { 0c }
	import @PSLengths named dout { 0c }
    {
	def @UpStroke    { "0" gap       "rmoveto" "0" length     "rlineto" }
	def @DownStroke  { "0" gap "neg" "rmoveto" "0" length "neg rlineto" }
	def @LeftStroke  { gap "neg" "0" "rmoveto" length "neg" "0 rlineto" }
	def @RightStroke { gap "0"       "rmoveto" length       "0 rlineto" }

	def @LLSpot { lout "neg"             dout "neg" moveto }
	def @LRSpot { xsize rout "add"       dout "neg" moveto }
	def @ULSpot { lout "neg"       ysize uout "add" moveto }
	def @URSpot { xsize rout "add" ysize uout "add" moveto }

	def @PDFStuff {
	    "__sub(-"gap", "lout")            __sub(0, "dout") m "
	    "__sub(__sub(-"gap", "lout"), "length") __sub(0, "dout") l"
	    "__sub(0, "lout")       __sub(-"gap", "dout") m "
	    "__sub(0, "lout") __sub(__sub(-"gap", "dout"), "length") l"
	    "__add(__xsize,"rout")       __sub(-"gap", "dout") m "
	    "__add(__xsize,"rout") __sub(__sub(-"gap", "dout"), "length") l"
	    "__add(__add(__xsize,"rout"),"gap")           __sub(0, "dout") m "
	    "__add(__add(__add(__xsize,"rout"),"gap"),"length") __sub(0, "dout") l"
	    "      __sub(__sub(0, "lout"), "gap")            __add(__ysize, "uout") m "
	    "__sub(__sub(__sub(0, "lout"), "gap"), "length") __add(__ysize, "uout") l"
	    "__sub(0, "lout")       __add(__add(__ysize, "uout"), "gap") m "
	    "__sub(0, "lout") __add(__add(__add(__ysize, "uout"), "gap"), "length") l"
	    "      __add(__add(__xsize, "rout"), "gap")            __add(__ysize, "uout") m "
	    "__add(__add(__add(__xsize, "rout"), "gap"), "length") __add(__ysize, "uout") l"
	    "__add(__xsize, "rout")       __add(__add(__ysize, "uout"), "gap") m "
	    "__add(__xsize, "rout") __add(__add(__add(__ysize, "uout"), "gap"), "length") l"

	    linewidth "w S"
	}

	@BackEnd @Case {

	    PostScript @Yield {
		{
		    @LLSpot @LeftStroke
		    @LLSpot @DownStroke
		    @LRSpot @DownStroke
		    @LRSpot @RightStroke
		    @ULSpot @LeftStroke
		    @ULSpot @UpStroke
		    @URSpot @RightStroke
		    @URSpot @UpStroke
	
		    linewidth "setlinewidth stroke"
		} @Graphic {}
	    }

	    PlainText @Yield ""

	    PDF @Yield { @PDFStuff @Graphic {} }
	}
    }

    ##########################################################################
    #                                                                        #
    #  @DocInfo                                                              #
    #                                                                        #
    ##########################################################################

    def @DocInfo
      named author {}
      named title {}
      named keywords {}
    {
      { @BackEnd @Case {
	PostScript @Yield
	{
	  "[" author @Case {
	    "" @Yield ""
	    else @Yield { "/Author ("author")" } }
	  title @Case {
	    "" @Yield ""
	    else @Yield { "/Title ("title")" } }
	  keywords @Case {
	    "" @Yield ""
	    else @Yield { "/Keywords ("keywords")" } }
	  "/DOCINFO pdfmark"
	}
	else @Yield @Null
      } } @Graphic { }
    }


    ##########################################################################
    #                                                                        #
    #  @NumberMarker, @NumberOf, @TitleMarker, @TitleOf,                     #
    #  @PageMark, @PageOf, @PageparityOf, @CrossLink, @ExternalLink          #
    #                                                                        #
    #  NB the default value ?? is desperately important for unsorted         #
    #  reference lists numbered by first appearance (@NumberOf @Tag),        #
    #  because it is the special sort key value that prevents merging,       #
    #  hence allowing all the references to be printed even though           #
    #  their sort keys are all ?? initially.                                 #
    #                                                                        #
    ##########################################################################

    export @Tag @Value
    def @NumberMarker
	named @Tag {}
	named @Value { "??" }
    {
	@Null
    }

    def @NumberOf
	right tag
    {
	@NumberMarker&&tag @Open { @Value }
    }


    export @Tag @Value
    def @TitleMarker
	named @Tag {}
	named @Value { "??" }
    {
	@Null
    }

    def @TitleOf
	right tag
    {
	@TitleMarker&&tag @Open { @Value }
    }


    export @Tag num rawnum parity
    def @PageMarker
	named @Tag {}
	named num {}
	named rawnum {}
	named parity {}
    {
	@PageLabel num
    }

    def @PageMark
	right tag
    {
	tag @LinkDest @Null & @PageMarker&&preceding @Tagged tag
    }

    def @NoLinkPageMark
	right tag
    {
	@PageMarker&&preceding @Tagged tag
    }

    def @PageOf
	right tag
    {
	@PageMarker&&tag @Open { num }
    }

    def @PageParityOf
	right tag
    {
	@PageMarker&&tag @Open { parity }
    }

    def @CrossLink
	left tag
	named @Format right @Body { @CrossLinkFormat @Body }
	right obj
    {
	@HContract @VContract {
	    tag @LinkSource @Format obj
	}
    }

    def @ExternalLink
	left tag
	named @Format right @Body { @ExternalLinkFormat @Body }
	right obj
    {
	@HContract @VContract {
	    tag @URLLink @Format obj
	}
    }


    ###########################################################################
    #                                                                         #
    #  @Join and @Sep                                                         #
    #                                                                         #
    #  Join two objects together with @NumberSeparator, unless one is         #
    #  empty in which case just return the other.                             #
    #                                                                         #
    ###########################################################################

    def @Join left x right y
    {
        x @Case {
	    {}   @Yield y
	    else @Yield {
	        y @Case {
		    {}   @Yield x
		    else @Yield { x{@NumberSeparator}y }
	        }
	    }
        }
    }

    def @Sep left x right y
    {
	x @Case {
	    {}   @Yield y
	    else @Yield {
		y @Case {
		    {}   @Yield x
		    else @Yield { x{@NumberSeparator} |2s y }
		}
	    }
        }
    }


    ###########################################################################
    #                                                                         #
    #  Miscellaneous.                                                         #
    #                                                                         #
    ###########################################################################

    def @Heading       right x { ragged @Break @HeadingFont      @Font x }
    def "^"		       { {} ^& {}				 }
    def "&-"  left x   right y { x &0ch y				 }


    ###########################################################################
    #                                                                         #
    #  @If @Not @And @Or @True                                                #
    #                                                                         #
    #  Used in databases to make optional fields format nicely.               #
    #                                                                         #
    ###########################################################################

    def @If
	precedence 97
	left x
	right y
    {
	y @Case {
	    {} @Yield @Null
	    else @Yield { @Null{x} }
	}
    }

    def @Not
	precedence 100
	right y
    {
	y @Case {
	    {} @Yield "*"
	    else @Yield ""
	}
    }

    def @And
	precedence 99
	left x
	right y
    {
	x @Case {
	   {} @Yield {}
	   else @Yield y
	}
    }

    def @Or
	precedence 98
	left x
	right y
    {
	x @Case {
	   {} @Yield y
	   else @Yield x
	}
    }

    def @True { "*" }


    ###########################################################################
    #                                                                         #
    #  Paragraphs.                                                            #
    #                                                                         #
    ###########################################################################

    macro @PP	{ //@ParaGap @ParaIndent @Wide &{0i}	}
    macro @LP	{ //{@ParaGap}			  	}
    macro @LLP	{ //{1vx}				}
    macro @DP	{ //{@DisplayGap}			}
    macro @LOP	{ //{@ListOuterGap}			}
    macro @NP	{ //{1.1b}				}
    macro @CNP	{ // 3.2v @High //0io //{}		}


    ###########################################################################
    #                                                                         #
    #  Beginning and ending of aligned displays.                              #
    #                                                                         #
    ###########################################################################

    def @APlace            { @Galley }
    def @EndAlignedPlace   { @Galley }
    def @AlignedPlace      { @Galley }

    def @BAligned into { @APlace&&preceding }
    {
	def @AlignedList { @AlignedPlace /1.1b @AlignedList }

	//1.1b @AlignedList
	//     @EndAlignedPlace
    }

    macro @BAD @BeginAlignedDisplays { // @APlace | @BAligned }
    def   @EAD @EndAlignedDisplays force into { @EndAlignedPlace&&preceding } {}


    ###########################################################################
    #                                                                         #
    #  New code for numbered displays that will cross section boundaries      #
    #                                                                         #
    ###########################################################################

    export @Tag val display_val
    def @NumDispCounterMarker
	named @Tag {}
	named val {}
	named display_val {}
    {
	@Null
    }

    def @NumDispNum right tag
    {
	@NumDispCounterMarker&&tag @Open { @Next val }
    }

    def @NumDispCounterIncrement
        named @BypassNumber { "dft" }
	right tag
    {
        def @DisplayNumber
        {
           @BypassNumber @Dft { @NumDispNum tag }
        }

        @NumDispCounterMarker&&preceding @Tagged tag
        # @NumDispCounterMarker val { @NumDispNum tag }
	# @NumberMarker @Tag { tag } @Value { @NumDispNum tag }
	@NumDispCounterMarker val { @NumDispNum tag } display_val { @DisplayNumber }
        @NumberMarker @Tag { tag } @Value { @DisplayNumber }
    }

    def @NN
    {
	@NumDispCounterMarker&&preceding @Open { @DisplayNumStyle display_val }
    }

    def @Do
        left x
        right y
    {
        x @Case {
            { No None } @Yield @Null
            else        @Yield y
        }
    }

    def @BeginDisplayCounter
	left condition
	right prefix
    {
	condition @Do @NumDispCounterMarker val { prefix @Join 0 }
    }


    ###########################################################################
    #                                                                         #
    #  Galleys that carry displays to their places.                           #
    #                                                                         #
    ###########################################################################

    def @DispPlace { @Galley }

    def @Disp into { @DispPlace&&preceding }
	right x
    {
	x
    }

    def @NDisp into { @DispPlace&&preceding }
	named @Tag {}
	named @BypassNumber { "dft" }
	right x
    {
	@OneRow {
           # @NumDispCounterIncrement @Tag
           @NumDispCounterIncrement @BypassNumber { @BypassNumber } @Tag
	   @PageMark @Tag
	   ^//
	   @OneRow x
	}
    }

    def @ADisp into { @AlignedPlace&&preceding }
	right x
    {
	x
    }

    def @ANDisp into { @AlignedPlace&&preceding }
	named @Tag {}
	named @BypassNumber { "dft" }
	right x
    {
	@OneRow {
           # @NumDispCounterIncrement @Tag
	   @NumDispCounterIncrement @BypassNumber { @BypassNumber } @Tag
	   @PageMark @Tag
	   ^/
	   @OneRow x
	}
    }


    ###########################################################################
    #                                                                         #
    #  Displays and raw displays.                                             #
    #                                                                         #
    ###########################################################################

    macro @G  { |@DefaultIndent      }
    macro @LG { |                    }
    macro @IG { |@DisplayIndent      }
    macro @CG { |0.5rt               }
    macro @RG { |1.0rt               }
    macro @QR { @DisplayIndent @Wide { |1rt @NN } }
    macro @DX { @DispPlace           }
    macro @DY { @Disp                }
    macro @AX { @APlace              }
    macro @AY { @ADisp               }
    macro @NY { @NDisp               }
    macro @MY { @ANDisp              }

    macro @D	 @Display			{ @DP @G   @DX  |         @DP // @DY }
    macro @LD	 @LeftDisplay			{ @DP @LG  @DX  |         @DP // @DY }
    macro @ID	 @IndentedDisplay		{ @DP @IG  @DX  |         @DP // @DY }
    macro @QD	 @QuotedDisplay			{ @DP @IG  @DX  @IG       @DP // @DY }
    macro @CD	 @CentredDisplay
		 @CenteredDisplay		{ @DP @CG  @DX  |         @DP // @DY }
    macro	 @RightDisplay			{ @DP @RG  @DX  |         @DP // @DY }


    macro @AD	 @AlignedDisplay		{ @DP @G   @AX  |         @DP // @AY }
    macro @LAD	 @LeftAlignedDisplay		{ @DP @LG  @AX  |         @DP // @AY }
    macro @IAD	 @IndentedAlignedDisplay	{ @DP @IG  @AX  |         @DP // @AY }
    macro @QAD	 @QuotedAlignedDisplay		{ @DP @IG  @AX  @IG       @DP // @AY }
    macro @CAD	 @CentredAlignedDisplay
		 @CenteredAlignedDisplay	{ @DP @CG  @AX  |         @DP // @AY }
    macro        @RightAlignedDisplay		{ @DP @RG  @AX  |         @DP // @AY }

    macro @ND	 @NumberedDisplay		{ @DP @G   @DX  |1rt @NN  @DP // @NY }
    macro @LND	 @LeftNumberedDisplay		{ @DP @LG  @DX  |1rt @NN  @DP // @NY }
    macro @IND	 @IndentedNumberedDisplay	{ @DP @IG  @DX  |1rt @NN  @DP // @NY }
    macro @QND	 @QuotedNumberedDisplay		{ @DP @IG  @DX  |1rt @QR  @DP // @NY }
    macro @CND	 @CentredNumberedDisplay
		 @CenteredNumberedDisplay	{ @DP @CG  @DX  |1rt @NN  @DP // @NY }
    macro	 @RightNumberedDisplay		{ @DP @RG  @DX  |1rt @NN  @DP // @NY }

    macro @AND	 @AlignedNumberedDisplay	{ @DP @G   @AX  |1rt @NN  @DP // @MY }
    macro @LAND	 @LeftAlignedNumberedDisplay	{ @DP @LG  @AX  |1rt @NN  @DP // @MY }
    macro @IAND	 @IndentedAlignedNumberedDisplay{ @DP @IG  @AX  |1rt @NN  @DP // @MY }
    macro @QAND  @QuotedAlignedNumberedDisplay	{ @DP @IG  @AX  |1rt @QR  @DP // @MY }
    macro @CAND	 @CentredAlignedNumberedDisplay
		 @CenteredAlignedNumberedDisplay{ @DP @CG  @AX  |1rt @NN  @DP // @MY }
    macro	 @RightAlignedNumberedDisplay	{ @DP @RG  @AX  |1rt @NN  @DP // @MY }


    macro @RD	 @RawDisplay			{     @G   @DX  |         // @DY }
    macro @RLD	 @RawLeftDisplay		{     @LG  @DX  |         // @DY }
    macro @RID	 @RawIndentedDisplay		{     @IG  @DX  |         // @DY }
    macro @RQD	 @RawQuotedDisplay		{     @IG  @DX  @IG |     // @DY }
    macro @RCD	 @RawCentredDisplay
		 @RawCenteredDisplay		{     @CG  @DX  | |       // @DY }
    macro @RRD	 @RawRightDisplay		{     @RG  @DX  |         // @DY }


    macro @RAD	 @RawAlignedDisplay		{     @G   @AX  |         // @AY }
    macro @RLAD	 @RawLeftAlignedDisplay		{     @LG  @AX  |         // @AY }
    macro @RIAD	 @RawIndentedAlignedDisplay	{     @IG  @AX  |         // @AY }
    macro @RQAD	 @RawQuotedAlignedDisplay	{     @IG  @AX  @IG |     // @AY }
    macro @RCAD	 @RawCentredAlignedDisplay
		 @RawCenteredAlignedDisplay	{     @CG  @AX  |         // @AY }
    macro @RRAD  @RawRightAlignedDisplay	{     @RG  @AX  |         // @AY }

    macro @RND	 @RawNumberedDisplay		{     @G   @DX  |1rt @NN  // @NY }
    macro @RLND	 @RawLeftNumberedDisplay	{     @LG  @DX  |1rt @NN  // @NY }
    macro @RIND	 @RawIndentedNumberedDisplay	{     @IG  @DX  |1rt @NN  // @NY }
    macro @RQND	 @RawQuotedNumberedDisplay	{     @IG  @DX  |1rt @QR  // @NY }
    macro @RCND	 @RawCentredNumberedDisplay
		 @RawCenteredNumberedDisplay	{     @CG  @DX  |1rt @NN  // @NY }
    macro @RRND	 @RawRightNumberedDisplay	{     @RG  @DX  |1rt @NN  // @NY }

    macro @RAND	 @RawAlignedNumberedDisplay	{     @G   @AX  |1rt @NN  // @MY }
    macro @RLAND @RawLeftAlignedNumberedDisplay {     @LG  @AX  |1rt @NN  // @MY }
    macro @RIAND @RawIndentedAlignedNumberedDisplay { @IG  @AX  |1rt @NN  // @MY }
    macro @RQAND @RawQuotedAlignedNumberedDisplay {   @IG  @AX  |1rt @QR  // @MY }
    macro @RCAND @RawCentredAlignedNumberedDisplay
		 @RawCenteredAlignedNumberedDisplay { @CG  @AX  |1rt @NN  // @MY }
    macro @RRAND @RawRightAlignedNumberedDisplay{     @RG  @AX  |1rt @NN  // @MY }


    ###########################################################################
    #                                                                         #
    #  Lists and raw lists.                                                   #
    #                                                                         #
    ###########################################################################


    def @ItemPlace          { @Galley }
    def @ParagraphItemPlace { @Galley }
    def @InterruptItemPlace { @Galley }
    def @NewPageItemPlace   { @Galley }
    def @TagPlace           { @Galley }
    def @EndListPlace       { @Galley }

    def @RawList
	named style right num { num              }
	named type  right num { num              }
	named gap             { @ListGap         }
	named indent          { @ListIndent      }
	named itemindent      { 0c		 }
	named rightindent     { @ListRightIndent }
	named labelwidth      { @ListLabelWidth  }
	named labelright      { @ListLabelRight  }
	named labelrightgap   { @ListLabelRightGap }
	named start           { 1                }
	named font            { @ListFont        }
	named break           { @ListBreak       }
	named colnum          { 1                }
	named colgap          { 1.0c             }
	named colheight       { 5.0c             }
    {
        def @MakeList right num
	{
	    def @NormalItem
	    {
	        def @Align right x
		{
		  labelright @Case {
		    { Yes yes } @Yield { labelwidth @Wide { |1rt @OneCol { x |labelrightgap } } }
		    else @Yield x
		  }
		}

	        |indent
	        labelwidth @Wide {
		    # @NumberMarker @Value {style num} {style num} &0io
		    # @NumberMarker @Value {num} {style type num} &0io
		    @NumberMarker @Value {type num} {@Align style type num} &0io
		}
	        |itemindent  break @Break font @Font @ItemPlace  |rightindent
	        //gap  @MakeList @NotRevealed @Next num
	    }

	    def @ParagraphItem
	    {
		@NumberMarker @Value {num} {style type num} &0io
	        |indent break @Break font @Font @ParagraphItemPlace |rightindent
	        //gap  @MakeList @NotRevealed @Next num
	    }

	    def @InterruptItem
	    {
		@InterruptItemPlace
		//gap  @MakeList @NotRevealed num
	    }

	    def @NewPageItem
	    {
		@NewPageItemPlace
		//1.1b  @MakeList @NotRevealed num
	    }

	    @OneOf
	    {
		@NormalItem
		@ParagraphItem
		@InterruptItem
		@NewPageItem
	    }
	}

	def @ListGalleyPlace { @Galley }

	def @ListGalley into { @ListGalleyPlace&&preceding }
	{
	    @MakeList start // @EndListPlace
	}

	def @ColPieceTwo
	{
	   colheight @High 500c @Wide @ListGalleyPlace ||colgap
	   colheight @High 500c @Wide @ListGalleyPlace @NotRevealed
	}

	def @ColPieceThree
	{
	   colheight @High 500c @Wide @ListGalleyPlace ||colgap
	   colheight @High 500c @Wide @ListGalleyPlace @NotRevealed ||colgap
	   colheight @High 500c @Wide @ListGalleyPlace @NotRevealed
	}

	def @ColPieceFour
	{
	   colheight @High 500c @Wide @ListGalleyPlace ||colgap
	   colheight @High 500c @Wide @ListGalleyPlace @NotRevealed ||colgap
	   colheight @High 500c @Wide @ListGalleyPlace @NotRevealed ||colgap
	   colheight @High 500c @Wide @ListGalleyPlace @NotRevealed
	}

	def @ColPieceFive
	{
	   colheight @High 500c @Wide @ListGalleyPlace ||colgap
	   colheight @High 500c @Wide @ListGalleyPlace @NotRevealed ||colgap
	   colheight @High 500c @Wide @ListGalleyPlace @NotRevealed ||colgap
	   colheight @High 500c @Wide @ListGalleyPlace @NotRevealed ||colgap
	   colheight @High 500c @Wide @ListGalleyPlace @NotRevealed
	}

	colnum @Case
	{
	  1 @Yield @ListGalleyPlace
	  2 @Yield @ColPieceTwo
	  3 @Yield @ColPieceThree
	  4 @Yield @ColPieceFour
	  5 @Yield @ColPieceFive
	  else @Yield @ListGalleyPlace
	}
	//
	@ListGalley
    }

    def listitem into { @ItemPlace&&preceding }
	named @Tag {}
	right x
    {
	   @NumberMarker&&preceding @Tagged @Tag
	// x
	// @PageMark @Tag   # weird placement, but @PageMark is definite now
    }

    def paragraphitem
        named @Tag {}
	named style right tag { @ParaIndent @Wide & tag. &2s }
	right x
    {

	def sendparagraphitem into { @ParagraphItemPlace&&preceding }
	   named tag { @Tag }
	{
	  @NumberMarker&&preceding @Tagged @Tag
	  // { style @NumberMarker&&@Tag @Open { @Value } } @Insert x
	  // @PageMark @Tag
	}

	sendparagraphitem
    }

    def droplistitem into { @ItemPlace&&preceding }
	named @Tag {}
	right x
    {
	   @NumberMarker&&preceding @Tagged @Tag
	// @PageMark @Tag
	//1vx x
    }

    def tagitem into { @ItemPlace&&preceding }
	named tag {}
	right x
    {
	def sendtag into { @TagPlace&&preceding } { tag }

	sendtag // x
    }

    def droptagitem into { @ItemPlace&&preceding }
	named tag {}
	right x
    {
	def sendtag into { @TagPlace&&preceding } { tag }

	sendtag // //1vxu x
    }

    def endlist force into { @EndListPlace&&preceding } {}

    def listnewpage into { @NewPageItemPlace&&preceding } {}

    def listinterruptitem into { @InterruptItemPlace&&preceding }
	right x
    {
	x
    }


    macro @LI   @ListItem		{ // listitem			}
    macro @PI   @ParagraphItem		{ // paragraphitem			}
    macro @LII  @ListInterruptItem	{ // listinterruptitem		}
    macro @LNP  @ListNewPage		{ // listnewpage		}
    macro @DLI  @DropListItem		{ // droplistitem		}
    macro @TI   @TagItem		{ // tagitem tag		}
    macro @DTI  @DropTagItem		{ // droptagitem tag		}
    macro @REL  @RawEndList		{ // & endlist // 		}
    macro @EL   @EndList		{ // & endlist @LOP		}


    macro @RLL    @RawLeftList		{ @RawList style {}
						   labelwidth { 0c }           }
    macro @RIL    @RawIndentedList	{ @RawList style {}                    }
    macro @RQL    @RawQuotedList	{ @RawList style {}
						   rightindent {@DisplayIndent}}
    macro @RCL    @RawCentredList	{ @RawList style {}
						   labelwidth {0c}
						   itemindent {0.5rt}          }
    macro         @RawCenteredList	{ @RawCentredList                      }
    macro @RNL    @RawNumberedList      { @RawList style { num.	             } }
    macro @RPNL   @RawParenNumberedList { @RawList style { (num)	     } }
    macro @RRL    @RawRomanList	        { @RawList type  { @Roman&&num }
						   style { num.    } }
    macro @RPRL   @RawParenRomanList    { @RawList type  { @Roman&&num }
						   style { (num)   } }
    macro @RUCRL  @RawUCRomanList       { @RawList type  { @UCRoman&&num }
						   style { num.  } }
    macro @RPUCRL @RawParenUCRomanList  { @RawList type  { @UCRoman&&num }
						   style { (num) } }
    macro @RAL    @RawAlphaList	        { @RawList type  { @Alpha&&num }
						   style { num.    } }
    macro @RPAL   @RawParenAlphaList    { @RawList type  { @Alpha&&num }
						   style { (num)   } }
    macro @RUCAL  @RawUCAlphaList       { @RawList type  { @UCAlpha&&num }
						   style { num.  } }
    macro @RPUCAL @RawParenUCAlphaList  { @RawList type  { @UCAlpha&&num }
						   style { (num) } }
    macro @RBL    @RawBulletList        { @RawList style { @Bullet	     } }
    macro @RSL    @RawStarList	        { @RawList style { @Star	     } }
    macro @RDL    @RawDashList	        { @RawList style { --	 	     } }
    macro @RTL    @RawTaggedList        { @RawList type { @TagPlace         } }
    macro @RWTL   @RawWideTaggedList    { @RawList type { @TagPlace         }
					           labelwidth { @WideIndent  } }
    macro @RVWTL  @RawVeryWideTaggedList{ @RawList type { @TagPlace         }
					        labelwidth { @VeryWideIndent } }


    macro @L     @List			{ @LOP @RawList			}
    macro @LL    @LeftList		{ @LOP @RawLeftList		}
    macro @IL    @IndentedList		{ @LOP @RawIndentedList		}
    macro @QL    @QuotedList		{ @LOP @RawQuotedList		}
    macro @CL    @CentredList		{ @LOP @RawCentredList		}
    macro        @CenteredList		{ @LOP @RawCenteredList		}
    macro @NL    @NumberedList		{ @LOP @RawNumberedList		}
    macro @PNL   @ParenNumberedList	{ @LOP @RawParenNumberedList	}
    macro @RL    @RomanList		{ @LOP @RawRomanList		}
    macro @PRL   @ParenRomanList	{ @LOP @RawParenRomanList	}
    macro @UCRL  @UCRomanList		{ @LOP @RawUCRomanList		}
    macro @PUCRL @ParenUCRomanList	{ @LOP @RawParenUCRomanList	}
    macro @AL    @AlphaList		{ @LOP @RawAlphaList		}
    macro @PAL   @ParenAlphaList	{ @LOP @RawParenAlphaList	}
    macro @UCAL  @UCAlphaList		{ @LOP @RawUCAlphaList		}
    macro @PUCAL @ParenUCAlphaList	{ @LOP @RawParenUCAlphaList	}
    macro @BL    @BulletList		{ @LOP @RawBulletList		}
    macro @SL    @StarList		{ @LOP @RawStarList		}
    macro @DL    @DashList		{ @LOP @RawDashList		}
    macro @TL    @TaggedList		{ @LOP @RawTaggedList		}
    macro @WTL   @WideTaggedList	{ @LOP @RawWideTaggedList	}
    macro @VWTL  @VeryWideTaggedList	{ @LOP @RawVeryWideTaggedList	}

@End @BasicSetup