%%
%% Copyright (C) 2022 by Friedemann Bartels
%%
%% This file 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.  The latest version of this license is in:
%%
%%    http://www.latex-project.org/lppl.txt
%%
%% and version 1.3c or later is part of all distributions of
%% LaTeX version 2008/05/04 or later.
%%

\documentclass[
  draft,
  twoside,
  beginright,
  % fanfold,
  import,
  optimize={quality=50, density=144}
]{xput}

\usepackage{lipsum}
\usepackage{tgheros}
\usepackage[T1]{fontenc}
\renewcommand*\familydefault{\sfdefault}

\pagewidth=200mm
\pageheight=200mm
\margin=20mm
\innermargin=40mm
\gutter=10mm
\bleed=3mm
\safetymargin=5mm
\spinewidth=7mm

\safezone

\newbeforepage{primary}{
  \setgrid[height=\margin, y=0mm]{{{}}}

  \leftpage{
    \text[center]{\thepage}
  }

  \rightpage{
    \text[center]{\hspace*{\fill}\thepage}
  }
}
\setbeforepage{primary}

\begin{document}
  \Large
  \pagenumbering{roman}

  \template[back cover,margin=0mm, inner margin=0mm]{f}{}

  \page[front cover,color=white,page graphic=koepi, inner margin=\margin]{
    \setgrid[width=100mm]{{{1}}}

    \text[bottom]{
      \fontsize{41.3mm}{46mm}\selectfont
      \hskip -3mm
      Berlin
      \fontsize{7.5mm}{13mm}\selectfont%
      \mbox{Photos by Friedemann Bartels}
    }

    \ifspine{
      \setgrid[width=\spinewidth,x=-\spinewidth]{{{1}}}
      \place{0 0 1 1}
      \tikzgraphic{
        \node[rotate=90] at (0.5\width,0.5\height){
          \fontsize{4mm}{8mm}\selectfont
          Xput\ \
        };
      }
    }
  }

  \page{
    \text{
      \strut
      \tableofcontents
    }
  }

  \pagenumbering{arabic}

  \setcounter{page}{0}
  \page[before page=]{}

  \page{
    \text{
      \strut
      \section{Introduction}
      \lipsum[1][1-7]
    }
  }

  \newgraphic{koepi wide}{vpos=0.43, file=koepi}
  \page[double, page graphic=koepi wide, before page=, color=white]{
    \rightpage{
      \text[bottom]{
        \lipsum[1][8-10]
      }
    }
  }

\end{document}