%%
%% This is file `layouts.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% layouts.dtx  (with options: `lays')
%% 
%% -----------------------------------------------------------------
%%   Author: Peter Wilson (Herries Press)
%%   Maintainer: Will Robertson (will dot robertson at latex-project dot org)
%%   Copyright 1998--2004 Peter R. Wilson
%% 
%%   This work may be distributed and/or modified under the
%%   conditions of the LaTeX Project Public License, either
%%   version 1.3c of this license or (at your option) any
%%   later version: <http://www.latex-project.org/lppl.txt>
%% 
%%   This work has the LPPL maintenance status "maintained".
%%   The Current Maintainer of this work is Will Robertson.
%% 
%%   This work consists of the files listed in the README file.
%% -----------------------------------------------------------------
%% 
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{layouts}[2009/09/02 v2.6d graphical depiction of document elements]

\@ifundefined{bs}{\newcommand{\bs}{\texttt{\char`\\}}}%
  {\renewcommand{\bs}{\texttt{\char`\\}}}

\newcommand{\l@yoneinch}{72}
\newcommand{\l@yeighthalfinch}{615}
\newcommand{\l@yteninch}{723}
\newcommand{\l@yeleveninch}{795}
\newcommand{\l@yonepoint}{65536}
\newcommand{\l@youtscale}{0.5}

\newlength{\l@ylen}
\newsavebox{\layoutsbox}
\newlength{\l@youtunitlength}
\newlength{\l@youtlinethick}
\newlength{\l@youtlinethickii}

\newlength{\l@ysetupparskip}
\newlength{\l@ysetupbaselineskip}

\newlength{\l@yonem}
\newlength{\l@yonex}

\newlength{\l@ylmarg}
\newlength{\l@yrmarg}
\newlength{\l@yitmindent}
\newlength{\l@ylblwidth}
\newlength{\l@ylblsep}
\newlength{\l@ylparindent}
\newlength{\l@ytsep}
\newlength{\l@ypskip}
\newlength{\l@yptsep}
\newlength{\l@ypsep}
\newlength{\l@yitmsep}

\newtoks\l@ytok

\newcount\l@youtpw
\newcount\l@youtph

\newcount\l@youthpi
\newcount\l@youthpii
\newcount\l@youthpiii
\newcount\l@youthpiv
\newcount\l@youthpv
\newcount\l@youthpvi
\newcount\l@youthpvii

\newcount\l@youtparskip
\newcount\l@youtvpi
\newcount\l@youtvpii
\newcount\l@youtvpiii
\newcount\l@youtvpiv
\newcount\l@youtvpv
\newcount\l@youtvpvi
\newcount\l@youtvpvii

\newcount\l@youthdo
\newcount\l@youthdi
\newcount\l@youthdii
\newcount\l@youthdiii
\newcount\l@youthdiv
\newcount\l@youthdv
\newcount\l@youthdvi
\newcount\l@youthdvii

\newcount\l@youtvdo
\newcount\l@youtvdi
\newcount\l@youtvdii
\newcount\l@youtvdiii
\newcount\l@youtvdiv
\newcount\l@youtvdv
\newcount\l@youtvdvi
\newcount\l@youtvdvii
\newcount\l@youtvdviii

\newcount\l@youtxci
\newcount\l@youtxcii
\newcount\l@youtxciii
\newcount\l@youtxciv
\newcount\l@youtxcv
\newcount\l@youtxcvi

\newcount\l@youtyci
\newcount\l@youtycii
\newcount\l@youtyciii
\newcount\l@youtyciv
\newcount\l@youtycv
\newcount\l@youtycvi
\newcount\l@youtycvii
\newcount\l@youtycviii

\newcount\l@youtxco
\newcount\l@youtyco

\newif\ifoddpagelayout
  \oddpagelayouttrue
\newif\iftwocolumnlayout
  \twocolumnlayoutfalse
\newif\ifdrawmarginpars
  \drawmarginparstrue
\newif\ifdrawparameters
  \drawparameterstrue
\newif\iflistaspara
  \listasparatrue
\newif\ifruninhead
  \runinheadfalse
\newif\ifprintparameters
  \printparameterstrue
\newif\ifdrawdimensions
  \drawdimensionsfalse
\newif\ifprintheadings
  \printheadingstrue
\newif\ifl@ytempif
\newcommand{\l@yor}[2]{%
  \l@ytempiftrue
  #1
  \else
    #2
    \else
      \l@ytempiffalse
    \fi
  \fi}
\newcommand{\l@ynnand}[2]{%
  \l@ytempiffalse
  #1
  \else
    #2
     \l@ytempiftrue
    \fi
  \fi}
\newcommand{\l@ynox}[2]{%
  \l@ytempiftrue
  #1
    #2
    \else
      \l@ytempiffalse
    \fi
  \fi}
\newcommand{\testdrawdimensions}{%
  \l@yor{\ifdrawparameters}{\ifdrawdimensions}}
\newcommand{\testprintparameters}{%
  \l@ynnand{\ifdrawparameters}{\ifprintparameters}}

