\input ltluatex.tex
\input luatex85.sty
\input ucwmac2.tex
\ucwmodule{luaofs}
\ucwmodule{verb}
\ucwmodule{link}
\clickablefalse

\pdfglyphtounicode{summationtext}{2211}
\pdfglyphtounicode{summationdisplay}{2211}
\pdfglyphtounicode{summation}{2211}

\pdfglyphtounicode{parenleftbig}{0028}
\pdfglyphtounicode{parenrightbig}{0029}
\pdfglyphtounicode{parenleftBig}{0028}
\pdfglyphtounicode{parenrightBig}{0029}
\pdfglyphtounicode{parenleftbigg}{0028}
\pdfglyphtounicode{parenrightbigg}{0029}
\pdfglyphtounicode{parenleftBigg}{0028}
\pdfglyphtounicode{parenrightBigg}{0029}

\pdfglyphtounicode{radicalbig}{221A}
\pdfglyphtounicode{radicalBig}{221A}


\input minim-xmp.tex
\startmetadata
    pdfaid:part 2
    pdfaid:conformance U
    stopmetadata


\pdfcompresslevel=0
\pdfobjcompresslevel=0
% \pdfobj{/Alternate /DeviceRGB}

\input glyphtounicode.tex
\pdfgentounicode=1




%Create an OutputIntent in order to correctly specify colours
\immediate\pdfobj stream attr{/N 3} file{sRGB.icc}
\pdfcatalog{%
  /OutputIntents [
    <<
      /Type /OutputIntent
      /S /GTS_PDFA1
      /DestOutputProfile \the\pdflastobj\space 0 R
      /OutputConditionIdentifier (sRGB)
      /Info (sRGB)
    >>
  ]
}





\parskip=5pt plus 3pt minus 2pt
\parindent=0sp

\def\strong#1{{%
\def\emph##1{{\bi{}##1}}%
\bf{}#1%
}}
\def\emph#1{{%
\def\strong##1{{\bi{}##1}}%
\it{}#1%
}}


\def\superscript#1{$^{\hbox{#1}}$}
\def\subscript#1{$_{\hbox{#1}}$}
\newcount\fncount
\fncount=1
\def\fnmark{\superscript{\the\fncount}}
\def\fn#1{\footnote\fnmark{#1}\advance\fncount by 1}
\def\section#1#2{
	{\settextsize{20}\parskip1em\baselineskip1.5em\relax\bf \vfil\eject{#1\kern 1em #2\vskip 12pt}}
	\addtoc\tocsection{#1}{}{#2}
}
\def\subsection#1#2{
	{\settextsize{18}\parskip0.5em\baselineskip1.5em\bf #1\kern 1em #2\vskip 7pt}
	\addtoc\tocsubsection{#1}{}{#2}
}
\def\subsubsection#1#2{
	{\parskip1em\settextsize{16}\bf #1\kern 1em #2}
	\addtoc\tocsubsubsection{#1}{}{#2}
}
\def\subsubsubsection#1#2{{\parskip1em\settextsize{14}\bf #1\kern 1em #2}}
\def\subsubsubsubsection#1#2{{\parskip1em\settextsize{12}\bf #1\kern 1em #2}}
\def\subsubsubsubsubsection#1#2{{\parskip1em\settextsize{10}\bi #1\kern 1em #2}}
\long\def\blockquote#1{\vskip\lineskip\vskip\parskip\hbox{\vrule\hskip5pt\vbox{#1}}}
\def\strikeout#1{FIXME: Strikeout not implemented}
\def\underline#1{FIXME: Underline not implemented}


\def\mathbb#1{\hbox{\bb #1}}



% Fonty
\ofsdeclarefamily [Pagella] {%
   \loadtextfam qplr;%
                qplb;%
                qpli;%
                qplbi;;%
}

% doporučen je horní, dolní a pravý okraj 25 mm, levý okraj 40 mm.
% Protože doba tisknutí prací je už pryč, my máme tejně velkou stránku uprostřed papíru
\voffset 25mm

\hoffset 32.5mm

\vsize\pdfpageheight
\advance\vsize -2\voffset

\hsize\pdfpagewidth
\advance\hsize -2\hoffset

\advance\voffset -\pdfvorigin
\advance\hoffset -\pdfhorigin

\def\MSfeat#1{:mode=node;script=latn;+tlig}
\registertfm qplr      -      file:texgyrepagella-regular.otf\MSfeat{}
\registertfm qplb      -      file:texgyrepagella-bold.otf\MSfeat{}
\registertfm qpli      -      file:texgyrepagella-italic.otf\MSfeat{}
\registertfm qplbi     -      file:texgyrepagella-bolditalic.otf\MSfeat{}

%\setfonts[Pagella/10]
%\def\h{\it}		% hint
%\def\bh{\bi}		% bold hint

\def\N{{\bb N}}
\def\R{{\bb R}}
\def\E{{\bb E}}
\def\O{{\cal O}}
\def\SYM{{\rm SYM}}
\def\frac#1#2{{{#1} \over {#2}}}

\def\mod{\mathrel{\rm mod}}

\settextsize{12}


\def\unparskip{\vskip-\parskip}

\def\floatinsert#1{\par{
	\setbox0=\vbox{\boxmaxdepth=2pt\relax #1}
	\dimen0=\dimexpr \ht0 + \dp0 + \baselineskip + \pagetotal - \pageshrink \relax
	\ifdim\dimen0 > \pagegoal
		\insert\topins{
			\penalty 100
			\splittopskip=0pt
			\splitmaxdepth=\maxdimen
			\floatingpenalty=0
			\box0
			\nobreak\bigskip\medskip
		}
	\else
		\goodbreak\bigskip
		\box0
		\goodbreak\bigskip
		\unparskip
	\fi
}}

% Obecny plovouci objekt: \float{objekt}{popisek}{optional-id}
\def\float#1#2#3{\floatinsert{
\medskip
\centerline{#1}
\medskip
\smallskip
{
	\setbox0=\hbox{#2}
	\ifdim\wd0 < 0.8\hsize
		\centerline{\box0}
	\else
		\centerline{\vtop{
			\hsize=0.8\hsize
			\parindent=0pt
			\leftskip=0pt plus 0.3\hsize
			\rightskip=0pt plus 0.3\hsize
			\parfillskip=0pt
			\spaceskip=0.3333em
			#2
		}}
	\fi
}}}

% Dva floaty vedle sebe: \float{objekt1}{popisek1}{id1}{objekt2}{popisek2}{id2}
\def\twofloats#1#2#3#4#5#6{\floatinsert{
\medskip
\centerline{\vbox{\halign{\hss##\hss&\qquad\hss##\hss\cr
#1&#4\cr
\noalign{\medskip\smallskip}
#2&#5\cr
}}}
}}




% Obsah a odkazy
\newwrite\tocfile
\immediate\openout\tocfile=toc-new.aux

% Voláme: \addtoc\tocmacro{number}{asterisks}{title}
\long\def\addtoc#1#2#3#4{
	\edef\brum{
		\write\tocfile{\string#1{\noexpand\the\noexpand\count0}{#2}{#3}{#4}}
	}
	\brum
}
