% ============================================================================
% SIMPLE NOVEL TEMPLATE for LaTeX
% Also good for short story anthologies
% 6" x 9" book through CreateSpace or Lulu
% Built by NewMexicoKid 2017-08-05
% Based on the answer by https://tex.stackexchange.com/users/30640/user12711
% Ref: https://tex.stackexchange.com/questions/66902/latex-template-for-typesetting-a-novel
% ============================================================================
\documentclass[ebook,11pt,twoside,openright]{memoir}
\usepackage[paperwidth=6.125in,paperheight=9.25in,top=69.0pt,bottom=66.0pt,headsep=21pt,headheight=66.0pt,outer=36pt,inner=53pt,heightrounded=true]{geometry}
% Use this to debug: showframe

%------------------------------------------------------------------------------
% Widows and orphans
% \usepackage[defaultlines=4,all]{nowidow} % get rid of widow lines - but bottom becomes ragged
\emergencystretch 3em
\widowpenalty=4500
\clubpenalty=4500
\setlength{\parskip}{3ex plus 2ex minus 2ex}
%------------------------------------------------------------------------------

\usepackage{textcomp}    % Not sure what this does
\usepackage{verse}       % for poetry, but you need to end each line with \\
\usepackage{alltt}       % for PRE-formatted poetry


%------------------------------------------------------------------------------
% FONTS:
\usepackage[no-math]{fontspec}    % Lets one use system fonts (but with no math)

% Enabling drop caps
\begin{filecontents}{Zallman.sty}
    \NeedsTeXFormat{LaTeX2e}
    \ProvidesPackage{Zallman}[2007/11/24 v1.0 Zallman CFR]

    \input Zallman.fd

    \DeclareRobustCommand{\Zallmanfamily}{%
    \fontencoding{U}%
    \fontseries{xl}%
    \fontshape{n}%
    \fontfamily{Zallman}%
    \selectfont}
    \DeclareTextFontCommand{\zall}{\Zallmanfamily}

    \endinput
    %% end Zallman.sty
\end{filecontents}
\usepackage[utf8]{inputenc}
\usepackage{lettrine,Zallman}
\renewcommand{\LettrineFontHook}{\Zallmanfamily}

