% vim: textwidth=75
% process with xelatex
% pdfa/1b validation: https://www.pdf-online.com/osa/validate.aspx
\newcommand\DAtitle{Eine Geschichte der Paraphrenie unter besonderer Berücksichtigung der Wiener Schule der Neurowissenschaften im 19.~und frühen 20.~Jahrhundert}
\newcommand\DAtitleen{A History Of Paraphrenia in the Context of the Vienna school of Neuroscience in the 19th and early 20th century}
\begin{filecontents}{\jobname.xmpdata}
\pdfxSetRGBcolorProfileDir{./}
\pdfxSetCMYKcolorProfileDir{./}
\Title{\DAtitle\sep(\DAtitleen)}
\Author{Alexander Ölzant-Faderler}
\Keywords{Geschichte, Paraphrenie, Medizin, Psychiatrie, Klassifikationssysteme, 19. Jahrhundert}
\Subject{Geschichte der Medizin\sep history and philosophy of science\sep medicine}
\SWOPCGATSI{}
\end{filecontents}

\documentclass[a4paper,12pt,oneside,american,greek,russian, %
draft, % CAVE - turns off hyperlinks unless final mode is chosen below
ngerman]{article} % ngerman == neue Rechtschreibung

%\special{dvipdfmx:config z 9}
% add bibliography to toc
%\usepackage[nottoc,numbib]{tocbibind}

% \usepackage[titleformat={italic,commasep},%
% authorformat={citationreversed,reducedifibidem},%
% ibidem=strict,% name&title&auto}, % lookforgender,%
% %ibidem=name&title&auto, % lookforgender,%
% %citefull=all,
% commabeforerest,% endnote,% crossref={long},%
% square,
% %compress,
% %raggedright,
% %numbered,
% %hyperref=true, %% hyperref-Paket verwenden, um Links zu erstellen (geht nicht)
% bibformat={%noetal,
% ibidem %style=authortitle,
% }]{jurabib} % ibidem
% 

