
\RequirePackage{ifpdf}

\ifpdf % We are running pdftex
%\typeout{juhtolv: preamble: We are running pdftex. Choosing ebook.}
%\documentclass[ebook,onecolumn,finnish,14pt,oneside,openany,final]{memoir}
\typeout{juhtolv: preamble: We are running pdftex. Choosing landscape, oneside and openany.}
\documentclass[a4paper,landscape,onecolumn,finnish,17pt,oneside,openany,final]{memoir}
\else % We are NOT running pdftex
%\typeout{juhtolv: preamble: We are not running pdftex. Choosing a4paper.}
\typeout{juhtolv: preamble: We are not running pdftex. Choosing twoside and openright.}
\documentclass[a4paper,onecolumn,finnish,17pt,twoside,openright,final]{memoir}
\fi

%%%%%%%%%%%%%%%%%%%%%
% Packages

% Suometus:
\usepackage[latin9]{inputenc}
\usepackage[T1]{fontenc}

% Loput suometukset (mutta myös enkunkieltä saatetaan tarvita):
\usepackage[finnish,english]{babel}

% if-then-else-rakenteita helposti
\usepackage{ifthen}

% Kuvien lisäys dokumenttiin:
\usepackage{graphicx}

% Laskutehtävien suoritusta (geometry-paketti hyötyy tästä):
\usepackage{calc}

% Helpottaa TeX:iin liittyvien nimien ladontaa (LaTeX, BibTeX jne.)
\usepackage{texnames}

%%%%%%%%%%%%%%%%%
% Font packages

% Yleisimmät erikoismerkit, kuten copyleft
\usepackage{textcomp}
\usepackage{lmodern}
\usepackage{mathpazo}
\renewcommand{\sfdefault}{cmbr}
\renewcommand{\ttdefault}{cmtt}

\renewcommand{\familydefault}{\rmdefault}

% Dingbats-fontteja
\usepackage{pifont}
\usepackage{marvosym}

% PostScript-versioita Computer Modern-fonteista mahd. paljon.
\usepackage{type1cm}
\usepackage{type1ec}

%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Chapter and section titles

\chapterstyle{default}
%\chapterstyle{article}
%\chapterstyle{section}

\setsecnumdepth{part}
\maxtocdepth{subsubsection}

\renewcommand{\parttitlefont}{\fontfamily{ugq}\fontsize{45}{60}\bfseries\raggedright}
\renewcommand{\partnamefont}{\fontfamily{ugq}\fontsize{45}{60}\bfseries\raggedright}
\renewcommand{\partnumfont}{\fontfamily{ugq}\fontsize{45}{60}\bfseries\raggedright}

\renewcommand{\chaptitlefont}{\fontfamily{ugq}\Huge\bfseries\raggedright}
\renewcommand{\chapnamefont}{\fontfamily{ugq}\Huge\bfseries\raggedright}
\renewcommand{\chapnumfont}{\fontfamily{ugq}\Huge\bfseries\raggedright}

\setsecheadstyle{\fontfamily{pag}\huge\bfseries\raggedright}
\setsubsecheadstyle{\fontfamily{pag}\LARGE\bfseries\raggedright}
\setsubsubsecheadstyle{\fontfamily{pag}\Large\bfseries\raggedright}
\setparaheadstyle{\fontfamily{pag}\large\bfseries\raggedright}
\setsubparaheadstyle{\fontfamily{pag}\normalsize\bfseries\raggedright}

%%%%%%%%%%%%%%%%%
% Marginals etc.
\setlength{\parindent}{0mm}

\ifpdf % We are running pdftex
\setlength\stockheight{210mm}
\setlength\stockwidth{297mm}
\settrimmedsize{\stockheight}{\stockwidth}{*}
\settrims{0pt}{0pt}
\setlrmarginsandblock{2cm}{2cm}{*}
\setulmarginsandblock{2cm}{2cm}{*}
\else
\setlength\stockheight{297mm}
\setlength\stockwidth{210mm}
\settrimmedsize{\stockheight}{\stockwidth}{*}
\settrims{0pt}{0pt}
\setlrmarginsandblock{2.5cm}{2.5cm}{*}
\setulmarginsandblock{2.5cm}{2.5cm}{*}
\fi

\ifpdf
\setlength\columnsep{2.5cm}
\else
\setlength\columnsep{0.5cm}
\fi