%------------------------------------------------------------
% Enabling black out for blacking out/censoring text with the \blackout command
\newlength{\blackoutwidth}
\newcommand{\blackout}[1]
{%necessary comment
\settowidth{\blackoutwidth}{#1}%necessary comment
\rule[-0.3em]{\blackoutwidth}{1.125em}%necessary comment
}
%------------------------------------------------------------

\setmainfont{Cardo} % Cardo font; https://www.fontsquirrel.com/fonts/cardo
%  --- Supports bolding
% \setmainfont{EBGaramond} % EBGaramond font; this is the free Garamond clone
% You can get EBGaramond from https://www.fontsquirrel.com/fonts/eb-garamond
%  --- Bolding doesn't show up well
% \setmainfont{Rosarivo} % Rosarivo font; see https://www.fontsquirrel.com/fonts/rosarivo
%  --- Didn't seem as complete
% \setmainfont{Crimson} % Crimson font; https://github.com/skosch/Crimson 
%  --- Supports bolding
%------------------------------------------------------------------------------

\let\footruleskip\undefined
\usepackage{fancyhdr} % fancy headers
\usepackage{microtype} % use this to improve typography
\usepackage{hyphenat}\hyphenation{my-word, hyphen-ate, never, hyphen} 

%------------------------------------------------------------------------------
% bottom margin consistency
\usepackage{setspace}
\frenchspacing\flushbottom % fairly consistent bottom margin
\OnehalfSpacing % line spacing set to 1.5 instead of 1
%
% \usepackage{setspace}\onehalfspacing\frenchspacing\flushbottom
% \usepackage{setspace}\onehalfspacing\frenchspacing\raggedbottom
% https://tex.stackexchange.com/questions/65355/flushbottom-vs-raggedbottom
%    \setstretch{1.15}
%    \setlength{\dimen0}{\textheight}
%    \addtolength{\dimen0}{-\topskip}
%    \divide\dimen0\baselineskip
%    \setlength{\textheight}{\number\dimen0 \baselineskip}
%    \addtolength{\textheight}{\topskip}
%------------------------------------------------------------------------------

\usepackage[normalem]{ulem} % Needed for \sout (strikeout)
\usepackage{suffix}         % Needed for different chapter headings
\usepackage[english]{babel}

%------------------------------------------------------------------------------
% Table of Contents
\usepackage{etoc}% only so far to enable multiple uses of "\tableofcontents"
% maybe the document class already allows it.

\usepackage[newparttoc]{titlesec}
% Originally \usepackage{titlesec}; not sure what newparttoc does
% remove chapter name and number: http://blog.chapagain.com.np/latex-remove-chapter-name-and-number/
\titleformat{\chapter}[display]
   {\normalfont\bfseries}{}{0pt}{\Huge}
\usepackage{titletoc} %

\titleformat{\part}[display]
  {\Huge\scshape\filright\centering}
  {}
  {20pt}
  {\thispagestyle{empty}}
\titlecontents{part}[0pt]{\addvspace{2pc}\centering\large\bfseries}{}{}{}%
%------------------------------------------------------------------------------

\usepackage{emptypage} % No headers on empty pages

\DeclareRobustCommand*\AUTHOR [1]{}
\newcommand\SHOWAUTHORS {%
\DeclareRobustCommand*\AUTHOR [1]{{\normalfont\small\itshape ##1}}}

%===================================================================================
% https://tex.stackexchange.com/questions/156862/displaying-author-for-each-chapter-in-book
% The following code not only displays chaptername and author in the TOC but also at the 
% start of each chapter.
\makeatletter
\newcommand\newchapter[2] {\gdef\@chaptertitle{#1}\gdef\@chapterauthor{#2}\chapter[#1 / \AUTHOR{#2}]{#1}\printchapterauthor{#2}}
\newcommand\@chapterauthor{}
\newcommand\@chaptertitle{}
\fancypagestyle{mystyle}{%
    \fancyhf{}%
    \fancyhead[LE]{\thepage\quad\textsc{\@chaptertitle}}% 
    \fancyhead[RO]{\textsc{\@chapterauthor}\quad\thepage}%}
    \renewcommand{\chaptermark}[1]{\markboth{##1}{}}%
}
\makeatother

\setcounter{secnumdepth}{0}
\renewcommand{\chaptername}{}
\renewcommand{\thechapter}{}

\makeatletter
\newcommand{\printchapterauthor}[1]{%
  {\parindent0pt\vspace*{-25pt}%
  \linespread{1.1}\large\scshape#1%
  \par\nobreak\vspace*{35pt}}
  \@afterheading%
}
\makeatother
%===================================================================================

% ---------------------------------------------
% Fancy headers with story name and author
% Refers back to mystyle defined above
% ---------------------------------------------
\pagestyle{mystyle} %fancy
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
% ---------------------------------------------
% bold, no-indent Inspiration with \medbreak
% ---------------------------------------------
\makeatletter
\newcommand{\inspire}[1]{
    \medbreak
    {\parindent0pt % no indentation for this section
    \textbf{#1}
    }
}
\makeatother
% -----------------------------------------------
% authorsc - small caps and bold the author name
% -----------------------------------------------
\makeatletter
\newcommand\authorsc[1]{\textbf{\textsc{#1}}}
\makeatother

% ========================================================================
% Needed for scene breaks with a "flowerleft" flourish
\usepackage{adforn}

% \Scene macro is used for scene breaks * * * * *
%%% \makeatletter
%%% \newcommand{\Scene}{%
%%%    \par\nobreak\@afterheading
%%%    \vspace{\topsep}
%%%    \addvspace{\topsep\relax}
%%%      \noindent\hfil%
%%%      \adfflourishleftdouble\quad\adfflowerleft\quad\adfflourishrightdouble%
%%%      \hfil\par%
%%%    \vspace{\topsep}
%%%    \@afterindentfalse\@afterheading%
%%% }
%%% \makeatother

\makeatletter
\newcommand{\Scene}{%
  \par\nobreak\@afterheading
  \bgroup
  \begin{center}%
      \addvspace{\topsep}
      {{\adfflourishleftdouble\quad\adfflowerleft\quad\adfflourishrightdouble}}%
      \end{center}
  \egroup\@afterindentfalse\@afterheading}
\makeatother
% ========================================================================

% ---------------------------------------------------------------------------
% use begin{itpars} ... end{itpars} around blocks of text to be italicized
% https://tex.stackexchange.com/questions/258394/make-block-of-text-italicized
\newenvironment{itpars}
    {\par\itshape}
    {\par}
% ---------------------------------------------------------------------------
% --------------------------------------------------------------------------
% hyperlinks for the e-book and PDF 
\usepackage{hyperref}
\usepackage{color}
\definecolor{Blue}{RGB}{4, 6, 145}
\hypersetup{colorlinks,linktocpage,linkcolor=Blue,urlcolor=Blue} % linktoc=all,
% --------------------------------------------------------------------------

% ===============================================================  
% Provide the author, title and date for the title page
\author{A Bunch of Authors} \title{Our Little Short Story Anthology} \date{2017-08-15}
% ===============================================================  

\usepackage{babel} % - for lorem ipsum
\usepackage{blindtext} % -- just for lorem ipsum

\begin{document}
\setlength{\parskip}{0pt}

\frontmatter       % the front of the book has (lowercase) roman numerals
\SHOWAUTHORS
% \tableofcontents
% -------------------------------------
% Import the front matter pages
\input{Front_Matter.tex}\clearpage
% -------------------------------------

\mainmatter        % the main part of the book will have standard pages
%
% ======================================================================
%
% Import the chapters; specify chapter title and author with \newchapter
      \part{Book One}
      \newchapter{Story One}{Author One}
      % \input{Story_One}
      \Blindtext\clearpage
      \Blindtext\clearpage
      \Blindtext\clearpage
      \clearpage
      \newchapter{Story Two}{Author Two}
      % \input{Story_Two}
      \Blindtext\clearpage
      \Blindtext\clearpage
      \Blindtext\clearpage
      \clearpage
      \part{Book Two}
      \newchapter{Story Three}{Author One}
      % \input{Story_One}
      \Blindtext\clearpage
      \Blindtext\clearpage
      \Blindtext\clearpage
      \clearpage
      \newchapter{Story Four}{Author Three}
      % \input{Story_Two}
      \Blindtext\clearpage
      \Blindtext\clearpage
      \Blindtext\clearpage
      \clearpage
% ======================================================================
\end{document}
