
% ##########################################################################################################
\documentclass[a4paper,12pt]{article}
% \usepackage{lipsum}
% \usepackage[columnwise]{lineno}
\usepackage{cxltx}
\usepackage[
left=30mm,
right=25mm,
top=15mm]{geometry}
% \usepackage[headheight=10mm]{geometry}
\usepackage{leading}
\usepackage{parskip}
\usepackage{xeCJK}
\usepackage{dirtree}
\usepackage{lscape} % needed for show-labels
% ..........................................................................................................
% a trick from http://tex.stackexchange.com/questions/16084/high-and-low-cjk-codepoints-in-a-single-xelatex-document
% to automatically select font based on glyph codepoint; note that in order for `zhspacing` to load at all,
% you must install both the SimSun and the SimHei font, even if those fonts are not listed in your font
% choices.
%
%   http://www.fontpalace.com/font-download/SimHei/
%   http://www.fontpalace.com/font-download/SimSun/
\usepackage{zhspacing}
\zhspacing
\newfontfamily\zhfont{Sun-ExtA}
\newfontfamily\commentfont{EB Garamond 12 Regular}
\newfontfamily\verbatimfont[Scale=0.75]{Flow DejaVu Sans Mono}
\newfontfamily\zhcjkextbfont{sunflower-u-cjk-xb}
% \setCJKmainfont{Sun-ExtA}
% \newCJKfontfamily\cjkxbIdeographFont[Scale=1.05,AutoFakeBold=1]{sunflower-u-cjk-xb}
% ..........................................................................................................
\usepackage[nottoc,numbib]{tocbibind} % to make references appear in TOC

