\startenvironment env_uno
\project project_uno

\enableregime[il1] % input encoding iso-latin1
\mainlanguage[de]
\setupencoding[default=ec] % font encoding

% FONT SETTINGS
\usetypescriptfile[type-ubuch] % type definitions
\usetypescript[fiee][ubuch]
\setupbodyfont[ubuch,rm,10pt]
\setupbodyfontenvironment[default][em=italic] % make italic default instead of slanted

\setupindenting[\bodyfontsize]
\setupalign[hanging] % that's not enough...

% LINE BREAKING SETTINGS (not that good...)
\setuptolerance[{horizontal, verytolerant},{vertical, verystrict}]
\clubpenalty=8000% no clubs / keine Schusterjungen
\widowpenalty=8000% no widows / keine Hurenkinder
%\tolerance=1750% line breaking tolerance (ca. 500--3000)
%\emergencystretch=10 pt% additional stretching space per line

% HEADINGS
\setupheads[sectionnumber=no, align=right,
page=no, style=\bf, tolerance=verytolerant]
\setuphead[part]
[style={\ss\bfc}, page=yes, number=yes,
frame=off, placehead=yes, align=right,
before={},
after=\blank, header=empty]
\setuphead[chapter]
[style={\ss\bfb}, header=empty, page=no,
before={\vfil\blank}, after={}, align=right]
\setuphead[title][chapter]
\setuphead[subject]
[style={\ss\bf}, before=\blank, after=\blank]
%\setuphead[subsubject][style=\bf]

\definelist[part]
\setuplist[part]
[before=\blank, style={\ss\bf},
partnumber=no, pagenumber=no,
margin=0pt, width=0pt, distance=0pt]
\definelist[chapter]
\setuplist[chapter]
[alternative=b, partnumber=no, criterium=all,
margin=0pt, width=0pt, distance=0pt, limittext={}]
% define combined table of contents
\definecombinedlist[inhalt]
[part, chapter]
[level=chapter, placehead=yes, criterium=all,
style={\tfc\em}, alternative=b,
offset=none]
\setupcombinedlist[inhalt]
[partnumber=no,
interaction=all]
% define index
\setupregister[index]
[partnumber=no, criterium=all,
pagestyle={\tf}, 
style={\WORD}, 
interaction=pagenumber,
align=yes]

\definepapersize[UNO][width=138mm, height=212mm]
\startmode[correction]
\setuppapersize[UNO][A4]
\stopmode
\startnotmode[correction]
\setuparranging[2SIDE] % imposing
\setuppapersize[UNO][UNO]
\stopnotmode

\setuplayout[alternative=doublesided,
location=middle,
grid=yes, marking=on,
backspace=13mm, width=105mm,
leftmargindistance=0pt,
topspace=13mm,
header=15pt, headerdistance=12pt,
footer=18pt,
textheight=11.5mm]
\setuptolerance[verytolerant]
\setupheader[text][state=stop]
\setupheadertexts[][chapter][part][]
\setupheader[leftwidth=.8\hsize, rightwidth=.8\hsize]
\setupbackgrounds[header][text][frame=off, bottomframe=on]

\setuppagenumbering[alternative=doublesided,
partnumber=no, sectionnumber=no, way=bytext,
location={text,footer,right}]
\setuppagenumber[state=start]
\setupfootnotes[way=bypage]

\def\dots{\thinspace.\thinspace.\thinspace.\thinspace} % ellipsis with smaller spaces (Ellipse mit kleineren Abständen)

% some chapters have long titles, and the publisher wanted to get something different in the t.o.c.:
\def\NurLang#1{\nomarking{\nolist{#1}}}% not in header line, not in toc (nicht in die Kopfzeile, nicht ins Inhaltsverzeichnis)
\def\ExtraTOCline#1{\writebetweenlist[chapter]{\placeongrid{\noindent #1}}}
\setupmarking[chapter][limittext={}] % \nomarking must not show an ellipsis

% lazy index commands
\def\Tindex#1{\index{#1}#1}% at the same time to text and index (gleichzeitig ins Register und in den Text)
\def\Person#1#2{\index{#2, #1}#1 #2}% names in text and "switched" in the index (Nachname, Vorname ins Register)

% subtitles
\def\Untertitel#1{\blank[3pt]{\ss\bf #1}\blank}
\def\Titel#1#2{{\nohyphens\chapter{#1}\Untertitel{#2}}}

\def\KomplexTitel#1#2#3{%
{\writetolist[chapter]{#3}{}%
\nohyphens\title{#1}%
\Untertitel{#2}}}

\def\Autor#1{\blank[small] \hfill #1}% author right aligned (Autorenangabe rechtsbündig)
\def\ILink#1{\goto{#1}[URL(http://#1)]}

% some chapters need remarks that are no footnotes
\definestartstop[Anmerkung][before={\vfill\startlinecorrection\vbox\bgroup\switchtobodyfont[ss,8pt]\noindent},
after={\egroup\stoplinecorrection}]

\setupfloats[width=fit, align=right]
\setupexternalfigures[directory={./bilder}]
\setupcaptions[number=no, align=right,
before={\blank[3pt]}, 
after={\blank[small]}, style={\ss\tfx}]
\setupcombinations[width=fit, align=right, style={\ss\tfx}]

\stopenvironment
