%
% Some macros and declarations
% to tailor the layout wich should be used by all texts
%
% Options:
%    nosectsty   - don't include package sectsty
%                  (seems to be incompatible with vmv03.cls)
%
% By: Gabriel Zachmann
%



%
% Options
%

\newif\if@mylayout@sectsty
\@mylayout@sectstytrue
\DeclareOption{nosectsty}{\@mylayout@sectstyfalse}

\ProcessOptions




%
% Typographical enhancement packages
%

\usepackage{ellipsis}		% typographically better '...' (ellipsis)


%
% Document layout parameters
% Bedeutung von Penalties:
% -10000 = hier unbedingt umbrechen;  10000 = hier keinesfalls umbrechen
%

\widowpenalty 10000			% prevent last line of para on first line of page
\displaywidowpenalty 10000	% dunno what this does
\clubpenalty 10000			% prevent first line of para on last line of page
\tolerance 500				% prevent too many overfull hboxes
\@beginparpenalty=5000		% discourage page breaks before lists

\parindent 0.75\baselineskip
\addtolength{\columnsep}{1ex}

%
%   Parameters dealing with placement and layout of floats
%

% Recommended by Donald Arsenau
\renewcommand{\topfraction}{.85} 
\renewcommand{\bottomfraction}{.7}
\renewcommand{\textfraction}{.15} 
\renewcommand{\floatpagefraction}{.66}
\renewcommand{\dbltopfraction}{.66} 
\renewcommand{\dblfloatpagefraction}{.66}
\setcounter{topnumber}{9} 
\setcounter{bottomnumber}{9}
\setcounter{totalnumber}{20} 
\setcounter{dbltopnumber}{9}

\setlength\floatsep{10\p@ \@plus 4\p@ \@minus 2\p@}
\setlength\dblfloatsep\floatsep



%
%  Footnotes
%

%  decrease the space between the footnote mark and the preceding
%  punctuation a little bit, but only, if the preceding char is really a
%  punctuation. The def of \@footnotemark is stolen from latex.ltx.
\def\@footnotemark{%
  \leavevmode
  \ifhmode\edef\@x@sf{\the\spacefactor}\nobreak\fi
  \ifnum\spacefactor>1200 \kern-.1em\fi% <- added
  \@makefnmark
  \ifhmode\spacefactor\@x@sf\fi
  \relax}

%  bottom = set footnotes at bottom of page even with \raggedbottom
%  marginal = set footnote mark in the margin
%  stable = treat footnotes in section titles correctly
%  multiple = treat multiple consecutive footnotes correctly
\usepackage[bottom,marginal,stable,multiple]{footmisc}
\footnotemargin -0.6em

%  Aus: Axel Reichert, typography.ps ("Typographie -- Gestaltung einer
%  Beispielklasse"), S.58
\setlength{\skip\footins}{14.5pt plus 4pt minus 2pt}
\renewcommand{\footnoterule}{\kern -5pt \hrule width 4cc \kern 4.6pt}


%
%  Blank headers/footers in empty pages
%  (is better when typesetting books, where chapters always start on odd
%  pages).
%  Copied from .../teTeX/share/texmf/tex/latex/base/latex.ltx
%  and modified according to fancyhdr.dvi

\def\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else
	\thispagestyle{empty}
    \hbox{}\newpage\if@twocolumn\hbox{}\newpage\fi\fi\fi}



% Figure captions in sans-serif small
% [Center last line of captions]
% A little bit less space between caption and figure
%

\@ifclassloaded{letter}{
% \abovecaptionskip is not defined
}
{
\RequirePackage{ccaption}
\captionnamefont{\sffamily\small}
\captiontitlefont{\sffamily\small}

\setlength\abovecaptionskip{0.15\baselineskip}
} % else, the document class is probably 'article', 'report', or 'book'


% Flush two columns vertically on last page
\usepackage{flushend}


%
%    Prevent headings from flowing into the margin
%    in case of twocolumn
%

\@ifclassloaded{letter}{
}
{
\if@mylayout@sectsty
\usepackage{sectsty}            % useful for other appearance changes, too
\allsectionsfont{\raggedright}  % with twocolumn, prevents too wide headings
\fi
}



%
%   Redefine \paragraph and \subparagraph,
%   because I don't like the standard LaTeX def.
%
%    BEFORESKIP : Absolute value = skip to leave above the heading.
%                 If negative, then paragraph indent of text following
%                 heading is suppressed.
%    AFTERSKIP  : if positive, then skip to leave below heading, else
%                 negative of skip to leave to right of run-in heading.


\renewcommand{\paragraph}{\@startsection{paragraph}%	% the name
 {4}%                									% the level
 {0pt}%            										% the indent
 {-1.0\baselineskip \@plus -0.5\baselineskip \@minus 0.5\baselineskip}%before..
 {0.5\baselineskip \@plus 0.2\baselineskip \@minus 0.2\baselineskip}% afterskip
 {\normalfont\normalsize\bfseries}%						% the style
}

\renewcommand\subparagraph{\@startsection{subparagraph}%
  {5}%
  {0pt}%
  {0ex  \@plus  1ex   \@minus  .0ex}%
  {-1em \@plus -0.5em \@minus -0.8em}%
  {\normalfont\normalsize\bfseries}%
}



%
%   Fix miscellaneous two column mode "features"
%

\usepackage{fix2col}

%
% Otherwise latex will refuse fractional size values with CM fonts
%

\usepackage{fix-cm}


%
%   Put list item bullets and enumeration numbers flush with the left margin
%   Does not work with mylatex.ltx!
%

\renewcommand\@mklab[1]{#1\hfil}
\let\DefaultMakelabel\@mklab
\g@addto@macro\enumerate{\let\makelabel\DefaultMakelabel}
\g@addto@macro\itemize{\let\makelabel\DefaultMakelabel}

\settowidth{\labelwidth}{0.}
\setlength{\leftmargini}{\labelwidth}
\addtolength{\leftmargini}{\labelsep}
% for equal steps:
\setlength{\leftmarginii}{\leftmargini}
\setlength{\leftmarginiii}{\leftmargini}
\setlength{\itemindent}{0pt}



%
%    Subscripts and Superscripts
%    TeX's default parameters do not move subscripts down far enough.
%    (from http://www.math.cornell.edu/~hatcher/AT/typography.html )
%

%\fontdimen16\textfont2=2.5pt
%\fontdimen17\textfont2=2.5pt
%\fontdimen14\textfont2=4.5pt
%\fontdimen13\textfont2=4.5pt


%
% With letters, we set paragraphs in the ``other'' way
%

\@ifclassloaded{letter}{
\usepackage[parfill]{parskip}
\parskip=0.5\baselineskip plus 0.1\baselineskip minus 0.3\baselineskip
}
{}
	