\usepackage{fancyhdr}
% \usepackage{fancyvrb}
% \renewcommand{\FancyVerbFormatLine}[1]{%
%   % \makebox[0cm][l]{$\Rightarrow$}#1%
%   % \fontsize{3mm}{3mm}%
%   \color{red}#1%
%   }
% \let\verbatim=\Verbatim
% \renewcommand\verbatim{\Verbatim}
\makeatletter
\renewcommand\verbatim@font{\color{DarkRed}\verbatimfont\leading{4mm}}%\fontsize{3mm}{3mm}}
\makeatletter
% necessary to capture Pandoc's LaTeX output which uses `\texttt` insted of `\verb`:
\renewcommand{\texttt}[1]{{\color{DarkRed}\verbatimfont\leading{4mm}#1}}

\usepackage{rotating} % provides `\begin{sidewaystable}`
\usepackage{etoolbox}
\patchcmd{\quote}{\rightmargin}{\leftmargin 1em\rightmargin}{}{}
\usepackage{enumitem}
\setlist[itemize]{leftmargin=*,label=¶}

\setmainfont[
Mapping=tex-text,
BoldFont={Liberation Sans Bold},
BoldFeatures={Scale=0.8},
ItalicFont={EB Garamond 12 Italic},
% Ligatures={Historic,Rare,TeX},
Ligatures={TeX},
Numbers={Uppercase},
% Style={Swash,Historic},
% CharacterVariant={11,5:0},% 11: make medieval digit `1` look different from small caps `i`
CharacterVariant={11},% 11: make medieval digit `1` look different from small caps `i`
]{EB Garamond 12 Regular}

% \usepackage{ulem} % provides `\dotuline`

\let\CXLTXquote=\quote
\renewenvironment{quote}{%
  \begingroup
  \begin{CXLTXquote}
  \em
}{%
  \end{CXLTXquote}%
  \endgroup%
}
\newenvironment{motto}{\list{}{%
  \begingroup%
  \em%
  \leftmargin=16em%
  \rightmargin=0.0mm}%
  \item[]%
}{%
  \endlist%
  \endgroup%
}
\renewenvironment{quote}{\list{}{%
  \begingroup%
  \em%
  \leftmargin=3em%
  \rightmargin=3em}%
  \item[]%
}{%
  \endlist%
  \endgroup%
}

% \usepackage[hang,flushmargin]{footmisc}
% \usepackage[hang,marginal]{footmisc}
\usepackage[marginal]{footmisc}%
\setlength{\footnotemargin}{-2ex}%
% \renewcommand{\footnotelayout}{\Large}%
\renewcommand{\thefootnote}{\larger[1]\arabic{footnote}}%

\newenvironment{jzrplain}{%
% ..........................................................................................................
% begin
  % thx to http://www.tug.org/TUGboat/tb28-1/tb88bazargan.pdf for the next two settings:
  \lineskiplimit=-10pt%
  \lineskip=0pt%
  \topskip=0pt%
  \setlength{\parskip}{4mm}%
  \setlength{\parindent}{0mm}%
  % \fontsize{\nominalfontsize}{\gridstrutlength}%
  \leading{5.5mm}
  % \makeatletter
  % \preto{\@verbatim}{\topsep=0pt \partopsep=0pt }
  % \makeatother
  \frenchspacing
  \widowpenalty=10000
  \clubpenalty=10000
  }%
% end
  {\par}

% this route should be given as relative to the folder from which you want to xelatex:
\renewcommand{\CXLTXcliRoute}{cxltx/lib/cli}
\renewcommand{\CXLTXtempOutRoute}{/tmp/CXLTXtempout.tex}
\renewcommand{\CXLTXtempErrRoute}{/tmp/CXLTXtemperr.tex}
\renewcommand{\CXLTXhost}{localhost:8910}
% \newcommand{\nodeRun}[2]{\nodeRunScript{\CXLTXcliRoute}{#1}{#2}}

% \makeatletter
% \def\verbatim{\tiny\@verbatim \frenchspacing\@vobeyspaces \@xverbatim}
% \makeatother

\makeatletter
\renewcommand{\paragraph}{%
  \@startsection{paragraph}{4}%
  {\z@}{1ex \@plus 1ex \@minus .2ex}{-1em}%
  {\normalfont\normalsize\bfseries}%
}
\makeatother

% ==========================================================================================================
% QUOTES AND QUOTATIONS
% ..........................................................................................................
% szs: \szs{sozusagen}
% \newcommand{\szs}[1]{‚#1‘}
% \newcommand{\szs}[1]{‹#1›} % 'französisch', 'Rowohlt'; evt extra weißraum lassen!
\newcommand{\szs}[1]{›#1‹} % 'deutsch'

% wrt: \wrt{wörtlich}
% \newcommand{\wrt}[1]{‚‚#1‘‘}
% \newcommand{\wrt}[1]{„#1“}
% \newcommand{\wrt}[1]{«#1»} % 'französisch', 'Rowohlt'; evt extra weißraum lassen!
\newcommand{\wrt}[1]{»#1«} % 'deutsch'

% ttl: \ttl{titel}
\newcommand{\ttl}[1]{\textit{#1}}
% \usepackage{bibgerm} % as per http://www.mrunix.de/forums/showthread.php?t=60922

% ##########################################################################################################
\begin{document}
\begin{jzrplain}



\input{intro.tex}

\clearpage
\begingroup
\thispagestyle{empty}
\tableofcontents
\input{conventions.tex}
\endgroup

\clearpage
\input{README.tex}

\clearpage
\input{examples.tex}

\clearpage
\input{epilogue.tex}

\clearpage
\input{outline.tex}

\bibliography{cxltx-manual}{}
\bibliographystyle{alpha}
% \bibliographystyle{authordate1}
% \bibliographystyle{gerapali} % problematic
% \bibliographystyle{abstract}
% \bibliographystyle{amsalpha}


% \begin{Verbatim}%
% [formatcom=\color{red}]
% First verbatim line.
% Second verbatim line.
% \end{Verbatim}

% % ----------------------------------------------------------------------------------------------------------
% \subsection{(testing)}

% \verb#\currfiledir#:  \currfiledir

% \verb#\currfilebase#: \currfilebase

% \verb#\currfileext#:  \currfileext

% \verb#\currfilename#: \currfilename

% \verb#\currfilepath#: \currfilepath

% \verb#\currfileabsdir#:   \currfileabsdir

% \verb#\currfileabspath#:  \currfileabspath

% % \begin{URL}
% \curlBETA{helo}{foo/bar}
% % \end{URL}

% \urlescapeALPHA{route/to/file}%
% \let\two=\urlescapecurrent%
% \two


% ##########################################################################################################
\end{jzrplain}
\end{document}
