% Set paper size
\setstocksize{9in}{6in}
\settrimmedsize{9in}{6in}{*}
\settrims{0pt}{0pt}

% Set page layout with memoir commands
\setlrmarginsandblock{0.75in}{0.75in}{*}
\setulmarginsandblock{0.75in}{0.75in}{*}
\checkandfixthelayout
\usepackage{graphicx}

% Get nice typography
\usepackage[final,protrusion=true,factor=1125,stretch=70,shrink=70]{microtype}
\usepackage[russian,spanish,UKenglish,american]{babel}
\usepackage [autostyle, english = american]{csquotes}

% Configure Fonts
\usepackage[T2A,T1]{fontenc}
\usepackage{fontspec}
\usepackage{xltxtra,xunicode}

\usepackage{titletoc}
\usepackage{layouts}

\usepackage{lettrine}
\usepackage{nth}

\setromanfont[
	Ligatures=TeX,
	Path=./Crimson_Pro/static/,
	UprightFont=CrimsonPro-Regular,
	BoldFont=CrimsonPro-Bold,
	ItalicFont=CrimsonPro-Italic,
	BoldItalicFont=CrimsonPro-BoldItalic
]{Crimson Pro}


\setsansfont[
	Path=./Rajdhani/,
	UprightFont=Rajdhani-Bold,
	BoldFont=Rajdhani-Bold,
	ItalicFont=Rajdhani-Bold,
	BoldItalicFont=Rajdhani-Bold
]{Rajdhani}

\newfontfamily\logotype[
	Path=./Rajdhani/,
	UprightFont=Rajdhani-Bold,
	BoldFont=Rajdhani-Bold,
	ItalicFont=Rajdhani-Bold,
	BoldItalicFont=Rajdhani-Bold
]{Rajdhani}

\newfontfamily\rajdhanibio[
	Path=./Rajdhani/,
	UprightFont=Rajdhani-Regular,
	BoldFont=Rajdhani-Bold,
	ItalicFont=Rajdhani-Medium,
	BoldItalicFont=Rajdhani-SemiBold
]{Rajdhani}

% Chinese font family for CJK characters
\newfontfamily\chinesefont{PingFang SC}

% Command to switch to Chinese font for CJK text
\newcommand{\cjktext}[1]{{\chinesefont #1}}
 
% Define RL command for dialogue formatting
\newcommand{\RL}[1]{#1}

% Knock down weird paragraphs
\sloppy
 
 % Chapter setup
 \usepackage[dvipsnames]{xcolor}
 \usepackage{tocloft}

 % Define colors used throughout
 \definecolor{dark-gray}{gray}{0.20}
  
 
 % Redefinition of ToC command to get centered heading
 \makeatletter
 \renewcommand\tableofcontents{%
   \pagestyle{DefaultStyle}
   \stdchapter*{\sffamily\LARGE \textbf{\MakeUppercase{\contentsname}}}
   \@mkboth{\MakeUppercase\contentsname}{\MakeUppercase\contentsname}%
   \@starttoc{toc}%
 }

 % Use tocloft to control TOC formatting precisely
 \renewcommand*{\chapternumberline}[1]{}
 \renewcommand*{\cftchapterfont}{\sffamily}
 \renewcommand*{\cftchapterpagefont}{\sffamily}
 \setlength{\cftchapterindent}{0pt}
 \setlength{\cftchapternumwidth}{0pt}
 \setlength{\cftbeforechapterskip}{6pt}




 \makeatother
 
 
 % Configure thes & footers
 \let\footruleskip\undefined
 \usepackage{fancyhdr}

 \nouppercaseheads
 \makepagestyle{DefaultStyle}
 \makeevenhead{DefaultStyle}{\sffamily \thepage}{\sffamily \textsc{\leftmark}}{}
 \makeoddhead{DefaultStyle}{}{\sffamily \textsc{\rightmark} }{\sffamily \thepage}
 \makeevenfoot{DefaultStyle}{}{}{}
 \makeoddfoot{DefaultStyle}{}{}{}

 \makeatletter
 \makepsmarks{DefaultStyle}{%
   \createmark{chapter}{left}{nonumber}{}{.\ }}


 \makeevenhead{plain}{}{}{}
 \makeoddhead{plain}{}{}{}
 \makeevenfoot{plain}{}{}{}
 \makeoddfoot{plain}{}{}{}
 \makeatletter
 \makepsmarks{plain}{%
   \createmark{chapter}{left}{nonumber}{}{.\ }}

 \makeatother

 \let\stdchapter\chapter
 \renewcommand{\chapter}[2]{
 \pagestyle{DefaultStyle}


 \stdchapter*{\sffamily\LARGE \textbf{\MakeUppercase{#1}}\\ \large \color{dark-gray} {\MakeUppercase{#2}}}
 \addcontentsline{toc}{chapter}{\protect\parbox[t]{\dimexpr\textwidth-3em}{\sffamily#1\\ \protect\small\protect\color{gray}\protect\textit{#2}}}
 \def\leftmark{#1}
 \def\rightmark{#2}
 }
 
 \pagestyle{DefaultStyle}
 
 \makeatother
 
 
 
 
 \newlength\drop
 \makeatletter
 \newcommand*\titleM{\begingroup
 \setlength\drop{0.08\textheight}
 \centering
 \vspace*{\drop}
 {\Huge\sffamily Think Weirder}\\[\baselineskip]
 {\scshape\sffamily The Year's Best Science Fiction Ideas}\\[\baselineskip]
 \vfill
 {\large\scshape CSF Press}\par
 \vfill
 %{\scshape \@date}\par
 \vspace*{2\drop}
 \endgroup}
 \makeatother