Blob Blame History Raw
%RCS: $Id: //TEI/web/Software/passivetex/fotex.sty#44 $, $Date: 2003/08/23 $
%
% Copyright 2003 Sebastian Rahtz/Oxford University  
%      <sebastian.rahtz@oucs.ox.ac.uk>
%
% Permission is hereby granted, free of charge, to any person obtaining
% a copy of this software and any associated documentation files (the
% ``Software''), to deal in the Software without restriction, including
% without limitation the rights to use, copy, modify, merge, publish,
% distribute, sublicense, and/or sell copies of the Software, and to
% permit persons to whom the Software is furnished to do so, subject to
% the following conditions:
% 
% The above copyright notice and this permission notice shall be included
% in all copies or substantial portions of the Software.
%
\batchmode
\ProvidesPackage{fotex}[2003/03/10: version 1.25. support for XSL formatting, S Rahtz]
\RequirePackage{graphicx,color}
%\IfFileExists{multicol.sty}
%  {\RequirePackage{multicol}[1997/12/16]}
%  {\newenvironment{multicols}[1]%
%  {\typeout{Warning,  at line \the\inputlineno, multicol package not available}}{}%
%}

\def\confirmnomulticols{
        \RequirePackage{nomulticol}[2003/01/09]
        \typeout{INFO (nomulticol.sty:  fo:block span="all" works}
}
\def\warnnomulticols{
        \RequirePackage{multicol}[1997/12/16]
        \typeout{WARNING (multicol.sty:  fo:block span="all" does not work}
        \fakenomulticols
}
\def\warnmulticols{
        \typeout{WARNING (no multicol.sty:  multiple columns not available}
        \newenvironment{multicols}[1]{\typeout{Warning,  at line \the\inputlineno, multicol package not available}}{}
        \fakenomulticols
}
\def\fakenomulticols{
        \def\nobeginmulticols##1{\begin{multicols}{##1}}
        \def\noendmulticols{\end{multicols}}
        \def\interbeginmulticols##1{}
        \let\interendmulticols\relax
        \let\refreshmulticols\relax
}
\IfFileExists{nomulticol.sty}
{\confirmnomulticols}
{\IfFileExists{multicol.sty}
        {\warnnomulticols}
        {\warnmulticols}
}
\RequirePackage{rotating}
\RequirePackage{array}
\gdef\arraybackslash{\let\\=\@arraycr}
\newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}}
\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}
\newcolumntype{R}[1]{>{\raggedleft\arraybackslash}p{#1}}
\newcolumntype{P}[1]{>{\arraybackslash}p{#1}}
\RequirePackage{soul}
\RequirePackage{amsmath}
\let\Vec\undefined
\RequirePackage{longtable}
\RequirePackage{url}
\RequirePackage[normalem]{ulem}
\RequirePackage{times}
\RequirePackage{mlnames}
\RequirePackage{unicode}
\RequirePackage{marvosym}
\RequirePackage{ucharacters}
%\usepackage{ucs}\usepackage[utf8]{inputenc}
\RequirePackage{nameref}
\RequirePackage[pdfcreator={PassiveTeX 1.25},colorlinks=false,plainpages=true,hypertexnames=false,pdfborder={1 0 0}]{hyperref}[1999/08/1]
%-------------------------------------------
\newcount\FOListBlocks
\edef\This@FOListBlocks{\the\FOListBlocks}
\newcount\FOTableNesting
\newcount\FOinList
\newcount\FOinTable
\newcount\NCols
\newcount\RowCount
\newcount\SimplePMRefs
\newskip\LeaderLength
\newdimen\CurrentCellWidth
\newdimen\FObalancespace
\newdimen\FOspaceleft
\newdimen\MasterBottomMargin
\newdimen\MasterLeftMargin
\newdimen\MasterRightMargin
\newdimen\MasterTopMargin
\newdimen\NoTableCellHeight
\newdimen\TableWidth
\newdimen\XFOendindent
\newdimen\XFOstartindent
\newdimen\bottommargin
\newdimen\FOtempdim
\newif\ifFOBlockGrab
\newif\ifFODebug
\newif\ifFODefiningPage
\newif\ifFOFirstCell
\newif\ifFOListBody
\newif\ifFOListInnerPar
\newif\ifFOSub
\newif\ifFOSuper
\newif\ifFOinLayout
\newif\ifFOinOutput
\newif\ifMulticolPending
\newif\ifNoTableCheckHeight
\newif\ifStartWithOmit
\newif\ifForcePageSetup
\newif\ifBlankPage
\newif\ifInInsertion
\newsavebox\BlockBox
\newsavebox\CellBox
\newsavebox\FOBOX
\newsavebox\ItemBox
\newtoks\ColSpecs
\newtoks\BoxedFootnotes
%
%\FODebugtrue
\FOBlockGrabfalse
\FODefiningPagefalse
\FOListBodyfalse
\FOListInnerParfalse
\FOinLayoutfalse
\FOinList0
\FOinOutputfalse
\FOTableNesting0
\FOinTable0
\MasterBottomMargin\z@
\MasterLeftMargin\z@
\MasterRightMargin\z@
\MasterTopMargin\z@
\MulticolPendingfalse
\StartWithOmitfalse
% smarts from Anton to deal with long lines in verbatim
\gdef\FOdiscretionary{\ifx\FOwrapoption\att@nowrap\discretionary{\kern-.5ex\lower1ex\hbox{$\hookleftarrow$}}{}{\kern1ex}\else\space\fi}
\def\obeyspaces{\catcode`\ =\active}
{\obeyspaces\global\let =\FOdiscretionary}
\def\DEBUG#1{%
 \ifFODebug
   \typeout{#1, at \the\inputlineno}%
 \fi
}
\def\expandFont#1 #2 #3\\{%
 \typeout{FONT expanding to #1 / #2 / #3}%
}
\def\expandBorder#1 #2 #3\\{%
    \def\FOborderstartcolor{#3}%
    \def\FOborderendcolor{#3}%
    \def\FOborderbeforecolor{#3}%
    \def\FOborderaftercolor{#3}%
    \def\FOborderstartwidth{#1}%
    \def\FOborderendwidth{#1}%
    \def\FOborderbeforewidth{#1}%
    \def\FOborderafterwidth{#1}%
    \def\FOborderstartstyle{#2}%
    \def\FOborderendstyle{#2}%
    \def\FOborderbeforestyle{#2}%
    \def\FOborderafterstyle{#2}%
        \interpretwidth
}
\def\FOexpandattributes{%
%
% links
\ifx\FObordertopstyle\LINK\else\let\FOborderbeforestyle\FObordertopstyle\fi
\ifx\FOborderbottomstyle\LINK\else\let\FOborderafterstyle\FOborderbottomstyle\fi
\ifx\FOborderrightstyle\LINK\else\let\FOborderendstyle\FOborderrightstyle\fi
\ifx\FOborderleftstyle\LINK\else\let\FOborderstartstyle\FOborderleftstyle\fi
\ifx\FObordertopwidth\LINK\else\let\FOborderbeforewidth\FObordertopwidth\fi
\ifx\FOborderbottomwidth\LINK\else\let\FOborderafterwidth\FOborderbottomwidth\fi
\ifx\FOborderrightwidth\LINK\else\let\FOborderendwidth\FOborderrightwidth\fi
\ifx\FOborderleftwidth\LINK\else\let\FOborderstartwidth\FOborderleftwidth\fi
\ifx\FObordertopcolor\LINK\else\let\FOborderbeforecolor\FObordertopcolor\fi
\ifx\FOborderbottomcolor\LINK\else\let\FOborderaftercolor\FOborderbottomcolor\fi
\ifx\FOborderrightcolor\LINK\else\let\FOborderendcolor\FOborderrightcolor\fi
\ifx\FOborderleftcolor\LINK\else\let\FOborderstartcolor\FOborderleftcolor\fi
% shortcuts
  \ifx\FObordercolor\att@black
  \else
    \let\FOborderstartcolor\FObordercolor
    \let\FOborderendcolor\FObordercolor
    \let\FOborderbeforecolor\FObordercolor
    \let\FOborderaftercolor\FObordercolor
  \fi  
  \ifx\FOborderwidth\@empty
  \else
    \let\FOborderstartwidth\FOborderwidth
    \let\FOborderendwidth\FOborderwidth
    \let\FOborderbeforewidth\FOborderwidth
    \let\FOborderafterwidth\FOborderwidth
  \fi  
  \ifx\FOborderstyle\@empty
  \else
    \let\FOborderstartstyle\FOborderstyle
    \let\FOborderendstyle\FOborderstyle
    \let\FOborderbeforestyle\FOborderstyle
    \let\FOborderafterstyle\FOborderstyle
  \fi  
  \ifx\FOborder\@empty
  \else
    \expandafter\expandBorder\FOborder\\{}%
  \fi
%  \ifx\FOfont\@empty
%  \else
%    \expandafter\expandFont\FOfont\relax  \\{}%
%  \fi
  \ifdim\FOpadding>\z@
    \let\FOpaddingstart\FOpadding
    \let\FOpaddingend\FOpadding
    \let\FOpaddingbefore\FOpadding
    \let\FOpaddingafter\FOpadding
  \fi  
  \ifx\FOmargin\@empty
  \else
    \let\tmpmargin\FOmargin
    \let\FOmarginleft\tmpmargin
    \let\FOmarginright\tmpmargin
    \let\FOmargintop\tmpmargin
    \let\FOmarginbottom\tmpmargin
  \fi  
% end of shortcuts
  \ifx\FOborderendstyle\att@solid
   \FOBlockGrabtrue
  \else
   \def\FOborderendwidth{\z@}%
  \fi
  \ifx\FOborderstartstyle\att@solid
   \FOBlockGrabtrue
  \else
   \def\FOborderstartwidth{\z@}%
  \fi
  \ifx\FOborderafterstyle\att@solid
  \else
   \def\FOborderafterwidth{\z@}%
  \fi
  \ifx\FOborderbeforestyle\att@solid
   \FOBlockGrabtrue
  \else
   \def\FOborderbeforewidth{\z@}%
  \fi
  \interpretwidth
}
%-------------------------------------------
%
% NoTable. Making tables using fixed width cells.
% From ideas and code by C V Radhakrishnan.
%
\newcount\AbsoluteTableCount
\newcount\CellCount
\newcount\arraylength
\newcounter{ArrayIndex}%
\newcounter{zeroCtr}%
\def\DeclareArray#1{%
   \Array{#1}[0]{}%
   \expandafter\gdef\csname #1\endcsname[##1]{\csname #1##1\endcsname}%
}
\def\Array#1[#2]#3{%
  \expandafter\xdef\csname #1#2\endcsname{#3}%
}

%
\def\getArraylength#1{%
   \arraylength0
   \loop\expandafter\ifx\csname #1\the\arraylength\endcsname\relax%
   \else\advance\arraylength by1\repeat}%
%
\def\addToArray#1#2{\arraylength0%
        \loop\expandafter\ifx\csname #1\the\arraylength\endcsname\relax%
        \else\advance\arraylength by 1\repeat%
        \Array{#1}[\the\arraylength]{#2}}%
%
\def\clearArray#1{\getArraylength{#1}%
        \loop\ifnum\arraylength >0%
        \global\expandafter\let\csname #1\the\arraylength\endcsname\relax%
        \advance\arraylength by-1\repeat}%
%
\long\def\ArrayIterator#1#2{%
        \setcounter{ArrayIndex}{1}\getArraylength{#1}%
        \setcounter{zeroCtr}{\c@arraylength}%
        \loop\ifnum\c@ArrayIndex<\c@zeroCtr{#2}%
        \stepcounter{ArrayIndex}\repeat%
}%

\def\NoTableSetup{%
  \global\advance\AbsoluteTableCount by 1
  \DeclareArray{fotable\the\AbsoluteTableCount:}%
  \DeclareArray{fotabletextalign\the\AbsoluteTableCount:}%
  \DeclareArray{fotableborderbeforestyle\the\AbsoluteTableCount:}%
  \DeclareArray{fotableborderafterstyle\the\AbsoluteTableCount:}%
  \DeclareArray{fotableborderstartstyle\the\AbsoluteTableCount:}%
  \DeclareArray{fotableborderendstyle\the\AbsoluteTableCount:}%
  \DeclareArray{fotableborderbeforewidth\the\AbsoluteTableCount:}%
  \DeclareArray{fotableborderafterwidth\the\AbsoluteTableCount:}%
  \DeclareArray{fotableborderstartwidth\the\AbsoluteTableCount:}%
  \DeclareArray{fotableborderendwidth\the\AbsoluteTableCount:}%
  \DeclareArray{fotableborderbeforecolor\the\AbsoluteTableCount:}%
  \DeclareArray{fotableborderaftercolor\the\AbsoluteTableCount:}%
  \DeclareArray{fotableborderstartcolor\the\AbsoluteTableCount:}%
  \DeclareArray{fotableborderendcolor\the\AbsoluteTableCount:}%
  \global\CellCount0
\ifnum\FOinTable=0
  \global\BoxedFootnotes{}%
  \global\let\FOfoottext\FOboxedfoottext
\fi
}

\def\NoTableFinish{
\ifnum\FOinTable=0
   \the\BoxedFootnotes
   \global\BoxedFootnotes={}%
   \global\let\FOfoottext\FOplainfoottext
\fi
}

\def\saveinterlineskip{%
        \edef\savedbaselineskip{\the\baselineskip}%
        \edef\savedlineskip{\the\lineskip}%
        \edef\savedlineskiplimit{\the\lineskiplimit}%
        \baselineskip=-1000pt\relax
        \lineskiplimit=16383pt\relax
        \lineskip=0pt
}

\def\restoreinterlineskip{%
        \baselineskip\savedbaselineskip\relax
        \lineskip\savedlineskip\relax
        \lineskiplimit\savedlineskiplimit\relax
}

\def\NoTableStart#1{#1}

\def\NoTableEnd{%
        \clearArray{fotable\the\AbsoluteTableCount:}%
        \clearArray{fotabletextalign\the\AbsoluteTableCount:}%
        \clearArray{fotableborderbeforestyle\the\AbsoluteTableCount:}%
        \clearArray{fotableborderafterstyle\the\AbsoluteTableCount:}%
        \clearArray{fotableborderstartstyle\the\AbsoluteTableCount:}%
        \clearArray{fotableborderendstyle\the\AbsoluteTableCount:}%
        \clearArray{fotableborderbeforewidth\the\AbsoluteTableCount:}%
        \clearArray{fotableborderafterwidth\the\AbsoluteTableCount:}%
        \clearArray{fotableborderstartwidth\the\AbsoluteTableCount:}%
        \clearArray{fotableborderendwidth\the\AbsoluteTableCount:}%
        \clearArray{fotableborderbeforecolor\the\AbsoluteTableCount:}%
        \clearArray{fotableborderaftercolor\the\AbsoluteTableCount:}%
        \clearArray{fotableborderstartcolor\the\AbsoluteTableCount:}%
        \clearArray{fotableborderendcolor\the\AbsoluteTableCount:}%
}

\def\NoTableColumn{%
        \ifx\@empty\FOcolumnnumber
                \global\advance\NCols by 1
        \else
                \global\NCols\FOcolumnnumber
        \fi
        \ifx\prop@width\FOcolumnwidth\def\FOcolumnwidth{1in}\fi
        \ifx\@empty\FOcolumnwidth\def\FOcolumnwidth{1in}\fi
        \TablePercentToDimen{\FOcolumnwidth}%
        \addToArray{fotable\the\AbsoluteTableCount:}{\the\@tempdima}%
        \addToArray{fotabletextalign\the\AbsoluteTableCount:}{\FOtextalign}%
        \addToArray{fotableborderbeforestyle\the\AbsoluteTableCount:}{\FOborderbeforestyle}%
        \addToArray{fotableborderafterstyle\the\AbsoluteTableCount:}{\FOborderafterstyle}%
        \addToArray{fotableborderstartstyle\the\AbsoluteTableCount:}{\FOborderstartstyle}%
        \addToArray{fotableborderendstyle\the\AbsoluteTableCount:}{\FOborderendstyle}%
        \addToArray{fotableborderbeforewidth\the\AbsoluteTableCount:}{\FOborderbeforewidth}%
        \addToArray{fotableborderafterwidth\the\AbsoluteTableCount:}{\FOborderafterwidth}%
        \addToArray{fotableborderstartwidth\the\AbsoluteTableCount:}{\FOborderstartwidth}%
        \addToArray{fotableborderendwidth\the\AbsoluteTableCount:}{\FOborderendwidth}%
        \addToArray{fotableborderbeforecolor\the\AbsoluteTableCount:}{\FOborderbeforecolor}%
        \addToArray{fotableborderaftercolor\the\AbsoluteTableCount:}{\FOborderaftercolor}%
        \addToArray{fotableborderstartcolor\the\AbsoluteTableCount:}{\FOborderstartcolor}%
        \addToArray{fotableborderendcolor\the\AbsoluteTableCount:}{\FOborderendcolor}%
        \DEBUG{Table Column \the\NCols, in Table \the\AbsoluteTableCount, 
        \FOcolumnwidth, = \the\@tempdima}%
}
\def\NoTableRow#1{%
 \setbox0=\vbox{
  \ifx\FOheight\att@auto%
    \strut They
  \else
    \rule{\z@}{\FOheight}%
  \fi
  }%
 \NoTableCellHeight=\ht0
 \advance\NoTableCellHeight by \dp0
 \global\CellCount0
 \NoTableCheckHeightfalse
 \setbox0=\vbox{\hbox{\let\FOfoottext\FOnofoottext#1}}%
 \@tempdima=\ht0
 \advance\@tempdima by \dp0
 \FOspaceleft=\pagegoal
 \advance\FOspaceleft by -\pagetotal
%   \DEBUG{Space check for \the\@tempdima, [\the\FOspaceleft] PageTotal [\the\pagetotal/\the\pagegoal] l.\the\inputlineno}%
 \ifdim\FOspaceleft<\@tempdima
   \DEBUG{ .. page in table break fires, l. \the\inputlineno... }%
   \clearpage
 \fi
 \ifdim\@tempdima>\NoTableCellHeight
%\typeout{row pass 2 at \the\inputlineno, as [\the\@tempdima] > [\the\NoTableCellHeight]}%
   \NoTableCellHeight=\@tempdima
 \fi
 \global\CellCount0
 \NoTableCheckHeighttrue
 \vbox to \NoTableCellHeight{\hbox{#1}}%
% \ifFOinOutput\else\vskip-\lineskip\fi
}

\def\inheritfromcolumn#1#2{%
        \explicitattribute{#1}%
        \ifx\isexplicit\relax
                \expandafter\edef\csname FO#2\endcsname{\csname fotable#2\the\AbsoluteTableCount:\the\CellCount\endcsname}%
        \fi
}

\def\NoTableCell#1{%
 \ifx\FOstartsrow\att@true
%    \vskip-\lineskip
    \global\CellCount1
 \else
    \global\advance\CellCount by 1
 \fi
 \ifnum\NCols<1
  \CurrentCellWidth\z@
  \setbox0=\hbox{\restoreinterlineskip#1\strut}%
  \CurrentCellWidth=\wd0
%\DEBUG{report \the\CurrentCellWidth}%
 \else
  \CurrentCellWidth=\csname fotable\the\AbsoluteTableCount:\the\CellCount\endcsname
  \inheritfromcolumn{text-align}{textalign}%
  \inheritfromcolumn{border-before-style}{borderbeforestyle}%
  \inheritfromcolumn{border-after-style}{borderafterstyle}%
  \inheritfromcolumn{border-start-style}{borderstartstyle}%
  \inheritfromcolumn{border-end-style}{borderendstyle}%
  \inheritfromcolumn{border-before-width}{borderbeforewidth}%
  \inheritfromcolumn{border-after-width}{borderafterwidth}%
  \inheritfromcolumn{border-start-width}{borderstartwidth}%
  \inheritfromcolumn{border-end-width}{borderendwidth}%
  \inheritfromcolumn{border-before-color}{borderbeforecolor}%
  \inheritfromcolumn{border-after-color}{borderaftercolor}%
  \inheritfromcolumn{border-start-color}{borderstartcolor}%
  \inheritfromcolumn{border-end-color}{borderendcolor}%
  \interpretwidth
 \fi
 \advance\CurrentCellWidth by -\FOpaddingstart
 \advance\CurrentCellWidth by -\FOpaddingend
 \ifx\FOborderstartstyle\att@solid\advance\CurrentCellWidth by -\FOborderstartwidth\fi
 \ifx\FOborderendstyle\att@solid\advance\CurrentCellWidth by -\FOborderendwidth\fi
 \advance\CurrentCellWidth by -\FOmarginright
 \advance\CurrentCellWidth by -\FOmarginleft
 \ifnum\FOnumbercolumnsspanned>1
    \@tempcnta1
    \loop\ifnum\@tempcnta<\FOnumbercolumnsspanned
        \advance\@tempcnta by 1
        \global\advance\CellCount by 1
        \advance\CurrentCellWidth\csname fotable\the\AbsoluteTableCount:\the\CellCount\endcsname
%        \typeout{add extra column \the\@tempcnta, to reach \FOnumbercolumnsspanned: \the\CurrentCellWidth}%
    \repeat
 \fi
 \ifx\XML@parent\FOTableRow
   \FOTableCellBlock#1\FOEndTableCellBlock
 \else
   \leavevmode\hbox{\FOTableCellBlock#1\FOEndTableCellBlock}%
 \fi
 \ifx\FOendsrow\att@true
%    \vskip-\lineskip
    \global\CellCount0
 \fi
}

\def\FOTableCellBlock{%
 \begin{lrbox}{\CellBox}%
 \vbox\bgroup
 \hsize\the\CurrentCellWidth
 \restoreinterlineskip
 \ifFOinOutput\else \color@begingroup\fi
 \FOSetFont{tablecellblock}%
 \ifx\FOwhitespace\att@pre\obeyspaces\obeylines\fi
 \ifx\FOwhitespacecollapse\att@false\obeyspaces\fi
 \ifx\FOwrapoption\att@nowrap\obeylines\fi
 \ifx\FOverticalalign\att@bottom\vfill\fi
 }

\def\FOEndTableCellBlock{%
 \ifx\FOverticalalign\att@top\vfill\fi
 \ifFOinOutput\else \color@endgroup\fi
 \egroup
 \end{lrbox}%
 \@tempdima\FOmargintop
 \advance\@tempdima\FOpaddingbefore
 \ifx\FOborderbeforestyle\att@solid\advance\@tempdima\FOborderbeforewidth\fi
% \advance\@tempdima\dp\CellBox
%\typeout{CELL to height \the\NoTableCellHeight. Padding \FOpaddingbefore,\FOpaddingafter,\FOpaddingstart,\FOpaddingend; Border \FOborderbeforewidth,\FOborderafterwidth,\FOborderstartwidth,\FOborderendwidth; lower by \the\@tempdima; Margin \FOmargintop,\FOmarginbottom,\FOmarginleft,\FOmarginright}%
\@tempdimb\wd\CellBox
\advance\@tempdimb by \FOpaddingstart
\advance\@tempdimb by \FOpaddingend
\hbox{%
    \lower\@tempdima
     \hbox{%
      \hskip\FOmarginleft
      \vbox{%
        \kern\FOmargintop
        \vbox{%
        \ifx\FOborderbeforestyle\att@solid
           {\color{\FOborderbeforecolor}\hrule\@height\FOborderbeforewidth}%
        \fi
        \hbox{%
          \ifx\FOborderstartstyle\att@solid
            {\color{\FOborderstartcolor}\vrule\@width\FOborderstartwidth}%
          \fi
          \ifx\FObackgroundcolor\att@transparent
          \else
           {\color{\FObackgroundcolor}\vrule\@width\@tempdimb\kern-\@tempdimb}%
          \fi
           \ifNoTableCheckHeight
% According to FOdisplayalign property, we put glue 
% before and/or after the cell contents
             \vtop to \NoTableCellHeight{%
               \kern\FOpaddingbefore
               \ifx\FOdisplayalign\att@auto
                 \else\ifx\FOdisplayalign\att@before
                   \else\ifx\FOdisplayalign\att@after\vfil
                     \else\ifx\FOdisplayalign\att@centered\vfil\fi
                   \fi
                 \fi
               \fi
               \hbox{\kern\FOpaddingstart\box\CellBox\kern\FOpaddingend}%
               \ifx\FOdisplayalign\att@auto\vfil
                 \else\ifx\FOdisplayalign\att@before\vfil
                   \else\ifx\FOdisplayalign\att@after
                     \else\ifx\FOdisplayalign\att@centered\vfil\fi
                   \fi
                 \fi
               \fi
               \kern\FOpaddingafter
             }%
           \else
            \vbox{%
              \kern\FOpaddingbefore
                \hbox{\kern\FOpaddingstart\box\CellBox\kern\FOpaddingend}%
              \kern\FOpaddingafter
              }%
           \fi
          \ifx\FOborderendstyle\att@solid
           {\color{\FOborderendcolor}\vrule\@width\FOborderendwidth}%
          \fi
        }%
        \ifx\FOborderafterstyle\att@solid
           {\color{\FOborderaftercolor}\hrule\@height\FOborderafterwidth}\fi
        }%
        \kern\FOmarginbottom
     }%
     \hskip\FOmarginright
    }%
   }%
}

\def\FOBoxedBlock#1{%
% Dirk Roorda: I cannot perceive what should be going on here.
% But \hbox{#1} cannot be right, since #1 is a length or even a dimen.
% In the latter case this leads to a TeX error!
% So I have commented out the then-branch.
% \ifdim\@tempdimb=\z@
%    \setbox0=\hbox{#1}\@tempdimb\wd0\relax
%\typeout{report \the\CurrentCellWidth}%
% \else
    \@tempdimb#1\relax%
% \fi
 \advance\@tempdimb by -\FOpaddingstart\relax
 \advance\@tempdimb by -\FOpaddingend\relax
 \ifx\FOborderstartstyle\att@solid\advance\@tempdimb by -\FOborderstartwidth\relax\fi
 \ifx\FOborderendstyle\att@solid\advance\@tempdimb by -\FOborderendwidth\relax\fi
 \advance\@tempdimb by -\FOmarginright\relax
 \advance\@tempdimb by -\FOmarginleft\relax
 \begin{lrbox}{\BlockBox}%
 \vbox\bgroup
 \hsize\the\@tempdimb
 \FOSetFont{tableblock}%
 \color@begingroup
 \ifx\FOwhitespace\att@pre\obeyspaces\obeylines\fi
 \ifx\FOwhitespacecollapse\att@false\obeyspaces\fi
 \ifx\FOwrapoption\att@nowrap\obeylines\fi
 \parindent\FOtextindent
 \Quadding
 %\strut
 \start@strut
 }

\def\FOEndBoxedBlock{%
 \start@strut
 \color@endgroup
 \egroup
 \end{lrbox}%
 \@tempdimb\FOmargintop
 \advance\@tempdimb\FOpaddingbefore
 \ifx\FOborderbeforestyle\att@solid\advance\@tempdimb\FOborderbeforewidth\fi
% \advance\@tempdimb by \dp\BlockBox
%\typeout{BLOCK. Padding \FOpaddingbefore,\FOpaddingafter,\FOpaddingstart,\FOpaddingend; Border \FOborderbeforewidth,\FOborderafterwidth,\FOborderstartwidth,\FOborderendwidth; lower by \the\@tempdimb, margin \FOmargintop,\FOmarginbottom,\FOmarginleft,\FOmarginright}%
\@tempdimc\wd\BlockBox
\advance\@tempdimc by \FOpaddingstart
\advance\@tempdimc by \FOpaddingend
\FOtempdim\FOmarginleft
\advance\FOtempdim by \FOtextindent
\hbox{%
    \lower\@tempdimb
     \hbox{%
      \kern\FOtempdim
      \vbox{%
        \kern\FOmargintop
        \vbox{%
        \ifx\FOborderbeforestyle\att@solid
           {\color{\FOborderbeforecolor}\hrule\@height\FOborderbeforewidth}%
        \fi
        \hbox{%
          \ifx\FOborderstartstyle\att@solid
            {\color{\FOborderstartcolor}\vrule\@width\FOborderstartwidth}\fi
          \ifx\FObackgroundcolor\att@transparent
          \else
           {\color{\FObackgroundcolor}\vrule\@width\@tempdimc\kern-\@tempdimc}%
          \fi
            \vbox{%
              \kern\FOpaddingbefore
               \hbox{\kern\FOpaddingstart\box\BlockBox\kern\FOpaddingend}%
              \kern\FOpaddingafter
              }%
          \ifx\FOborderendstyle\att@solid
           {\color{\FOborderendcolor}\vrule\@width\FOborderendwidth}\fi
        }%
        \ifx\FOborderafterstyle\att@solid
           {\color{\FOborderaftercolor}\hrule\@height\FOborderafterwidth}\fi
        }%
        \kern\FOmarginbottom
     }%
     \kern\FOmarginright
    }%
   }%
}

\def\OldTableCell#1{%
    \ifx\FOendsrow\att@true
     \gdef\w@@t{\\}%
    \else
     \gdef\w@@t{\tabcellsep}%
    \fi
    \ifx\FOstartsrow\att@true
     \gdef\w@@@t{\\}%
    \else
     \gdef\w@@@t{}%
    \fi
    \xdef\MyRows{\FOnumberrowsspanned}%
    \xdef\MyCols{\FOnumbercolumnsspanned}%
    \ifnum\MyCols>1
     \gdef\w@t{\multicolumn{\MyCols}{l}{#1}\w@@t}%
    \else
     \ifnum\MyRows>1
      \gdef\w@t{\sbox{\FOBOX}{\hbox{#1}}%
      \@tempdima\ht\FOBOX
      \advance\@tempdima by -\baselineskip
      \raisebox{-\@tempdima}[\z@][\z@]{\usebox{\FOBOX}}\w@@t}%
     \else
      \gdef\w@t{\w@@@t#1\w@@t}%
     \fi
    \fi
    \aftergroup\w@t
}
%-------------------------------------------
% utility macros
\def\protectCS#1{%
 \begingroup
       \utfeight@protect@chars
       \xdef\FOtempCS{#1}%
 \endgroup
 \let#1\FOtempCS}%
\def\GrabFileName#1:#2\@nil{%
 \DEBUG{Graphic #1 +  #2}%
 \xdef\FOsrcname{#1}%
}
\def\NColumns{1}
\gdef\PrevNColumns{1}
\def\Pass#1\\{\expandafter\@Pass#1}
\def\@Pass#1|#2|#3|#4|{%
 \columnsep=#1
 \def\NColumns{#2}%
 \def\Marginbottom{#3}%
 \def\Margintop{#4}%
 }
\def\FOfiletest#1#2#3#4#5#6#7#8\@{%
  \def\@tempa{#1#2#3#4#5#6#7}%
  \def\@tempb{#1#2#3#4#5}%
  \def\@tempc{#1#2#3#4}%
  \ifx\@tempa\file@prefix
    \xdef\FOsrcname{#8}%
  \else
   \ifx\@tempb\file@shortprefix
      \xdef\FOsrcname{#6#7#8}%
   \else
    \ifx\@tempc\file@urlprefix
      \expandafter\FOurlfiletest#5#6#7#8\@empty\@empty\@empty\@empty\@empty\@empty\@empty\@empty\@empty\@empty
    \else
      \xdef\FOsrcname{#1#2#3#4#5#6#7#8}%
    \fi
   \fi
  \fi}

\def\FOurlfiletest#1#2#3#4#5#6#7#8){%
  \def\@tempa{#1#2#3#4#5#6#7}%
  \def\@tempb{#1#2#3#4#5}%
  \ifx\file@prefix\@tempa
    \xdef\FOsrcname{#8}%
  \else
   \ifx\@tempb\file@shortprefix
      \xdef\FOsrcname{#6#7#8}%
   \else
      \xdef\FOsrcname{#1#2#3#4#5#6#7#8}%
   \fi
  \fi}


{\catcode`\%=12\relax
\gdef\percentother{%}
}
{\catcode`\%=13\relax
\gdef\defpercentother{\xdef%{\percentother}}
}
{\catcode`\%=12\relax
\gdef\percenttest#1%#2#3\@{\ifx#2\relax\def\percentval{#1}\expandafter\@firstoftwo
  \else
    \expandafter\@secondoftwo
  \fi}
\gdef\performpercent#1{\defpercentother\edef\dopercent{\noexpand\percenttest#1\relax%.\noexpand\@}\dopercent}

\gdef\TablePercentToDimen#1{\performpercent{#1}
        {\@tempdimb\percentval pt\relax\divide\@tempdimb by 100
   \edef\SCALE{\strip@pt\@tempdimb}\global\@tempdima=\SCALE\TableWidth}{\global\@tempdima#1}
}
\gdef\PercentToDimen#1{\performpercent{#1}
  {\@tempdimb\percentval pt\relax\divide\@tempdimb by 100
   \edef\SCALE{\strip@pt\@tempdimb}\global\@tempdima=\SCALE\hsize}{\global\@tempdima#1}
}
\gdef\FOSetGWidth{\performpercent{\FOcontentwidth}
  {\@tempdima\percentval pt\relax\divide\@tempdima by 100
  \edef\WSCALE{\strip@pt\@tempdima}\setkeys{Gin}{width=\WSCALE\Gin@nat@width}}{\setkeys{Gin}{width=\FOcontentwidth}}}

\gdef\FOSetGHeight{\performpercent{\FOcontentheight}
  {\@tempdima\percentval pt\relax\divide\@tempdima by 100 
  \edef\HSCALE{\strip@pt\@tempdima}\setkeys{Gin}{height=\HSCALE\Gin@nat@height}}{\setkeys{Gin}{height=\FOcontentheight}}}

\gdef\PlayWithFSize#1{\@default\f@size pt
  \performpercent{#1}
      {\dimen@0.01\@default
     \multiply\dimen@\percentval\relax}{\dimen@#1}\edef\FOfontsizefinal{\the\dimen@}}
\gdef\PlayWithShift{performpercent{\FOverticalalign}
      {\dimen@0.01\baselineskip\multiply\dimen@\percentval\relax}{\dimen@\FOverticalalign}}
}
\def\strip@pt@and@otherjunk#1{\expandafter\rem@ptetc\the#1!} 
\begingroup
  \catcode`P=12
  \catcode`T=12
  \lowercase{\endgroup
  \gdef\rem@ptetc#1.#2PT#3!{#1\ifnum#2>\z@.#2\fi}%
}          
\catcode`\/\active

\def\@basiclink#1//#2\@nil#3\@nil#4\@nil{%
    {%
\ifx\\#2\\%
  \href{#4}{\FO@inlinesequence{#1}}%
\else
  \href{#4}{\FO@inlinesequence{\XURL{#3}}}%
\fi
   }%
}
\catcode`\/=12
%
\def\nocontentbox{\vbox to \z@{}}

\def\BlankPage{%
 \DEBUG{Blank Page \the\c@page}%
% \def\@thehead{\csname\FirstHead\endcsname}%
% \def\@thefoot{\csname\FirstTail\endcsname}%
% \let\@themargin\oddsidemargin
% \def\headheight{\FirstHeadExtent}%
% \def\tailheight{\FirstTailExtent}%
% \mark{}%
 \global\BlankPagetrue
 \nocontentbox
 \newpage
}
%-----------------------------------------------
% longtable
\LTpre\z@
\LTpost-10\p@
\def\LTleft@center{\LTleft=\FOmarginleft plus 1.0fill}
\def\LTright@center{\LTright=\FOmarginright plus 1.0fill}
\def\LTleft@start{\LTleft=\FOmarginleft}
\def\LTright@start{\LTright=\fill}
\def\LTleft@end{\LTleft=\fill}
\def\LTright@end{\LTright=\FOmarginright}
\def\LTleft@justify{\LTleft=\fill}
\def\LTright@justify{\LTright=\fill}
\gdef\LeftMargin{\FOmarginleft}
\gdef\RightMargin{\FOmarginright}
\gdef\TopMargin{\Margintop}
\gdef\BottomMargin{\Marginbottom}
\gdef\EndIndent{\ifx\FOendindent\att@labelend\z@\else\FOendindent\fi}
\gdef\StartIndent{\ifx\FOstartindent\att@bodystart\z@\else\FOstartindent\fi}
\gdef\OddTail {}
\gdef\OddHead {}
\gdef\EvenTail {}
\gdef\EvenHead {}
\gdef\FirstTail {}
\gdef\FirstHead {}
\gdef\OddTailExtent{\z@}
\gdef\OddHeadExtent{\z@}
\gdef\EvenTailExtent{\z@}
\gdef\EvenHeadExtent{\z@}
\gdef\FirstTailExtent{\z@}
\gdef\FirstHeadExtent{\z@}

\DefineCharacter{8232}{2028}{\newline}
\DefineCharacter{8208}{2010}{-\/}
\def\XURL{\begingroup \urlstyle{same}\Url}
\def\T@pageref#1{%
  \expandafter\@setref\csname r@#1\endcsname\@secondoffive{#1}%
}           
\let\@@ReadBookmarks\ReadBookmarks
\def\ReadBookmarks{{\let\InputIfFileExists\@input\@@ReadBookmarks}}
\def\XReadBookmarks{%
  \begingroup
    \escapechar=`\\%
    \let\escapechar\@gobble %
    \def\@@BOOKMARK [##1][##2]##3##4##5{\calc@bm@number{##5}}%
    \@input{\jobname.out}%
    \ifx\WriteBookmarks\relax
      \global\let\WriteBookmarks\relax
    \fi
    \def\@@BOOKMARK[##1][##2]##3##4##5{%
      \def\Hy@temp{##4}%
      \pdfoutline goto
        name{##3}%
        count ##2\check@bm@number{##3}{%
          \expandafter\strip@prefix\meaning\Hy@temp
        }%
   }%
   {%
    \def\WriteBookmarks{0}%
    \@input{\jobname.out}%
   }%
   %{\escapechar\m@ne\InputIfFileExists{\jobname.out}{}{}}%
   \ifx\WriteBookmarks\relax\else
     \if@filesw\immediate\openout\@outlinefile=\jobname.out
      \ifHy@typexml
       \immediate\write\@outlinefile{<relaxxml>\relax}%
      \fi
     \fi
   \fi
   \endgroup
}

\def\oline#1{$\overline{\mbox{#1}}$}
\def\TableHeader{}
\def\DECO@{\@firstofone}
\def\DECO@blink{\uwave}
\def\DECO@underline{\uline}
\def\DECO@overline{\oline}
\expandafter\def\csname DECO@line-through\endcsname{\sout}
\def\QuaddingStart{%
 \ifx\FOtextalignlast\att@relative
   \csname startQ@\FOtextalign\endcsname
 \else
   \csname startQ@\FOtextalignlast\endcsname
 \fi
}%
\def\QuaddingEnd{%
 \ifx\FOtextalignlast\att@relative
   \csname endQ@\FOtextalign\endcsname
 \else
   \csname endQ@\FOtextalignlast\endcsname
 \fi
}%
\def\Quadding{%
 \ifx\FOtextalignlast\att@relative
   \csname Q@\FOtextalign\endcsname
 \else
   \csname Q@\FOtextalignlast\endcsname
 \fi
}%
% page number compression (by David Carlisle)
\def\fopagecitation{\csname r@\FOrefid\endcsname}
%was \hyperlink{\FOrefid}{\pageref{\FOrefid}}}
\newcount\sortcount
\newtoks\sorttoks
\def\fosortpagecitation{%
   \setbox0\hbox{\global\sortcount=0\expandafter\expandafter\expandafter
   \@secondoffive\csname r@\FOrefid\endcsname
      \relax\relax\relax\relax\relax}%
    \let\@elt\fosort@elt
    \global\sorttoks\expandafter{\expandafter}\the\sorttoks
    \ifnum\sortcount<\maxdimen
   \global\sorttoks\expandafter{%
       \the\expandafter\sorttoks\expandafter\@elt\expandafter{\the\sortcount}}%
  \fi
    }

\def\fosort@elt#1{%
 \ifnum#1>\sortcount
   \global\sorttoks\expandafter{\the\expandafter\sorttoks\expandafter\@elt
       \expandafter{\the\sortcount}\@elt{#1}}%
  \global\sortcount\maxdimen
  \else
   \ifnum#1<\sortcount
   \global\sorttoks\expandafter{\the\sorttoks\@elt{#1}}%
   \fi
 \fi
}

\gdef\focompress@elt#1{%
        \global\advance\sortcount\@ne
        \ifnum#1=\sortcount\relax
                \edef\foheld{#1}%
        \else
                \ifx\foheld\relax
                \else
                        \FOrangechar
                \fi
                \foheld\fosep#1\relax   
                \let\foheld\relax
        \fi
        \global\sortcount#1\relax
        \def\fosep{, }%
} 

% headers
\def\FirstHead{\csname right-xsl-before\endcsname}
\def\FirstFoot{\csname right-xsl-after\endcsname}
\expandafter\def\csname left-xsl-before\endcsname{}
\expandafter\def\csname left-xsl-after\endcsname{}
\expandafter\def\csname right-xsl-before\endcsname{}
\expandafter\def\csname right-xsl-after\endcsname{}
\@ifundefined{pdfoutput}{}{\def\pdfBorderAttrs{/Border [0 0 0]}}

%color
\def\@declaredcolor#1{%
  \@ifundefined{\string\color @#1}%
   {\expandafter\HTMLXColor#1000000\\{#1}}%
   {}%
   \expandafter\let\expandafter\current@color
     \csname\string\color @#1\endcsname
     \set@color
  \ignorespaces}

\def\HTMLXColor#1#2#3#4#5#6#7#8\\#9{%
% \typeout{Defining color #9 as RGB "#2#3, "#4#5, "#6#7}%
 \toks@{\definecolor{#9}{RGB}}%
\uppercase{\the\toks@{"#2#3, "#4#5, "#6#7}}%
}
\def\HTMLColor#1#2#3#4#5#6#7#8{%
 \definecolor{#1}{RGB}{"#3#4, "#5#6, "#7#8}}
\HTMLColor{aqua}.00FFFF
\HTMLColor{black}.000000
\HTMLColor{blue}.0000FF
\HTMLColor{fuchsia}.FF00FF
\HTMLColor{gray}.808080    
\HTMLColor{green}.008000
\HTMLColor{lime}.00FF00
\HTMLColor{maroon}.800000
\HTMLColor{navy}.000080
\HTMLColor{olive}.808000
\HTMLColor{purple}.800080
\HTMLColor{red}.FF0000
\HTMLColor{silver}.C0C0C0
\HTMLColor{teal}.008080
\HTMLColor{white}.FFFFFF
\HTMLColor{yellow}.FFFF00

\definecolor{orange}{cmyk}{0,0.61,0.87,0}
    \long\def\@firstoffive#1#2#3#4#5{#1}%
    \long\def\@secondoffive#1#2#3#4#5{#2}%
    \long\def\@thirdoffive#1#2#3#4#5{#3}%
    \long\def\@fourthoffive#1#2#3#4#5{#4}%
    \long\def\@fifthoffive#1#2#3#4#5{#5}%

\expandafter\let\csname Format-1\endcsname\@arabic
\expandafter\let\csname Format-i\endcsname\@roman
\expandafter\let\csname Format-I\endcsname\@Roman
\expandafter\let\csname Format-a\endcsname\@alph
\expandafter\let\csname Format-A\endcsname\@Alph

\def\FOgeneratePage#1#2\@null{\csname Format-#1\endcsname{\c@page}#2}

\def\endtrivlist{%
  \if@inlabel
    \leavevmode
    \global \@inlabelfalse
  \fi
  \if@newlist
    \@noitemerr
    \global \@newlistfalse
  \fi
  \ifhmode\unskip \par\fi
  \if@noparlist \else
  \ifInInsertion\else
    \ifdim\lastskip >\z@
      \@tempskipa\lastskip \vskip -\lastskip
      \advance\@tempskipa\parskip \advance\@tempskipa -\@outerparskip
      \vskip\@tempskipa
    \fi
  \fi
    \@endparenv
  \fi
}

\def\@endparenv{%
  \ifInInsertion\else\addpenalty\@endparpenalty\addvspace\@topsepadd\@endpetrue\fi
}

\def\@item[#1]{%
  \if@noparitem
    \@donoparitem
  \else
    \if@inlabel
      \indent \par
    \fi
    \ifhmode
      \unskip\unskip \par
    \fi
        \ifInInsertion
        \else
        \if@newlist
% removed this test 2000/11/05. always put in topsep.
%               \if@nobreak
%                       \@nbitem
%               \else
                        \addpenalty\@beginparpenalty
                        \addvspace\@topsep
                        \addvspace{-\parskip}%
%               \fi
        \else
                \addpenalty\@itempenalty
                \addvspace\itemsep
        \fi
        \fi
    \global\@inlabeltrue
  \fi
  \global\everypar{%
    \@minipagefalse
    \global\@newlistfalse
    \if@inlabel
      \global\@inlabelfalse
      {\setbox\z@\lastbox
       \ifvoid\z@
         \kern-\itemindent
       \fi}%
      \box\@labels\FOlabel
      \penalty\z@
    \fi
    \if@nobreak
      \global\@nobreakfalse
      \clubpenalty \@M
    \else
      \clubpenalty \@clubpenalty
      \global\everypar{}%
    \fi
  }%
  \if@noitemarg
    \@noitemargfalse
    \if@nmbrlist
      \refstepcounter\@listctr
    \fi
  \fi
  \sbox\@tempboxa{\makelabel{#1}}%
%\typeout{LIST at \the\inputlineno, \the\itemindent, \the\labelwidth, \the\wd\@tempboxa}%
  \global\setbox\@labels\hbox{%
    \unhbox\@labels
    \hskip \itemindent
    \hskip -\labelwidth
    \hskip -\labelsep
    \ifdim \wd\@tempboxa >\labelwidth
      \box\@tempboxa
    \else
      \hbox to\labelwidth {\unhbox\@tempboxa}%
    \fi
    \hskip \labelsep}%
  \ignorespaces}


% support for markers
\gdef\FOmarks{}

\gdef\FOaddmarker#1#2{%
 \ifx\relax#1
 \else
   \def\FOtemp{#1}%
   \ifx\FOtemp\FOmarkerclassname
   \else
        \toks@\expandafter{\the\toks@{#1}{#2}}%
   \fi
   \expandafter\FOaddmarker
 \fi}
   

\gdef\FOgetmarker#1#2{%
  \ifx\relax#1
  \DEBUG{unknown mark \FOretrieveclassname, at \the\inputlineno}%
  \else
   \def\FOtemp{#1}%
    \ifx\FOtemp\FOthisretrieveclassname
%      \typeout{\the\inputlineno: Retrieve mark (\FOretrieveposition):
%      \FOthisretrieveclassname: #2}%
      \FOmarkergobble{#2}%
     \fi
   \expandafter\FOgetmarker
  \fi}
   
\gdef\FOmarkergobble#1#2\relax\relax{\fi\fi#1}

% linebreak
\def\FOLINEBREAK{%
\ifnum\FOTableNesting>0
\else
 \\
\fi
}


%\tracingpages3\relax
% vertical spacing
\newskip\FOafterskip
\def\FOvspaceafter{%
        \ifFOinOutput
        \else
                \ifnum\FOTableNesting>0
                \else
                        \ifx\@empty\FOspaceafter
                                \@tempdima\FOspaceafteroptimum
                                \advance\@tempdima by -\FOspaceafterminimum
                                \@tempdimb\FOspaceafteroptimum
                                \advance\@tempdimb by \FOspaceaftermaximum
                                \FOafterskip\FOspaceafteroptimum plus \@tempdimb minus \@tempdima
                        \else
                                \FOafterskip\FOspaceafter
                        \fi
                        \@tempswafalse
                        \ifx\FOkeepwithnext\att@always\@tempswatrue\fi
                        \ifx\FOkeepwithnextColumn\att@always\@tempswatrue\fi
                        \ifx\FOkeepwithnextPage\att@always\@tempswatrue\fi
                        \addvspace\FOafterskip
                        \if@tempswa \addpenalty{9996}\fi
                \fi
        \fi
}

\@secpenalty = -300
\def\FOvspacebefore{%
        \ifFOinOutput
        \else
                \ifx\@empty\FOspacebefore
                        \@tempdima\FOspacebeforeoptimum
                        \advance\@tempdima by -\FOspacebeforeminimum
                        \@tempdimb\FOspacebeforeoptimum
                        \advance\@tempdimb by \FOspacebeforemaximum
                        \@tempskipa\FOspacebeforeoptimum plus \@tempdimb minus \@tempdima
                \else
                        \@tempskipa\FOspacebefore
                \fi
        %\typeout{SPACE BEFORE \the\inputlineno: \the\@tempskipa, \FOspacebeforeminimum/\FOspacebeforemaximum/\FOspacebeforeoptimum}%
                \ifnum\FOTableNesting>0
                        \rule{\z@}{\@tempskipa}%
                \else
                        \@tempswafalse
                        \ifx\FOkeepwithnext\att@always\@tempswatrue\fi
                        \ifx\FOkeepwithnextColumn\att@always\@tempswatrue\fi
                        \ifx\FOkeepwithnextPage\att@always\@tempswatrue\fi
                        \@tempskipb\f@baselineskip\relax\@tempskipb3\@tempskipb\relax
                        %\ifx\@empty\FOspacebefore\else
                        %\if@tempswa\vskip0pt plus \@tempskipb
                        %\addpenalty\@secpenalty\vskip-\lastskip\fi\fi
                        \if@tempswa\addpenalty\@secpenalty\fi
                        \addvspace\@tempskipa
                \fi
        \fi
        \def\FOspacebefore{\z@}%
}

\def\addpenalty#1{%
        \ifvmode
        \if@minipage
        \else
                \if@nobreak
                \else
                        \ifdim\lastskip=\z@
                                \penalty#1\relax
                        \else
                                \@tempskipb\lastskip
                                \vskip -\lastskip
                                \penalty#1%
                                \vskip\@tempskipb
                        \fi
                \fi
        \fi
        \else
                \@noitemerr
        \fi
}
% lets do some setup
% setup
\paperwidth211mm
\paperheight297mm
\hoffset-1in
\voffset-1in
\def\fps@table{!htbp}
\def\fps@figure{!htbp}
\parindent\z@
\parskip\z@
\emergencystretch 3em
\tabcolsep3pt
\hbadness=4000
\hyphenpenalty=400
\pretolerance=500
\relpenalty=500
\tolerance=1000
\vbadness=3000
\widowpenalty=0
\clubpenalty=0
\@twosidetrue
\fboxsep0pt
\setcounter{topnumber}{5}
\renewcommand\topfraction{.9}
\setcounter{bottomnumber}{12}
\renewcommand\bottomfraction{.9}
\setcounter{totalnumber}{6}
\renewcommand\textfraction{.1}
\def\FOpdfsetpagesize#1#2{%
 \@ifundefined{pdfoutput}{}{%
   \global\pdfpagewidth\paperwidth
   \global\pdfpageheight\paperheight
    \DEBUG{Setting pdf size to \the\pdfpagewidth, \the\pdfpageheight}%
    }%
}
\let\SpecialOffset\z@
% and now read the .cfg
\openin\@inputcheck fotex.cfg
\ifeof\@inputcheck\relax    
\else
  \closein\@inputcheck
  \input{fotex.cfg}
\fi
\begingroup
\catcode`\^^M\active\catcode`\ \active\gdef\@resetactivechars{\def^^M{<m>}\def {<s>}}\endgroup
%\catcode`\^^M\active\gdef\@resetactivechars{\def^^M{x}}\endgroup

\def\@outputpage{%
        \begingroup           % the \endgroup is put in by \aftergroup
        \let\protect\noexpand
%  \@resetactivechars
        \@parboxrestore
        \shipout\vbox{%
        \set@typeset@protect
        \aftergroup\endgroup
        \aftergroup\set@typeset@protect
                                % correct? or just restore by ending
                                % the group?
                \if@specialpage
%       \typeout{PAGE=FIRST \the\c@page}%
                        \global\@specialpagefalse
                        \def\@thehead{\csname\FirstHead\endcsname}%
                        \def\@thefoot{\csname\FirstTail\endcsname}%
                        \let\@themargin\oddsidemargin
                        \def\headheight{\FirstHeadExtent}%
                        \def\tailheight{\FirstTailExtent}%
                \else
                        \ifBlankPage
%\typeout{PAGE=BLANK \the\c@page}%
                                \global\BlankPagefalse
                                \def\@thehead{\csname\BlankHead\endcsname}%
                                \def\@thefoot{\csname\BlankTail\endcsname}%
                                \let\@themargin\oddsidemargin
                                \def\headheight{\BlankHeadExtent}%
                                \def\tailheight{\BlankTailExtent}%
                        \else
                                \ifodd\count\z@ 
%       \typeout{PAGE=ODD \the\c@page}%
                                        \def\@thehead{\csname\OddHead\endcsname}%
                                        \def\@thefoot{\csname\OddTail\endcsname}%
                                        \let\@themargin\oddsidemargin
                                        \def\headheight{\OddHeadExtent}%
                                        \def\tailheight{\OddTailExtent}%
                                \else 
%       \typeout{PAGE=EVEN \the\c@page}%
                                        \def\@thehead{\csname\EvenHead\endcsname}%
                                        \def\@thefoot{\csname\EvenTail\endcsname}%
                                        \let\@themargin\evensidemargin
                                        \def\headheight{\EvenHeadExtent}%
                                        \def\tailheight{\EvenTailExtent}%
                                \fi
                        \fi
                \fi
                \@tempdima\textwidth
                \advance\@tempdima by -\FOheadindent
                \reset@font
                \normalsize
                \normalsfcodes
                \let\label\@gobble
                \let\index\@gobble
                \let\glossary\@gobble
  %\baselineskip\z@skip \lineskip\z@skip \lineskiplimit\z@
                \offinterlineskip
                \@begindvi
        \vskip \topmargin
        \vskip -\InnerTopMargin
        \moveright\@themargin \vbox {%
                \setbox\@tempboxa \vbox to\z@{%
                        \color@hbox
                        \normalcolor
                        \hb@xt@\textwidth{\hfill\llap{\hb@xt@\@tempdima{\@thehead}}}%
                        \color@endbox
                        \vss
                }%
                \dp\@tempboxa \z@
                \box\@tempboxa
                \vskip\headsep
                \vskip\InnerTopMargin
                \box\@outputbox
                \baselineskip\footskip
                \vskip\bottommargin
                \vskip-\tailheight
                        \@tempdima\textwidth
                        \advance\@tempdima by -\FOheadindent
                \setbox\@tempboxa \vbox to\tailheight{%
                        \color@hbox
                        \normalcolor
                        \hb@xt@\textwidth{\hfill\llap{\hb@xt@\@tempdima{\@thefoot}}}%
                        \color@endbox
                        \vfil
                }%
                \dp\@tempboxa \z@
                \box\@tempboxa
        }%
        }%
        \global \@colht \textheight
        \stepcounter{page}%
        \ifForcePageSetup
                \global\advance\SimplePMRefs1\relax
                \DEBUG{Start page \the\SimplePMRefs\space of page sequence, using layout \CurrentPageMaster, at page \the\c@page}%
                \setaccordingtomaster
                \ifnum\NColumns>1\relax
                        \refreshmulticols % this is defined in nomulticols.sty
                \fi
        \else
                \DEBUG{Skipping page set up at page \the\c@page}%
        \fi
        \let\firstmark\botmark
}

\def\FO@character#1{%
\ifx\FOverticalalign\att@baseline
  #1%
\else
 \ifx\FOverticalalign\att@super
   \textsuperscript{#1}%
 \else
    \ifx\FOverticalalign\att@sub
      \textsubscript{#1}%
    \else
      \PlayWithShift
      \raisebox{\dimen@}{#1}%
    \fi
 \fi
\fi
}
\def\FO@inlinesequence#1{%
        \FOSetFont{normal}%
        \ifx\FOletterspacing\att@normal
                \def\pre@sequence{{#1}}%
        \else
                \def\pre@sequence{\@ifundefined{thisso}{\sodef\thisso{}{\FOletterspacing}{.4em}{.5em}}{}{\thisso{#1}}}%
        \fi
        \ifx\FOverticalalign\att@baseline
                \csname DECO@\FOtextdecoration\endcsname{\FOlabel\pre@sequence}%
        \else
                \ifx\FOverticalalign\att@super
                        \textsuperscript{\csname DECO@\FOtextdecoration\endcsname{\FOlabel\pre@sequence}}%
                \else
                \ifx\FOverticalalign\att@sub
                        \textsubscript{\csname DECO@\FOtextdecoration\endcsname{\FOlabel\pre@sequence}}%
                \else
                        \PlayWithShift
                        \raisebox{\dimen@}{\csname DECO@\FOtextdecoration\endcsname{\FOlabel\pre@sequence}}%
                \fi
                \fi
        \fi
}
\def\interpretwidth{%
   \ifx\FOborderwidth\att@thin\def\FOborderwidth{0.4pt}\fi
   \ifx\FOborderwidth\att@medium\def\FOborderwidth{0.8pt}\fi
   \ifx\FOborderwidth\att@thick\def\FOborderwidth{1.2pt}\fi
   \ifx\FOborderbeforewidth\att@thin\def\FOborderbeforewidth{0.4pt}\fi
   \ifx\FOborderbeforewidth\att@medium\def\FOborderbeforewidth{0.8pt}\fi
   \ifx\FOborderbeforewidth\att@thick\def\FOborderbeforewidth{1.2pt}\fi
   \ifx\FOborderafterwidth\att@thin\def\FOborderafterwidth{0.4pt}\fi
   \ifx\FOborderafterwidth\att@medium\def\FOborderafterwidth{0.8pt}\fi
   \ifx\FOborderafterwidth\att@thick\def\FOborderafterwidth{1.2pt}\fi
   \ifx\FOborderstartwidth\att@thin\def\FOborderstartwidth{0.4pt}\fi
   \ifx\FOborderstartwidth\att@medium\def\FOborderstartwidth{0.8pt}\fi
   \ifx\FOborderstartwidth\att@thick\def\FOborderstartwidth{1.2pt}\fi
   \ifx\FOborderendwidth\att@thin\def\FOborderendwidth{0.4pt}\fi
   \ifx\FOborderendwidth\att@medium\def\FOborderendwidth{0.8pt}\fi
   \ifx\FOborderendwidth\att@thick\def\FOborderendwidth{1.2pt}\fi
}

\def\FOboxedsequence#1{%
\FOSetFont{normal}%
\ifx\FOborderwidth\@empty
\else
        \interpretwidth
        \fboxrule\FOborderwidth
\fi
\ifx\FOverticalalign\att@baseline
 \fbox{\csname DECO@\FOtextdecoration\endcsname{\FOlabel#1}}%
\else
 \ifFOSuper
     \fbox{\textsuperscript{\FOlabel#1}}%
 \else
     \ifFOSub
       \fbox{\textsubscript{\FOlabel#1}}%
     \else
       \PlayWithShift
       \fbox{\raisebox{\dimen@}{\FOlabel#1}}%
     \fi
 \fi
\fi
}
%
\def\FOSetStatic{\expandafter\@SetStatic\FOtextindent\\}
\def\@SetStatic#1\\{\expandafter\@@SetStatic\FOfontsize\\{#1}}
\def\@@SetStatic#1\\#2{\expandafter\@@@SetStatic\FOfontweight\\{#1}{#2}}
\def\@@@SetStatic#1\\#2#3{\expandafter\@@@@SetStatic\FOfontvariant\\{#1}{#2}{#3}}
\def\@@@@SetStatic#1\\#2#3#4{\expandafter\@@@@@SetStatic\FOfontstyle\\{#1}{#2}{#3}{#4}}
\def\@@@@@SetStatic#1\\#2#3#4#5{\expandafter\@@@@@@SetStatic\FOfontstretch\\{#1}{#2}{#3}{#4}{#5}}
\def\@@@@@@SetStatic#1\\#2#3#4#5#6{\expandafter\@@@@@@@SetStatic\FOfontfamily\\{#1}{#2}{#3}{#4}{#5}{#6}}

\expandafter\def\csname Static:DummyRegion\endcsname{}
\def\@@@@@@@SetStatic#1\\#2#3#4#5#6#7#8#9{%
  \DEBUG{ set up static area Static:#9 [#8]}%
   \expandafter\gdef\csname Static:#9\endcsname{%
     {%
      {\def\XML@parent{}\global\FOinOutputtrue
       \def\FOwhitespacecollapse{true}%
       \def\FOwrapoption{wrap}%
       \def\FOtextalign{start}%
       \def\FOfontfamily{#1}%
       \def\FOfontsize{#6}%
       \def\FOfontstretch{#2}%
       \def\FOfontvariant{#4}%
       \def\FOfontweight{#5}%
       \def\FOfontstyle{#3}#8\global\FOinOutputfalse}}}%
        \ifx\FOflowname\att@xsl@footnote@separator\relax
                \xdef\footnoterulepre{Static:#9}%
                \global\footnotesep\z@\relax
                \setbox\@tempboxa\vbox{\csname\footnoterulepre\endcsname}%
                \@tempdima=\z@\relax
                \advance\@tempdima\ht\@tempboxa\relax
                \advance\@tempdima\dp\@tempboxa\relax
                \global\skip\footins\@tempdima\relax
                \gdef\footnoterule{\vfill\vbox to\z@{\vss\csname\footnoterulepre\endcsname}}%
        \fi
}

\def\setaccordingtomaster{%
    \global\@specialpagetrue
        \@ifundefined{Atomic:\CurrentPageMaster}
        {
                \@ifundefined{Lead:\the\SimplePMRefs:\CurrentPageMaster}
                {
                        \ifnum\SimplePMRefs>1\relax\global\@specialpagefalse\fi
                        \@ifundefined{First:\CurrentPageMaster}
                        {
                                \ifx\FOinitialpagenumber\att@auto
                                        \ifodd\c@page
                                                \DEBUG{Master \CurrentPageMaster: no first page, use odd page}
                                                \xdef\PFirst{\csname Odd:\CurrentPageMaster\endcsname}
                                        \else
                                                \DEBUG{Master \CurrentPageMaster: no first page, use even page}
                                                \@ifundefined{Even:\CurrentPageMaster}
                                                {\xdef\PFirst{\csname Odd:\CurrentPageMaster\endcsname}}
                                                {\xdef\PFirst{\csname Even:\CurrentPageMaster\endcsname}}
                                        \fi
                                \else
                                        \ifx\FOinitialpagenumber\att@autoeven
                                                \@ifundefined{Even:\CurrentPageMaster}
                                                {\xdef\PFirst{\csname Odd:\CurrentPageMaster\endcsname}}
                                                {\xdef\PFirst{\csname Even:\CurrentPageMaster\endcsname}}
                                        \else
                                                \ifx\FOinitialpagenumber\att@autoodd
                                                        \xdef\PFirst{\csname Odd:\CurrentPageMaster\endcsname}
                                                \else
                                                        \ifodd\FOinitialpagenumber
                                                                \xdef\PFirst{\csname Odd:\CurrentPageMaster\endcsname}
                                                        \else
                                                                \@ifundefined{Even:\CurrentPageMaster}
                                                                {\xdef\PFirst{\csname Odd:\CurrentPageMaster\endcsname}}
                                                                {\xdef\PFirst{\csname Even:\CurrentPageMaster\endcsname}}
                                                        \fi
                                                \fi
                                        \fi
                                \fi
                        }
                        {
                                \xdef\PFirst{\csname First:\CurrentPageMaster\endcsname}
                        }
                        \@ifundefined{Blank:\CurrentPageMaster}
                                {\xdef\PBlank{\csname Odd:\CurrentPageMaster\endcsname}}
                                {\xdef\PBlank{\csname Blank:\CurrentPageMaster\endcsname}}
                        \@ifundefined{Even:\CurrentPageMaster}
                                {\xdef\PEven{\csname Odd:\CurrentPageMaster\endcsname}}
                                {\xdef\PEven{\csname Even:\CurrentPageMaster\endcsname}}
                        \xdef\POdd{\csname Odd:\CurrentPageMaster\endcsname}
                }
                {
                        \xdef\PFirst{\csname Lead:\the\SimplePMRefs:\CurrentPageMaster\endcsname}
                        \global\let\POdd\PFirst
                        \global\let\PEven\PFirst
                        \global\let\PBlank\PFirst
                }
        }
        {
        \global\let\PFirst\CurrentPageMaster
        \global\let\PBlank\CurrentPageMaster
        \global\let\POdd\CurrentPageMaster
        \global\let\PEven\CurrentPageMaster
        }
        \DEBUG{ first page master is [\PFirst]}
        \DEBUG{ odd  page master is [\POdd]}
        \DEBUG{ even page master is [\PEven]}
        \DEBUG{ blank page master is [\PBlank]}
        \expandafter\Pass\csname\POdd:xsl-region-body\endcsname\\
        \csname Atomic:\POdd\endcsname
        \global\oddsidemargin\MasterLeftMargin
        \global\evensidemargin\MasterLeftMargin
        \global\advance\evensidemargin by \SpecialOffset
        \global\advance\oddsidemargin by \SpecialOffset
        \@ifundefined{Atomic:\PEven}
        {
                \DEBUG{no master for Atomic:\PEven}
        }
    {
                \csname Atomic:\PEven\endcsname
        \global\evensidemargin\MasterLeftMargin
        \global\advance\evensidemargin by \SpecialOffset
    }
        \xdef\EvenHeadExtent{\csname\PEven:before-extent\endcsname}
        \xdef\EvenHead{Static:\csname\PEven:before\endcsname}
        \xdef\EvenTailExtent{\csname\PEven:after-extent\endcsname}
        \xdef\EvenTail{Static:\csname\PEven:after\endcsname}
        \xdef\FirstHeadExtent{\csname\PFirst:before-extent\endcsname}
        \xdef\FirstHead{Static:\csname\PFirst:before\endcsname}
        \xdef\FirstTailExtent{\csname\PFirst:after-extent\endcsname}
        \xdef\FirstTail{Static:\csname\PFirst:after\endcsname}
        \xdef\OddHeadExtent{\csname\POdd:before-extent\endcsname}
        \xdef\OddHead{Static:\csname\POdd:before\endcsname}
        \xdef\OddTailExtent{\csname\POdd:after-extent\endcsname}
        \xdef\OddTail{Static:\csname\POdd:after\endcsname}
        \xdef\BlankHeadExtent{\csname\PBlank:before-extent\endcsname}
        \xdef\BlankHead{Static:\csname\PBlank:before\endcsname}
        \xdef\BlankTailExtent{\csname\PBlank:after-extent\endcsname}
        \xdef\BlankTail{Static:\csname\PBlank:after\endcsname}
        \FOSetPage
}

\let\olditem\item
\def\item{\if@inlabel\leavevmode\fi\olditem}
\def\FOlabel{%
 \ifx\@empty\FOid\else
 % \typeout{Hypertext label \FOid, at \the\inputlineno}%
  \@bsphack
  \protected@write\@mainaux{}%
    {\string\newlabel{\FOid}{{}{\noexpand\FOgeneratePage\FOformat\noexpand\@null}{}{}{}}}%
  \@esphack
  \hyper@@anchor{\FOid}{\relax}%
  \global\let\FOid\@empty
 \fi
}

\def\FOListBlock{%
   \FOSetFont{normal}%
   \get@external@font\xdef\FOlistlabelfont{\external@font}%
   \ifx\@empty\FOspacebefore
      \@tempdima\FOspacebeforeoptimum
      \advance\@tempdima by -\FOspacebeforeminimum
      \@tempdimb\FOspacebeforeoptimum
      \advance\@tempdimb by \FOspacebeforemaximum
      \itemsep\FOspacebeforeoptimum plus \@tempdimb minus \@tempdima
    \else
      \itemsep\FOspacebefore
    \fi
  \itemindent=\FOstartindent
  \PercentToDimen{\FOprovisionaldistancebetweenstarts}%
  \leftmargin=\@tempdima\relax
  \rightmargin=\FOmarginright
  \labelwidth=\@tempdima\relax
  \advance\labelwidth by -\FOprovisionallabelseparation
  \expandafter\csname List\FOtextalign\endcsname
%\typeout{List at \the\inputlineno: labelwidth: \the\labelwidth, 
% labelsep: \the\labelsep, leftmargin: \the\leftmargin, itemindent 
% \the\itemindent, makelabel: \meaning\makelabel, 
% itemsep: \the\itemsep, \FOtextalign}%
}

\def\FOOutputBlock{%
 \FOSetFont{output}%
 \ifx\FOtextalignlast\att@relative
   \csname startQ@\FOtextalign\endcsname
%   \csname Q@\FOtextalign\endcsname
 \else
   \csname startQ@\FOtextalignlast\endcsname
%   \csname Q@\FOtextalignlast\endcsname
 \fi
% \Quadding
 \ifFOBlockGrab
   \FOBoxedBlock{\textwidth}%
 \fi
}

\def\list#1#2{%
  \ifnum \@listdepth >5\relax
    \@toodeep
  \else
    \global\advance\@listdepth\@ne
  \fi
  \rightmargin\z@
  \listparindent\z@
  \itemindent\z@
  \csname @list\romannumeral\the\@listdepth\endcsname
  \def\@itemlabel{#1}%
  \let\makelabel\@mklab
  \@nmbrlistfalse
  #2\relax
  \@trivlist
  \parskip\parsep
  \parindent\listparindent
  \global\advance\linewidth -\rightmargin
  \global\advance\linewidth -\leftmargin
  \advance\@totalleftmargin \leftmargin
  \parshape \@ne \@totalleftmargin \linewidth
  \ignorespaces}

\def\FONormalBlock{%
        \ifnum\FOTableNesting>0
                \ifx\FOtextalign\att@centered
                \centering
                \fi
                \FOSetFont{normalblock}%
%               \vrule height \f@baselineskip depth \z@ width \z@\relax
        \else
        \ifnum\FOinList>0
                \ifFOListInnerPar
                                \unskip\par
                                \FOvspacebefore
                        \fi
                \ifx\FOwhitespace\att@pre\obeyspaces\obeylines\fi
                \ifx\FOwhitespacecollapse\att@false\obeyspaces\fi
                \ifx\FOwrapoption\att@nowrap\obeylines\fi
                        \ifInInsertion\start@strut\fi
        \else
                        \ifx\FObreakbefore\att@page
                                \let\tempID\FOid
%                       \penalty -\@M
                                \newpage
                                \let\FOid\tempID
                        \else
                                \ifx\FObreakbefore\att@oddpage
                                        \let\tempID\FOid
%                               \penalty -\@M
                                        \newpage
                                        \ifodd\c@page\else\BlankPage\fi
                                        \let\FOid\tempID
                                \else
                                        \ifx\FObreakbefore\att@evenpage
                                                \let\tempID\FOid
%                               \penalty -\@M
                                                \newpage
                                                \ifodd\c@page\BlankPage\fi
                                                \let\FOid\tempID
                                        \fi
                                \fi
                        \fi
                        \par
                        \Quadding
                        \ifFOBlockGrab
                                \FOBoxedBlock{\linewidth}%
                        \else
                                \FOBorderTop
                                \ifdim\FOpaddingbefore>\z@
                                        \vskip\FOpaddingbefore
                                \fi
                                \FOvspacebefore
                                \parindent\FOtextindent
                                \advance\leftskip by  \FOpaddingstart
                                \advance\leftskip by  \FOmarginleft
                                \advance\rightskip by \FOpaddingend
                                \advance\rightskip by \FOmarginright
                        \fi
%               \par
                        \ifx\FOwhitespace\att@pre\obeyspaces\obeylines\fi
                        \ifx\FOwhitespacecollapse\att@false\obeyspaces\fi
                        \ifx\FOwrapoption\att@nowrap\obeylines\fi
                        \FOlabel
                \fi
        \ifx\XML@parent\FOFootnoteBody\else\FOSetFont{normal}\fi
        \fi
}

\def\FOEndOutputBlock{%
 \ifx\FOtextalignlast\att@relative
   \csname endQ@\FOtextalign\endcsname
 \else
   \csname endQ@\FOtextalignlast\endcsname
 \fi
 \ifFOBlockGrab
       \FOEndBoxedBlock
 \fi
 \par
}
\def\FOEndBlock{%
  \ifx\XML@parent\FOListItemLabel
  \else
    \ifnum\FOinList>0
      \ifInInsertion\start@strut\fi
      \ifFOListInnerPar\unskip\par\fi
    \else
       \ifnum\FOTableNesting>0
       \else
         \FOEndBlockTwo
       \fi
    \fi
   \fi
}


\def\FOEndBlockTwo{%
  \par
   \ifFOBlockGrab
       \FOEndBoxedBlock
   \else
        \ifdim\FOpaddingafter>\z@
         \vskip\FOpaddingafter
        \fi
        \FOBorderBottom
   \fi
   \ifx\FObreakafter\att@page
                \clearpage
%        \penalty -\@M
   \else
        \ifx\FObreakafter\att@oddpage
                \ifodd\c@page\cleardoublepage\else\clearpage\fi
                \else
          \ifx\FObreakafter\att@evenpage
                  \ifodd\c@page\clearpage\else\cleardoublepage\fi
                  \fi
        \fi
   \fi
   \@tempswafalse
   \ifx\FOkeepwithnext\att@always\@tempswatrue\fi
   \ifx\FOkeepwithnextColumn\att@always\@tempswatrue\fi
   \ifx\FOkeepwithnextPage\att@always\@tempswatrue\fi
   \if@tempswa\addpenalty{9993}\fi
   \FOvspaceafter
%   \if@tempswa\@afterheading\fi
}

% \FOStartGrab is never called, so it seems
\def\FOStartGrab#1{%
         \@tempdima#1
         \XFOstartindent\FOstartindent
         \ifnum\XFOstartindent=\z@
         \else
          \advance\XFOstartindent by -\FOmarginleft
          \advance\XFOstartindent by -\FOborderstartwidth
          \advance\XFOstartindent by -\FOpaddingstart
          \advance\@tempdima by -\XFOstartindent
         \fi
         \advance\@tempdima by -\FOmarginleft
         \advance\@tempdima by -\FOborderstartwidth
         \advance\@tempdima by -\FOpaddingstart
         \XFOendindent\FOendindent
         \ifx\FOstartindent\att@bodystart
           \let\FOstartindent\z@
         \fi
         \ifx\FOendindent\att@labelend
           \let\FOendindent\z@
         \fi
         \ifnum\XFOendindent=\z@
         \else
          \advance\XFOendindent by -\FOpaddingend
          \advance\XFOendindent by -\FOmarginright
          \advance\XFOendindent by -\FOborderendwidth
          \advance\@tempdima by -\XFOendindent
         \fi
         \advance\@tempdima by -\FOpaddingend
         \advance\@tempdima by -\FOmarginright
         \advance\@tempdima by -\FOborderendwidth
%\typeout{Block at\the\inputlineno,Padding:\FOpaddingstart/\FOpaddingend,Border:\FOborderstartwidth/\FOborderendwidth,Margin:\FOmarginleft/\FOmarginleft,Indent:\FOstartindent/\FOendindent, \the\XFOstartindent/\the\XFOendindent}%
%
         \begin{lrbox}{\BlockBox}%
         \begin{minipage}[b]{\@tempdima}%
         \vskip\FOpaddingbefore
         \parindent\FOtextindent\leftskip\z@\rightskip\z@
}
% \FOEndGrab is never called, so it seems
\def\FOEndGrab#1{%
  \vspace*{\FOpaddingafter}%
  \end{minipage}%
  \end{lrbox}%
%\typeout{Grabbed Block at\the\inputlineno,Padding:\FOpaddingstart/\FOpaddingend,|\FOpaddingbefore/\FOpaddingafter, Border:\FOborderstartwidth/\FOborderendwidth,Margin:\FOmarginleft/\FOmarginleft,Indent:\FOstartindent/\FOendindent, \the\XFOstartindent/\the\XFOendindent}%
  \FOvspacebefore
  \@tempdima\ht\BlockBox
%  \advance\@tempdima by \FOpaddingbefore
%  \advance\@tempdima by \FOpaddingafter
  \advance\@tempdima by \FOborderbeforewidth
  \advance\@tempdima by \FOborderafterwidth
  \ifx\FOborderstyle\att@solid
     \interpretwidth
   \ifx\FObackgroundcolor\att@transparent
     \fboxrule\FOborderwidth
     \fboxsep\FOpadding
     \vbox to \@tempdima{\hsize#1\parindent\z@\vfil
       \hbox{\hfil\fbox{\usebox{\BlockBox}}\hfil}\vfil}%
   \else
    \vbox to \@tempdima{\hsize#1\vfil\fboxsep\FOpadding\fboxrule\FOborderwidth
     \hbox{\hfil\fcolorbox{\FObordercolor}{\FObackgroundcolor}%
       {\box\BlockBox}\hfil}\vfil}%
   \fi
  \else
   \vbox to \@tempdima{\hsize#1\parindent\z@\vfil
   \ifdim\FOborderbeforewidth>\z@
    {\color{\FOborderbeforecolor}%
    \vrule width #1 depth \z@ height \FOborderbeforewidth}%
   \fi
   \hbox{%
   \hskip\XFOstartindent
   \hskip\FOmarginleft
   \ifdim\FOborderstartwidth>\z@
      {\color{\FOborderstartcolor}%
     \vrule width \FOborderstartwidth height \the\@tempdima}%
   \fi
   \hskip\FOpaddingstart
   \ifx\FObackgroundcolor\att@transparent
      \hbox{\box\BlockBox}%
   \else
      \colorbox{\FObackgroundcolor}%
              {\box\BlockBox}%
   \fi
   \hskip\FOpaddingend
   \ifdim\FOborderendwidth>\z@
    {\color{\FOborderendcolor}%
    \vrule width \FOborderendwidth depth \z@ height
      \the\@tempdima}%
   \fi
   \hskip\FOmarginright
   \hskip\XFOendindent
   }%
   \ifdim\FOborderafterwidth>\z@
    {\color{\FOborderaftercolor}%
     \vrule width #1 depth \z@ height \FOborderafterwidth }%
   \fi
   \vfil
   }%
  \fi
}

\def\FOBorderBottom{%
  \ifx\FOborderafterstyle\att@solid
   \ifx\FOborderafterwidth\att@thin\def\FOborderafterwidth{0.4pt}\fi
   \ifx\FOborderafterwidth\att@medium\def\FOborderafterwidth{0.8pt}\fi
   \ifx\FOborderafterwidth\att@thick\def\FOborderafterwidth{1.2pt}\fi
  \else
   \def\FOborderafterwidth{\z@}%
  \fi
  \ifx\FOborderbeforestyle\att@solid
   \ifx\FOborderbeforewidth\att@thin\def\FOborderbeforewidth{0.4pt}\fi
   \ifx\FOborderbeforewidth\att@medium\def\FOborderbeforewidth{0.8pt}\fi
   \ifx\FOborderbeforewidth\att@thick\def\FOborderbeforewidth{1.2pt}\fi
   \FOBlockGrabtrue
  \else
   \def\FOborderbeforewidth{\z@}%
  \fi
   \ifdim\FOborderafterwidth>\z@
    \ifx\FOborderafterstyle\att@solid
      {\color{\FObordercolor}\hrule height \FOborderafterwidth}%
    \fi
   \fi
}

\def\FOBorderTop{%
  \ifdim\FOborderbeforewidth>\z@
   \ifx\FOborderbeforestyle\att@solid
    {\color{\FObordercolor}\hrule height \FOborderbeforewidth}%
   \fi
 \fi
}

\def\FOfootnotemark{\protect\@FOfootnotemark}
\def\@FOfootnotemark#1{% tag
    \def\@thefnmark{#1}%
    \expandafter\let\csname p@footnote\endcsname\relax
    \@footnotemark%
}
\def\FOfootnotetext{\protect\@FOfootnotetext}
\def\@FOfootnotetext#1#2{% plain tag and text, no interpretation
  \def\@thefnmark{#1}%
  \expandafter\let\csname p@footnote\endcsname\relax
  \@footnotetext{\FOlabel#2}}

\def\start@strut{%
        \vrule height \ht\strutbox depth \dp\strutbox width \z@\relax
}

\def\FOplainfootmark#1{#1}

\newtoks\sav@everypar
\newbox\sav@labels

%\showboxbreadth10
%\showboxdepth10
\gdef \@makecol {%
   \ifvoid\footins
     \setbox\@outputbox \box\@cclv
   \else
%       \showbox\footins
     \setbox\@outputbox \vbox {%
       \boxmaxdepth \@maxdepth
       \@tempdima\dp\@cclv
       \unvbox \@cclv
       \vskip \skip\footins
       \color@begingroup
         \normalcolor
         \footnoterule
         \unvbox \footins
       \color@endgroup
       }%
   \fi
   \xdef\@freelist{\@freelist\@midlist}%
   \global \let \@midlist \@empty
   \@combinefloats
   \ifvbox\@kludgeins
     \@makespecialcolbox
   \else
     \setbox\@outputbox \vbox to\@colht {%
       \@texttop
       \dimen@ \dp\@outputbox
       \unvbox \@outputbox
       \vskip -\dimen@
       \@textbottom
       }%
   \fi
   \global \maxdepth \@maxdepth
}

\long\def\FOplainfoottext#1{%
        \insert\footins{\relax
        \reset@font\footnotesize
        \FORestoreFontSize
        \size@update
        \interlinepenalty\interfootnotelinepenalty
        \splittopskip0pt\relax
        \splitmaxdepth \dp\strutbox \floatingpenalty \@MM
        \hsize\columnwidth\@parboxrestore
        \color@begingroup\InInsertiontrue
        \xdef\Sav@FOListBlocks{\the\FOListBlocks}\FOListBlocks0\relax
        \global\let\sav@if@inlabel\if@inlabel
        \global\let\sav@if@nobreak\if@nobreak
        \global\let\sav@if@newlist\if@newlist
        \global\setbox\sav@labels\box\@labels
        \expandafter\global\expandafter\sav@everypar\expandafter{\the\everypar}\global\everypar{}\relax
        \FOinList0\relax
        \FOListBodyfalse
        #1\ifhmode\nobreak\fi
        \global\FOListBlocks\Sav@FOListBlocks\relax
        \global\let\if@inlabel\sav@if@inlabel
        \global\let\if@nobreak\sav@if@nobreak
        \global\let\if@newlist\sav@if@newlist
        \global\setbox\@labels\box\sav@labels
        \expandafter\global\expandafter\everypar\expandafter{\the\sav@everypar}\relax
        %\vskip\lineskip
        \color@endgroup}%
}
\let\FOfoottext\FOplainfoottext

\def\FOboxedfoottext#1{
        \edef\boxedfootnotetext{\the\BoxedFootnotes\noexpand\FOplainfoottext}%
        \global\BoxedFootnotes=\expandafter{\boxedfootnotetext{#1}}%
}

\def\FOnofoottext#1{}

\ColSpecs={}%
\NCols0
\RowCount0
\def\doTable#1\\#2{%
  \par
  \advance\leftskip by  \FOpaddingstart
  \advance\rightskip by \FOpaddingend
  \advance\rightskip by \FOmarginright
  \advance\leftskip by  \FOmarginleft
  \FOSetFont{normal}%
  \csname LTleft@\FOtextalign\endcsname
  \csname LTright@\FOtextalign\endcsname
%\typeout{LT: \FOtextalign, \the\LTleft, \the\LTright}%
  \FOlabel
  \ifnum\NColumns>1
    \tabular{#1}
  \else
    \ifnum\FOTableNesting>1
      \tabular{#1}%
    \else
      \longtable{#1}%
    \fi
  \fi
  #2}

\newdimen\@default
\@default=10pt

% set up hyphenation and font-related things
\def\LastLanguage{(undefined)}
\selectlanguage{english}

\def\LoadLanguage#1{%
 \begingroup\utfeight@protect@chars\xdef\newL{#1}\endgroup
% \@ifundefined{L@\newL}{%
%  \DEBUG{WARNING: unknown language \newL, loading english}%
%  \csname L@us\endcsname
% }{%
  \ifx\newL\LastLanguage
  \else
    \DEBUG{\the\inputlineno: hyphenation \newL, to replace \LastLanguage}%
    \csname L@\newL\endcsname
  \fi
%}
\edef\LastLanguage{\newL}}

\def\FoTeXSetSpacingStyle{%
  \ifx\FoTeXSpacingStyle\att@french
          \frenchspacing
          \typeout{INFO: Using french-spacing in document}%
  \else
          \typeout{INFO: Using normal, i.e. nonfrench-spacing in document}%
          %\nonfrenchspacing
  \fi
}
\def\FOSetHyphenation{%
  \ifx\FOhyphenate\att@true
     \LoadLanguage{\FOlanguage}%
     \hyphenpenalty=\exhyphenpenalty
  \else
      \hyphenpenalty=10000
  \fi
}
\def\FOSetFont#1{%
 \FOSetHyphenation
 \edef\LaTeXshape{\csname Width@\FOfontstretch\endcsname
      \csname Weight@\FOfontweight\endcsname}%
 \ifx\LaTeXshape\@empty\def\LaTeXshape{m}\fi
\edef\fFamName{\FOfontfamily}%
\DEBUG{#1: \FOfontweight, \FOfontstyle,
  \FOfontsize, \FOtextalign, \LaTeXshape}%
 \edef\f@series{\LaTeXshape}%
 \edef\f@shape{\csname Posture@\FOfontstyle\endcsname}%
 \ifx\FOfontvariant\att@smallcaps
   \def\f@shape{sc}%
 \fi
 \let\f@family\relax
 \@for\FOfoo:=\FOfontfamily\do{%
    \ifx\f@family\relax
    \expandafter\let\expandafter\f@family
         \csname Family@\FOfoo\endcsname
    \fi}%
    \ifx\f@family\relax
      \def\f@family{\csname Family@\Defaultx@fontfamily\endcsname}%
    \fi
 \FOSetFontSize
 \selectfont
 \ifx\FOcolor\@empty
 \else
   \color{\FOcolor}%
 \fi
}
\expandafter\def\csname size-xx-small\endcsname{7pt}
\expandafter\def\csname size-x-small\endcsname{8pt}
\expandafter\def\csname size-small\endcsname{9pt}
\expandafter\def\csname size-medium\endcsname{10pt}
\expandafter\def\csname size-large\endcsname{14.4pt}
\expandafter\def\csname size-x-large\endcsname{18pt}
\expandafter\def\csname size-xx-large\endcsname{20pt}
\def\computeFOfontsize{%
  \expandafter\ifx\csname size-\FOfontsize\endcsname\relax
    \PlayWithFSize\FOfontsize
  \else
    \edef\FOfontsizefinal{\csname size-\FOfontsize\endcsname}%
  \fi
}
\def\FOSetFootFont{%
 \computeFOfontsize
 \ifx\FOlineheight\att@normal
   \@tempdima\FOfontsizefinal
   \multiply\@tempdima by 12
   \divide\@tempdima by 10
   \set@fontsize\FOfootnotesize{\FOfontsizefinal}{\@tempdima}%
 \else
   \@setfontsize\FOfootnotesize{\FOfontsizefinal}{\FOlineheight}%
 \fi
}
\def\FOSetFontSize{%
 \computeFOfontsize
 \ifx\FOlineheight\att@normal
   \@tempdima\FOfontsizefinal
   \multiply\@tempdima by 12
   \divide\@tempdima by 10
   \set@fontsize\baselinestretch{\FOfontsizefinal}{\@tempdima}%
 \else
   \set@fontsize\baselinestretch{\FOfontsizefinal}{\FOlineheight}%
 \fi
}
\def\FOSaveFontSize{%
 \computeFOfontsize
 \ifx\FOlineheight\att@normal
   \@tempdima\FOfontsizefinal
   \multiply\@tempdima by 12
   \divide\@tempdima by 10
   \xdef\FORestoreFontSize{\noexpand\set@fontsize\noexpand\baselinestretch{\FOfontsizefinal}{\the\@tempdima}}%
 \else
   \xdef\FORestoreFontSize{\noexpand\set@fontsize\noexpand\baselinestretch{\FOfontsizefinal}{\FOlineheight}}%
 \fi
}


\DeclareRobustCommand*\textsubscript[1]{%
  \@textsubscript{\selectfont#1}}
%\def\@textsubscript#1{%
% {\m@th\ensuremath{_{\mbox{\fontsize\sf@size\z@#1}}}}}
\def\@textsubscript#1{%
  {\m@th\ensuremath{_{\mbox{#1}}}}}
\def\@textsuperscript#1{%
  {\m@th\ensuremath{^{\mbox{#1}}}}}
\def\reserved@e{}

\def\FOSetPage{%
 \global\bottommargin\Marginbottom
% \headsep\Margintop
 \global\headsep\z@
 \global\topmargin\MasterTopMargin
 \global\advance\topmargin by \SpecialOffset
 \global\textheight\paperheight
 \global\textwidth\paperwidth
% \advance\textheight by -\FirstHeadExtent
% \advance\textheight by -\FirstTailExtent
 \global\advance\textheight by -\MasterTopMargin
% \advance\textheight by -\Margintop
 \global\advance\textheight by -\MasterBottomMargin
% \advance\textheight by -\Marginbottom
 \global\advance\textwidth by -\MasterLeftMargin
 \global\advance\textwidth by -\MasterRightMargin
 \FOpdfsetpagesize{\paperwidth}{\paperheight}
 \global\@colht\textheight
 \global\@colroom\textheight
 \global\vsize\textheight
 \global\columnwidth\textwidth
 \global\hsize\columnwidth
 \global\linewidth\hsize
 \gdef\headheight{12pt}%
% if we are in the middle of a list, we have to redo some of the list assignments
 \FOResetPageParts
    \DEBUG{Page size is \the\textwidth/\the\textheight,
  on paper   \the\paperwidth/\the\paperheight,^^J
  with paper margins \the\MasterRightMargin/\the\MasterLeftMargin,
  and region margins \the\topmargin/\the\MasterBottomMargin;^^J
  footskip is \the\footskip, headsep is \the\headsep^^J
  evensidemargin \the\evensidemargin, oddsidemargin \the\oddsidemargin}%
}

\def\FOResetPageParts{
        \expandafter\ifx\csname This@LineWidth\endcsname\relax\else
                \global\linewidth\This@LineWidth\relax
        \fi
}

% don't ask
\def\supppdf{supp-pdf}
\let\FOinputIfFileExists\InputIfFileExists
\def\InputIfFileExists#1#2#3{%
 {\def\@tempa{#1}\ifx\@tempa\supppdf\else
   \FOinputIfFileExists{#1}{#2}{#3}\fi}}
%\catcode`^^M=10
\providecommand\textasciitilde{~}

\define@key{Gin}{scale}{%
  \if@tempswa
    \edef\@tempa{\toks@{\noexpand\Gscale@box{#1}[#1]{\the\toks@}}}%
    \@tempa
  \else
    \def\Gin@req@sizes{%
      \def\Gin@scalex{#1}\let\Gin@scaley\Gin@exclamation
      \Gin@req@height\Gin@scalex\Gin@nat@height
      \Gin@req@width\Gin@scalex\Gin@nat@width}%
  \fi
  \@tempswatrue}


\def\usewhitespace{%
 \UnicodeCharacter{13}{ \ignorespaces}%
 \UnicodeCharacter{32}{ \ignorespaces}%
 \UnicodeCharacter{9}{ \ignorespaces}%
}
\def\ignorewhitespace{%
 \UnicodeCharacter{13}{}%
 \UnicodeCharacter{32}{}%
 \UnicodeCharacter{9}{}%
}

% taken from Heiko Oberdiek's epstopdf.sty
% but the redefinitions need to be global
\global\let\orgGin@setfile\Gin@setfile
\global\def\Gin@setfile#1#2#3{%
  \if`\@car #3\relax\@nil
    \let\Gin@base\filename@base
    \immediate\write18{\@cdr #3\@empty\@nil}%
    \orgGin@setfile{#1}{#2}{\filename@base #2}%
  \else
    \orgGin@setfile{#1}{#2}{#3}%
  \fi
}

% support .gif and .eps
\g@addto@macro\Gin@extensions{,.eps}
\g@addto@macro\Gin@extensions{,.gif}
\@namedef{Gin@rule@.eps}#1{{pdf}{.pdf}{`epstopdf #1}}
\@namedef{Gin@rule@.gif}#1{{png}{.png}{`giftopng #1}}
\errorstopmode
\endinput