\usepackage{setspace} % needs to be before hypersetup so footnotes don't break
\usepackage{pgfplots} 
\pgfplotsset{compat=1.16}
\usepackage[a-1b]{pdfx}
\usepackage{fontspec,xgreek,polyglossia}
\usepackage{graphicx}
\XeTeXinputencoding "utf8"
% Package inputenc Warning: inputenc package ignored with utf8 based engines.
% \usepackage[utf8]{inputenc}   % utf8 is required
%\usepackage{fontspec,xunicode}
% greek? 
%\usepackage[LGR,T1]{fontenc}
%\newcommand{\textgreek}[1]{\begingroup\fontencoding{T1}\selectfont#1\endgroup}
%\newcommand{\textgreek}[1]{\selectlanguage{greek}#1}
% ???
% \defaultfontfeatures{Scale=MatchLowercase,Mapping=tex-text}

\selectlanguage{ngerman}
%\selectlanguage{german}
\setdefaultlanguage{german}
\setotherlanguage[variant=british]{english}
\setotherlanguage[variant=ancient]{greek}
\setotherlanguage{russian}
\usepackage[T2A,T1]{fontenc}
\usepackage[autostyle]{csquotes}
\usepackage{verbatim}
% for roman numeral enumerate ...
\usepackage{enumerate}

% https://de.wikibooks.org/wiki/LaTeX-W%C3%B6rterbuch:_Silbentrennung
\RequirePackage[ngerman=ngerman-x-latest]{hyphsubst}

\setmainfont[Ligatures=TeX]{CMU Serif}
%\setmainfont{CMUSerif-Roman:script=DFLT,language=dflt}
\setsansfont{CMU Sans Serif}
\setmonofont{CMU Typewriter Text}
\newfontfamily{\greekfont}{CMU Serif}
\newfontfamily{\cyrillicfont}{CMU Serif}
% \newfontfamily{\cyrillicfonttt}{Liberation Mono}
\newfontfamily{\greekfontsf}{CMU Sans Serif}
%\usepackage[10pt]{type1ec}% greek
% already called by documentclass
%\usepackage[ngerman,english,greek,russian]{babel}

% Prostituierten- und SchusterInnenkinder vermeiden 
%\clubpenalty = 10000 
%\widowpenalty = 10000
\widowpenalties=3 10000 10000 150
\clubpenalties=3 10000 10000 150

% \title{ A History Of Paraphrenia in the Context of Psychiatric Classification}
%\def\DAtitle{ Eine Geschichte der Paraphrenie im Kontext der Entstehung psychiatrischer Klassifikationssysteme 1863 - 1914 }
%\def\DAtitleen{ A History Of Paraphrenia in the Context of the Development of Psychiatric Classification Systems 1863 - 1914 }
\makeatletter
\def\ifdraft{\ifdim\overfullrule>\z@
  \expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi}
\makeatother
%\date{\today}
% no date, would appear on title page
\date{}
\author{
%\begin {center}
%Eingereicht von \\
%Alexander Ölzant-Faderler\\
%	09301547
%\end {center}
}


\makeatletter
\title{ 
\thispagestyle{empty}
\begin {center} 
\vspace*{-4cm} 
\hspace{-5cm}\includegraphics[scale=0.5,draft=false]{meduni.jpg}\\
\vspace*{0.5cm} 
\Large{\ifdraft{ENTWURF der }{}Diplomarbeit} \\
\vspace*{0.5cm} 
\Large \bfseries {\DAtitle} \\
\vspace{1cm} 
\normalsize zur Erlangung des akademischen Grades \\
\Large \bfseries Doktor der gesamten Heilkunde \\
\Large \bfseries (Dr.~med.~univ.) \\
\vspace{1cm} 
\normalsize an der \\
\Large \bfseries Medizinischen Universität Wien \\
\vspace{0.5cm} 
\normalsize unter der Anleitung von\\
Priv.-Doz.~Mag.~Dr.~phil.~Dr.~med.~Sonia~Horn\\
\vspace{0.5cm} 
\normalsize externe Lehre \\
\vspace{0.5cm} 
eingereicht von \\
\xmp@Author\\
      09301547 \\
\vspace{2cm}
\noindent\makebox[\linewidth]{
\rule{6cm}{0.4pt}\hfill\rule{6cm}{0.4pt}
}
\vspace{1cm}
Ort, Datum\hfill Unterschrift (Studierende*r)
\end {center}
}
\makeatother

%\fontspec[BoldFont={CMUSerif-Bold}]
%                        {CMU Serif}
%              Helvetica Neue Ultra Light           \\
%{\itshape     Helvetica Neue Ultra Light (italic)} \\
%{\bfseries         Helvetica Neue Roman (bold)}       \\
%{\bfseries\itshape Helvetica Neue Roman (bold italic)}\\


%\DeclareFontFamily{T1}{CMU Serif}{}
%\DeclareFontShape{T1}{CMU Serif}{m}{n}{<-> cmunrm10}{}
%\DeclareFontShape{T1}{CMU Serif}{m}{\itdefault}{<-> ec-lmtlo10}{}
%\DeclareFontShape{T1}{CMU Serif}{\bfdefault}{n}{<-> cmunsx10}{}
%\DeclareFontShape{T1}{CMU Serif}{\bfdefault}{\itdefault}{<-> cmunbi10}{}



% jurabib 2019:
% \AddTo\bibsngerman{\renewcommand*{\urldatecomment}{Abruf: }} %
% \AddTo\bibsngerman{ \def\bibidemSmname{---}\def\idemSmname{Ders.}
% \def\bibidemsmname{---}\def\idemsmname{ders.} }
% \AddTo\bibsngerman{\def\janname{Jänner}}
% \let\biburlprefixold\biburlprefix
% \let\biburlsuffixold\biburlsuffix
% \let\jburldefold\jburldef
% \renewcommand{\biburlprefix}{}
% \renewcommand{\biburlsuffix}{}
% \renewcommand{\jburldef}{}

% xxx
% \AddTo\bibsgerman{\renewcommand{\jburldef}{}}
%\AtEveryCitekey{\clearfield{url}}

% https://www.mrunix.de/forums/showthread.php?50405-jurabib-crossref-bei-INCOLLECTION
% \renewcommand*{\jbpagesep}{:} % Doppelpunkt anstelle Komma vor Seite (Zitat)
% \renewcommand*{\bibansep}{: } % Doppelpunkt nach Autor (Zitat)
% \renewcommand*{\bibsnfont}{\textit} %api = article/essay in coll. it = italic = kursiv
% \renewcommand*{\bibjtfont}{\textit} %api = article/essay in coll. it = italic = kursiv
% \renewcommand*{\bibbtfont}{\textit} %api = article/essay in coll. it = italic = kursiv
% \renewcommand*{\bibapifont}{\textit} %api = article/essay in coll. it = italic = kursiv
% \renewcommand{\bibbtsep}{in } % booktitle and
% \renewcommand{\bibjtsep}{in } % journaltitle separation
% \renewcommand{\bibatsep}{. } % after title sep
%
\newcommand{\tilda}{\def\~{}}
\newcommand{\grad}{\ensuremath{^\circ}}
%\usepackage{german}
%\selectlanguage{\austrian}

% \usepackage[ 
%  breaklinks=true,
%  colorlinks=false, %
%  %allbordercolors={0 0 0},
%  pdfborderstyle={/S/U/W 0.1},
%  pdfhighlight=/I
% % , final % otherwise draft mode above turns off hyperlinks
% ]{hyperref}
\hypersetup{
 breaklinks=true,
 colorlinks=false, %
 % colorlinks, allcolors=blue,
 %allbordercolors={0 0 0},
 pdfborderstyle={/S/U/W 0.1},
 pdfhighlight=/I,
 final, % otherwise draft mode above turns off hyperlinks
% "Option `...' has already been used
%	pdfauthor = {\xmp@Author},
%						pdftitle = {\DAtitle (\DAtitleen)},
%						pdfsubject = {\xmp@Subject},
%						pdfkeywords = {\xmp@keywords},
%						pdfcreator = {XeLaTeX with fonts from http://cm-unicode.sourceforge.net/},
%						pdfproducer = {xdvipdfmx -z 9}
}

						\AtBeginDocument{%
\def\hyper@link@[#1]#2#3#4{\textcolor{\@linkcolor}{#4}\Hy@xspace@end}%
}

% not yet supported with xelatex
% \usepackage{tagpdf}
% \tagpdfsetup{activate-all}

\usepackage[backend=biber,style=authoryear]{biblatex}
\ExecuteBibliographyOptions[book:editor]{useauthor=false}
\renewcommand*{\bibfont}{\small}
\bibliography{paraphrenia_project}

%\let\oldFootnote\footnote
%\newcommand\nextToken\relax
%
%\renewcommand\footnote[1]{%
%    \oldFootnote{#1}\futurelet\nextToken\isFootnote}
%
%\newcommand\isFootnote{%
%    \ifx\footnote\nextToken\textsuperscript{,}\fi}
%
\newcommand\fnsep{\textsuperscript{,}}
% auch größere Abstände akzeptieren, um im Blocksatz zu bleiben:
\sloppy

% \addtolength{\oddsidemargin}{-1.5cm}
% \addtolength{\evensidemargin}{-1.5cm}
% \addtolength{\textwidth}{1.5cm}

% Zeilenabstand: https://texwelt.de/fragen/3/wie-stelle-ich-einen-zeilenabstand-von-15-ein#
% \usepackage{setspace} needs to be before hypersetup so footnotes don't break
\makeatletter
\newcommand{\abstractspacing}{%
  \setstretch{1.44}%  default
  \ifcase \@ptsize \relax % 10pt
    \setstretch {1.263}%
  \or % 11pt
    \setstretch {1.220}%
  \or % 12pt
    \setstretch {1.250}%
  \fi
}

\newcommand{\MSonehalfspacing}{%
  \setstretch{1.44}%  default
  \ifcase \@ptsize \relax % 10pt
    \setstretch {1.448}%
  \or % 11pt
    \setstretch {1.399}%
  \or % 12pt
    \setstretch {1.433}%
  \fi
}
\newcommand{\MSdoublespacing}{%
  \setstretch {1.92}%  default
  \ifcase \@ptsize \relax % 10pt
    \setstretch {1.936}%
  \or % 11pt
    \setstretch {1.866}%
  \or % 12pt
    \setstretch {1.902}%
  \fi
}
\makeatother

\usepackage[margin=2.5cm,left=3cm,nohead]{geometry} % für \enlargethispage


\usepackage[printwatermark]{xwatermark}
\ifdraft{
\newwatermark*[allpages,color=black!50,angle=0,fontsize=12pt,scale=1,xpos=0,ypos=138]{Entwurf \today}
}

\begin{document}
% mehr Platz pro Seite 2021:
%\setlength{\rightmargin}{-1.5cm}% 
%\addtolength{\topmargin}{-1cm}% 
%\addtolength{\textheight}{2cm}%
\input{paraphrenia_hyphenation.tex} 
%
%\fontspec[BoldFont={CMUSerif-Bold}]
%                      {CMU Serif}
\abstractspacing
\enlargethispage{6cm}
\clearpage
\maketitle
\thispagestyle{empty}
\tableofcontents
\thispagestyle{empty}
\clearpage
\input{paraphrenia_0abstracts.tex}
\MSonehalfspacing
\clearpage
\input{paraphrenia_0intro.tex}
\clearpage
\input{paraphrenia_0methods.tex}
\clearpage
\input{paraphrenia_1psych19.tex}
\clearpage
\input{paraphrenia_2paraphrenia.tex}
\clearpage
\input{paraphrenia_3meynert.tex}
\clearpage
\input{paraphrenia_4paraphrenia20c.tex}
\clearpage
\input{paraphrenia_5schluss.tex}
\clearpage
\abstractspacing
\nocite{*}
\printbibliography[heading=bibintoc,title={Literatur}]
%
%jurabib 2019:
%\let\biburlprefix\biburlprefixold
%\let\biburlsuffix\biburlsuffixold
%\let\jburldef\jburldefold
%\bibliography{paraphrenia_project}
%\bibliographystyle{jurabib}       % (uses file "plain.bst")

\end{document}