\newcommand{\setlabelfont}[1]{\renewcommand{\l@ylabelfont}{#1}}
  \newcommand{\l@ylabelfont}{\normalfont}
\newcommand{\setparametertextfont}[1]{\renewcommand{\l@yparamfont}{#1}}
  \newcommand{\l@yparamfont}{\footnotesize}
\newcommand{\setvaluestextsize}[1]{\renewcommand{\l@yvalsize}{#1}}
  \newcommand{\l@yvalsize}{\normalsize}
\newcommand{\setlayoutscale}[1]{\setlength{\l@youtunitlength}{1pt}
  \l@youtunitlength = #1\l@youtunitlength
  \renewcommand{\l@youtscale}{#1}
  \PackageWarning{layouts}{Layout scale set to #1}}
%%%\setlayoutscale{0.5}
\newcommand{\setuplayouts}{%
  \setlength{\l@ysetupparskip}{\parskip}
  \setlength{\l@ysetupbaselineskip}{\baselineskip}
  \setlength{\l@yonem}{1em}
  \setlength{\l@yonex}{1ex}
  \setlayoutscale{0.5}
%%%  \PackageWarning{layouts}{Layout scale set to 0.5}
}
\AtBeginDocument{\setuplayouts}
\newcommand{\l@yltoc}[2]{\setlength{\l@ylen}{#1}%
                         \ifdim\l@ylen > \z@ \advance\l@ylen by 0.5\p@ \else
                           \ifdim\l@ylen < \z@ \advance\l@ylen by -0.5\p@
                           \fi
                         \fi
                         #2=\l@ylen
                         \divide #2 by \l@yonepoint\relax}
\newcommand{\l@yvuda}[3]{\put(#1,#2){\vector(0,1){#3}}
                         \put(#1,#2){\vector(0,-1){0}}}
\newcommand{\l@yhrda}[3]{\put(#1,#2){\vector(1,0){#3}}
                         \put(#1,#2){\vector(-1,0){0}}}
\newcommand{\l@yvudia}[3]{\begingroup
                          \l@youthpvii=#1\relax
                          \l@youtvpvii=#2\relax
                          \l@youthdvii=#3\relax
                          \put(\l@youthpvii,\l@youtvpvii){\vector(0,1){0}}
                          \advance\l@youtvpvii by \l@youthdvii
                          \put(\l@youthpvii,\l@youtvpvii){\vector(0,-1){0}}
                          \endgroup}
\newcommand{\l@yhrdia}[3]{\begingroup
                          \l@youthpvii=#1\relax
                          \l@youtvpvii=#2\relax
                          \l@youthdvii=#3\relax
                          \put(\l@youthpvii,\l@youtvpvii){\vector(1,0){0}}
                          \advance\l@youthpvii by \l@youthdvii
                          \put(\l@youthpvii,\l@youtvpvii){\vector(-1,0){0}}
                          \endgroup}
\newcommand{\l@ypcmd}[1]{{\l@yparamfont\texttt{\bs #1}}}
\newcommand{\l@ycmd}[1]{\texttt{\bs #1}}

\newcommand{\printinunitsof}[1]{%
  \def\l@yunitperpt{1.0}\def\l@yunits{pt}%
  \def\l@yta{#1}\def\l@ytb{pt}%
  \ifx \l@yta\l@ytb
    \def\l@yunitperpt{1.0}\def\l@yunits{pt}%
  \else
    \def\l@ytb{pc}%
    \ifx \l@yta\l@ytb
      \def\l@yunitperpt{0.083333}\def\l@yunits{pc}%
    \else
      \def\l@ytb{in}%
      \ifx \l@yta\l@ytb
        \def\l@yunitperpt{0.013837}\def\l@yunits{in}%
      \else
        \def\l@ytb{mm}%
        \ifx \l@yta\l@ytb
          \def\l@yunitperpt{0.351459}\def\l@yunits{mm}%
        \else
          \def\l@ytb{cm}%
          \ifx \l@yta\l@ytb
            \def\l@yunitperpt{0.0351459}\def\l@yunits{cm}%
          \else
            \def\l@ytb{bp}%
            \ifx \l@yta\l@ytb
              \def\l@yunitperpt{0.996264}\def\l@yunits{bp}%
            \else
              \def\l@ytb{dd}%
              \ifx \l@yta\l@ytb
                \def\l@yunitperpt{0.9345718}\def\l@yunits{dd}%
              \else
                \def\l@ytb{cc}%
                \ifx \l@yta\l@ytb
                  \def\l@yunitperpt{0.0778809}\def\l@yunits{cc}%
                \else
                  \def\l@ytb{PT}%
                  \ifx \l@yta\l@ytb
                    \def\l@yunitperpt{1.0}\def\l@yunits{PT}%
                  \fi
                \fi
              \fi
            \fi
          \fi
        \fi
      \fi
    \fi
  \fi
}
\printinunitsof{pt}

\newlength{\l@ytempdima}
\newcommand{\prntlen}[1]{%
  \def\l@yta{pt}\ifx\l@yta\l@yunits\the#1\else
    \def\l@yta{PT}%
    \l@ytempdima=\l@yunitperpt #1\relax\strip@pt\l@ytempdima
      \ifx\l@yta\l@yunits pt\else\l@yunits\fi\fi}

%%% \newcommand{\l@yval}[1]{\the#1}
\newcommand{\l@yval}[1]{\prntlen{#1}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%    PAGE LAYOUT
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\trypaperwidth}[1]{\l@yltoc{#1}{\l@youtpw}}
\newcommand{\trypaperheight}[1]{\l@yltoc{#1}{\l@youtph}}
\newcommand{\tryhoffset}[1]{\l@yltoc{#1}{\l@youthpi}}
\newcommand{\tryvoffset}[1]{\l@yltoc{#1}{\l@youtvpi}}
\newcommand{\trytopmargin}[1]{\l@yltoc{#1}{\l@youtvpii}}
\newcommand{\tryheadheight}[1]{\l@yltoc{#1}{\l@youtvpiii}}
\newcommand{\tryheadsep}[1]{\l@yltoc{#1}{\l@youtvpiv}}
\newcommand{\trytextheight}[1]{\l@yltoc{#1}{\l@youtvpv}}
\newcommand{\tryfootskip}[1]{\l@yltoc{#1}{\l@youtvpvi}}
\newcommand{\tryoddsidemargin}[1]{\l@yltoc{#1}{\l@youthpv}}
\newcommand{\tryevensidemargin}[1]{\l@yltoc{#1}{\l@youthpiv}}
\newcommand{\trytextwidth}[1]{\l@yltoc{#1}{\l@youthpii}}
\newcommand{\trymarginparsep}[1]{\l@yltoc{#1}{\l@youthpvi}}
\newcommand{\trymarginparwidth}[1]{\l@yltoc{#1}{\l@youthpvii}}
\newcommand{\trymarginparpush}[1]{\l@yltoc{#1}{\l@youtvpvii}}
\newcommand{\trycolumnsep}[1]{\l@yltoc{#1}{\l@youthpiii}}
\newcommand{\trycolumnseprule}[1]{\setlength{\l@youtlinethick}{#1}}
\newcommand{\setfootbox}[2]{\l@yltoc{#1}{\l@youtvdv}\l@yltoc{#2}{\l@youtvdvi}}
\newif\ifreversemarginpar
  \reversemarginparfalse
\newif\ifmarginparswitch
  \marginparswitchtrue

\newif\ifl@yrightmpars
  \l@yrightmparstrue
\newcommand{\currentpage}{%
  \@ifundefined{paperwidth}{\trypaperwidth{8.5in}}%
    {\trypaperwidth{\paperwidth}}%
  \@ifundefined{paperheight}{\trypaperheight{11in}}%
    {\trypaperheight{\paperheight}}%
  \tryhoffset{\hoffset}%               % typically 0pt
  \tryvoffset{\voffset}%               % typically 0pt
  \tryoddsidemargin{\oddsidemargin}%   % typically 21-63pt
  \tryevensidemargin{\evensidemargin}% % typically 39-82pt
  \trytopmargin{\topmargin}%           % typically 27pt
  \commonl@ypage%
}
\newcommand{\commonl@ypage}{%
  \trymarginparwidth{\marginparwidth}% % typically 68-107pt
  \trymarginparsep{\marginparsep}%     % typically 10-11pt
  \trymarginparpush{\marginparpush}%   % typically 5-7pt
  \tryheadheight{\headheight}%         % typically 12pt
  \tryheadsep{\headsep}%               % typically 25pt
  \tryfootskip{\footskip}%             % typically 30pt
  \trytextheight{\textheight}%         % typically 36-43 times baselineskip
  \trytextwidth{\textwidth}%           % typically 345-390pt
  \trycolumnsep{\columnsep}%           % typically 10pt
  \trycolumnseprule{\columnseprule}%   % typically 0pt
  \setfootbox{\baselineskip}{0pt}%     % footheight = 1 line
  \reversemarginparfalse               % reversemargin
  \if@reversemargin \reversemarginpartrue \fi
  \marginparswitchfalse               % mparswitch
  \if@mparswitch \marginparswitchtrue \fi
  \twocolumnlayoutfalse
  \if@twocolumn \twocolumnlayouttrue \fi
  \oddpagelayouttrue
  \if@twoside
    \ifodd\count\z@
    \else
      \oddpagelayoutfalse
    \fi
  \fi
}
\newcommand{\drawpage}{%
  \l@youtvdiii=\l@yteninch\relax
    \divide\l@youtvdiii by 24\relax
  \l@youthdii=\l@youtvdiii
  \ifdrawparameters
    \l@youtph=\l@yeleveninch\relax     % page height
    \l@youtpw=\l@yeighthalfinch\relax  % page width
    \l@youtvpi=\z@                  % voffset
    \l@youtvpii=\l@youtvdiii        % topmargin
    \l@youtvpiii=\l@youtvdiii       % headheight
    \l@youtvpiv=\l@youtvdiii        % headsep
    \l@youtvpv=\l@yoneinch\relax       % textheight
      \multiply\l@youtvpv by 6\relax
    \l@youtvpvi=\l@youtvdiii        % footskip
      \multiply\l@youtvpvi by \tw@
    \l@youtvdv=\l@youtvdiii         % default footboxheight
    \l@youtvdvi=\z@                 % default footboxdepth
    \l@youtvpvii=\l@youtvdiii       % marginparpush
    \l@youthpi=\z@            % hoffset
    \l@youthpii=\l@youthdii   % textwidth
      \multiply\l@youthpii by 13\relax
    \l@youthpiii=\l@youthdii  % columnsep
    \l@youthpiv=\l@youthdii   % evensidemargin
    \l@youthpv=\l@youthdii    % oddsidemargin
    \l@youthpvi=\l@youthdii   % marginparsep
    \l@youthpvii=\l@youthdii  % marginparwidth
      \multiply\l@youthpvii by \tw@
  \fi
  \l@youtycvi=\l@youtph                  % one inch below top of page
    \advance\l@youtycvi by -\l@yoneinch\relax
  \l@youtxci=\l@youthpi                  % hofref
    \advance\l@youtxci by \l@yoneinch\relax
  \l@youtycv=\l@youtycvi                 % vofref
    \advance\l@youtycv by -\l@youtvpi
  \l@youtyciv=\l@youtycv                 % headref
    \advance\l@youtyciv by -\l@youtvpii
    \advance\l@youtyciv by -\l@youtvpiii
  \l@youtycii=\l@youtyciv                % bodyref
    \advance\l@youtycii by -\l@youtvpiv
    \advance\l@youtycii by -\l@youtvpv
  \ifnum\l@youtvdv>\l@youtvpvi
    \PackageWarning{layouts}{The footbox is higher than the footskip}
    \l@youtvdv=\l@youtvpvi
  \fi
  \l@youtyci=\l@youtycii                 % footref
    \advance\l@youtyci by -\l@youtvpvi
    \advance\l@youtyci by -\l@youtvdvi   % box depth
  \l@youtvdvii=\l@youtvdv                % box height
    \advance\l@youtvdvii by \l@youtvdvi  % plus depth
  \l@youtvdii=\l@youtvpv                 % noteheight
    \divide\l@youtvdii by 4\relax
  \l@youtyciii=\l@youtycii               % noteref
    \advance\l@youtyciii by \l@youtvdii
    \advance\l@youtyciii by \l@youtvpvii
  \l@youtxcii=\l@youtxci                 % marginref
  \ifoddpagelayout
    \advance\l@youtxcii by \l@youthpv
  \else
    \advance\l@youtxcii by \l@youthpiv
  \fi
  \l@youtxciv=\l@youtxcii                % margnoteref
  \@tempcnta\@ne
  \ifmarginparswitch
    \ifoddpagelayout \else \@tempcnta\m@ne \fi
  \fi
  \ifreversemarginpar \@tempcnta -\@tempcnta \fi
  \ifnum\@tempcnta > \z@
    \l@yrightmparstrue
    \advance\l@youtxciv by \l@youthpii
    \advance\l@youtxciv by \l@youthpvi
  \else
    \l@yrightmparsfalse
    \advance\l@youtxciv by -\l@youthpvi
    \advance\l@youtxciv by -\l@youthpvii
  \fi
  \l@youthdi=\l@youthpii                 % columnwidth
  \l@youtxciii=\l@youtxcii               % colref
  \iftwocolumnlayout
    \advance\l@youthdi by -\l@youthpiii
    \divide\l@youthdi by \tw@
    \advance\l@youtxciii by \l@youthdi
    \advance\l@youtxciii by \l@youthpiii
    \l@youtxcv=\l@youthpiii              % centre of gutter
      \divide\l@youtxcv by \tw@
      \advance\l@youtxcv by \l@youtxcii
      \advance\l@youtxcv by \l@youthdi
  \fi
  \l@yor{\ifdrawparameters}{\ifprintheadings}
  \begin{center}
  \ifl@ytempif
  \begin{small} The circle is at 1 inch from the top and left of the
    page. Dashed lines represent (\texttt{\bs hoffset + 1 inch}) and
    (\texttt{\bs voffset + 1 inch}) from the top and left of the
    page.
  \end{small} \\
  \medskip
  \fi
  \setlength{\unitlength}{\l@youtunitlength}
  \begin{picture}(\l@youtpw,\l@youtph)
    \thicklines
    \ifdrawparameters
      \put(0,0){\line(0,1){\l@youtph}}
      \put(0,\l@youtph){\line(1,0){\l@youtpw}}
    \else
      \put(0,0){\framebox(\l@youtpw,\l@youtph){}}
    \fi
    \put(\l@yoneinch,\l@youtycvi){\circle{12}}
    \put(0,\l@youtycv){\dashbox{10}(\l@youtpw,0){}}
    \put(\l@youtxci,0){\dashbox{10}(0,\l@youtph){}}
    \put(\l@youtxcii,\l@youtyciv){\framebox(\l@youthpii,\l@youtvpiii)%
      {\l@ylabelfont Header}}
    \iftwocolumnlayout
      \put(\l@youtxcii,\l@youtycii){\framebox(\l@youthdi,\l@youtvpv)%
        {\l@ylabelfont Col. 1}}
      \put(\l@youtxciii,\l@youtycii){\framebox(\l@youthdi,\l@youtvpv)%
        {\l@ylabelfont Col. 2}}
      \linethickness{\l@youtscale\l@youtlinethick}
      \put(\l@youtxcv,\l@youtycii){\line(0,1){\l@youtvpv}}
      \thicklines
    \else
      \put(\l@youtxcii,\l@youtycii){\framebox(\l@youthpii,\l@youtvpv)%
        {\l@ylabelfont Body}}
    \fi
    \put(\l@youtxcii,\l@youtyci){\framebox(\l@youthpii,\l@youtvdvii)%
        {\l@ylabelfont Footer}}
    \ifdrawmarginpars
      \ifdrawparameters
        \put(\l@youtxciv,\l@youtycii){\framebox(\l@youthpvii,\l@youtvdii){}}
        \put(\l@youtxciv,\l@youtyciii){\framebox(\l@youthpvii,\l@youtvdii)%
          {\l@ylabelfont\shortstack{Margin\\Note}}}
      \else
        \put(\l@youtxciv,\l@youtycii){\framebox(\l@youthpvii,\l@youtvdii)%
          {\l@ylabelfont Note}}
        \put(\l@youtxciv,\l@youtyciii){\framebox(\l@youthpvii,\l@youtvdii)%
          {\l@ylabelfont Margin}}
      \fi
    \fi
    \ifnum\l@youtvdvi > \z@
      \thinlines
      \advance\l@youtyci by \l@youtvdvi
      \put(\l@youtxcii,\l@youtyci){\dashbox{10}(\l@youthpii,0){}}
    \fi
    \testdrawdimensions
    \ifl@ytempif
      \thinlines
      \l@youtxcv=\l@youtxcii                % X coord for vertical dimensions
        \advance\l@youtxcv by \l@youthdii
      \l@youtxcvi=\l@youthpvii              % X coord for marginparpush
        \divide\l@youtxcvi by \tw@
        \advance\l@youtxcvi by \l@youtxciv
      \l@youtvdviii=\l@youtvdiii             % half l@youtvdiii
        \divide\l@youtvdviii by \tw@
      \l@youtycvii=\l@youtycii              % Y coord for low dimensions
        \advance\l@youtycvii by \l@youtvdiii
      \l@youtycviii=\l@youtycvii              % Y coord for mid dimensions
        \advance\l@youtycviii by \l@youtvdiii
      \l@youtvdi=\l@youtvpv                 % Y coord for top dimensions
        \multiply\l@youtvdi by \tw@
        \divide\l@youtvdi by 3\relax
        \advance\l@youtvdi by \l@youtycii
      \put(\l@youtxcv,\l@youtycv){\vector(0,-1){\l@youtvpii}}
      \put(\l@youtxcv,\l@youtycv){\begin{picture}(\l@youtvdviii,\l@youtvdviii)
        \put(\l@youtvdviii,-\l@youtvdviii){\l@ypcmd{topmargin}}
        \end{picture}}
      \put(\l@youtxcv,\l@youtyciv){\line(0,1){\l@youtvpiii}}
      \put(\l@youtxcv,\l@youtyciv){\vector(0,-1){0}}
      \put(\l@youtxcv,\l@youtyciv){\begin{picture}(\l@youtvdviii,\l@youtvdviii)
        \put(\l@youtvdviii,\l@youtvdviii){\l@ypcmd{headheight}}
        \end{picture}}
      \put(\l@youtxcv,\l@youtyciv){\vector(0,-1){\l@youtvpiv}}
      \put(\l@youtxcv,\l@youtyciv){\begin{picture}(\l@youtvdviii,\l@youtvdviii)
        \put(\l@youtvdviii,-\l@youtvdviii){\l@ypcmd{headsep}}
        \end{picture}}
      \put(\l@youtxcv,\l@youtycii){\line(0,1){\l@youtvpv}}
      \put(\l@youtxcv,\l@youtycii){\vector(0,-1){0}}
      \put(\l@youtxcv,\l@youtycii){\begin{picture}(\l@youtvdviii,\l@youtvdviii)
        \put(\l@youtvdviii,\l@youtvdviii){\l@ypcmd{textheight}}
        \end{picture}}
      \put(\l@youtxcv,\l@youtycii){\vector(0,-1){\l@youtvpvi}}
      \put(\l@youtxcv,\l@youtycii){\begin{picture}(\l@youtvdviii,\l@youtvdviii)
        \put(\l@youtvdviii,-\l@youtvdviii){\l@ypcmd{footskip}}
        \end{picture}}
      \ifdrawmarginpars
        \put(\l@youtxcvi,\l@youtyciii){\vector(0,-1){\l@youtvpvii}}
        \put(\l@youtxcvi,\l@youtyciii){\begin{picture}(\l@youtvdviii,\l@youtvdviii)
          \put(\l@youtvdviii,-\l@youtvdviii){\l@ypcmd{marginparpush}}
          \end{picture}}
      \fi
      \ifdrawmarginpars
        \put(\l@youtxciv,\l@youtycvii){\vector(1,0){\l@youthpvii}}
        \put(\l@youtxciv,\l@youtycvii){\begin{picture}(\l@youtvdviii,\l@youtvdviii)
          \put(\l@youtvdviii,\l@youtvdviii){\l@ypcmd{marginparwidth}}
          \end{picture}}
      \fi
      \ifoddpagelayout
        \put(\l@youtxci,\l@youtvdi){\vector(1,0){\l@youthpv}}
      \else
        \put(\l@youtxci,\l@youtvdi){\vector(1,0){\l@youthpiv}}
      \fi
      \put(\l@youtxci,\l@youtvdi){\begin{picture}(\l@youtvdviii,\l@youtvdviii)
      \ifoddpagelayout
        \put(\l@youtvdviii,\l@youtvdviii){\l@ypcmd{oddsidemargin}}
      \else
        \put(\l@youtvdviii,\l@youtvdviii){\l@ypcmd{evensidemargin}}
      \fi
        \end{picture}}
      \ifdrawmarginpars
        \ifl@yrightmpars
          \put(\l@youtxciv,\l@youtycviii){\line(-1,0){\l@youthpvi}}
          \put(\l@youtxciv,\l@youtycviii){\vector(1,0){0}}
          \put(\l@youtxciv,\l@youtycviii){\begin{picture}(\l@youtvdviii,\l@youtvdviii)
            \put(-\l@youtvdviii,\l@youtvdviii){\l@ypcmd{marginparsep}}
            \end{picture}}
        \else
          \put(\l@youtxcii,\l@youtycviii){\vector(-1,0){\l@youthpvi}}
          \put(\l@youtxcii,\l@youtycviii){\begin{picture}(\l@youtvdviii,\l@youtvdviii)
            \put(-\l@youtvdviii,\l@youtvdviii){\l@ypcmd{marginparsep}}
            \end{picture}}
        \fi
      \fi
      \put(\l@youtxcii,\l@youtyciii){\vector(1,0){\l@youthpii}}
      \put(\l@youtxcv,\l@youtyciii){\begin{picture}(\l@youtvdviii,\l@youtvdviii)
        \put(\l@youtvdviii,\l@youtvdviii){\l@ypcmd{textwidth}}
        \end{picture}}
      \iftwocolumnlayout
        \put(\l@youtxciii,\l@youtvdi){\line(-1,0){\l@youthpiii}}
        \put(\l@youtxciii,\l@youtvdi){\vector(1,0){0}}
        \put(\l@youtxciii,\l@youtvdi){\begin{picture}(\l@youtvdviii,\l@youtvdviii)
          \put(-\l@youtvdviii,\l@youtvdviii){\l@ypcmd{columnsep}}
          \end{picture}}
      \fi
    \fi
    \end{picture}
    \end{center}
    \setlength{\unitlength}{1pt}
    \testprintparameters
    \ifl@ytempif
      \begin{center}
      \begin{footnotesize}
         Lengths are to the nearest pt. \\
      \begin{ttfamily}
      \begin{tabular}{l@{\hspace{20pt}}l}
      \textrm{page height}   = \number\l@youtph pt &
      \textrm{page width}    = \number\l@youtpw pt  \\
      \l@ycmd{hoffset}       = \number\l@youthpi pt         &
      \l@ycmd{voffset}       = \number\l@youtvpi pt         \\
      \ifoddpagelayout
        \l@ycmd{oddsidemargin} = \number\l@youthpv pt
      \else
        \l@ycmd{evensidemargin} = \number\l@youthpiv pt
      \fi
      & \l@ycmd{topmargin}   = \number\l@youtvpii pt    \\
      \l@ycmd{headheight}    = \number\l@youtvpiii pt    &
      \l@ycmd{headsep}       = \number\l@youtvpiv pt        \\
      \l@ycmd{textheight}    = \number\l@youtvpv pt      &
      \l@ycmd{textwidth}     = \number\l@youthpii pt      \\
      \l@ycmd{footskip}      = \number\l@youtvpvi pt       &
      \l@ycmd{marginparsep}  = \number\l@youthpvi pt   \\
      \l@ycmd{marginparpush} = \number\l@youtvpvii pt &
      \l@ycmd{columnsep}     = \number\l@youthpiii pt     \\
      \l@ycmd{columnseprule} = \the\l@youtlinethick & \\
      \end{tabular}
      \end{ttfamily}\end{footnotesize}
      \end{center}
    \fi
}

\newcommand{\pagediagram}{\drawparameterstrue\drawpage}
\newcommand{\pagedesign}{\drawparametersfalse\drawpage}

\newcommand{\pagevalues}{%
%%  \begin{center}
  \ifprintheadings
    Actual page layout values.\\[\baselineskip]
  \fi
  \begingroup\l@yvalsize
  \begin{tabular}{l@{\hspace{20pt}}l}
  \l@ycmd{paperheight} = \@ifundefined{paperheight}{??}{\l@yval{\paperheight}}  &
  \l@ycmd{paperwidth}  = \@ifundefined{paperwidth}{??}{\l@yval{\paperwidth}}   \\
  \l@ycmd{hoffset}        = \l@yval{\hoffset}        &
  \l@ycmd{voffset}        = \l@yval{\voffset}        \\
  \l@ycmd{evensidemargin} = \l@yval{\evensidemargin} &
  \l@ycmd{oddsidemargin}  = \l@yval{\oddsidemargin}  \\
  \l@ycmd{topmargin}      = \l@yval{\topmargin}      &
  \l@ycmd{headheight}     = \l@yval{\headheight}     \\
  \l@ycmd{headsep}        = \l@yval{\headsep}        &
  \l@ycmd{textheight}     = \l@yval{\textheight}     \\
  \l@ycmd{textwidth}      = \l@yval{\textwidth}      &
  \l@ycmd{footskip}       = \l@yval{\footskip}       \\
  \l@ycmd{marginparsep}   = \l@yval{\marginparsep}   &
  \l@ycmd{marginparpush}  = \l@yval{\marginparpush}  \\
  \l@ycmd{columnsep}      = \l@yval{\columnsep}      &
  \l@ycmd{columnseprule}  = \l@yval{\columnseprule}  \\
  1em = \l@yval{\l@yonem}  & 1ex = \l@yval{\l@yonex} \\
  \end{tabular}
  \endgroup
%%  \end{center}
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%    STOCK LAYOUT
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\@ifundefined{stockwidth}{\newlength{\stockwidth}}{}
\@ifundefined{stockheight}{\newlength{\stockheight}}{}
\@ifundefined{trimedge}{\newlength{\trimedge}}{}
\@ifundefined{trimtop}{\newlength{\trimtop}}{}
\@ifundefined{uppermargin}{\newlength{\uppermargin}}{}
\@ifundefined{spinemargin}{\newlength{\spinemargin}}{}

\newcommand{\trystockwidth}[1]{\l@yltoc{#1}{\l@youthdo}}
\newcommand{\trystockheight}[1]{\l@yltoc{#1}{\l@youtvdo}}
\newcommand{\trytrimedge}[1]{\l@yltoc{#1}{\l@youthpi}}
\newcommand{\trytrimtop}[1]{\l@yltoc{#1}{\l@youtvpi}}
\newcommand{\tryuppermargin}[1]{\l@yltoc{#1}{\l@youtvpii}}
\newcommand{\tryspinemargin}[1]{\l@yltoc{#1}{\l@youthpv}}

\newcommand{\currentstock}{%
  \trystockwidth{\stockwidth}%         % typically 8.5in
  \trystockheight{\stockheight}%       % typically 11in
  \trypaperwidth{\paperwidth}%         % typically 8.5in
  \trypaperheight{\paperheight}%       % typically 11in
  \trytrimedge{\trimedge}%             % typically 0pt
  \trytrimtop{\trimtop}%               % typically 0pt
  \tryspinemargin{\spinemargin}%       % typically 110pt
  \tryuppermargin{\uppermargin}%       % typically 125pt
  \commonl@ypage
}

\newcommand{\drawstock}{%
  \l@youtvdiii=\l@yteninch\relax
    \divide\l@youtvdiii by 24\relax
  \l@youthdii=\l@youtvdiii

  \ifdrawparameters
    \l@youtvdo=\l@yeleveninch\relax            % stock height
    \l@youthdo=\l@yeighthalfinch\relax         % stock width
    \l@youtvpi=\z@                          % trimtop
      \advance\l@youtvpi by \l@youtvdiii
    \l@youthpi=\z@                          % trimedge
      \advance\l@youthpi by \l@youtvdiii
    \l@youtph=\l@youtvdo                    % page height (= stock height)
      \advance\l@youtph by -\l@youtvpi         % minus trimtop
      \advance\l@youtph by -\l@youtvpi         % minus trimtop
      \advance\l@youtph by -\l@youtvpi         % minus trimtop
    \l@youtpw=\l@youthdo                    % page width (= stock width)
      \advance\l@youtpw by -\l@youthpi         % minus trimedge
      \advance\l@youtpw by -\l@youthpi         % minus trimedge
      \advance\l@youtpw by -\l@youthpi         % minus trimedge
    \l@youtvpiii=\l@youtvdiii               % headheight
    \l@youtvpiv=\l@youtvdiii                % headsep
    \l@youtvpii=\l@youtvdiii                % uppermargin
      \advance\l@youtvpii by \l@yoneinch          % plus 1in
      \advance\l@youtvpii by \l@youtvpiii      % plus headheight
      \advance\l@youtvpii by \l@youtvpiv       % plus headsep
    \l@youtvpv=\l@yoneinch\relax               % textheight
      \multiply\l@youtvpv by 6\relax
    \l@youtvpvi=\l@youtvdiii                % footskip
      \multiply\l@youtvpvi by \tw@
    \l@youtvdv=\l@youtvdiii                 % default footboxheight
    \l@youtvdvi=\z@                         % default footboxdepth
    \l@youtvpvii=\l@youtvdiii               % marginparpush
    \l@youthpii=\l@youthdii                 % textwidth
      \multiply\l@youthpii by 12\relax
    \l@youthpv=\l@youthdii                  % spine margin
      \advance\l@youthpv by \l@yoneinch           % plus 1in
      \multiply\l@youthpv by 7\relax           % and take 70%
      \divide\l@youthpv by 10\relax
    \l@youthpiii=\l@youthdii                % columnsep
    \l@youthpvi=\l@youthdii   % marginparsep
    \l@youthpvii=\l@youthdii  % marginparwidth
      \multiply\l@youthpvii by \tw@
  \fi

  \ifoddpagelayout
    \l@youtxco=\l@youthdo                % X coord of page bottom left (= stockwidth)
      \advance\l@youtxco by -\l@youthpi    % minus trimedge
      \advance\l@youtxco by -\l@youtpw     % minus page width
  \else
    \l@youtxco=\l@youthpi                % X coord of page bottom left = trimedge
  \fi
  \l@youtyco=\l@youtvdo                  % Y coord of page bottom left (= stockheight)
    \advance\l@youtyco by -\l@youtvpi      % minus trimtop
    \advance\l@youtyco by -\l@youtph       % minus page height
  \l@youtxcii=\l@youtxco                 % X coord of left of textblock (= left of page)
  \ifoddpagelayout
      \advance\l@youtxcii by \l@youthpv    % plus spinemargin
  \else
      \advance\l@youtxcii by \l@youtpw     % plus pagewidth
      \advance\l@youtxcii by -\l@youthpv   % minus spinemargin
      \advance\l@youtxcii by -\l@youthpii  % minus textwidth
  \fi
    \l@youtxciv=\l@youtxcii              % X coord of left of marginnote (= left of textblock)
  \l@youtxciv=\l@youtxcii
  \@tempcnta\@ne
  \ifmarginparswitch
    \ifoddpagelayout \else \@tempcnta\m@ne \fi
  \fi
  \ifreversemarginpar \@tempcnta -\@tempcnta \fi
  \ifnum\@tempcnta >\z@
    \l@yrightmparstrue
    \advance\l@youtxciv by \l@youthpii   % plus textwidth
    \advance\l@youtxciv by \l@youthpvi   % plus marginnotesep
  \else
    \l@yrightmparsfalse
    \advance\l@youtxciv by -\l@youthpvii % minus marginparwidth
    \advance\l@youtxciv by -\l@youthpvi  % minus marginnotesep
  \fi
  \l@youtycii=\l@youtvdo                 % Y coord of bottom of text (= stockheight)
    \advance\l@youtycii by -\l@youtvpi     % minus trimtop
    \advance\l@youtycii by -\l@youtvpii    % minus uppermargin
    \advance\l@youtycii by -\l@youtvpv     % minus textheight
  \ifnum\l@youtvdv>\l@youtvpvi
    \PackageWarning{layouts}{The footbox is higher than the footskip}
    \l@youtvdv=\l@youtvpvi
  \fi
  \l@youtyci=\l@youtycii                 % Y coord of bottom of footer (= bottom of text)
    \advance\l@youtyci by -\l@youtvpvi     % minus footskip
    \advance\l@youtyci by -\l@youtvdvi     % minus box depth
  \l@youtvdvii=\l@youtvdv                % box height
    \advance\l@youtvdvii by \l@youtvdvi    % plus depth
  \l@youtyciv=\l@youtycii                % Y coord of bottom of header (= bottom of text)
    \advance\l@youtyciv by \l@youtvpv      % plus textheight
    \advance\l@youtyciv by \l@youtvpiv     % plus headsep

  \l@youtvdii=\l@youtvpv                 % height of a marginal note
    \divide\l@youtvdii by 4\relax
  \l@youtyciii=\l@youtycii               % Y coord of bottom of top note (= bottom of bottom note)
    \advance\l@youtyciii by \l@youtvdii    % plus note height
    \advance\l@youtyciii by \l@youtvpvii   % plus marginparpush
  \l@youthdi=\l@youthpii                 % columnwidth = textwidth
  \l@youtxciii=\l@youtxcii               % X coord of right col
  \iftwocolumnlayout
    \advance\l@youthdi by -\l@youthpiii  % colwidth = textwidth - colsep
    \divide\l@youthdi by \tw@              % divided in half
    \advance\l@youtxciii by \l@youthdi   % X coord of right col X coord of text + col width
      \advance\l@youtxciii by \l@youthpiii % plus colsep
    \l@youtxcv=\l@youthpiii              % centre of gutter
      \divide\l@youtxcv by \tw@
      \advance\l@youtxcv by \l@youtxcii
      \advance\l@youtxcv by \l@youthdi
  \fi
  \begin{center}
  \l@yor{\ifdrawparameters}{\ifprintheadings}
  \ifl@ytempif
    \begin{small} Dashed lines represent the actual page size after trimming
                  the stock. \end{small} \\
    \medskip
  \fi
  \setlength{\unitlength}{\l@youtunitlength}
  \begin{picture}(\l@youthdo,\l@youtvdo)
    \thicklines
    \put(0,0){\framebox(\l@youthdo,\l@youtvdo){}}                        % the stock
    \put(\l@youtxco,\l@youtyco){\dashbox{10}(\l@youtpw,\l@youtph){}}     % the page
    \put(\l@youtxcii,\l@youtyciv){\framebox(\l@youthpii,\l@youtvpiii)%   % the header
      {\l@ylabelfont Header}}
    \iftwocolumnlayout
      \put(\l@youtxcii,\l@youtycii){\framebox(\l@youthdi,\l@youtvpv)%    % col 1
        {\l@ylabelfont Col. 1}}
      \put(\l@youtxciii,\l@youtycii){\framebox(\l@youthdi,\l@youtvpv)%   % col2
        {\l@ylabelfont Col. 2}}
      \linethickness{\l@youtscale\l@youtlinethick}
      \put(\l@youtxcv,\l@youtycii){\line(0,1){\l@youtvpv}}               % rule
      \linethickness{1pt}
    \else
      \put(\l@youtxcii,\l@youtycii){\framebox(\l@youthpii,\l@youtvpv)%   % one col
        {\l@ylabelfont Body}}
    \fi
    \put(\l@youtxcii,\l@youtyci){\framebox(\l@youthpii,\l@youtvdvii)%      % footer
        {\l@ylabelfont Footer}}
    \ifdrawmarginpars
      \ifdrawparameters
        \put(\l@youtxciv,\l@youtycii){\framebox(\l@youthpvii,\l@youtvdii){}}
        \put(\l@youtxciv,\l@youtyciii){\framebox(\l@youthpvii,\l@youtvdii)%
          {\l@ylabelfont\shortstack{Margin\\Note}}}
      \else
        \put(\l@youtxciv,\l@youtycii){\framebox(\l@youthpvii,\l@youtvdii)%
          {\l@ylabelfont Note}}
        \put(\l@youtxciv,\l@youtyciii){\framebox(\l@youthpvii,\l@youtvdii)%
          {\l@ylabelfont Margin}}
      \fi
    \fi

    \ifnum\l@youtvdvi > \z@
      \thinlines
      \advance\l@youtyci by \l@youtvdvi
      \put(\l@youtxcii,\l@youtyci){\dashbox{10}(\l@youthpii,0){}}
    \fi
    \testdrawdimensions
    \ifl@ytempif
      \thinlines
      \l@youtycv=\l@youtyco                 % Y coord of top of page (= page bottom)
        \advance\l@youtycv by \l@youtph       % plus pageheight
      \l@youtvdviii=\l@youtvdiii             % half l@youtvdiii (a small distance)
        \divide\l@youtvdviii by \tw@
      \l@youtxcv=\l@youtxcii                % X coord for vertical dimensions
        \advance\l@youtxcv by \l@youthdii     % for `standard' vertical vectors
 %% do headheight
      \put(\l@youtxcv,\l@youtyciv){\vector(0,1){\l@youtvpiii}}
      \put(\l@youtxcv,\l@youtyciv){\vector(0,-1){0}}
      \put(\l@youtxcv,\l@youtyciv){\begin{picture}(\l@youtvdviii,\l@youtvdviii)
        \put(\l@youtvdviii,\l@youtvdviii){\l@ypcmd{headheight}}
        \end{picture}}
 %% do headsep
      \put(\l@youtxcv,\l@youtyciv){\vector(0,-1){\l@youtvpiv}}
      \put(\l@youtxcv,\l@youtyciv){\vector(0,1){0}}
      \put(\l@youtxcv,\l@youtyciv){\begin{picture}(\l@youtvdviii,\l@youtvdviii)
        \put(\l@youtvdviii,-\l@youtvdviii){\l@ypcmd{headsep}}
        \end{picture}}
 %% do textheight
      \put(\l@youtxcv,\l@youtycii){\vector(0,1){\l@youtvpv}}
      \put(\l@youtxcv,\l@youtycii){\vector(0,-1){0}}
      \put(\l@youtxcv,\l@youtycii){\begin{picture}(\l@youtvdviii,\l@youtvdviii)
        \put(\l@youtvdviii,\l@youtvdviii){\l@ypcmd{textheight}}
        \end{picture}}
 %% do footskip
      \put(\l@youtxcv,\l@youtycii){\vector(0,-1){\l@youtvpvi}}
      \put(\l@youtxcv,\l@youtycii){\begin{picture}(\l@youtvdviii,\l@youtvdviii)
        \put(\l@youtvdviii,-\l@youtvdviii){\l@ypcmd{footskip}}
        \end{picture}}
      \ifdrawmarginpars
        \l@youtxcv=\l@youthpvii              % X coord for marginparpush
          \divide\l@youtxcv by \tw@
          \advance\l@youtxcv by \l@youtxciv
 %% do marginparpush
        \put(\l@youtxcv,\l@youtyciii){\vector(0,-1){\l@youtvpvii}}
        \put(\l@youtxcv,\l@youtyciii){\begin{picture}(\l@youtvdviii,\l@youtvdviii)
          \put(\l@youtvdviii,-\l@youtvdviii){\l@ypcmd{marginparpush}}
          \end{picture}}
      \fi
%% calculate X coord for uppermargin/trimtop parameters
      \ifoddpagelayout
        \ifl@yrightmpars
          \l@youtxcv=\l@youtxciv              % X coord for uppermargin, etc (= edge of note)
        \else
          \l@youtxcv=\l@youtxciv
            \advance\l@youtxcv by \l@youthpvii  % plus marginparwidth
        \fi
      \else
        \ifl@yrightmpars
          \l@youtxcv=\l@youtxciv
        \else
          \l@youtxcv=\l@youtxciv
            \advance\l@youtxcv by \l@youthpvii  % plus marginparwidth
        \fi
      \fi
 %% do uppermargin
      \put(\l@youtxcv,\l@youtycv){\vector(0,-1){\l@youtvpii}}
      \put(\l@youtxcv,\l@youtycv){\begin{picture}(\l@youtvdviii,\l@youtvdviii)
        \put(\l@youtvdviii,-\l@youtvdviii){\l@ypcmd{uppermargin}}
        \end{picture}}
 %% do trimtop
      \put(\l@youtxcv,\l@youtvdo){\vector(0,-1){\l@youtvpi}}
      \put(\l@youtxcv,\l@youtvdo){\begin{picture}(\l@youtvdviii,\l@youtvdviii)
        \put(\l@youtvdviii,-\l@youtvdviii){\l@ypcmd{trimtop}}
        \end{picture}}
%% X coord for stock height
      \ifoddpagelayout
        \ifl@yrightmpars
          \l@youtxcv=\l@youtxco               % X coord for stock height
            \divide\l@youtxcv by \tw@           % 1/2 stock/paper left edges
        \else
          \l@youtxcv=\l@youtxco               % X coord for stock height
            \advance\l@youtxcv by \l@youtpw     % plus page width
            \advance\l@youtxcv by \l@youthpi    % plus trimedge
        \fi
      \else
        \ifl@yrightmpars
          \l@youtxcv=\l@youtxco               % X coord for stock height
            \divide\l@youtxcv by \tw@           % 1/2 stock/paper left edges
        \else
          \l@youtxcv=\l@youtxco               % X coord for stock height
            \advance\l@youtxcv by \l@youtpw     % plus page width
            \advance\l@youtxcv by \l@youthpi    % plus trimedge
        \fi
      \fi
 %% do stockheight
      \put(\l@youtxcv,0){\vector(0,1){\l@youtvdo}}
      \put(\l@youtxcv,0){\vector(0,-1){0}}
      \put(\l@youtxcv,\l@youtvdo){\begin{picture}(\l@youtvdviii,\l@youtvdviii)
        \put(\l@youtvdviii,-\l@youtvdviii){\l@ypcmd{stockheight}}
        \end{picture}}
%% X coord for paper height
      \ifoddpagelayout
        \ifl@yrightmpars
          \l@youtxcv=\l@youtxco               % X coord for paper height
            \advance\l@youtxcv by \l@youtxcii   % plus left edge of text
            \divide\l@youtxcv by \tw@
        \else
          \l@youtxcv=\l@youtxco               % X coord for paper height
            \advance\l@youtxcv by \l@youtpw     % plus page width
            \advance\l@youtxcv by \l@youtxcii   % plus left edge of text
            \advance\l@youtxcv by \l@youthpii   % plus text width
            \divide\l@youtxcv by \tw@
        \fi
      \else
        \ifl@yrightmpars
          \l@youtxcv=\l@youtxco               % X coord for paper height
            \advance\l@youtxcv by \l@youtxcii   % plus left edge of text
            \divide\l@youtxcv by \tw@
        \else
          \l@youtxcv=\l@youtxco               % X coord for paper height
            \advance\l@youtxcv by \l@youtpw     % plus page width
            \advance\l@youtxcv by \l@youtxcii   % plus left edge of text
            \advance\l@youtxcv by \l@youthpii   % plus text width
            \divide\l@youtxcv by \tw@
        \fi
      \fi
 %% do paperheight
      \put(\l@youtxcv,\l@youtyco){\vector(0,1){\l@youtph}}
      \put(\l@youtxcv,\l@youtyco){\vector(0,-1){0}}
      \put(\l@youtxcv,\l@youtycv){\begin{picture}(\l@youtvdviii,\l@youtvdviii)
        \put(\l@youtvdviii,-\l@youtvdviii){\l@ypcmd{paperheight}}
        \end{picture}}

      \l@youtvpiii=\l@youtycii              % Y coord for low dimensions
        \advance\l@youtvpiii by \l@youtvdiii
      \l@youtvpiv=\l@youtvpiii              % Y coord for mid dimensions
        \advance\l@youtvpiv by \l@youtvdiii
      \l@youtvdi=\l@youtvpv               % Y coord for top dimensions
        \multiply\l@youtvdi by \tw@       % 2/3 of text height
        \divide\l@youtvdi by 3\relax
        \advance\l@youtvdi by \l@youtycii
      \ifdrawmarginpars
 %% do marginparwidth
        \put(\l@youtxciv,\l@youtvpiii){\vector(1,0){\l@youthpvii}}
        \put(\l@youtxciv,\l@youtvpiii){\begin{picture}(\l@youtvdviii,\l@youtvdviii)
          \put(\l@youtvdviii,\l@youtvdviii){\l@ypcmd{marginparwidth}}
          \end{picture}}
      \fi
      \ifoddpagelayout
 %% do spinemargin
        \put(\l@youtxco,\l@youtvdi){\vector(1,0){\l@youthpv}}
        \put(\l@youtxco,\l@youtvdi){\begin{picture}(\l@youtvdviii,\l@youtvdviii)
          \put(\l@youtvdviii,\l@youtvdviii){\l@ypcmd{spinemargin}}
          \end{picture}}
 %% do trimedge
        \put(\l@youthdo,\l@youtyciv){\vector(-1,0){\l@youthpi}}
        \put(\l@youthdo,\l@youtyciv){\begin{picture}(\l@youtvdviii,\l@youtvdviii)
          \put(-\l@youtvdviii,\l@youtvdviii){\l@ypcmd{trimedge}}
          \end{picture}}
      \else
        \l@youtxcv=\l@youtxcii         % X coord of right edge of text
          \advance\l@youtxcv by \l@youthpii
 %% do spinemargin
        \put(\l@youtxcv,\l@youtvdi){\line(1,0){\l@youthpv}}
        \put(\l@youtxcv,\l@youtvdi){\vector(-1,0){0}}
        \put(\l@youtxcv,\l@youtvdi){\begin{picture}(\l@youtvdviii,\l@youtvdviii)
          \put(\l@youtvdviii,\l@youtvdviii){\l@ypcmd{spinemargin}}
          \end{picture}}
 %% do trimedge
        \put(0,\l@youtyciv){\vector(1,0){\l@youthpi}}
        \put(0,\l@youtyciv){\begin{picture}(\l@youtvdviii,\l@youtvdviii)
          \put(\l@youtvdviii,\l@youtvdviii){\l@ypcmd{trimedge}}
          \end{picture}}
      \fi
  %% marginal elements
      \ifdrawmarginpars
 %% do marginparsep
        \ifl@yrightmpars
          \put(\l@youtxciv,\l@youtvpiv){\line(-1,0){\l@youthpvi}}
          \put(\l@youtxciv,\l@youtvpiv){\vector(1,0){0}}
          \put(\l@youtxciv,\l@youtvpiv){\begin{picture}(\l@youtvdviii,\l@youtvdviii)
            \put(-\l@youtvdviii,\l@youtvdviii){\l@ypcmd{marginparsep}}
            \end{picture}}
        \else
          \put(\l@youtxcii,\l@youtvpiv){\vector(-1,0){\l@youthpvi}}
          \put(\l@youtxcii,\l@youtvpiv){\begin{picture}(\l@youtvdviii,\l@youtvdviii)
            \put(-\l@youtvdviii,\l@youtvdviii){\l@ypcmd{marginparsep}}
            \end{picture}}
        \fi
      \fi

      \l@youtxcv=\l@youtxcii          % X coord for mid textwidth
        \multiply\l@youtxcv by \tw@
        \advance\l@youtxcv by \l@youthpii
        \divide\l@youtxcv by \tw@
 %% do textwidth
      \put(\l@youtxcii,\l@youtyciii){\vector(1,0){\l@youthpii}}
      \put(\l@youtxcii,\l@youtyciii){\vector(-1,0){0}}
      \put(\l@youtxcv,\l@youtyciii){\begin{picture}(\l@youtvdviii,\l@youtvdviii)
        \put(\l@youtvdviii,\l@youtvdviii){\l@ypcmd{textwidth}}
        \end{picture}}
      \iftwocolumnlayout
 %% do columnsep
        \put(\l@youtxciii,\l@youtvdi){\vector(-1,0){\l@youthpiii}}
        \put(\l@youtxciii,\l@youtvdi){\vector(1,0){0}}
        \put(\l@youtxciii,\l@youtvdi){\begin{picture}(\l@youtvdviii,\l@youtvdviii)
          \put(-\l@youtvdviii,\l@youtvdviii){\l@ypcmd{columnsep}}
          \end{picture}}
      \fi

      \l@youtxcv=\l@youthdo        % X coord of middle of picture
        \divide\l@youtxcv by \tw@
 %% do stockwidth
      \l@youtvpiii=\l@youtyco      % Y coord for stockwidth
        \divide\l@youtvpiii by 3\relax
      \put(0,\l@youtvpiii){\vector(1,0){\l@youthdo}}
      \put(0,\l@youtvpiii){\vector(-1,0){0}}
      \put(\l@youtxcv,\l@youtvpiii){\begin{picture}(\l@youtvdviii,\l@youtvdviii)
        \put(\l@youtvdviii,\l@youtvdviii){\l@ypcmd{stockwidth}}
        \end{picture}}
 %% do paperwidth
      \l@youtvpiii=\l@youtyci      % Y coord for paperwidth
        \advance\l@youtvpiii by -\l@youtyco
        \multiply\l@youtvpiii by 3\relax
        \divide\l@youtvpiii by 10\relax
        \advance\l@youtvpiii by \l@youtyco
      \put(\l@youtxco,\l@youtvpiii){\vector(1,0){\l@youtpw}}
      \put(\l@youtxco,\l@youtvpiii){\vector(-1,0){0}}
      \put(\l@youtxcv,\l@youtvpiii){\begin{picture}(\l@youtvdviii,\l@youtvdviii)
        \put(\l@youtvdviii,\l@youtvdviii){\l@ypcmd{paperwidth}}
        \end{picture}}
      \fi
    \end{picture}
    \end{center}
    \setlength{\unitlength}{1pt}

    \testprintparameters
    \ifl@ytempif
      \begin{center}
      \begin{footnotesize}
         Lengths are to the nearest pt. \\
      \begin{ttfamily}
      \begin{tabular}{l@{\hspace{20pt}}l}
      \l@ycmd{stockheight}   = \number\l@youtvdo pt    &
      \l@ycmd{stockwidth}    = \number\l@youthdo pt     \\
      \l@ycmd{pageheight}    = \number\l@youtph pt      &
      \l@ycmd{pagewidth}     = \number\l@youtpw pt       \\
      \l@ycmd{textheight}    = \number\l@youtvpv pt      &
      \l@ycmd{textwidth}     = \number\l@youthpii pt      \\
      \l@ycmd{trimtop}       = \number\l@youtvpi pt         &
      \l@ycmd{trimedge}      = \number\l@youthpi pt        \\
      \l@ycmd{uppermargin}   = \number\l@youtvpii pt    &
      \l@ycmd{spinemargin}   = \number\l@youthpv pt     \\
      \l@ycmd{headheight}    = \number\l@youtvpiii pt    &
      \l@ycmd{headsep}       = \number\l@youtvpiv pt        \\
      \l@ycmd{footskip}      = \number\l@youtvpvi pt       &
      \l@ycmd{marginparsep}  = \number\l@youthpvi pt   \\
      \l@ycmd{marginparpush} = \number\l@youtvpvii pt &
      \l@ycmd{columnsep}     = \number\l@youthpiii pt     \\
      \l@ycmd{columnseprule} = \the\l@youtlinethick  &  \\
      \end{tabular}
      \end{ttfamily}\end{footnotesize}
      \end{center}
    \fi
}

\newcommand{\stockdiagram}{\drawparameterstrue\drawstock}
\newcommand{\stockdesign}{\drawparametersfalse\drawstock}

\newcommand{\stockvalues}{%
%%  \begin{center}
  \ifprintheadings
    Actual stock page layout values.\\[\baselineskip]
  \fi
  \begingroup
    \l@yvalsize
  \begin{tabular}{l@{\hspace{20pt}}l}
  \l@ycmd{stockheight}    = \l@yval{\stockheight}       &
  \l@ycmd{stockwidth}     = \l@yval{\stockwidth}        \\
  \l@ycmd{paperheight}    = \l@yval{\paperheight}       &
  \l@ycmd{paperwidth}     = \l@yval{\paperwidth}         \\
  \l@ycmd{textheight}     = \l@yval{\textheight}     &
  \l@ycmd{textwidth}      = \l@yval{\textwidth}      \\
  \l@ycmd{trimtop}        = \l@yval{\trimtop}        &
  \l@ycmd{trimedge}       = \l@yval{\trimedge}      \\
  \l@ycmd{uppermargin}    = \l@yval{\uppermargin}      &
  \l@ycmd{spinemargin}    = \l@yval{\spinemargin}       \\
  \l@ycmd{headheight}     = \l@yval{\headheight}     &
  \l@ycmd{headsep}        = \l@yval{\headsep}        \\
  \l@ycmd{footskip}       = \l@yval{\footskip}       &
  \l@ycmd{marginparsep}   = \l@yval{\marginparsep}   \\
  \l@ycmd{marginparpush}  = \l@yval{\marginparpush}  &
  \l@ycmd{columnsep}      = \l@yval{\columnsep}      \\
  \l@ycmd{columnseprule}  = \l@yval{\columnseprule}  & \\
  1em = \l@yval{\l@yonem}  & 1ex = \l@yval{\l@yonex} \\
  \end{tabular}
  \endgroup
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%    LIST LAYOUT
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcommand{\tryitemindent}[1]{\l@yltoc{#1}{\l@youthpi}}
\newcommand{\trylabelwidth}[1]{\l@yltoc{#1}{\l@youthpii}}
\newcommand{\trylabelsep}[1]{\l@yltoc{#1}{\l@youthpiii}}
\newcommand{\tryleftmargin}[1]{\l@yltoc{#1}{\l@youthpiv}
                     \ifnum\l@youthpiv < \z@
                       \l@youthpiv = \z@
                     \fi}
\newcommand{\tryrightmargin}[1]{\l@yltoc{#1}{\l@youthpv}}
\newcommand{\trylistparindent}[1]{\l@yltoc{#1}{\l@youthpvi}}
\newcommand{\trytopsep}[1]{\l@yltoc{#1}{\l@youtvpi}}
\newcommand{\tryparskip}[1]{\l@yltoc{#1}{\l@youtparskip}}
\newcommand{\trypartopsep}[1]{\l@yltoc{#1}{\l@youtvpiii}}
\newcommand{\tryparsep}[1]{\l@yltoc{#1}{\l@youtvpiv}}
\newcommand{\tryitemsep}[1]{\l@yltoc{#1}{\l@youtvpv}}

\newcommand{\currentlist}{%
  \tryitemindent{\itemindent}       % typically 0pt
  \trylabelwidth{\labelwidth}       % typically  pt
  \trylabelsep{\labelsep}           % typically 0.5em
  \tryleftmargin{\leftmargin}       % typically  pt
  \tryrightmargin{\rightmargin}     % typically  pt
  \trylistparindent{\listparindent} % typically 0pt
  \trytopsep{\topsep}               % typically  pt
  \tryparskip{\l@ysetupparskip}     % typically  pt
  \trypartopsep{\partopsep}         % typically  pt
  \tryparsep{\parsep}               % typically  pt
  \tryitemsep{\itemsep}             % typically  pt
}

\newcommand{\drawlist}{%
  \l@youthdo=\l@yoneinch\relax
  \l@youtvdo=\l@yoneinch\relax
    \multiply\l@youtvdo by 12\relax
    \divide\l@youtvdo by 10\relax
  \l@youthdi=\l@yeighthalfinch\relax  % major textwidth
  \ifdrawparameters
    \l@youthpi=60\relax                      % itemindent
    \l@youthpii=80\relax                     % labelwidth
    \l@youthpiii=\l@youthpi                  % labelsep
      \divide\l@youthpiii by \tw@
    \l@youthpiv=\l@youthpi                   % leftmargin
      \advance\l@youthpiv by \l@youthpii
      \advance\l@youthpiv by \l@youthpiii
    \l@youthpv=\l@youthpiv                   % rightmargin
      \multiply\l@youthpv by \tw@
      \divide\l@youthpv by \thr@@
    \l@youthpvi=\l@youthpi                   % listparindent
      \multiply\l@youthpvi by 4\relax
      \divide\l@youthpvi by \thr@@
    \l@youtvpi=40\relax                      % topsep
    \l@youtparskip=\l@youtvpi                % parskip
    \l@youtvpiii=\l@youtvpi                  % partopsep
    \l@youtvpiv=\l@youtvpi                   % parsep
    \l@youtvpv=\l@youtvpi                    % itemsep
  \fi
  \l@youtvdvii=\l@youtvpi                  % topsep + parskip (+ partopsep)
    \advance\l@youtvdvii by \l@youtparskip
    \iflistaspara
      \advance\l@youtvdvii by \l@youtvpiii
    \fi
  \l@youtvdvi=\l@youtvpv                   % itemsep + parsep
    \advance\l@youtvdvi by \l@youtvpiv
  \l@youtyci=\l@yoneinch\relax                % Y coord of base of item 2
    \advance\l@youtyci by \l@youtvdvii
  \l@youtxci=\z@                           % X coord of LH list text
    \advance\l@youtxci by \l@youthpiv
  \l@youthdii=\l@youthdi                   % major width of item text
    \advance\l@youthdii by -\l@youthpiv
    \advance\l@youthdii by -\l@youthpv
  \l@youthdiii=\l@youthpi                  % inset of labelled list line
  \l@youtvdii=\l@youtvdo                   % vertical dim of short inset line
    \divide\l@youtvdii by 4\relax
  \l@youthdiv=\l@youthdii                  % X dim of item 2 box top
    \advance\l@youthdiv by -\l@youthdiii
  \l@youtvdi=\l@youtvdo                    % Y dim of RH item box
    \advance\l@youtvdi by \l@youtvdii
  \l@youtvdiii=\l@youtvdii                 % height of label box
    \multiply\l@youtvdiii by \thr@@
    \divide\l@youtvdiii by 4\relax
  \l@youtxcii=\l@youthdiii                 % X coord of BL of label box
    \advance\l@youtxcii by -\l@youthpiii
    \advance\l@youtxcii by -\l@youthpii
  \l@youtycii=\l@youtvdi                   % Y coord of BL of label box
    \advance\l@youtycii by -\l@youtvdiii
  \l@youtyciii=\l@youtyci                  % Y coord of base of para
    \advance\l@youtyciii by \l@youtvdi
    \advance\l@youtyciii by \l@youtvdvi
  \l@youthdv=\l@youthdii                   % Hor. dim of top of para box
    \advance\l@youthdv by -\l@youthpvi
  \l@youtyciv=\l@youtyciii                 % Y coord of base of item 1
    \advance\l@youtyciv by \l@youtvdi
    \advance\l@youtyciv by \l@youtvpiv
  \l@youtycv=\l@youtyciv                   % Y coord of base of preceding text
    \advance\l@youtycv by \l@youtvdi
    \advance\l@youtycv by \l@youtvdvii
  \l@youtvdiv=\l@youtycv                   % Height of picture
    \advance\l@youtvdiv by \l@yoneinch\relax
  \l@youtxciii=\l@youtxci                  % X coord of vertical lines
    \advance\l@youtxciii by \l@youtxci
    \advance\l@youtxciii by \l@youthdii
    \divide\l@youtxciii by \tw@
  \l@youtycvi=\l@youtvdi                   % Y coord for margin lines
    \divide\l@youtycvi by \tw@
  \l@youtvdv=\l@youtvpiv                   % small dimension (1/2 parsep)
    \divide\l@youtvdv by \tw@
  \l@youtxciv=\l@youtycii                 % Y coord for labelwidth (note XCIV)
    \advance\l@youtxciv by \l@youtvdiii
    \advance\l@youtxciv by \l@youtvdv
  \begin{center}
  \setlength{\unitlength}{\l@youtunitlength}
  \begin{picture}(\l@yeighthalfinch,\l@youtvdiv)
    \thinlines
    \put(0,0){\dashbox{10}(\l@youthdi,\l@youtvdiv){}}
    \thicklines
    \put(0,0){\framebox(\l@youthdi,\l@yoneinch){\l@ylabelfont Following Text}}
    \put(\l@youtxci,\l@youtyci){\begin{picture}(\l@youthdii,\l@youtvdi)
      \put(0,0){\line(1,0){\l@youthdii}}
      \put(0,0){\line(0,1){\l@youtvdo}}
      \ifnum\l@youthdiii > \z@
        \put(\l@youthdiii,\l@youtvdo){\line(-1,0){\l@youthdiii}}
      \else
        \put(\l@youthdiii,\l@youtvdo){\line(1,0){-\l@youthdiii}}
      \fi
      \put(\l@youthdiii,\l@youtvdo){\line(0,1){\l@youtvdii}}
      \put(\l@youthdii,\l@youtvdi){\line(0,-1){\l@youtvdi}}
      \put(\l@youthdii,\l@youtvdi){\line(-1,0){\l@youthdiv}}
      \put(0,0){\makebox(\l@youthdii,\l@youtvdi){\l@ylabelfont Item 2}}
      \put(\l@youtxcii,\l@youtycii){\framebox(\l@youthpii,\l@youtvdiii){}}
      \put(\l@youtxcii,\l@youtycii){\makebox(\l@youthpii,\l@youtvdiii)[r]%
          {\l@ylabelfont Label}}
      \end{picture}}
    \put(\l@youtxci,\l@youtyciii){\begin{picture}(\l@youthdii,\l@youtvdi)
      \put(0,0){\line(1,0){\l@youthdii}}
      \put(0,0){\line(0,1){\l@youtvdo}}
      \ifnum\l@youthpvi < \z@
        \put(\l@youthpvi,\l@youtvdo){\line(1,0){-\l@youthpvi}}
      \else
        \put(\l@youthpvi,\l@youtvdo){\line(-1,0){\l@youthpvi}}
      \fi
      \put(\l@youthpvi,\l@youtvdo){\line(0,1){\l@youtvdii}}
      \put(\l@youthdii,\l@youtvdi){\line(0,-1){\l@youtvdi}}
      \put(\l@youthdii,\l@youtvdi){\line(-1,0){\l@youthdv}}
      \put(0,0){\makebox(\l@youthdii,\l@youtvdi){\l@ylabelfont Item 1, Paragraph 2}}
      \testdrawdimensions
      \ifl@ytempif
        \put(0,\l@youtvdi){\vector(1,0){\l@youthpvi}}
        \put(0,\l@youtvdi){\begin{picture}(\l@youtvdv,\l@youtvdv)
          \put(0,\l@youtvdv){\l@ypcmd{listparindent}}
          \end{picture}}
        \put(-\l@youthpiv,\l@youtycvi){\vector(1,0){\l@youthpiv}}
        \put(-\l@youthpiv,\l@youtycvi){\begin{picture}(\l@youtvdv,\l@youtvdv)
          \put(\l@youtvdv,\l@youtvdv){\l@ypcmd{leftmargin}}
          \end{picture}}
        \ifnum\l@youthpv < \z@
          \put(\l@youthdii,\l@youtycvi){\line(-1,0){-\l@youthpv}}
        \else
          \put(\l@youthdii,\l@youtycvi){\line(1,0){\l@youthpv}}
        \fi
        \put(\l@youthdii,\l@youtycvi){\vector(-1,0){0}}
        \put(\l@youthdii,\l@youtycvi){\begin{picture}(\l@youtvdv,\l@youtvdv)
          \put(\l@youtvdv,\l@youtvdv){\l@ypcmd{rightmargin}}
          \end{picture}}
      \fi
      \end{picture}}
    \put(\l@youtxci,\l@youtyciv){\begin{picture}(\l@youthdii,\l@youtvdi)
      \put(0,0){\line(1,0){\l@youthdii}}
      \put(0,0){\line(0,1){\l@youtvdo}}
      \ifnum\l@youthdiii > \z@
        \put(\l@youthdiii,\l@youtvdo){\line(-1,0){\l@youthdiii}}
      \else
        \put(\l@youthdiii,\l@youtvdo){\line(1,0){-\l@youthdiii}}
      \fi
      \put(\l@youthdiii,\l@youtvdo){\line(0,1){\l@youtvdii}}
      \put(\l@youthdii,\l@youtvdi){\line(0,-1){\l@youtvdi}}
      \put(\l@youthdii,\l@youtvdi){\line(-1,0){\l@youthdiv}}
      \put(0,0){\makebox(\l@youthdii,\l@youtvdi){\l@ylabelfont Item 1}}
      \put(\l@youtxcii,\l@youtycii){\framebox(\l@youthpii,\l@youtvdiii){}}
      \put(\l@youtxcii,\l@youtycii){\makebox(\l@youthpii,\l@youtvdiii)[r]%
          {\l@ylabelfont Label}}
%%      \ifdrawparameters
      \testdrawdimensions
      \ifl@ytempif
        \ifnum\l@youthpi > \z@
          \put(0,\l@youtycvi){\vector(1,0){\l@youthpi}}
        \else
          \put(0,\l@youtycvi){\vector(-1,0){-\l@youthpi}}
        \fi
        \put(0,\l@youtycvi){\begin{picture}(\l@youtvdv,\l@youtvdv)
          \put(0,-\l@youtvdv){\l@ypcmd{itemindent}}
          \end{picture}}
        \put(\l@youthdiii,\l@youtvdi){\vector(-1,0){\l@youthpiii}}
        \put(\l@youthdiii,\l@youtvdi){\begin{picture}(\l@youtvdv,\l@youtvdv)
          \put(0,\l@youtvdv){\l@ypcmd{labelsep}}
          \end{picture}}
        \put(\l@youtxcii,\l@youtxciv){\line(1,0){\l@youthpii}}
        \put(\l@youtxcii,\l@youtxciv){\vector(-1,0){0}}
        \put(\l@youtxcii,\l@youtxciv){\begin{picture}(\l@youtvdv,\l@youtvdv)
          \put(0,\l@youtvdv){\l@ypcmd{labelwidth}}
          \end{picture}}
      \fi
      \end{picture}}
    \put(0,\l@youtycv){\framebox(\l@youthdi,\l@yoneinch){\l@ylabelfont Preceding Text}}
%%    \ifdrawparameters
    \testdrawdimensions
    \ifl@ytempif
      \put(\l@youtxciii,\l@youtyci){\vector(0,-1){\l@youtvdvii}}
      \put(\l@youtxciii,\l@youtyci){\begin{picture}(\l@youtvdv,\l@youtvdv)
        \put(\l@youtvdv,-\l@youtvdv){%
          \l@yparamfont\texttt{\bs topsep + \bs parskip [+ \bs partopsep]}}
        \end{picture}}
      \put(\l@youtxciii,\l@youtyciii){\vector(0,-1){\l@youtvdvi}}
      \put(\l@youtxciii,\l@youtyciii){\begin{picture}(\l@youtvdv,\l@youtvdv)
        \put(\l@youtvdv,-\l@youtvdv){%
          \l@yparamfont\texttt{\bs itemsep + \bs parsep}}
        \end{picture}}
      \put(\l@youtxciii,\l@youtyciv){\vector(0,-1){\l@youtvpiv}}
      \put(\l@youtxciii,\l@youtyciv){\begin{picture}(\l@youtvdv,\l@youtvdv)
        \put(\l@youtvdv,-\l@youtvdv){\l@ypcmd{parsep}}
        \end{picture}}
      \put(\l@youtxciii,\l@youtycv){\vector(0,-1){\l@youtvdvii}}
      \put(\l@youtxciii,\l@youtycv){\begin{picture}(\l@youtvdv,\l@youtvdv)
        \put(\l@youtvdv,-\l@youtvdv){%
          \l@yparamfont\texttt{\bs topsep + \bs parskip [+ \bs partopsep]}}
        \end{picture}}
    \fi
    \end{picture}
    \end{center}
    \setlength{\unitlength}{1pt}
   \testprintparameters
   \ifl@ytempif
    \begin{center}
    \begin{footnotesize}
      Lengths are to the nearest pt. \\
    \begin{ttfamily}
    \begin{tabular}{l@{\hspace{20pt}}l}
    \l@ycmd{leftmargin}    = \number\l@youthpiv pt    &
    \l@ycmd{rightmargin}   = \number\l@youthpv pt    \\
    \l@ycmd{itemindent}    = \number\l@youthpi pt     &
    \l@ycmd{labelwidth}    = \number\l@youthpii pt    \\
    \l@ycmd{labelsep}      = \number\l@youthpiii pt     &
    \l@ycmd{listparindent} = \number\l@youthpvi pt \\
    \l@ycmd{topsep}        = \number\l@youtvpi pt         &
    \l@ycmd{parskip}       = \number\l@youtparskip pt    \\
    \l@ycmd{partopsep}     = \number\l@youtvpiii pt    &
    \l@ycmd{parsep}        = \number\l@youtvpiv pt        \\
    \l@ycmd{itemsep}       = \number\l@youtvpv pt  &     \\
    \end{tabular}
    \end{ttfamily}\end{footnotesize}
    \end{center}
  \fi
}

\newcommand{\listdiagram}{\drawparameterstrue\drawlist}
\newcommand{\listdesign}{\drawparametersfalse\drawlist}

\newcommand{\listvalues}{%
  \setlength{\l@ylmarg}{\leftmargin}
  \setlength{\l@yrmarg}{\rightmargin}
  \setlength{\l@yitmindent}{\itemindent}
  \setlength{\l@ylblwidth}{\labelwidth}
  \setlength{\l@ylblsep}{\labelsep}
  \setlength{\l@ylparindent}{\listparindent}
  \setlength{\l@ytsep}{\topsep}
  \setlength{\l@ypskip}{\parskip}
  \setlength{\l@yptsep}{\partopsep}
  \setlength{\l@ypsep}{\parsep}
  \setlength{\l@yitmsep}{\itemsep}
  \ifprintheadings
    Actual list layout values.\\[\baselineskip]
  \fi
  \begingroup\l@yvalsize
  \begin{tabular}{l@{\hspace{20pt}}l}
  \l@ycmd{leftmargin}    = \l@yval{\l@ylmarg}      &
  \l@ycmd{rightmargin}   = \l@yval{\l@yrmarg}      \\
  \l@ycmd{itemindent}    = \l@yval{\l@yitmindent}  &
  \l@ycmd{labelwidth}    = \l@yval{\l@ylblwidth}   \\
  \l@ycmd{labelsep}      = \l@yval{\l@ylblsep}     &
  \l@ycmd{listparindent} = \l@yval{\l@ylparindent} \\
  \l@ycmd{topsep}        = \l@yval{\l@ytsep}       &
  \l@ycmd{parskip}       = \l@yval{\l@ypskip}      \\
  \l@ycmd{partopsep}     = \l@yval{\l@yptsep}      &
  \l@ycmd{parsep}        = \l@yval{\l@ypsep}       \\
  \l@ycmd{itemsep}       = \l@yval{\l@yitmsep}     &  \\
  1em = \l@yval{\l@yonem}  & 1ex = \l@yval{\l@yonex} \\
  \end{tabular}
  \endgroup
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%    FOOTNOTE LAYOUT
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcommand{\tryfootins}[1]{\l@yltoc{#1}{\l@youtvpi}}
\newcommand{\tryfootnotesep}[1]{\l@yltoc{#1}{\l@youtvpii}}
\newcommand{\tryfootnotebaseline}[1]{\l@yltoc{#1}{\l@youtvpiii}}
\newcommand{\tryfootruleheight}[1]{\setlength{\l@youtlinethick}{#1}}
\newcommand{\tryfootrulefrac}[1]{\setlength{\l@ylen}{8.5in}
            \l@ytok={#1}
            \l@ylen = #1\l@ylen
            \l@youthdvii=\l@ylen
     \divide\l@youthdvii by \l@yonepoint}

\newcommand{\currentfootnote}{%
  \tryfootins{\skip\footins}
  \tryfootnotesep{\footnotesep}
  \tryfootnotebaseline{10pt}
  \tryfootruleheight{0.4pt}
  \tryfootrulefrac{0.25}
}

\newcommand{\drawfootnote}{%
  \l@youtvdo=4\relax                % vertical scale factor
  \l@youthdi=\l@yeighthalfinch\relax   % textwidth
  \l@youtvdi=\l@yoneinch\relax         % small height of note box
  \ifdrawparameters
    \l@youtvpi=20\relax                     %  \skip\footins
    \l@youtvpii=30\relax                    %  footenotesep
    \l@youtvpiii=10\relax                   %  footnote baseline
    \setlength{\l@youtlinethick}{0.4pt}     % rule thickness
    \l@youthdvii=\l@yeighthalfinch\relax       % rule length
      \multiply\l@youthdvii by 4\relax
      \divide\l@youthdvii by 10\relax
    \l@youtvdii=\l@youtvpiii                 % vertical box inset
      \multiply\l@youtvdii by \l@youtvdo
  \else
    \l@youtvdii=\l@youtvpiii                % vertical box inset
      \multiply\l@youtvdii by \l@youtvdo
      \multiply\l@youtvdii by 8\relax
      \divide\l@youtvdii by 10\relax
  \fi
  \multiply\l@youtvdii by 3\relax
  \divide\l@youtvdii by 4\relax
  \l@youtvdv=\l@youtvpi                   % Y dim of footins
    \multiply\l@youtvdv by \l@youtvdo
  \l@youthdii=\l@youtvdii                 % horizontal box inset
  \l@youtvdiii=\l@youtvdi                 % box height
    \advance\l@youtvdiii by \l@youthdii
  \l@youthdiii=\l@youthdi                 % box top length
    \advance\l@youthdiii by -\l@youthdii
  \l@youtvdiv=\l@youtvpii                 % vertical note spacing
    \ifnum\l@youtvdiv < \l@youtvpiii
      \l@youtvdiv=\l@youtvpiii
    \fi
    \multiply\l@youtvdiv by \l@youtvdo
  \l@youtyci=\l@youtvdi                  % Y coord of 1st box base
    \advance\l@youtyci by \l@youtvdiv
  \l@youtycii=\l@youtyci                 % Y coord of rule
    \advance\l@youtycii by \l@youtyci
  \l@youtyciii=\l@youtycii               %  Y coord of text base
    \advance\l@youtyciii by \l@youtvdv
  \l@youtyciv=\l@youtyciii               % top of main text box
    \advance\l@youtyciv by \l@yoneinch\relax
  \l@youthdiv=\l@youthdvii               % length of rule
  \l@youtvdvi=\l@youtvpiv                % height of rule
    \multiply\l@youtvdvi by \l@youtvdo
  \l@youthdv=\l@youthdii                 % small value (1/2 box inset)
    \divide\l@youthdv by \tw@
  \l@youthdvi=\l@youthdv                 % 1/2 l@youthdv
    \divide\l@youthdvi by \tw@
  \begin{center}
  \setlength{\unitlength}{\l@youtunitlength}
  \begin{picture}(\l@youthdi,\l@youtyciv)
    \thicklines
    \put(0,0){\begin{picture}(\l@youthdi,\l@youtvdiii)
      \put(0,0){\line(1,0){\l@youthdi}}
      \put(0,0){\line(0,1){\l@youtvdi}}
      \put(\l@youthdii,\l@youtvdi){\line(-1,0){\l@youthdii}}
      \put(\l@youthdii,\l@youtvdi){\line(0,1){\l@youtvdii}}
      \put(\l@youthdi,\l@youtvdiii){\line(-1,0){\l@youthdiii}}
      \put(\l@youthdi,\l@youtvdiii){\line(0,-1){\l@youtvdiii}}
      \put(\l@youthdv,\l@youtvdiii){\makebox(0,0)[t]{2}}
      \end{picture}}
    \put(0,\l@youtyci){\begin{picture}(\l@youthdi,\l@youtvdiii)
      \put(0,0){\line(1,0){\l@youthdi}}
      \put(0,0){\line(0,1){\l@youtvdi}}
      \put(\l@youthdii,\l@youtvdi){\line(-1,0){\l@youthdii}}
      \put(\l@youthdii,\l@youtvdi){\line(0,1){\l@youtvdii}}
      \put(\l@youthdi,\l@youtvdiii){\line(-1,0){\l@youthdiii}}
      \put(\l@youthdi,\l@youtvdiii){\line(0,-1){\l@youtvdiii}}
      \put(\l@youthdv,\l@youtvdiii){\makebox(0,0)[t]{1}}
      \end{picture}}
    \multiply\l@youtlinethick by \l@youtvdo
    \linethickness{\l@youtlinethick}
    \put(0,\l@youtycii){\line(1,0){\l@youthdvii}}
    \thicklines
    \put(0,\l@youtyciii){\framebox(\l@youthdi,\l@yoneinch){\l@ylabelfont MAIN TEXT}}
    \testdrawdimensions
    \ifl@ytempif
      \thinlines
    \put(\l@youthdvi,\l@youtyci){\vector(0,-1){\l@youtvdiv}}
    \put(\l@youthdvi,\l@youtyci){\begin{picture}(\l@youthdv,\l@youthdv)
      \put(\l@youthdvi,-\l@youthdv){\l@ypcmd{footnotesep}}
      \end{picture}}
    \put(\l@youthdvi,\l@youtycii){\vector(0,-1){\l@youtvdiv}}
    \put(\l@youthdvi,\l@youtycii){\begin{picture}(\l@youthdv,\l@youthdv)
      \put(\l@youthdvi,-\l@youthdv){\l@ypcmd{footnotesep}}
      \end{picture}}
    \put(\l@youthdii,\l@youtyciii){\vector(0,-1){\l@youtvdv}}
    \put(\l@youthdii,\l@youtyciii){\begin{picture}(\l@youthdv,\l@youthdv)
      \put(\l@youthdvi,-\l@youthdv){\l@ypcmd{skip}\l@ypcmd{footins}}
      \end{picture}}
    \put(\l@youthdiv,\l@youtycii){\begin{picture}(\l@youthdv,\l@youthdv)
      \put(\l@youthdv,0){\l@ypcmd{footnoterule}}
      \end{picture}}
    \fi
    \end{picture}
  \end{center}
  \setlength{\unitlength}{1pt}
   \testprintparameters
   \ifl@ytempif
    \begin{center}
    \begin{footnotesize}
      Lengths are to the nearest pt. \\
    \begin{ttfamily}
    \begin{tabular}{l@{\hspace{20pt}}l}
    \l@ycmd{footins}         = \number\l@youtvpi pt &
    \l@ycmd{footnotesep}     = \number\l@youtvpii pt \\
    \l@ycmd{baselineskip}    = \number\l@youtvpiii pt &
    \textrm{note separation} = \number\l@youtvdiv pt \\
    \textrm{rule thickness}  = \the\l@youtlinethick & \\
    \multicolumn{2}{c}{\textrm{rule length} = \the\l@ytok{} times the \bs textwidth} \\
    \end{tabular}
    \end{ttfamily}\end{footnotesize}
    \end{center}
  \fi
}

\newcommand{\footnotediagram}{\drawparameterstrue\drawfootnote}
\newcommand{\footnotedesign}{\drawparametersfalse\drawfootnote}

\newcommand{\footnotevalues}{%
  \setlength{\l@ylen}{\columnwidth}
    \l@ylen = .4\l@ylen
  \ifprintheadings
    Actual footnote layout values.\\[\baselineskip]
  \fi
  \begingroup\l@yvalsize
  \begin{tabular}{l@{\hspace{20pt}}l}
  \l@ycmd{footins}     = \l@yval{\skip\footins} &
  \l@ycmd{footnotesep} = \l@yval{\footnotesep}  \\
  rule thickness      = ??               &
  rule length         = ??    \\
  1em = \l@yval{\l@yonem}  & 1ex = \l@yval{\l@yonex} \\
  \end{tabular}
  \endgroup
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%    PARAGRAPH LAYOUT
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcommand{\tryparindent}[1]{\l@yltoc{#1}{\l@youthdii}}
\newcommand{\tryparlinewidth}[1]{\l@yltoc{#1}{\l@youthdi}}
\newcommand{\tryparbaselineskip}[1]{\l@yltoc{#1}{\l@youtvdii}}

\newcommand{\currentparagraph}{%
  \tryparindent{\parindent}
  \tryparskip{\parskip}
  \tryparlinewidth{\linewidth}
  \tryparbaselineskip{\baselineskip}
}

\newcommand{\drawparagraph}{%
  \l@youtvdi=\l@yoneinch\relax            % height of bottom of inset box
  \ifdrawparameters
    \l@youtvdii=15\relax                %  \baselineskip
    \l@youthdii=40\relax                 %  \parindent
    \l@youtparskip=30\relax              %  \parskip
    \l@youthdi=\l@yeighthalfinch\relax      % linewidth
  \fi
    \l@youtvdiii=\l@youtvdi              % total height of para box
      \advance\l@youtvdiii by \l@youtvdii
    \l@youtvdiv=\l@youtvdiii             % bottom of Preceding box
      \advance\l@youtvdiv by \l@youtparskip
    \l@youtvdv=\l@youtvdiv               % total picture height
      \advance\l@youtvdv by \l@yoneinch\relax
    \l@youthdiii=\l@youthdi               % length of top of para box
      \advance\l@youthdiii by -\l@youthdii
    \l@youtxci=\l@youthdi                % x coord of middle of picture
      \divide\l@youtxci by \tw@
  \l@youthdv=10\relax                    % small value
  \l@youthdvi=5\relax                    % 1/2 l@youthdv
  \begin{center}
  \setlength{\unitlength}{\l@youtunitlength}
  \begin{picture}(\l@youthdi,\l@youtvdv)
    \thicklines
    \put(0,0){\begin{picture}(\l@youthdi,\l@youtvdiii)
      \put(0,0){\line(1,0){\l@youthdi}}
      \put(0,0){\line(0,1){\l@youtvdi}}
      \ifnum\l@youthdii < \z@
        \l@youthdv=-\l@youthdii
        \put(\l@youthdii,\l@youtvdi){\line(1,0){\l@youthdv}}
      \else
        \put(\l@youthdii,\l@youtvdi){\line(-1,0){\l@youthdii}}
      \fi
      \put(\l@youthdii,\l@youtvdi){\line(0,1){\l@youtvdii}}
      \put(\l@youthdi,\l@youtvdiii){\line(-1,0){\l@youthdiii}}
      \put(\l@youthdi,\l@youtvdiii){\line(0,-1){\l@youtvdiii}}
      \end{picture}}
      \put(0,\l@youtvdiv){\framebox(\l@youthdi,\l@yoneinch){\l@ylabelfont Preceding Text}}
    \testdrawdimensions
    \ifl@ytempif
      \thinlines
    \put(\l@youtxci,\l@youtvdiv){\begin{picture}(\l@youthdv,\l@youthdv)
      \put(0,0){\vector(0,-1){\l@youtparskip}}
      \put(\l@youthdvi,-\l@youthdv){\l@ypcmd{parskip}}
      \end{picture}}
    \put(0,\l@youtvdiii){\begin{picture}(\l@youthdv,\l@youthdv)
      \ifnum\l@youthdii < \z@
        \put(0,0){\vector(-1,0){-\l@youthdii}}
        \put(0,0){\vector(1,0){0}}
      \else
        \put(0,0){\vector(1,0){\l@youthdii}}
      \fi
      \put(0,\l@youthdv){\l@ypcmd{parindent}}
      \end{picture}}
    \fi
    \end{picture}
  \end{center}
  \setlength{\unitlength}{1pt}
  \testprintparameters
  \ifl@ytempif
    \begin{center}
    \begin{footnotesize}
      Lengths are to the nearest pt. \\
    \begin{ttfamily}
    \begin{tabular}{l@{\hspace{20pt}}l}
    \l@ycmd{parindent}    = \number\l@youthdii pt &
    \l@ycmd{parskip}      = \number\l@youtparskip pt \\
    \l@ycmd{baselineskip} = \number\l@youtvdii pt &
    \l@ycmd{linewidth}    = \number\l@youthdi pt \\
    \end{tabular}
    \end{ttfamily}\end{footnotesize}
    \end{center}
  \fi
}

\newcommand{\paragraphdiagram}{\drawparameterstrue\drawparagraph}
\newcommand{\paragraphdesign}{\drawparametersfalse\drawparagraph}

\newcommand{\paragraphvalues}{%
  \setlength{\l@ylen}{\parindent}
  \ifprintheadings
    Actual paragraph layout values.\\[\baselineskip]
  \fi
  \begingroup\l@yvalsize
  \begin{tabular}{l@{\hspace{20pt}}l}
  \l@ycmd{parindent}    = \l@yval{\l@ylen}               &
  \l@ycmd{parskip}      = \l@yval{\l@ysetupparskip}      \\
  \l@ycmd{baselineskip} = \l@yval{\l@ysetupbaselineskip} &
  \l@ycmd{linewidth}    = \l@yval{\linewidth}            \\
  1em = \l@yval{\l@yonem}  & 1ex = \l@yval{\l@yonex} \\
  \end{tabular}
  \endgroup
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%    SECTION HEADING LAYOUT
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcommand{\trybeforeskip}[1]{\l@yltoc{#1}{\l@youtvpi}}
\newcommand{\tryafterskip}[1]{\l@yltoc{#1}{\l@youtvpii}}
\newcommand{\tryindent}[1]{\l@yltoc{#1}{\l@youthpi}}

\newcommand{\currentheading}{%
  \trybeforeskip{2\l@ysetupbaselineskip}
  \tryafterskip{\l@ysetupbaselineskip}
  \tryindent{2\l@ysetupbaselineskip}
  \tryparskip{\l@ysetupparskip}
}

\newcommand{\drawheading}[1]{%
  \l@yltoc{\textwidth}{\l@youthdi}               % textwidth
  \l@yltoc{\baselineskip}{\l@youtvdi}            % baselineskip
  \ifdrawparameters
    \Huge \l@youtvdii=\baselineskip \normalsize  % Heading baselineskip
      \divide\l@youtvdii by \l@yonepoint
    \l@yltoc{40pt}{\l@youtvpi}                   % beforeskip
    \ifruninhead
      \l@yltoc{-72pt}{\l@youtvpii}                % afterskip
      \l@yltoc{50pt}{\l@youthpi}                  % indent
    \else
      \l@yltoc{45pt}{\l@youtvpii}                 % afterskip
      \l@yltoc{72pt}{\l@youthpi}                  % indent
    \fi
    \setbox0 = \hbox{{\Huge 3.5 Heading Title }}
    \l@yltoc{\wd0}{\l@youthdv}  % width of heading text
  \else
    {#1 \l@youtvdii=\baselineskip\normalfont\normalsize} % heading baselineskip
      \divide\l@youtvdii by \l@yonepoint
    \setbox0 = \hbox{{#1 3.5 Heading Title }}
    \l@yltoc{\wd0}{\l@youthdv}  % width of heading text
  \fi
  \l@youtvdiii=\l@youtvpii            % afterskip + parskip + textbaselineskip
    \advance\l@youtvdiii by \l@youtparskip
    \advance\l@youtvdiii by \l@youtvdi
  \l@youtvdiv=\l@youtvpi              % beforeskip + parskip + headbaselineskip
    \ifnum\l@youtvdiv < \z@
      \l@youtvdiv = -\l@youtvdiv
    \fi
    \advance\l@youtvdiv by \l@youtparskip
    \advance\l@youtvdiv by \l@youtvdii
  \l@youtyci=\l@youtvdi                  % Y coord of base of after text
  \l@youtycii=\l@youtyci                 % Y coord of base of heading text
    \advance\l@youtycii by \l@youtvdiii
  \l@youthdiv=\z@                        % 0 or abs(-afterskip)
  \ifnum\l@youtvpii < \z@
    \l@youthdiv = -\l@youtvpii
    \l@youtvdiii=\l@youtvdi              %  textbaselineskip
    \l@youtxci=\l@youthpi                % X coord of end of heading text
      \advance\l@youtxci by \l@youthdv
    \l@youtxcii=\l@youtxci               % X coord of start of after text
      \advance\l@youtxcii by \l@youthdiv
    \l@youtycii=\l@youtvdi               % Y coord of base of heading text
  \fi
  \l@youtyciii=\l@youtycii               % Y coord of base of prior text
    \advance\l@youtyciii by \l@youtvdiv
  \l@youtyciv=\l@youtyciii               % Y coord of top of prior text
    \advance\l@youtyciv by \l@youtvdi
  \l@youtycv=\l@youtyciv                 % 2*l@youtvdi + l@youtyciv
    \advance\l@youtycv by \l@youtvdi
    \advance\l@youtycv by \l@youtvdi
  \l@youthdii=\l@youtvdi                 % a small amount
  \l@youthdiii=\l@youthdii               % half a small amount
    \divide\l@youthdiii by \tw@
  \begin{center}
  \setlength{\unitlength}{\l@youtunitlength}
  \begin{picture}(\l@youthdi,\l@youtycv)
    \ifnum\l@youtvpii < \z@
      \put(0,\l@youtyci){\begin{picture}(\l@youthdi,\l@youtyciv)
        \put(0,0){\l@ylabelfont second line of text following the heading \ldots}
        \ifdrawparameters
          \put(\l@youthpi,\l@youtycii){{\Huge 3.5 Heading Title}}
        \else
          \put(\l@youthpi,\l@youtycii){{#1 3.5 Heading Title}}
        \fi
        \put(\l@youtxcii,\l@youtycii){\l@ylabelfont Start of text \ldots}
        \put(0,\l@youtyciii){\l@ylabelfont \ldots end of last line of preceding text.}
%%        \ifdrawparameters
        \testdrawdimensions
        \ifl@ytempif
          \put(0,\l@youtyciii){\vector(0,-1){\l@youtvdiv}}
          \put(0,\l@youtyciii){\begin{picture}(\l@youthdii,\l@youthdii)
            \put(\l@youthdiii,-\l@youthdii){\makebox(0,0)[tl]%
              {\l@yparamfont \textit{$\|$beforeskip$\|$} +
               \l@ypcmd{parskip} (of text font) + \l@ypcmd{baselineskip}
                (of heading font)}}
            \end{picture}}
          \put(0,\l@youtycii){\vector(1,0){\l@youthpi}}
          \put(0,\l@youtycii){\begin{picture}(\l@youthdii,\l@youthdii)
            \put(\l@youthdii,\l@youthdiii){\l@yparamfont \textit{indent}}
            \end{picture}}
          \put(\l@youtxci,\l@youtycii){\vector(1,0){\l@youthdiv}}
          \put(\l@youtxci,\l@youtycii){\begin{picture}(\l@youthdii,\l@youthdii)
            \put(\l@youthdiii,\l@youthdii){\l@yparamfont \textit{afterskip} ($< 0$)}
            \end{picture}}
        \fi
        \end{picture}}
    \else
      \put(0,\l@youtyci){\begin{picture}(\l@youthdi,\l@youtyciv)
        \put(0,0){\l@ylabelfont second line of text following the heading \ldots}
        \put(0,\l@youtyci){\l@ylabelfont This is the start of the after-heading text,
                           which continues on \ldots}
        \ifdrawparameters
          \put(\l@youthpi,\l@youtycii){{\Huge 3.5 Heading Title}}
        \else
          \put(\l@youthpi,\l@youtycii){{#1 3.5 Heading Title}}
        \fi
        \put(0,\l@youtyciii){\l@ylabelfont \ldots end of last line of preceding text.}
%%        \ifdrawparameters
        \testdrawdimensions
        \ifl@ytempif
          \put(0,\l@youtyciii){\vector(0,-1){\l@youtvdiv}}
          \put(0,\l@youtyciii){\begin{picture}(\l@youthdii,\l@youthdii)
            \put(\l@youthdiii,-\l@youthdii){\makebox(0,0)[tl]%
              {\l@yparamfont \textit{$\|$beforeskip$\|$} +
               \l@ypcmd{parskip} (of text font) + \l@ypcmd{baselineskip}
                (of heading font)}}
            \end{picture}}
          \put(0,\l@youtycii){\vector(1,0){\l@youthpi}}
          \put(0,\l@youtycii){\begin{picture}(\l@youthdii,\l@youthdii)
            \put(\l@youthdii,\l@youthdiii){\l@yparamfont \textit{indent}}
            \end{picture}}
          \put(0,\l@youtycii){\vector(0,-1){\l@youtvdiii}}
          \put(0,\l@youtycii){\begin{picture}(\l@youthdii,\l@youthdii)
            \put(\l@youthdiii,-\l@youthdii){\makebox(0,0)[tl]%
              {\l@yparamfont \textit{afterskip} +
               \l@ypcmd{parskip} (of heading font) + \l@ypcmd{baselineskip}
                (of text font)}}
            \end{picture}}
        \fi
        \end{picture}}
      \fi
      \put(0,0){\line(1,0){\l@youthdi}}
      \put(0,\l@youtycv){\line(1,0){\l@youthdi}}
      \end{picture}
    \end{center}
    \setlength{\unitlength}{1pt}
%%    \ifdrawparameters\else
    \testprintparameters
    \ifl@ytempif
      \begin{center}
      \begin{footnotesize}
        Lengths are to the nearest pt. \\
      \begin{ttfamily}
      \begin{tabular}{l@{\hspace{20pt}}l}
      \textit{beforeskip}      = \number\l@youtvpi pt &
      \textit{afterskip}       = \number\l@youtvpii pt \\
      \textit{indent}          = \number\l@youthpi pt &
      \textrm{(heading font)}
         \l@ycmd{baselineskip} = \number\l@youtvdii pt \\
      \l@ycmd{parskip}         = \number\l@youtparskip pt &
      \textrm{heading font}    = \string#1 \\
      \end{tabular}
      \end{ttfamily}\end{footnotesize}
      \end{center}
    \fi
}

\newcommand{\headingdiagram}[1]{\drawparameterstrue\drawheading{#1}}
\newcommand{\headingdesign}[1]{\drawparametersfalse\drawheading{#1}}

\newcommand{\headingvalues}{%
  \PackageWarning{layouts}{The \protect\headingvalues\space command does nothing}}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%    INDIVIDUAL FLOAT LAYOUT
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcommand{\trytextfloatsep}[1]{\l@yltoc{#1}{\l@youtvpi}}
\newcommand{\tryfloatsep}[1]{\l@yltoc{#1}{\l@youtvpii}}
\newcommand{\tryintextsep}[1]{\l@yltoc{#1}{\l@youtvpiii}}
\newcommand{\trytopfigrule}[1]{\setlength{\l@youtlinethick}{#1}}
\newcommand{\trybotfigrule}[1]{\setlength{\l@youtlinethickii}{#1}}

\newcommand{\currentfloat}{%
  \trytextfloatsep{\textfloatsep}
  \tryfloatsep{\floatsep}
  \tryintextsep{\intextsep}
  \trytopfigrule{0pt}        % guesstimate
  \trybotfigrule{0pt}        % guesstimate
}

\newcommand{\drawfloat}{%
  \ifdrawparameters
    \l@yltoc{40pt}{\l@youtvpi}             % textfloatsep
    \l@yltoc{40pt}{\l@youtvpii}            % floatsep
    \l@yltoc{40pt}{\l@youtvpiii}           % intextsep
    \setlength{\l@youtlinethick}{1pt}     % toprule height
    \setlength{\l@youtlinethickii}{2pt}   % botrule height
  \fi
  \l@yltoc{\textwidth}{\l@youthdo}
    \multiply\l@youthdo by 8\relax
    \divide\l@youthdo by 10\relax
  \l@yltoc{\baselineskip}{\l@youtvdvii}  % baselineskip
  \l@youthdi=\l@youthdo                  % width of floats
    \divide\l@youthdi by \tw@
  \l@youtvdi=\l@youthdi                  % float box height
    \divide\l@youtvdi by 4\relax
  \l@youtvdii=\l@youtvdvii               % text box height
    \multiply\l@youtvdii by \thr@@
  \l@youtvdvi=\l@youtvdvii               % height of top text line
    \multiply\l@youtvdvi by \tw@
  \l@youtxci=\l@youthdo                  % X coord of LH of float
    \advance\l@youtxci by -\l@youthdi
    \divide\l@youtxci by \tw@
  \l@youtxcii=\l@youthdo                 % X coord of vertical dims.
    \divide\l@youtxcii by \tw@
  \l@youtyci=\l@youtvdi                  % Y coord of top of BFl-n
  \l@youtycii=\l@youtyci                 % Y coord of bottom of text
    \advance\l@youtycii by \l@youtvpi
  \l@youtyciii=\l@youtycii               % Y coord of bottom of HF box
    \advance\l@youtyciii by \l@youtvdii
    \advance\l@youtyciii by \l@youtvpiii
  \l@youtyciv=\l@youtyciii               % Y coord of bottom top text box
    \advance\l@youtyciv by \l@youtvdi
    \advance\l@youtyciv by \l@youtvpiii
  \l@youtycv=\l@youtyciv                 % Y coord of bottom of TFl-2 box
    \advance\l@youtycv by \l@youtvdii
    \advance\l@youtycv by \l@youtvpi
  \l@youtycvi=\l@youtycv                 % Y coord of bottom of TFl-1 box
    \advance\l@youtycvi by \l@youtvdi
    \advance\l@youtycvi by \l@youtvpii
  \l@youtvdo=\l@youtycvi                 % Y dim of text on page
    \advance\l@youtvdo by \l@youtvdi
  \l@youthdii=\l@youtvpi                 % a small amount
    \divide\l@youthdii by \tw@
  \l@youthdiii=\l@youthdii               % half a small amount
    \divide\l@youthdiii by \tw@
  \begin{center}
%%%  \setlayoutscale{1}
  \setlength{\unitlength}{\l@youtunitlength}
  \begin{picture}(\l@youthdo,\l@youtvdo)
    \thicklines
    \put(\l@youtxci,0){\framebox(\l@youthdi,\l@youtvdi){\l@ylabelfont A BOTTOM FLOAT}}
    \put(0,\l@youtycii){\begin{picture}(\l@youthdo,\l@youtvdii)
      \put(0,0){\makebox(\l@youthdo,0)[br]{\l@ylabelfont \ldots last text line before bottom float.}}
      \put(0,\l@youtvdvi){\l@ylabelfont First text line after `here' float \ldots}
      \end{picture}}
    \put(\l@youtxci,\l@youtyciii){\framebox(\l@youthdi,\l@youtvdi){\l@ylabelfont A `HERE' FLOAT}}
    \put(0,\l@youtyciv){\begin{picture}(\l@youthdo,\l@youtvdii)
      \put(0,0){\makebox(\l@youthdo,0)[br]{\l@ylabelfont \ldots last text line before `here' float.}}
      \put(0,\l@youtvdvi){\l@ylabelfont First text line after top float \ldots}
      \end{picture}}
    \put(\l@youtxci,\l@youtycv){\framebox(\l@youthdi,\l@youtvdi){\l@ylabelfont A TOP FLOAT}}
    \put(\l@youtxci,\l@youtycvi){\framebox(\l@youthdi,\l@youtvdi){\l@ylabelfont A TOP FLOAT}}
    \thinlines
    \put(0,0){\dashbox{10}(\l@youthdo,\l@youtvdo){}}
    \linethickness{\l@youtlinethick}
    \put(0,\l@youtycv){\line(1,0){\l@youthdo}}
    \linethickness{\l@youtlinethickii}
    \put(0,\l@youtyci){\line(1,0){\l@youthdo}}
    \thinlines
    \testdrawdimensions
    \ifl@ytempif
      \put(\l@youtxcii,\l@youtycii){\vector(0,-1){\l@youtvpi}}
      \put(\l@youtxcii,\l@youtycii){\begin{picture}(\l@youthdii,\l@youthdii)
        \put(\l@youthdiii,-\l@youthdii){\l@ypcmd{textfloatsep}}
        \end{picture}}
      \put(\l@youtxcii,\l@youtyciii){\vector(0,-1){\l@youtvpiii}}
      \put(\l@youtxcii,\l@youtyciii){\begin{picture}(\l@youthdii,\l@youthdii)
        \put(\l@youthdiii,-\l@youthdii){\l@ypcmd{intextsep}}
        \end{picture}}
      \put(\l@youtxcii,\l@youtyciv){\vector(0,-1){\l@youtvpiii}}
      \put(\l@youtxcii,\l@youtyciv){\begin{picture}(\l@youthdii,\l@youthdii)
        \put(\l@youthdiii,-\l@youthdii){\l@ypcmd{intextsep}}
        \end{picture}}
      \put(\l@youtxcii,\l@youtycv){\vector(0,-1){\l@youtvpi}}
      \put(\l@youtxcii,\l@youtycv){\begin{picture}(\l@youthdii,\l@youthdii)
        \put(\l@youthdiii,-\l@youthdii){\l@ypcmd{textfloatsep}}
        \end{picture}}
      \put(\l@youtxcii,\l@youtycvi){\vector(0,-1){\l@youtvpii}}
      \put(\l@youtxcii,\l@youtycvi){\begin{picture}(\l@youthdii,\l@youthdii)
        \put(\l@youthdiii,-\l@youthdii){\l@ypcmd{floatsep}}
        \end{picture}}
      \put(\l@youthdo,\l@youtycv){\begin{picture}(\l@youthdii,\l@youthdii)
        \put(-\l@youthdiii,\l@youthdii){\vector(0,-1){\l@youthdii}}
        \put(-\l@youthdii,\l@youthdii){\makebox(0,0)[tr]{\l@ypcmd{topfigrule}}}
        \end{picture}}
      \put(\l@youthdo,\l@youtyci){\begin{picture}(\l@youthdii,\l@youthdii)
        \put(-\l@youthdiii,-\l@youthdii){\vector(0,1){\l@youthdii}}
        \put(-\l@youthdii,-\l@youthdii){\makebox(0,0)[br]{\l@ypcmd{botfigrule}}}
        \end{picture}}
    \fi
    \end{picture}
  \end{center}
  \setlength{\unitlength}{1pt}
  \testprintparameters
  \ifl@ytempif
    \begin{center}
    \begin{footnotesize}
      Lengths are to the nearest pt. \\
    \begin{ttfamily}
    \begin{tabular}{l@{\hspace{20pt}}l}
    \l@ycmd{floatsep}     = \number\l@youtvpii pt    &
    \l@ycmd{textfloatsep} = \number\l@youtvpi pt \\
    \l@ycmd{intextsep}    = \number\l@youtvpiii pt  &
    \textrm{topfigrule thickness} = \the\l@youtlinethick \\
    \textrm{botfigrule thickness} = \the\l@youtlinethickii &  \\
    \end{tabular}
    \end{ttfamily}\end{footnotesize}
    \end{center}
  \fi
}

\newcommand{\floatdiagram}{\drawparameterstrue\drawfloat}
\newcommand{\floatdesign}{\drawparametersfalse\drawfloat}

\newcommand{\floatvalues}{%
  \ifprintheadings
    Actual float layout values.\\[\baselineskip]
  \fi
  \begingroup\l@yvalsize
  \begin{tabular}{l@{\hspace{20pt}}l}
  \l@ycmd{floatsep}             = \l@yval{\floatsep}       &
  \l@ycmd{textfloatsep}         = \l@yval{\textfloatsep}   \\
  \l@ycmd{intextsep}            = \l@yval{\intextsep}      &  \\
  topfig rule thickness        = ??                   &
  botfig rule thickness        = ??                   \\
  \l@ycmd{topnumber}            = \the\c@topnumber & % \l@yval{\c@topnumber}    &
  \l@ycmd{topfraction}          = \topfraction             \\
  \l@ycmd{bottomnumber}         = \the\c@bottomnumber & % \l@yval{\c@bottomnumber} &
  \l@ycmd{bottomfraction}       = \bottomfraction          \\
  \l@ycmd{totalnumber}          = \the\c@totalnumber & % \l@yval{\c@totalnumber}  &
  \l@ycmd{textfraction}         = \textfraction            \\
  \l@ycmd{dblfloatsep}          = \l@yval{\dblfloatsep}    &
  \l@ycmd{dbltextfloatsep}      = \l@yval{\dbltextfloatsep} \\
  \l@ycmd{dbltopnumber}         = \the\c@dbltopnumber & % \l@yval{\c@dbltopnumber} &
  \l@ycmd{dbltopfraction}       = \dbltopfraction          \\
  \l@ycmd{dblfloatpagefraction} = \dblfloatpagefraction    &
  \l@ycmd{floatpagefraction}    = \floatpagefraction       \\
  1em = \l@yval{\l@yonem}  & 1ex = \l@yval{\l@yonex} \\
  \end{tabular}
  \endgroup
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%    FLOAT PAGE LAYOUT
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcommand{\trytotalnumber}[1]{\l@youtvpvi = #1}
\newcommand{\trytopnumber}[1]{\l@youtvpv = #1}
\newcommand{\trybottomnumber}[1]{\l@youtvpi = #1}
\newcommand{\trytopfraction}[1]{\setlength{\l@ylen}{10in}
          \l@ylen = #1\l@ylen
          \l@youtvpiv=\l@ylen
          \divide\l@youtvpiv by \l@yonepoint
          \setlength{\l@ylen}{1000sp}
          \l@ylen=#1\l@ylen
          \l@youthdiv=\l@ylen}
\newcommand{\trytextfraction}[1]{\setlength{\l@ylen}{10in}
          \l@ylen = #1\l@ylen
          \l@youtvpiii=\l@ylen
          \divide\l@youtvpiii by \l@yonepoint
          \setlength{\l@ylen}{1000sp}
          \l@ylen=#1\l@ylen
          \l@youthdv=\l@ylen}
\newcommand{\trybottomfraction}[1]{\setlength{\l@ylen}{10in}
          \l@ylen = #1\l@ylen
          \l@youtvpii=\l@ylen
          \divide\l@youtvpii by \l@yonepoint
          \setlength{\l@ylen}{1000sp}
          \l@ylen=#1\l@ylen
          \l@youthdvi=\l@ylen}

\newcommand{\currentfloatpage}{%
  \trytotalnumber{\value{totalnumber}}   % typically 3
  \trytopnumber{\value{topnumber}}       % typically 2
  \trytopfraction{0.7}                   % typically 0.7
  \trytextfraction{0.2}                  % typically 0.2
  \trybottomfraction{0.3}                % typically 0.3
  \trybottomnumber{\value{bottomnumber}} % typically 1
}

\newcommand{\drawfloatpage}{%
  \ifdrawparameters
    \l@youtvpvi=\thr@@          % total number
    \l@youtvpv=\tw@             % topnumber
    \l@youthdiv=300\relax       % 1000 times topfraction
    \setlength{\l@ylen}{10in}
    \l@ylen=0.3\l@ylen
    \l@yltoc{\l@ylen}{\l@youtvpiv}  % topfraction
    \l@youthdv=200\relax        % 1000 times textfraction
    \setlength{\l@ylen}{10in}
    \l@ylen=0.2\l@ylen
    \l@yltoc{\l@ylen}{\l@youtvpiii}  % textfraction
    \l@youthdvi=300\relax       % 1000 times botfraction
    \setlength{\l@ylen}{10in}
    \l@ylen=0.3\l@ylen
    \l@yltoc{\l@ylen}{\l@youtvpii}  % bottomfraction
    \l@youtvpi=\@ne             % bottomnumber
  \fi
  \l@youtvdo=\l@yteninch\relax                    % textheight
  \l@youthdo=\l@yeighthalfinch\relax              % textwidth
  \l@youthdi=\l@youthdo                  % width of text box
    \multiply\l@youthdi by 8\relax
    \divide\l@youthdi by 10\relax
  \l@youtyci=\l@youtvdo                  % Y coord of base of textfraction
    \advance\l@youtyci by -\l@youtvpiii
    \divide\l@youtyci by \tw@
  \l@youtycii=\l@youtvpii                % Y coord of top of bottomfraction
  \l@youtyciii=\l@youtvdo                % Y coord of base of topfraction
    \advance\l@youtyciii by -\l@youtvpiv
  \l@youtyciv=\l@youtyci                 % Y coord of top of textfraction
    \advance\l@youtyciv by \l@youtvpiii
  \l@youtycv=\l@youtyci                  % Y coord of centre of text box
    \advance\l@youtycv by \l@youtyciv
    \divide\l@youtycv by \tw@
  \l@youtxcii=\l@youthdo                 % X coord of centre dims
    \divide\l@youtxcii by \tw@
  \l@youtxci=\l@youtxcii                 % X coord of LH dims
    \divide\l@youtxci by \tw@
  \l@youtxciii=\l@youtxcii               % X coord of RH dims
    \advance\l@youtxciii by \l@youtxci
  \l@youtxciv=\l@youthdo                 % X coord of LH of text box
    \advance\l@youtxciv by -\l@youthdi
    \divide\l@youtxciv by \tw@
  \l@youthdii=\l@youtxciv                % a small dimension
  \l@youthdiii=\l@youthdii               % half a small dimension
    \divide\l@youthdiii by \tw@
  \begin{center}
  \setlength{\unitlength}{\l@youtunitlength}
  \begin{picture}(\l@youthdo,\l@youtvdo)
    \thicklines
    \put(0,0){\framebox(\l@youthdo,\l@youtvdo){}}
    \put(0,\l@youtycii){\dashbox{10}(\l@youthdo,0){}}
%%%    \ifdrawparameters
      \put(0,0){\makebox(\l@youthdo,\l@youtvpii){\l@ypcmd{bottomnumber}}}
      \thinlines
      \put(\l@youtxciii,0){\vector(0,1){\l@youtvpii}}
      \thicklines
%%%    \fi
    \put(\l@youtxciv,\l@youtyci){\framebox(\l@youthdi,\l@youtvpiii){}}
    \put(0,\l@youtyciii){\dashbox{10}(\l@youthdo,0){}}
%%%    \ifdrawparameters
      \put(0,\l@youtyciii){\makebox(\l@youthdo,\l@youtvpiv){\l@ypcmd{topnumber}}}
      \thinlines
      \put(\l@youtxci,\l@youtvdo){\vector(0,-1){\l@youtvpiv}}
      \thicklines
%%%    \fi
    \thinlines
    \testdrawdimensions
    \ifl@ytempif
      \put(\l@youtxciii,0){\begin{picture}(\l@youthdii,\l@youthdii)
        \put(-\l@youthdiii,\l@youthdiii){%
          \makebox(0,0)[br]{\l@ypcmd{bottomfraction}}}
        \end{picture}}
      \put(\l@youtxcii,\l@youtyci){\vector(0,1){\l@youtvpiii}}
      \put(\l@youtxcii,\l@youtyci){\vector(0,-1){0}}
      \put(\l@youtxcii,\l@youtycv){\begin{picture}(\l@youthdii,\l@youthdii)
        \put(\l@youthdiii,0){%
          \makebox(0,0)[l]{\l@ypcmd{textfraction}}}
        \end{picture}}
      \put(\l@youtxci,\l@youtvdo){\begin{picture}(\l@youthdii,\l@youthdii)
        \put(\l@youthdiii,-\l@youthdiii){%
          \makebox(0,0)[tl]{\l@ypcmd{topfraction}}}
        \end{picture}}
    \fi
    \end{picture}
  \end{center}
  \setlength{\unitlength}{1pt}
  \testprintparameters
  \ifl@ytempif
    \begin{center}
    \begin{footnotesize}\begin{ttfamily}
    \begin{tabular}{l@{\hspace{20pt}}l}
    \l@ycmd{topnumber}      = \number\l@youtvpv &
    \l@ycmd{topfraction}    = 0.\number\l@youthdiv \\
    \l@ycmd{bottomnumber}   = \number\l@youtvpi &
    \l@ycmd{bottomfraction} = 0.\number\l@youthdvi \\
    \l@ycmd{totalnumber}    = \number\l@youtvpvi &
    \l@ycmd{textfraction}   = 0.\number\l@youthdv \\
    \end{tabular}
    \end{ttfamily}\end{footnotesize}
    \end{center}
  \fi
}

\newcommand{\floatpagediagram}{\drawparameterstrue\drawfloatpage}
\newcommand{\floatpagedesign}{\drawparametersfalse\drawfloatpage}

\newcommand{\floatpagevalues}{\floatvalues}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%    TOC LAYOUT
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcommand{\trytocindent}[1]{\l@yltoc{#1}{\l@youthpi}}
\newcommand{\trytocnumwidth}[1]{\l@yltoc{#1}{\l@youthpii}}
\newcommand{\trytoclinewidth}[1]{\l@yltoc{#1}{\l@youthdo}}
\newcommand{\trytocrmarg}[1]{\l@yltoc{#1}{\l@youthpiii}}
\newcommand{\trytocpnumwidth}[1]{\l@yltoc{#1}{\l@youthpiv}}
\newcommand{\l@ydotsep}{\@dotsep}
\newcommand{\trytocdotsep}[1]{\renewcommand{\l@ydotsep}{#1}
            \setlength{\l@ylen}{1em}
            \l@ylen = #1\l@ylen
            \divide\l@ylen by 18\relax    % 18mu = 1em
            \addtolength{\l@ylen}{0.4pt}  % small addition for the dot width
            \l@yltoc{\l@ylen}{\l@youthpv}}

\newcommand{\currenttoc}{%
  \trytocindent{1.5em}                  % guesstimate
  \trytocnumwidth{2.3em}                % guesstimate
  \trytoclinewidth{\textwidth}
  \trytocrmarg{\@tocrmarg}
  \trytocpnumwidth{\@pnumwidth}
  \trytocdotsep{\@dotsep}
}

\newcommand{\drawtoc}{%
  \ifdrawparameters
    \l@yltoc{100pt}{\l@youthpi}           % indent
    \l@yltoc{50pt}{\l@youthpii}           % numwidth
    \l@yltoc{100pt}{\l@youthpiii}         % tocrmarg
    \l@yltoc{60pt}{\l@youthpiv}           % pnumwidth
    \l@yltoc{20pt}{\l@youthpv}            % dotsep
    \l@yltoc{6.5in}{\l@youthdo}           % linewidth
  \fi
  \l@yltoc{20pt}{\l@youtvdi}          % baselineskip
  \l@youtvdii=\l@youtvdi                    % twice baselineskip
    \multiply\l@youtvdii by \tw@
  \l@youtvdiii=\l@youtvdi                    % three times baselineskip
    \multiply\l@youtvdiii by \thr@@
  \l@youtvdiv=\l@youtvdi                    % four times baselineskip
    \multiply\l@youtvdiv by 4\relax
  \l@youtxci=\l@youthpi                    % X coord of start of numwidth
  \l@youtxcii=\l@youtxci                    % X coord of start of text
    \advance\l@youtxcii by \l@youthpii
  \l@youtxciii=\l@youthdo                    % X coord of start of pnumwidth
    \advance\l@youtxciii by -\l@youthpiv
  \l@youtxciv=\l@youthdo                    % X coord of start of tocrmarg
    \advance\l@youtxciv by -\l@youthpiii
  \l@youtxcv=\l@youtxciv                    % X coord of penultimate dot
    \advance\l@youtxcv by -\l@youthpv
  \l@youtyci=\z@                    % Y coord of base of dotsep text
  \l@youtycii=\l@youtyci                    % dotsep vector
    \advance\l@youtycii by \l@youtvdii
  \l@youtyciii=\l@youtycii                    % Y coord of base of bottom text
    \advance\l@youtyciii by \l@youtvdii
  \l@youtyciv=\l@youtyciii                    % Y coord of base of middle text
    \advance\l@youtyciv by \l@youtvdi
  \l@youtycv=\l@youtyciv                    % Y coord of base of top text
    \advance\l@youtycv by \l@youtvdi
  \l@youtycvi=\l@youtycv                    % Y coord of top vectors
    \advance\l@youtycvi by \l@youtvdi
    \advance\l@youtycvi by \l@youtvdi
  \l@youtvdo=\l@youtycvi                    % picture height
    \advance\l@youtvdo by \l@youtvdii
  \l@youthdii=\l@youtxciv                    % width of title text
    \advance\l@youthdii by -\l@youtxcii
  \l@youthdiii=\l@youtvdi                    % a small amount
  \l@youthdiv=\l@youthdiii                    % half a small amount
    \divide\l@youthdiv by \tw@
  \begin{center}
  \setlength{\unitlength}{\l@youtunitlength}
  \begin{picture}(\l@youthdo,\l@youtvdo)
    \thinlines
    \put(0,0){\framebox(\l@youthdo,\l@youtvdo){}}
    \put(\l@youtxci,\l@youtycv){\l@ylabelfont \textbf{3.5}}
    \put(\l@youtxcii,\l@youtycv){\l@ylabelfont Heading \ldots}
    \put(\l@youtxciv,\l@youtycv){\makebox(0,0)[br]{\l@ylabelfont \ldots title}}
    \put(\l@youtxcii,\l@youtyciv){\l@ylabelfont continue \ldots}
    \put(\l@youtxciv,\l@youtyciv){\makebox(0,0)[br]{\l@ylabelfont \ldots title}}
    \put(\l@youtxcii,\l@youtyciii){\l@ylabelfont title end}     % end of title heading
    \put(\l@youthdo,\l@youtyciii){\makebox(0,0)[br]{\l@ylabelfont 487}} % page number
    \settowidth{\l@ylen}{\l@ylabelfont title end\space}
    \l@yltoc{\l@ylen}{\l@youthdv}              % width of `title end' text
      \l@youthpvi=\l@youtunitlength
      \multiply\l@youthdv by \l@yonepoint\relax
      \divide\l@youthdv by \l@youthpvi\relax
    \l@youthdvi=\l@youtxciv                    % space for dots
      \advance\l@youthdvi by -\l@youtxcii
      \advance\l@youthdvi by -\l@youthdv
    \l@youthdvii=\l@youthdvi                   % number of dots
      \divide\l@youthdvii by \l@youthpv
    \ifdrawparameters
      \multiput(\l@youtxciv,\l@youtyciii)(-\l@youthpv,0){\l@youthdvii}%
          {\makebox(0,0)[r]{.}}                  % draw the dots
    \else
      \multiply\l@youthpv by 4\relax
      \l@youthdvii=\l@youthdvi
        \divide\l@youthdvii by \l@youthpv
        \advance\l@youthdvii by \@ne
      \ifnum\l@youthdvii >\@ne
        \multiput(\l@youtxciv,\l@youtyciii)(-\l@youthpv,0){\l@youthdvii}%
            {\makebox(0,0)[r]{.}}                  % draw the dots
      \fi
    \fi
%%    \ifdrawparameters
    \testdrawdimensions
    \ifl@ytempif
      \put(0,\l@youtycvi){\begin{picture}(\l@youthdo,\l@yoneinch)
        \put(0,0){\vector(1,0){\l@youthpi}}
        \put(\l@youtxci,0){\line(0,-1){\l@youthdiii}}
        \put(0,0){\begin{picture}(\l@youthdiii,\l@youthdiii)
          \put(\l@youthdiv,\l@youthdiv){\l@yparamfont\textit{indent}}
          \end{picture}}
        \put(\l@youtxci,0){\vector(1,0){\l@youthpii}}
        \put(\l@youtxcii,0){\line(0,-1){\l@youthdiii}}
        \put(\l@youtxci,0){\begin{picture}(\l@youthdiii,\l@youthdiii)
          \put(\l@youthdiv,\l@youthdiv){\l@yparamfont\textit{numwidth}}
          \end{picture}}
        \put(\l@youthdo,0){\vector(-1,0){\l@youthpiv}}
        \put(\l@youtxciii,0){\line(0,-1){\l@youthdiii}}
        \put(\l@youthdo,0){\begin{picture}(\l@youthdiii,\l@youthdiii)
          \put(-\l@youthdiv,\l@youthdiv){\makebox(0,0)[br]%
            {\l@ypcmd{@pnumwidth}}}
          \end{picture}}
        \end{picture}}
      \thicklines
      \put(0,\l@youtvdo){\vector(1,0){\l@youthdo}}
      \thinlines
      \put(0,\l@youtvdo){\begin{picture}(\l@youthdiii,\l@youthdiii)
        \put(\l@youtxcii,-\l@youthdiv){\makebox(0,0)[tl]%
          { \quad  \l@ypcmd{linewidth}}}
        \end{picture}}
      \put(0,\l@youtycii){\begin{picture}(\l@youthdo,\l@yoneinch)
        \put(\l@youthdo,0){\vector(-1,0){\l@youthpiii}}
        \put(\l@youtxciv,0){\line(0,1){\l@youthdiii}}
        \put(\l@youthdo,0){\begin{picture}(\l@youthdiii,\l@youthdiii)
          \put(-\l@youthdiv,-\l@youthdiv){\makebox(0,0)[tr]%
            {\l@ypcmd{@tocrmarg}}}
          \end{picture}}
        \put(\l@youtxciv,0){\vector(-1,0){\l@youthpv}}
        \put(\l@youtxciv,0){\vector(1,0){0}}
        \put(\l@youtxcv,0){\line(0,1){\l@youthdiii}}
        \put(\l@youtxciv,0){\begin{picture}(\l@youthdiii,\l@youthdiii)
          \put(0,-\l@youthdiv){\makebox(0,0)[tr]%
            {\l@ypcmd{@dotsep}}}
          \end{picture}}
        \end{picture}}
    \fi
    \end{picture}
  \end{center}
  \setlength{\unitlength}{1pt}
%%  \ifdrawparameters\else
  \testprintparameters
  \ifl@ytempif
    \begin{center}
    \begin{footnotesize}
      Lengths are to the nearest pt. \\
    \begin{ttfamily}
    \begin{tabular}{l@{\hspace{20pt}}l}
    \textit{indent}     = \number\l@youthpi pt &
    \textit{numwidth}   = \number\l@youthpii pt \\
    \l@ycmd{@tocrmarg}  = \number\l@youthpiii pt &
    \l@ycmd{@pnumwidth} = \number\l@youthpiv pt \\
    \l@ycmd{@dotsep}    = \l@ydotsep &   \\
    \end{tabular}
    \end{ttfamily}\end{footnotesize}
    \end{center}
  \fi
}

\newcommand{\tocdiagram}{\drawparameterstrue\drawtoc}
\newcommand{\tocdesign}{\drawparametersfalse\drawtoc}

\newcommand{\tocvalues}{%
  \ifprintheadings
    Actual ToC layout values.\\[\baselineskip]
  \fi
  \begingroup\l@yvalsize
  \begin{tabular}{l@{\hspace{20pt}}l}
  \l@ycmd{@tocrmarg}  = \@tocrmarg  &
  \l@ycmd{@pnumwidth} = \@pnumwidth \\
  \l@ycmd{@dotsep}    = \@dotsep    &
  \textit{indent}     = ??    \\
  \textit{numwidth}   = ??    &  \\
  1em = \l@yval{\l@yonem}  & 1ex = \l@yval{\l@yonex} \\
  \end{tabular}
  \endgroup
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%    SPREAD PAGE LAYOUT
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcommand{\drawaspread}[8][0]{%
  \begingroup
  \setlength{\unitlength}{1pt}
  \setlength{\l@youtunitlength}{#2}
  \l@yltoc{\l@youtunitlength}{\l@youthdo}  % page width
  \l@youthdiv=\l@youthdo                   % total width of double spread
    \advance\l@youthdiv by \l@youthdo
  \setlength{\l@ylen}{#3\l@youtunitlength}
  \l@yltoc{\l@ylen}{\l@youtvdo}           % page height
  \setlength{\l@ylen}{#5\l@youtunitlength}
  \l@yltoc{\l@ylen}{\l@youthdiii}           % spine width
  \setlength{\l@youtunitlength}{\l@ylen}
  \setlength{\l@ylen}{#7\l@youtunitlength}
  \l@yltoc{\l@ylen}{\l@youthdi}             % fore edge width
  \l@youthdii=\l@youthdo                  % text width
    \advance\l@youthdii by -\l@youthdi
    \advance\l@youthdii by -\l@youthdiii
  \l@youtxci=\l@youthdo
    \advance\l@youtxci by \l@youthdiii
  \setlength{\l@ylen}{#6\l@youtunitlength}
  \l@yltoc{\l@ylen}{\l@youtvdiii}         % top margin
  \setlength{\l@ylen}{#1\l@youtunitlength}
  \l@yltoc{\l@ylen}{\l@youtvdi}           % bottom margin
  \setlength{\l@ylen}{\l@youthdii pt}
  \setlength{\l@ylen}{#4\l@ylen}
  \l@yltoc{\l@ylen}{\l@youtvdii}          % text height
  \ifnum\l@youtvdi=\z@
    \l@youtvdi=\l@youtvdo
    \advance\l@youtvdi by -\l@youtvdiii
    \advance\l@youtvdi by -\l@youtvdii
  \fi
  \setlength{\l@ylen}{#8\l@youtunitlength}
  \l@yltoc{\l@ylen}{\l@youthdv}           % gutter width
  \ifnum\l@youthdv=\z@
    \begin{picture}(\l@youthdiv,\l@youtvdo)
      \thicklines
      \put(0,0){\framebox(\l@youthdiv,\l@youtvdo){}} % spread pages
      \put(\l@youthdo,0){\line(0,1){\l@youtvdo}}     % the spine
      \thinlines
      \put(\l@youthdi,\l@youtvdi){\framebox(\l@youthdii,\l@youtvdii){}} % LH text
      \put(\l@youtxci,\l@youtvdi){\framebox(\l@youthdii,\l@youtvdii){}} % RH text
      \end{picture}
  \else
    \l@youthdvi=\l@youthdii      % column width
      \advance\l@youthdvi by -\l@youthdv
      \divide\l@youthdvi by \tw@
    \l@youtxcii=\l@youthdi          % X coord of LH inner column
      \advance\l@youtxcii by \l@youthdvi
      \advance\l@youtxcii by \l@youthdv
    \l@youtxciii=\l@youtxci          % X coord of RH outer column
      \advance\l@youtxciii by \l@youthdvi
      \advance\l@youtxciii by \l@youthdv
    \begin{picture}(\l@youthdiv,\l@youtvdo)
      \thicklines
      \put(0,0){\framebox(\l@youthdiv,\l@youtvdo){}} % spread pages
      \put(\l@youthdo,0){\line(0,1){\l@youtvdo}}     % the spine
      \thinlines
      \put(\l@youthdi,\l@youtvdi){\framebox(\l@youthdvi,\l@youtvdii){}} % LH LH col
      \put(\l@youtxcii,\l@youtvdi){\framebox(\l@youthdvi,\l@youtvdii){}} % LH RH col
      \put(\l@youtxci,\l@youtvdi){\framebox(\l@youthdvi,\l@youtvdii){}} % RH LH col
      \put(\l@youtxciii,\l@youtvdi){\framebox(\l@youthdvi,\l@youtvdii){}} % RH RH col
      \end{picture}
  \fi
\endgroup
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%    FONT LAYOUT
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcommand{\drawfontframe}[1]{%
  \savebox{\layoutsbox}{#1}%
  \l@yltoc{\wd\layoutsbox}{\l@youthdo}%
  \l@yltoc{\ht\layoutsbox}{\l@youtvdii}%
  \l@yltoc{\dp\layoutsbox}{\l@youtvdi}%
  \l@youtvdo=\l@youtvdi
  \advance\l@youtvdo by \l@youtvdii
  \l@youtxci=\l@youthdo
  \divide\l@youtxci by \tw@
  \begin{picture}(\l@youthdo,\l@youtvdii)
    \thinlines
    \put(0,0){\usebox{\layoutsbox}}
    \put(0,0){\circle*{2}}
    \qbezier[\l@youtxci](0,0)(\l@youtxci,0)(\l@youthdo,0)
    \put(0,-\l@youtvdi){\framebox(\l@youthdo,\l@youtvdo){}}
  \end{picture}%
}

\newcommand{\drawfontframelabel}[1]{%
  \savebox{\layoutsbox}{#1}%
  \l@yltoc{\wd\layoutsbox}{\l@youthdo}%
  \l@yltoc{\ht\layoutsbox}{\l@youtvdii}%
  \l@yltoc{\dp\layoutsbox}{\l@youtvdi}%
  \l@youtvdo=\l@youtvdi
  \advance\l@youtvdo by \l@youtvdii
  \l@youtxci=\l@youthdo
  \divide\l@youtxci by \tw@
  \l@youthdvi=5\relax
  \l@youtycv=\l@youtvdii
  \advance\l@youtycv by 17\relax
  \l@youtxcii=\l@youthdo
  \advance\l@youtxcii by 35\relax
  \begin{picture}(\l@youtxcii,\l@youtycv)
    \thinlines
    \put(0,0){\usebox{\layoutsbox}}
    \put(0,0){\circle*{2}}
    \qbezier[\l@youtxci](0,0)(\l@youtxci,0)(\l@youthdo,0)
    \put(0,-\l@youtvdi){\framebox(\l@youthdo,\l@youtvdo){}}
    \begin{tiny}
    \put(-\l@youthdvi,0){\makebox(0,0)[r]{reference}}
    \l@youtycv=\l@youtvdii
    \advance\l@youtycv by \l@youthdvi
    \ifnum\l@youthdo > 6\relax
      \l@yhrda{0}{\l@youtycv}{\l@youthdo}
    \else
      \l@yhrdia{0}{\l@youtycv}{\l@youthdo}
    \fi
    \advance\l@youtycv by \l@youthdvi
    \put(\l@youtxci,\l@youtycv){\makebox(0,0)[b]{width}}
    \l@youtxcii=\l@youthdo
    \advance\l@youtxcii by \l@youthdvi
    \l@youtxciii=\l@youtxcii
    \advance\l@youtxciii by \l@youthdvi
    \ifnum\l@youtvdii > \z@
      \ifnum\l@youtvdii > 6\relax
        \l@yvuda{\l@youtxcii}{0}{\l@youtvdii}
      \else
        \l@yvudia{\l@youtxcii}{0}{\l@youtvdii}
      \fi
      \divide\l@youtvdii by \tw@
      \put(\l@youtxciii,\l@youtvdii){\makebox(0,0)[l]{height}}
    \fi
    \ifnum\l@youtvdi > \z@
      \ifnum\l@youtvdi > 6\relax
        \l@yvuda{\l@youtxcii}{-\l@youtvdi}{\l@youtvdi}
      \else
        \l@yvudia{\l@youtxcii}{-\l@youtvdi}{\l@youtvdi}
      \fi
      \divide\l@youtvdi by \tw@
      \put(\l@youtxciii,-\l@youtvdi){\makebox(0,0)[l]{depth}}
    \fi
    \end{tiny}
  \end{picture}
  \ifprintparameters
    \begin{center}\begin{footnotesize}\begin{ttfamily}
      \begin{tabular}{lll}
        \textrm{width} = \the\wd\layoutsbox &
        \textrm{height} = \the\ht\layoutsbox &
        \textrm{depth} = \the\dp\layoutsbox \\
      \end{tabular}
    \end{ttfamily}\end{footnotesize}\end{center}
  \fi
}

\endinput
%%
%% End of file `layouts.sty'.