\setlength\columnseprule{0.5pt}

\setlength\marginparsep{1pt}
\setlength\marginparwidth{1pt}

\checkandfixthelayout

% Normal
\makepagestyle{juhtolv1}
\makerunningwidth{juhtolv1}{\headwidth}
\makeheadrule{juhtolv1}{\headwidth}{1pt}

\ifthenelse{\boolean{@twoside}}{%
\makeheadposition{juhtolv1}{flushright}{flushleft}{}{}
\makeevenhead{juhtolv1}{\myfooterfont\rightmark}{}{} % Chapter
\makeoddhead{juhtolv1}{}{}{\myfooterfont\leftmark} % Section
}%
{%
\makeheadposition{juhtolv1}{flushright}{flushright}{}{}
\makeevenhead{juhtolv1}{}{\myfooterfon\righttmark}{} % Chapter
\makeoddhead{juhtolv1}{}{\myfooterfont\rightmark}{} % Chapter
}%


\ifpdf % We are running pdftex
\typeout{juhtolv: preamble: We are running pdftex. Putting NavigationBar to footer.}
\makeevenfoot{juhtolv1}{}{\myfooterfont\thepage}{\NavigationBar}
\makeoddfoot{juhtolv1}{}{\myfooterfont\thepage}{\NavigationBar}
\else
\typeout{juhtolv: preamble: We are not running pdftex. Not putting NavigationBar to footer.}
\makeevenfoot{juhtolv1}{}{\myfooterfont\thepage}{}
\makeoddfoot{juhtolv1}{}{\myfooterfont\thepage}{}
\fi

\pagestyle{juhtolv1}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Poetry commands (verse)

% Vertical lengths


\setlength{\stanzaskip}{\bigskipamount}
\setlength{\beforepoemtitleskip}{\smallskipamount}
\setlength{\afterpoemtitleskip}{\smallskipamount}
\renewcommand{\poemtitlefont}{\thispagestyle{juhtolv1}\fontfamily{pag}\huge\bfseries\raggedright}

% Horizontal lengths
\setlength{\vgap}{1.5em}

% (re)newcommands
%\renewcommand{\poemtoc}{chapter}
\renewcommand{\poemtoc}{section}

\newcommand{\attrib}[1]{%
\nopagebreak{\medskip \raggedleft\fontsize{20pt}{22pt}\selectfont #1\par}}

% linenumbers
\linenumberfrequency{5}
\linenumberfont{\fontsize{12pt}{14pt}\fontfamily{pag}\selectfont}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Paragraafin eli jakson ekan rivin sisennys:
\setlength{\parindent}{0cm}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ALKAA
%

\begin{document}

\fontfamily{\familydefault} \fontsize{17}{20} \selectfont

% Tämä kytkee päälle roomalaisen sivunumeroinnin yms.
\frontmatter

% Tästedes puhumme suomea:
\selectlanguage{finnish}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Titlepage
%

\killtitle
\begin{titlingpage}

  \begin{center}

    \vfill

    \vfill

    \fontfamily{pag} \selectfont

    {\Huge \textbf{Juhapekka Tolvanen}}

    \vfill

    \fontfamily{ugq} \fontsize{80}{80} \selectfont

    \textbf{Joku hieno otsikko}

    \fontsize{60}{60} \selectfont

    \Female \Email \Mundus \Printer \Male

    \fontfamily{\familydefault} \fontsize{17}{20} \selectfont

    \vfill

    {\huge \textbf{runoja}}

  \end{center}

\end{titlingpage}

\thispagestyle{empty}

\ifpdf
\fontfamily{\familydefault} \fontsize{14}{17} \selectfont
\else
\fontfamily{\familydefault} \fontsize{17}{20} \selectfont
\fi

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Paragraafin eli jakson ekan rivin sisennys:
\setlength{\parindent}{0cm}

% Tämä kytkee päälle normaalin arabialaisia numeroita käyttävän
% sivunumeroinnin ja varmaan jotain muutakin kivaa:
\mainmatter

\ifpdf
\twocolumn
\fi

% Varsinainen leipäteksti alkaa
\pagestyle{juhtolv1}

\chapter{Eka}

Lorem ipsum

\chapter{Toka}

Dolor sit amet


\backmatter

\end{document}

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 

