% ================
% = Layout Setup =
% ================
% see http://ftp.snt.utwente.nl/pub/software/tex/macros/latex/contrib/memoir/memman.pdf

\setstocksize{216mm}{151mm} 		% Page Setup: 3 en 6mm afloop, zoals Word template
\settrimmedsize{210mm}{148mm}{*} 	% Page Size: A5 (\pageav)
\settrims{0mm}{0mm} 				% Zit in de stock size
\settypeblocksize{170mm}{110mm}{*}
%\setpagecc{\paperheight}{\paperwidth}{*} % centers page on stock (trimmings in middle) - NIET nodig, geen A5 op A4 meer

\setlrmargins{*}{17mm}{*} % Horizontal margin. spine, edge, ratio. Spine gets most, auto-calculated.
\setulmargins{*}{20mm}{*}  % Vertical   margin. upper, lower, ratio. 

\setheadfoot{\baselineskip}{2\baselineskip} % headheight and footskip
\setheaderspaces{0.5in}{*}{*} % headdrop, headsep, and ratio

\checkandfixthelayout

% stock/paper and layout settings
%\stockaiv % default is letterpaper (11 by 8.5 inches)
%\pageaiv
%\semiisopage % sets size and pos of typeblock with respect to the page (must call checkandfix...)
%\settrimmedsize{148mm}{210mm}{*} % calculates paper height and width
%\setpagecc{\paperheight}{\paperwidth}{*} % centers page layout on stock page (trimmings in middle)
%\settypeblocksize{}{}{*} % height, width, ratio
%\setlrmargins{}{}{*} % spine, edge, ratio
%\checkandfixthelayout


% ===========================
% = Paragraph/Content Setup =
% ===========================
% paragraph indentation
\usepackage{parskip}
\setlength{\parindent}{15pt}

% for itemization, other symbol - labelitemii, iii, iv, ... kan ook
\renewcommand{\labelitemi}{$\circ$}

% starbreak: only add if at beginning of new page. MD: just '* * *'
\newcommand{\starbreak}{%
    \fancybreak{* * *}%
}
\DeclareRobustCommand{\cs}[1]{\texttt{\char`\\#1}}
\newlength{\tpheight}\setlength{\tpheight}{0.9\textheight}
\newlength{\txtheight}\setlength{\txtheight}{0.9\tpheight}
\newlength{\tpwidth}\setlength{\tpwidth}{0.9\textwidth}
\newlength{\txtwidth}\setlength{\txtwidth}{0.9\tpwidth}
\newlength{\drop}


% =============================
% = Footer/header/index Setup =
% =============================
% for index
\usepackage{imakeidx}
\makeindex[title=Appendix,columns=2,intoc,options= -s indexstyle.ist]
\makepagestyle{desem}
\makeevenfoot{desem}{\footnotesize \thepage}{}{} % hstylei, hlefti, hcenteri, hrighti
\makeoddfoot{desem}{}{}{\footnotesize \thepage}


% ===================
% = Font/Text Setup =
% ===================
\usepackage{tcolorbox}
\usepackage{etoolbox}
\usepackage{fontspec}
\usepackage{mathpazo}
\setmainfont
     [ BoldFont       = texgyrepagella-bold.otf ,
       ItalicFont     = texgyrepagella-italic.otf ,
       BoldItalicFont = texgyrepagella-bolditalic.otf ]
     {texgyrepagella-regular.otf}
% for Japanese chars
\usepackage{xeCJK}
\setCJKmainfont[BoldFont=STHeiti,ItalicFont=STKaiti]{STSong}


% ================
% = Images Setup =
% ================
% for png/pdf inclusion (pdfpages: full-page)
\usepackage{graphicx}
\graphicspath{{img/}}

\usepackage{wrapfig}    % inline l/r
\usepackage{subcaption} % subfigure
\usepackage{calc}		% for adjustimg cmd calculations
\usepackage{changepage} % full-page 
\newcommand{\adjustimg}{% Horizontal adjustment of image
  \checkoddpage%
  \ifoddpage\hspace*{\dimexpr\evensidemargin-\oddsidemargin}\else\hspace*{-\dimexpr\evensidemargin-\oddsidemargin}\fi%
}
\newcommand{\centerimg}[2][width=\textwidth]{% Center an image
  \makebox[\textwidth]{\adjustimg\includegraphics[#1]{#2}}%
}
% \usepackage{pdfpages} % for fullpage png/pdf includes

% figure caption styles - http://www.peteryu.ca/tutorials/publishing/latex_captions
\usepackage[skip=4pt,font=small]{caption}
\captionsetup[figure]{labelformat=simple, labelsep=colon, labelfont=bf, textfont={it}}
\renewcommand{\thefigure}{\thechapter.\Alph{figure}} % set caption label style to 1.A


% ==================
% = Chapter Styles =
% ==================
% hoofdstuk header style ( - 1 -, naam HF)
% to add subtitle to \maketitle
\makeatletter
\providecommand{\subtitle}[1]{
  \apptocmd{\@title}{\par {\large #1 \par}}{}{}
}
\makeatother

\chapterstyle{dash}\renewcommand*{\chaptitlefont}{\normalfont\itshape\LARGE}
\setlength{\beforechapskip}{2\onelineskip}
\setsecheadstyle{\normalfont\Large\raggedright}
