Subversion Repositories svnkaklik

Rev

Go to most recent revision | Blame | Last modification | View Log | Download

% ctustyle.ex -- the template for typesetting theses at CTU in Prague
% --------------------------------------------------------------------
% Petr Olsak  Jan. 2013

\def\ctustyleversion{beta(q) Mar.2014}

\message{CTUstyle: Thesis at Czech Technical University in Prague, 
         v. <\ctustyleversion>}

%%% Testing versions of csplain / opmac

\def\ctustyleERR#1{\message{ERROR -- #1.}\expandafter\end}

\ifx\chyph\undefined
   \expandafter\ifx \csname @@end\endcsname \relax \else % LaTeX's \end 
      \expandafter \let\expandafter \end \csname @@end\endcsname \fi
   \ctustyleERR {csplain isn't detected, use ``pdfcsplain \jobname'' command}%
\fi

\ifx\pdfoutput\undefined
   \ctustyleERR {pdfTeX isn't detected, use ``pdfcsplain \jobname'' command}%
\fi
\pdfoutput=1

\def\tmp#1#2\end{\if$#2$\else 
   \ctustyleERR {csplain doesn't read UTF-8 encoding, may be it is an old version}\fi}%
\tmp č\end

\newread\testinput
\def\testfile#1#2{\openin\testinput=#1
   \ifeof\testinput \ctustyleERR {#1 not found, install it from #2}\fi 
   \closein\testinput
}
\testfile{opmac.tex}{petr.olsak.net/opmac.html}
\testfile{ams-math.tex}{petr.olsak.net/opmac.html}
\testfile{lmfonts.tex}{petr.olsak.net/csplain.html}

\def\totlist{} \def\toflist{}

\def\Xtab#1#2#3{\addto\totlist{\totline{#1}{#2}{#3}}}
\def\Xfig#1#2#3{\addto\toflist{\tofline{#1}{#2}{#3}}}

\input opmac

\ifx\remskip\undefined
   \ctustyleERR {OPmac older than Jun. 2013. Upgrade from petr.olsak.net/opmac.html}%
\fi

%%% Declaration commands:

\newtoks\faculty
\newtoks\department
\newtoks\title
\newtoks\subtitle
\newtoks\author
\newtoks\supervisor   \let\supervisors=\supervisor
\newtoks\date
\newtoks\studyinfo
\newtoks\authorinfo
\newtoks\workinfo
\newtoks\workname
\newtoks\pagetwo
\newtoks\titleEN     \newtoks\titleCZ     \newtoks\titleSK
\newtoks\subtitleEN  \newtoks\subtitleCZ  \newtoks\subtitleSK
\newtoks\abstractEN  \newtoks\abstractCZ  \newtoks\abstractSK
\newtoks\keywordsEN  \newtoks\keywordsCZ  \newtoks\keywordsSK
\newtoks\thanks
\newtoks\declaration
\newtoks\specification

%%% Mandatory declaration commands

\def\mandatorydecl#1{\if&\the#1&%
   \ctustyleERR {the mandatory item \string#1 is undeclared or empty}%
   \fi
}
\def\makefront{%
   \ifx\mainlanguage\undefined
      \ctustyleERR {The \string\worktype[<type>/<lang>] command 
                    is missing before \string\makefront}\fi
   \everypar={}
   \mandatorydecl\faculty
   \mandatorydecl\title
   \mandatorydecl\author
   \mandatorydecl\date
   \ifnum\worktypenum>0
      \mandatorydecl\abstractEN
      \def\tmp{EN}\ifx\mainlanguage\tmp
         \if&\the\abstractSK&\mandatorydecl\abstractCZ \fi
      \fi
      \def\tmp{CZ}\ifx\mainlanguage\tmp \mandatorydecl\abstractCZ \abstractSK={} \fi
      \def\tmp{SK}\ifx\mainlanguage\tmp \mandatorydecl\abstractSK \abstractCZ={} \fi
      \mandatorydecl\declaration
   \else \mandatorydecl\workname
   \fi
   \edef\tmpa{:F1:F2:F3:F4:F5:F6:F7:F8:MUVS:}
   \edef\tmpb{\noexpand\isinlist\noexpand\tmpa{:\the\faculty:}}\tmpb
   \iftrue \else
      \ctustyleERR {The \noexpand\faculty {\the\faculty} 
                    is not in the list F1, F2, ..., F8, MUVS}%
   \fi
}

\everypar={\normaltypingdenied}

\def\normaltypingdenied{%
   \ctustyleERR{Text outside parameters on line \the\inputlineno.
                Use \noexpand\makefront first}\relax}


%%% Automatically generated multilingual texts:

\def\slet#1#2{\expandafter\let\csname#1\expandafter\endcsname\csname#2\endcsname}
\def\mtdef#1#2#3#4{\sdef{mt:#1:en}{#2} \sdef{mt:#1:\czs}{#3}
  \if$#4$\slet{mt:#1:sk}{mt:#1:\czs}
  \else  \sdef{mt:#1:sk}{#4}
  \fi
}
\edef\czs{\csname lan:5\endcsname} % cz (old) or cs (new)

\mtdef {ctu}   {Czech\nl Technical\nl University\nl in Prague} 
               {České\nl vysoké\nl učení technické\nl v Praze} {} 
% The name of University/Faculty is in Czech even if the document is in Slovak
\mtdef {F1}    {Faculty of Civil Engineering}
               {Fakulta stavební} {}
\mtdef {F2}    {Faculty of Mechanical Engineering}
               {Fakulta strojní} {}
\mtdef {F3}    {Faculty of Electrical Engineering}
               {Fakulta elektrotechnická} {}
\mtdef {F4}    {Faculty of Nuclear Sciences and Physical Engineering}
               {Fakulta jaderná a fyzikálně inženýrská} {}
\mtdef {F5}    {Faculty of Architecture}
               {Fakulta architektury} {}
\mtdef {F6}    {Faculty of Transportation Sciences}
               {Fakulta dopravní} {}
\mtdef {F7}    {Faculty of Biomedical Engineering}
               {Fakulta biomedicínského inženýrství} {}
\mtdef {F8}    {Faculty of Information Technology}
               {Fakulta informačních technologií} {}
\mtdef {MUVS}  {Masaryk Institute of Advanced Studies}
               {Masarykův ústav vyšších studií} {}

\mtdef {abstract}     {Abstract}          {Abstrakt}       {}
\mtdef {thanks}       {Acknowledgement}   {Poděkování}     {Poďakovanie} 
\mtdef {thanks0}      {Acknowledgement}   {Podekovani}     {Podakovanie} 
\mtdef {declaration}  {Declaration}       {Prohlášení}     {Prehlásenie} 
\mtdef {declaration0} {Declaration}       {Prohlaseni}     {Prehlasenie}
\mtdef {keywords}     {Keywords}          {Klíčová slova}  {Kľúčové slová}
\mtdef {trans}        {Title translation} {Překlad titulu} {Preklad titulu}
\mtdef {title0}       {TITLE}             {TITUL}          {}
\mtdef {contents}     {Contents}          {Obsah}          {}
\mtdef {tables}       {Tables}            {Tabulky}        {Tabuľky}
\mtdef {figures}      {Figures}           {Obrázky}        {}
\mtdef {figures0}     {Figures}           {Obrazky}        {}
\mtdef {supervisor}   {Supervisor}        {Vedoucí práce}  {Vedúci práce}
\mtdef {supervisorD}  {Supervisor}        {Školitel}       {Školiteľ}
\mtdef {bibliography} {References}        {Literatura}     {Literatúra}
\mtdef {appendix}     {Appendix}          {Příloha}        {Príloha}     
\mtdef {specifi}      {Specification}     {Zadání}         {Zadanie}
\mtdef {specifi0}     {Specification}     {Zadani}         {Zadanie}

\mtdef {B} {Bachelor's thesis} {Bakalářská práce}  {Bakalárska práca}
\mtdef {M} {Master's thesis}   {Diplomová práce}   {Diplomová práca}
\mtdef {D} {Ph.D. thesis}      {Dizertační práce}  {Dizertačná práca}

\def\keepacc#1{\slet{mt:#10:sk}{mt:#1:sk}\slet{mt:#10:\czs}{mt:#1:\czs}}
\def\keepaccents{\keepacc{thanks}%
  \keepacc{declaration}\keepacc{figures}\keepacc{specifi}}


%%% Worktype

\def\worktype[#1/#2]{%
   \isdefined{wt:#1}\iftrue \csname wt:#1\endcsname \relax
      \else \ctustyleERR {Unknown \noexpand\worktype parameter}\fi
   \isdefined{wl:#2}\iftrue \csname wl:#2\endcsname \relax
      \else \ctustyleERR {Unknown \noexpand\worktype parameter}\fi
}
\sdef{wt:O}{\chardef\worktypenum=0}
\sdef{wt:B}{\chardef\worktypenum=1}
\sdef{wt:M}{\chardef\worktypenum=2}
\sdef{wt:D}{\chardef\worktypenum=3}

\sdef{wl:EN}{\def\mainlanguage{EN}\ehyph}
\sdef{wl:CZ}{\def\mainlanguage{CZ}\chyph}
\sdef{wl:SK}{\def\mainlanguage{SK}\shyph}

%%% Fonts

\input lmfonts
\ifx\font\corkencoded \def\tmp{ec}\else\def\tmp{cs}\fi

\let\serifbf=\tenbf \let\serifbi=\tenbi
\font\tenbf=\tmp-lmssbx10 
\font\tenbi=\tmp-lmssbo10
\font\tenss=\tmp-lmss10
\font\tenssi=\tmp-lmsso10
\regfont\tenss \regfont\tenssi
\def\ss{\tenss} \def\ssi{\tenssi}

%%% Characters

\ifx\font\corkencoded
   \chardef\endash="15
   \chardef\emdash="16
\else
   \chardef\endash="7B
   \chardef\emdash="7C
\fi

\ifx\mubyte\undefined \else
   \mubyte \endash ^^e2^^80^^93\endmubyte % en dash
   \mubyte \emdash ^^e2^^80^^94\endmubyte % em dash
\fi


%%% Colors

\def\Blue{\setcmykcolor{1 .43 0 0}}
\def\liBlue{\setcmykcolor{.2 .08 0 0}}
\def\liGrey{\setcmykcolor{0 0 0 0.13}}
\let\nBlue=\Blue 

\def\blackwhite{\let\Blue=\Grey \let\nBlue=\Black \let\Red=\Grey \let\liBlue=\liGrey}
\let\trysavetoner=\relax

\def\savetoner{\def\trysavetoner{%
  \ifx\drafttext\empty
     \message{WARNING: final (not \string\draft) version,
              \noexpand\savetoner ignored}
  \else
     \let\liBlue=\White
  \fi 
}}

\hyperlinks{\Black}{\Black}
\def\tocborder{1 .8 0} 
\let\pgborder\tocborder
\let\citeborder\tocborder
\let\refborder\tocborder
\let\urlborder\tocborder

\ifx\localcolor\undefined  \let\locc=\relax \else \let\locc=\localcolor \fi


%%% Typesetting area

\margins/2 a4 (32,32,30,30)mm
\typosize[11/13.6]
\parindent=4.1mm \iindent=\parindent

\emergencystretch=2em

\def\makeheadline{\vbox to0pt{\vskip-34pt
  \line{\vbox to10pt{}\the\headline}\vss}\nointerlineskip}
\def\makefootline{\baselineskip=34pt \lineskiplimit=0pt \line{\the\footline}}


%%% Draft

{\tt\thefontsize[10] \global\let\ttt=\thefont}

\def\drafttext{}
\def\draft{\let\destbox=\draftdestbox 
     \def\drafttext{\vbox to0pt{\vss \llap{   
     \Grey \bf\thefontsize[11] Draft: \the\day. \the\month.
     \the\year\Black}}}}

\def\linespacing=#1#2 {\def\thelinespacing{#1#2}}  
\linespacing=1

\def\setlinespacing{%
   \ifdim\thelinespacing pt=1pt \else
      \ifx\drafttext\empty 
            \message{WARNING: final (not \string\draft) version, 
                     \noexpand\linespacing ignored}
         \else
            \baselineskip=\thelinespacing\baselineskip
      \fi 
   \fi
}
\def\draftdestbox[#1#2:#3]{\vbox to0pt{\kern-\destheight
   \pdfdest name{#1#2:#3} xyz\relax
   \if#1r\kern-3pt\llap{\locc\Red\ttt[#3]}\vss
   \else \if#1c\vss\llap{\locc\Red\ttt[\tmpb] }\kern-\prevdepth
   \else \vss \fi\fi}}

%%% PDF info data

\def\pdfinfodata{%
   {\def\TeX{TeX}\def\nl{ }%
    \ifx\pdfunidef\undefined
       \edef\tmp{/Author(\the\author)
            /CreationDate(\the\date)
            /Creator(TeX + CTUstyle)
            /Title(\the\title)
            /Subject(\ifcase\worktypenum
                \the\workname \or \mtext{B}\or \mtext{M}\or \mtext{D}\fi)
            /Keywords(\the\keywordsEN)}
       \edef\toasciidata{\toasciidata}\expandafter \setlccodes \toasciidata{}{}%
       \lowercase\expandafter{\expandafter\def\expandafter\tmp\expandafter{\tmp}}%
    \else
       \pdfunidef\tmpb{\the\author}\edef\tmp{/Author(\tmpb) /CreationDate(\the\date) }%
       \pdfunidef\tmpb{\the\title}%
       \edef\tmp{\tmp /Creator(TeX + CTUstyle) /Title(\tmpb) }%
       \pdfunidef\tmpb{\ifcase\worktypenum
                \the\workname \or \mtext{B}\or \mtext{M}\or \mtext{D}\fi}%
       \edef\tmp{\tmp /Subject(\tmpb) /Keywords(\the\keywordsEN)}%
    \fi
    \pdfinfo{\tmp}}
    \ifx\pdfunidef\undefined\else \keepaccents
       \let\insertoutlineI=\insertoutline
       \def\insertoutline##1{\pdfunidef\tmp{##1}\insertoutlineI{\tmp}}
    \fi
}
\addto\makefront{\pdfinfodata}

%%% Title page

\def\titlepage{
   \insertoutline{\mtext{title0}}
   \line{\locc \let\longlocalcolor=\localcolor
      \Blue \vrule height 230mm width 4mm \Black \hss 
      \vbox to230mm{\advance\hsize by-8mm \parindent=0pt
         \kern.3pt
         \leavevmode \strut\bf \ifcase\worktypenum  
                \the\workname \or \mtext{B}\or \mtext{M}\or \mtext{D}\fi 
         \vskip5mm \picw=3cm \def\picdir{}%
         \line{\inspic{ctulogo.pdf} \hss
            \vbox{\advance\hsize by-34mm
               \baselineskip=17pt\bf\thefontsize[15] 
               \Blue \mtext{ctu}\par
            \kern.5pt}}
         \vskip8mm
         \line{\hbox{\bf\thefontsize[32] \printfaculty}\hss
             \vbox{\advance\hsize by-34mm
                \Black \mtext{\the\faculty}\par
                \the\department}}
         \vskip35mm
         \rightskip=0pt plus1fil
         {\typosize[25/30]\bf \nBlue \the\title \par}
         \if&\the\subtitle&\else \smallskip \fi
         {\typosize[15/25]\bf \nBlue \the\subtitle \par}
         \vskip15mm
         {\bf\thefontsize[15]\Black \the\author \par}
         \the\studyinfo \par
         \the\authorinfo \par
         \vss
         \the\date\par
         \the\workinfo\par
         \if$\the\supervisor$\else 
             \ifnum\worktypenum=3 \mtext{supervisorD}%
             \else \mtext{supervisor}\fi: \the\supervisor\par\fi
         \kern-\prevdepth \kern1pt
}}}
\addto\makefront{%
   \bgroup \hbadness=4000 
   \pageno=-1 \def\advancepageno{\global\advance\pageno by-1 }
   \footline={\hss\drafttext} \titlepage \vfil\break
}
\def\printfaculty{\edef\tmpa{\the\faculty}\def\tmpb{MUVS}%
   \ifx\tmpa\tmpb \thefontsize[28] MÚVS\else \the\faculty \fi}

%%% Page Two

\def\printpagetwo{\null\vskip0pt plus1fil {\parindent=0pt \the\pagetwo\endgraf}}
\addto\makefront{\printpagetwo \endgraf\break} 

%%% Specification page

\def\specifipage{\if&\the\specification&\else
   \insertoutline{\mtext{specifi0}}
   \the\expandafter\specification\space \nextoddpage \fi}
\addto\makefront{\specifipage}

%%% Common front page

\newbox\leftbox  \newbox\rightbox
\newdimen\frontht  \frontht=220mm

\def\sethsizefront{\advance\hsize by-12mm \divide\hsize by2 
   \emergencystretch=2em \righthyphenmin=2 \hbadness=5000 \penalty0 }

\def\frontpage [#1/#2]{
   \hrule height0pt \vskip0pt plus 1filll
   \line{\locc\bf\thefontsize[19]
      \Blue\hss\llap{#1}
      \def\tmp{}\if$#1$\else\def\tmp{/}\fi \if$#2$\else\def\tmp{/}\fi
      \hbox to10mm{\hss\tmp\hss}\rlap{#2}\Black\hss}
   \nobreak\medskip
   \line{\locc\sethsizefront
      \vtop{\hrule width\hsize height0pt \unvbox\leftbox}\hss
      \Blue\vrule height-2pt depth\frontht width4mm\Black\hss
      \vtop{\hrule width\hsize height0pt \unvbox\rightbox}}
}


%%% Declaration page

\splittopskip=12pt plus20pt

\def\prepbox#1{\setbox0=\vsplit #1to0pt \relax}

\def\declpage{
   \setbox\leftbox=\vbox{\sethsizefront \leavevmode\the\thanks}
   \prepbox\leftbox
   \setbox\rightbox=\vbox{\sethsizefront \leavevmode\the\declaration}
   \prepbox\rightbox
   \ifvoid\leftbox \ifvoid\rightbox \let\declpage=\relax \fi\fi
   \ifx\declpage\relax \else
      \insertoutline{\if&\the\thanks&\else\mtext{thanks0}\fi/\mtext{declaration0}}
      \frontpage[\if&\the\thanks&\else\mtext{thanks}\fi/\mtext{declaration}]
   \fi
}
\addto\makefront{%
   \footline={\hss\tenss\thefontsize[11]\romannumeral-\pageno\hss\drafttext}
   \declpage \vfil\break
}
\def\signature {\vskip2cm \indent\tocdotfill\null}
\def\tocdotfill{\leaders\hbox to.4em{\hss.\hss}\hskip 1em plus1fill\relax} 


%%% Abstract page

\def\abstractpage{
   \chardef\orilang=\language
   \setbox\leftbox=\vbox{\sethsizefront \def\message##1{}\leavevmode
         \if&\the\abstractCZ&\shyph \the\abstractSK \par
            \let\keywords=\keywordsSK 
            \let\titleL=\titleSK
            \let\subtitleL=\subtitleSK
         \else \chyph \the\abstractCZ \par
            \let\keywords=\keywordsCZ 
            \let\titleL=\titleCZ
            \let\subtitleL=\subtitleCZ
         \fi
         \if&\the\keywords&\else{\bf\mtext{keywords}:} \the\keywords\par\fi
         \ifnum\orilang=\language \else
            \if&\the\titleL&\else{\bf\mtext{trans}:} \the\titleL
               \if&\the\subtitleL&\else \space(\the\subtitleL)\fi\fi\fi}
   \setbox\rightbox=\vbox{\sethsizefront \def\message##1{}\leavevmode
         \ehyph \the\abstractEN \par
         \if&\the\keywordsEN&\else{\bf\mtext{keywords}:} \the\keywordsEN\par\fi
         \ifnum\orilang=\language \else
            \if&\the\titleEN&\else{\bf\mtext{trans}:} \the\titleEN
               \if&\the\subtitleEN&\else \space(\the\subtitleEN)\fi\fi\fi}
   \prepbox\leftbox \prepbox\rightbox
   \ifvoid\leftbox \ifvoid\rightbox \let\abstractpage=\relax \fi\fi
   \ifx\abstractpage\relax \else
      \insertoutline{Abstrakt/Abstract}
      \frontpage[Abstrakt/Abstract]
   \fi
}
\addto\makefront{%
   \abstractpage \vfil\break
}

%%% Contents

\newbox\tocbox


\def\toclinehook{\advance\rightskip by0pt plus1em}

\def\tocpages{   
   \setbox\tocbox=\vbox{\sethsizefront \iindent=4.7mm \maketoc\vfil}
   \prepbox\tocbox
   \setbox\rightbox=\vsplit\tocbox to\frontht 
   \ifvoid\tocbox
      \insertoutline{/\mtext{contents}}
      \frontpage[/\mtext{contents}]
   \else
      \setbox\leftbox=\box\rightbox
      \setbox\rightbox=\vsplit\tocbox to\frontht
      \insertoutline{\mtext{contents}/}
      \frontpage[\mtext{contents}/]
   \fi      
   \loop \ifvoid\tocbox \let\tmp=\relax
         \else  \vfil\break 
                \setbox\leftbox=\vsplit\tocbox to\frontht
                \setbox\rightbox=\vsplit\tocbox to\frontht
                \frontpage[/]\let\tmp=\do 
         \fi 
         \ifx\tmp\do \repeat
}
\addto\makefront{%
   \tocpages \vfil\break
}

%%% Tables / Figures

\newbox\tofbox  \newbox\totbox

\def\tofpages{
   \setbox\tofbox=\vbox{\sethsizefront \iindent=9mm \toflist\vfil}
   \setbox\totbox=\vbox{\sethsizefront \iindent=9mm \totlist\vfil}
   \prepbox\tofbox \prepbox\totbox
   \let\tmp=\do
   \ifvoid\tofbox \ifvoid\totbox \let\tmp=\relax \fi\fi
   \ifx\tmp\do
      \insertoutline{\ifvoid\totbox\else \mtext{tables}\fi/%
                     \ifvoid\tofbox\else \mtext{figures0}\fi}
      \setbox\leftbox=\vsplit\totbox to\frontht
      \setbox\rightbox=\vsplit\tofbox to\frontht
      \frontpage[\ifdim\wd\leftbox=0pt  \else\mtext{tables}\fi/%
                 \ifdim\wd\rightbox=0pt \else\mtext{figures}\fi]
      \loop \let\tmp=\relax
            \ifvoid\totbox \else \setbox\leftbox=\vsplit\totbox to\frontht
                                 \let\tmp=\do \fi
            \ifvoid\tofbox \else \setbox\rightbox=\vsplit\tofbox to\frontht 
                                 \let\tmp=\do \fi
            \ifx\tmp\do \vfil\break \frontpage[/] \repeat
   \fi
}
\addto\makefront{%
   \tofpages \vfil\break
}

%%% Typessetting of the document:

\addto\makefront{%
   \footline={\hss\drafttext}
   \ifodd\pageno\else \null\vfil\break \fi
   \pageno=-\pageno \advance\pageno by-1 % page ranges (roman/decimal numeral)
   \pdfcatalog{/PageLabels<</Nums[0<</S/r>>\the\pageno<</S/D>>]>>}
   \egroup
   \setlinespacing
   \trysavetoner
   \pageno=1 \def\advancepageno{\global\advance\pageno by1 }
   \footline={\hss\tenss\thefontsize[11]\the\pageno\hss\drafttext}
   \outlines{0}\pdfcatalog{/PageMode /UseOutlines}
}

%%% Chapter, section

\def\printchap#1{\vfil\supereject \vglue1cm
  \headline={\hfil\nextheadline}\xdef\headchap{\ifnonum\else\thechapnum.\ \fi#1}\mark{}
  \line{\locc\Blue\vrule height 11mm width4mm
  \hss\vtop{\advance\hsize by-8mm
     \chapfont \noindent
     \Black \ifnonum\else\mtext{chap} \fi
     {\bf\thefontsize[30]\dotocnum{\thechapnum}}\par\nobreak
  \noindent\nBlue #1\strut\nbpar}}%
  \nobreak\bigskip
  \firstnoindent
}
\def\printsec#1{\removelastskip 
  \ifnum \lastpenalty<1000 \goodbreak \fi \bigskip\medskip
  \line{\locc\Blue\vrule height 6mm width4mm depth1mm
  \hss\vtop{\locc\advance\hsize by-8mm
     \secfont \noindent \Black\dotocnum{\thesecnum\quad}%
     \nBlue#1\strut\nbpar}}%
  \insertmark{#1}%
  \nobreak\medskip 
  \firstnoindent
}
\def\printsecc#1{\removelastskip 
  \ifnum \lastpenalty<1000 \goodbreak \fi \smallskip\medskip
  \line{\locc\Blue\vrule height 3.5mm width4mm\Black 
  \hss\vtop{\locc\advance\hsize by-8mm
   \seccfont \noindent \dotocnum{\theseccnum\quad}%
   \nBlue#1\strut\nbpar\kern-4.5pt}}%
  \nobreak\smallskip\kern2pt
  \firstnoindent
}
\def\sechook#1\relax{\seccnum=0 \relax}

\def\nextheadline{\global\headline={\printheadline}}

\def\printheadline{\locc\tenssi\thefontsize[10]\ifodd\pageno
     \hskip-3.7cm\tecky\if&\firstmark&\else\ \fi\locpgcolor\Grey\firstmark\Black
   \else\locpgcolor\Grey\headchap\ \tecky\hskip-3.7cm\fi}

\def\onesideprinting{\def\printheadline{\locc\tenssi\thefontsize[10]
     \locpgcolor\Grey\expandafter\ignoretospace\headchap\ \tecky
     \if&\firstmark&\else\ \fi\locpgcolor\Grey\firstmark\Black}
   \def\nextoddpage{\vfil\supereject}\shiftoffset=0pt
}
\def\ignoretospace#1\ {}

\bf\thefontsize[25]\let\bigdotfont=\thefont \rm
\def\tecky{\locc\liBlue\xleaders\hbox to10.5pt{\bf\bigdotfont\hss.\hss}\hfil\Black}

%%% Appendicies

\newcount\appnum
\def\appletter{\ifcase\appnum ?\or A\or B\or C\or D\or E\or F\or G\or H\or
   I\or J\or K\or L\or M\or N\or O\or P\or Q\or R\or S\or T\or U\or V\or
   W\or X\or Y\or Z\else ?\fi}

\def\app#1\par{\global\advance\appnum by1
  \ifx\chap\nochap \else \nextoddpage \global\let\chap=\nochap \fi
  \secnum=0 \seccnum=0 \relax
  \edef\theappnum{\appletter}\let\thechapnum=\theappnum \let\thetocnum=\theappnum
  \gdef\sechook ##1\def{\global\seccnum=0 
       \edef\thesecnum{\theappnum.\the\secnum}\let\thetocnum=\thesecnum
       \def}%
  \gdef\secchook ##1\def{%
       \edef\theseccnum{\theappnum.\the\secnum.\the\seccnum}\let\thetocnum=\thes
       \def}%
  \def\dotocnumafter{\wcontents\Xchap{#1}}% 
  \printapp{#1\unskip}\mark{}%
  \nobreak
}
\def\nochap#1\par{\message{CTUstyle WARNING: \noexpand\chap inside
                           Appendices is ignored.}}

\def\printapp#1{\vfil\supereject \vglue1cm
  \headline={\hfil\nextheadline}\xdef\headchap{\theappnum\ #1}\mark{}
  \line{\locc\Blue\vrule height 11mm width4mm\Black
  \hss\vtop{\locc\advance\hsize by-8mm
     \chapfont \noindent
     \mtext{appendix} {\bf\thefontsize[30]\dotocnum{\theappnum}}\par\nobreak
  \noindent\nBlue #1\strut\nbpar}}%
  \nobreak\bigskip
  \firstnoindent
}

\def\bibchap{\nonum \chap \mtext{bibliography}\par}


%%% Captions

\def\thetnum{\thechapnum.\the\tnum}
\def\athetnum{.}
\def\thefnum{\thechapnum.\the\fnum}
\def\athefnum{.}
\def\captionhook#1{\typosize[10/12]%
   \ifx\clabeltext\undefined \else
      \ifx#1t\edef\tmp{\noexpand\wref\noexpand\Xtab
                       {{\lastlabel}{\thetnum}{\clabeltext}}}\tmp
      \else  \edef\tmp{\noexpand\wref\noexpand\Xfig
                       {{\lastlabel}{\thefnum}{\clabeltext}}}\tmp
   \fi\fi
   \global\let\clabeltext=\undefined
}
\def\printcaption#1#2{{\bf#1 #2.}\enspace}

\def\clabel[#1]#2{\gdef\clabeltext{#2}\label[#1]}

\def\tofline#1#2#3{{\leftskip=\iindent \rightskip=\iindent plus1em
   \noindent\llap{\bf\ref[#1].\enspace}%
   {#3\unskip}\nobreak\tocdotfill\pgref[#1]\nobreak\hskip-\iindent\null\par}}
\let\totline=\tofline

%%% Numbered paragraphs

\newcount\numA \newcount\numB \newcount\numC \newcount\numD \newcount\numE

\def\chaphook#1\relax{\numA=0 \numB=0 \numC=0 \numD=0 \numE=0 
   \secnum=0 \seccnum=0 \tnum=0 \fnum=0 \dnum=0 \relax}

\def\numberedpar#1#2{\par \global\advance\csname num#1\endcsname by1
   \noindent\wlabel{\thechapnum.\the\csname num#1\endcsname}%
   {\bf#2 \thechapnum.\the\csname num#1\endcsname.}\space} 

%%% Blue verbatim

\ttindent=\parindent

{\tenss \thefontscale[700] \global\let\sevenss=\thefont}

\def\tthook{\parskip=0pt \typosize[10.5/13.6]}

\def\begtt{\ttskip\bgroup \wipeepar
   \setverb \adef{ }{ }%
   \ifx\savedttchar\undefined \else \catcode\savedttchar=12 \fi
   \parindent=\ttindent
   \tthook\relax
   \everypar={\rlap{\locc\liBlue 
    \hskip-\ttindent \vrule width\hsize \strut}%
    \ifnum\ttline<0 \else \global\advance\ttline by1
                \llap{\locc\Blue\sevenss\the\ttline\kern.5em\indent}\fi \kern2pt\Black}
   \def\par##1{\endgraf\ifx##1\egroup\else\penalty\ttpenalty\vskip-1pt\leavevmode\fi ##1}
   \obeylines \startverb
}

\def\viprintline{\vskip-1pt\indent
   \rlap{\locc\liBlue \hskip-\ttindent \vrule width\hsize \strut}%
   \ifnum \ttline<-1 \else 
      \llap{\locc\Blue\sevenrm\ifnum\ttline<0 \the\viline \else
               \global\advance\ttline by1 \the\ttline \fi \kern.5em\indent}\kern2pt
   \fi
   \Black \tmp\par % print the line from \tmp
}

 
%%% Blue centered tables

\def\ctable#1#2{
   \centerline{\setbox0=\table{#1}{#2}%
   \rlap{\locc\liBlue \tmpdim=\ht0 \advance\tmpdim by3pt
   \vrule width\wd0 height\tmpdim depth5pt\Black}\box0}\nobreak\medskip
}
\def\tabiteml{\indent}\def\tabitemr{\indent}

\def\cinspic#1 {\centerline{\inspic #1 }\nobreak\medskip}
\let\oriendinsert=\endinsert
\def\endinsert{\par\oriendinsert}

%%% Items

\def\normalitem{\locc\Blue{\bf\thefontsize[35].\kern-4pt}\Black\enspace}
\sdef{item:x}{\raise.4ex\hbox{\locc\Blue\bf\thefontsize[17].\Black} }
\sdef{item:n}{\the\itemnum.\kern.25em }

%%% BibItems

\let\oriurl=\url

\def\bibtexhook{%
   \parindent=2\iindent
   \def\url##1{\unskip\hfil\break %{\rm\thefontsize[8]URL}:
      {\typosize[10/]\nobreak\space\oriurl{##1}}}
}
\def\bib[#1]{\par \ifnum\bibnum>0 \bibskip \fi
   \advance\bibnum by1
   \wbib{#1}{\the\bibnum}%
   \hangindent=2\iindent
   \noindent \dest[cite:\the\bibnum]{1.2em}%
   \indent \llap{[\the\bibnum] }\ignorespaces
}


%%% Last thinks:

\def\abbrv[#1]{\par \noindent\llap{#1\quad}\ignorespaces}

\def\urlnote#1{\fnote{\url{#1}}}
\def\nextoddpage{\vfil\supereject
   \ifodd\pageno \else \shipout\null \advancepageno \fi}

\addto\runningfnotes{\addto\chaphook{\global\fnotenum=0}}

\shortcitations
\def\dprime{"}
\activettchar"

\endinput

%%% Versions:

beta(a) Jan.2013  First version released
beta(b) Jan.2013  - 1 mm corrected in title page
                  - Dodatok -> Priloha (Slovak phrase)
                  - liBlue is somewhat lighter (0.3 -> 0.2)
                  - \blackwhite and \savetonner introduced
                  - \headline, \footline shifted
                  - empty \thanks corrected
                  - \nextoddpage, \urlnote introduced
beta(c) Jan.2013  - new internal color macros
beta(d) Feb.2013  - skolitel/vedouci-prace set off
beta(e) Feb.2013  - \bibchap introduced, more space below \headline
beta(f) Feb.2013  - \numberedpar introduced
beta(g) Mar.2013  - \pagetwo added
beta(h) Mar.2013  - \ifnum\lastpenalty added
beta(i) May 2013  - \Black title in \blackwhite version
                  - pagenumbers are now shown in right type in Acroread
                  - pdfinfo introduced  
beta(j) May 2013  - \input pdfuni gives accented PDFoutlines + pdfinfo
beta(k) Jul.2013  - Correction for OPmac version Jul 2013
                  - \blackwhite mode: titles in Black
                  - \specification introduced
beta(l) Jul.2013  - \splittopskip-12pt plus20pt in order to avoid underfull
beta(m) Sep.2013  - \tofline: \rightskip=1\iindent
                  - \margins centered
beta(n) Oct.2013  - \savetonner -> \savetoner
                  - \onesideprinting introduced
beta(o) Nov.2013  - multilanguage: cz -> cz (accepts both variants)
beta(p) Dec.2013  - \mtext in \bibchap added (bug correction)
                  - \supereject in \chap, \app, \nextoddpage (bug correction)
beta(q) Mar.2014  - \declaration+abstracts are optional if \worktype[O/*]