From 520d48c8fa8936a7a59c6155651dd84116788842 Mon Sep 17 00:00:00 2001
From: Karl Berry <karl@freefriends.org>
Date: Tue, 1 Mar 2016 23:37:17 +0000
Subject: turabian-formatting (28feb16)

git-svn-id: svn://tug.org/texlive/trunk@39910 c570f23f-e606-0410-a88d-b1316a301751
---
 .../turabian-formatting/turabian-formatting.sty    | 833 ++++++++++++---------
 1 file changed, 478 insertions(+), 355 deletions(-)

(limited to 'Master/texmf-dist/tex/latex/turabian-formatting/turabian-formatting.sty')

diff --git a/Master/texmf-dist/tex/latex/turabian-formatting/turabian-formatting.sty b/Master/texmf-dist/tex/latex/turabian-formatting/turabian-formatting.sty
index 4721c0e9db4..36636109f96 100644
--- a/Master/texmf-dist/tex/latex/turabian-formatting/turabian-formatting.sty
+++ b/Master/texmf-dist/tex/latex/turabian-formatting/turabian-formatting.sty
@@ -27,487 +27,610 @@
 
 
 \NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{turabian-formatting}[2015/11/14 Turabian Formatting]
+\ProvidesPackage{turabian-formatting}[2016/02/27 Turabian Formatting]
 
 
 % Flags adjusted with package options
 
 \newif\if@optraggedright\@optraggedrightfalse
 
-\newif\if@optemptymargins\@optemptymarginsfalse
-
 \newif\if@appendbibformat\@appendbibformattrue
 
 \newif\if@endnotesformat\@endnotesformatfalse
 
 
-% Options for package
+% Declare package options
 
 \DeclareOption{raggedright}{\@optraggedrighttrue}
 
-\DeclareOption{emptymargins}{\@optemptymarginstrue}
+\DeclareOption{noadjustbib}{\@appendbibformatfalse}
 
 \DeclareOption{endnotes}{\@endnotesformattrue}
 
-\DeclareOption{noadjustbib}{\@appendbibformatfalse}
 
-\ProcessOptions\relax
+% emptymargins (deprecated option and flag)
 
+\newif\if@optemptymargins\@optemptymarginsfalse
 
-% Packages used throughout
+\DeclareOption{emptymargins}{\@optemptymarginstrue}
 
-\RequirePackage{setspace, xifthen, etoolbox}
 
+\ProcessOptions\relax
 
-% Page geometry and layout
 
-\RequirePackage{geometry}
+\RequirePackage{etoolbox}
 
-\geometry{margin=1in, ignoreall}
-\geometry{headheight=14.5pt, headsep=0.5in-\headheight}
-\geometry{footskip=0.5in-\headheight}
 
-\if@optemptymargins
-	\geometry{includehead}
+% Default margin size of 1 inch on all sides
+\setlength\textwidth{\paperwidth}
+	\addtolength\textwidth{-2in}
+\setlength\hoffset{\z@}
+
+\setlength\textheight{\paperheight}
+	\addtolength\textheight{-2in}
+\setlength\voffset{\z@}
+
+\setlength\oddsidemargin{\z@}
+\setlength\evensidemargin{\z@}
+
+% Default header height set to height of 1 line of text
+\ifcase \@ptsize
+	\setlength\headheight{10pt}
+\or
+	\setlength\headheight{11pt}
+\or
+	\setlength\headheight{12pt}
 \fi
 
+% Set header top and footer baseline to 0.5in from page edges
+\setlength\topmargin{-0.5in}
+\setlength\headsep{0.5in}
+	\addtolength\headsep{-\headheight}
+
+\setlength\footskip{0.5in}
 
-% Text formatting
 
-\doublespacing
-\setlength{\parindent}{0.5in}
+% Set default text spacing as double spaced
+\RequirePackage{setspace}
+\setstretch{2}
 
+% Preserve length of one line of text for subsequent use
+\newlength\tf@singlelineskip
+\setlength\tf@singlelineskip{0.5\baselineskip}
+
+% Set default paragraph indent
+\setlength\parindent{0.5in}
 \if@optraggedright
-	\newlength{\@parindentraggedright}
-	\setlength{\@parindentraggedright}{\parindent}
+	\newlength\tf@parindentraggedright
+	\setlength\tf@parindentraggedright{\parindent}
 	\raggedright
-	\setlength{\parindent}{\@parindentraggedright}
+	\setlength\parindent{\tf@parindentraggedright}
 \fi
 
-\RequirePackage[defaultlines=2, all]{nowidow}
-
-\RequirePackage{url}
-\urlstyle{same}
+% Prevent widowed text with 2 line default
+\PassOptionsToPackage{defaultlines=2, all}{nowidow}
+\AtEndPreamble{%
+	\@ifpackageloaded{nowidow}%
+		{}%
+		{\RequirePackage{nowidow}}}
 
 
-% Notes layout and formatting
+% Footnote layout and formatting
 
+\PassOptionsToPackage{bottom, marginal}{footmisc}
 \if@endnotesformat
 	\PassOptionsToPackage{perpage}{footmisc}
 \fi
 
-\RequirePackage[bottom, marginal]{footmisc}
+\RequirePackage{footmisc}
+
+\setlength\footnotemargin{\parindent}
 
-\setlength{\skip\footins}{12pt}
-\setlength{\footnotesep}{0.833\baselineskip}
+% Chicago symbols used when needed
+\setfnsymbol{chicago}
 
+% Separation between footnotes based on text size
+\ifcase \@ptsize
+	\setlength\footnotesep{16.65pt}
+\or
+	\setlength\footnotesep{18.7pt}
+\or
+	\setlength\footnotesep{20.4pt}
+\fi
+
+\setlength{\skip\footins}{\footnotesep}
+
+% Readjust default footnote rule size and placement
 \renewcommand{\footnoterule}{%
 	\vspace*{-3pt}
 	\hrule width 2in height 0.4pt
-	\vspace*{-10.4pt}}
+	\vspace*{-4pt}}
 
-% Footnote marker formatting: adjust \parindent and raggedright option
-\setlength{\footnotemargin}{0.5in}
+% Command to set footnote punctuation
+\newcommand{\tf@setfnpunct}[1]{\def\tf@thefnpunct{#1\,\,}}
+\tf@setfnpunct{.}
 
+% Renew command for typesetting footnotes
 \renewcommand{\@makefntext}[1]{%
 	\if@optraggedright
 		\raggedright%
 	\fi
-	\setlength{\parindent}{\footnotemargin}%
-	\@thefnmark.\,\,#1}
-
-
-% Header and footer style layouts
-
-\RequirePackage{fancyhdr}
-
-% Other identifier accompanying page number (deprecated formatting command)
-\newcommand{\pageidentifier}{}
-
-\newlength{\@pageidentifierspace}
-\setlength{\@pageidentifierspace}{0em}
-
-\newcommand{\setpageidentifier}[2][3ex]{%
-	\setlength{\@pageidentifierspace}{#1}
-	\renewcommand{\pageidentifier}{%
-		#2\hspace*{\@pageidentifierspace}}}
-
-\setpageidentifier{}
-
-% Draft indicator text (deprecated command not functional)
-\newcommand{\setdraftindicator}[1]{}
-
-% fancyhdr: page styles
-\fancyhf{}
-
-\renewcommand{\headrulewidth}{0pt}
-\renewcommand{\footrulewidth}{0pt}
-
-\fancypagestyle{plain}{%
-	\fancyhf{}
-	\fancyfoot[C]{\normalfont\singlespace \thepage}
-	\if@optemptymargins
-		\setlength{\headheight}{0pt}
-		\setlength{\headsep}{0pt}
-	\fi}
-
-\renewcommand{\plainheadrulewidth}{0pt}
-\renewcommand{\plainfootrulewidth}{0pt}
-
-\fancypagestyle{headings}{%
-	\fancyhf{}
-	\fancyhead[R]{\normalfont\singlespace \pageidentifier\thepage}}
-
-% fancy page style: allow customization of geometry first
-\AtEndPreamble{%
-	\pagestyle{headings}}
+	\setlength\parindent{\footnotemargin}%
+	\@thefnmark\tf@thefnpunct#1}
+
+
+% Redefine headings page style (places page number in header)
+\def\ps@headings{%
+	\let\@oddfoot\@empty
+	\let\@evenfoot\@empty
+	\def\@evenhead{\thepage\hfil\slshape\leftmark}
+	\def\@oddhead{{\slshape\rightmark}\hfil\thepage}
+	\let\@mkboth\@gobbletwo
+	\let\markboth\@mkboth
+	\let\chaptermark\@gobble
+	\let\sectionmark\@gobble}
+
+% Set myheadings page style to be the same as the headings page style 
+\let\ps@myheadings\ps@headings
+
+% Set default page style and page numbering
+\pagestyle{headings}
+\pagenumbering{arabic}
+
+% Adjust empty page style if twoside option used
+\if@twoside
+	\def\cleardoublepage{%
+		\clearpage
+		\ifodd\c@page
+		\else
+			\hbox{}
+			\thispagestyle{empty}
+			\newpage
+		\fi}
+\fi
 
-% Thesis-related front and main matter formatting
-\newlength{\@bindingoffsetfm}
-\setlength{\@bindingoffsetfm}{0in}
 
-\newlength{\@lmarginfm}
-\newlength{\@rmarginfm}
-\newlength{\@tmarginfm}
-\newlength{\@bmarginfm}
-
-% \frontmatter and \tableofcontents preserves geometry specified in preamble
-\AtEndPreamble{%
-	\setlength{\@bindingoffsetfm}{\Gm@bindingoffset}
-	\setlength{\@lmarginfm}{\Gm@lmargin}
-	\setlength{\@rmarginfm}{\Gm@rmargin}
-	\setlength{\@tmarginfm}{\Gm@tmargin}
-	\setlength{\@bmarginfm}{\Gm@bmargin}}
+% Thesis-related document structure formatting
 
 \appto{\frontmatter}{%
-	\singlespacing
-	\newgeometry{left=\@lmarginfm, right=\@rmarginfm, top=\@tmarginfm, bottom=\@bmarginfm, bindingoffset=\@bindingoffsetfm, ignoreall, noheadfoot}
+	\pagenumbering{roman}
 	\pagestyle{empty}}
 
-\if@optemptymargins
-	\preto{\tableofcontents}{%
-		\renewcommand{\contentsname}{Table of Contents}
-		\newgeometry{left=\@lmarginfm, right=\@rmarginfm, top=\@tmarginfm, bottom=\@bmarginfm, bindingoffset=\@bindingoffsetfm, ignoreall, nohead, includefoot, bottom=1in+\headheight}
-		\pagestyle{plain}}
-\else
-	\preto{\tableofcontents}{%
-		\renewcommand{\contentsname}{Table of Contents}
-		\restoregeometry
-		\pagestyle{plain}}
-\fi
+\renewcommand{\contentsname}{Table of Contents}
+
+\preto{\tableofcontents}{%
+	\pagestyle{plain}}
 
 \appto{\mainmatter}{%
-	\doublespacing
-	\restoregeometry
+	\pagenumbering{arabic}
 	\pagestyle{headings}}
 
 
-% Test if \chapter is defined by document class
-% Note: Important to test before titlesec defines \chapter
+% Headings formatting of \chapter, \section, \subsection, and \subsubsection
 
-\newif\if@nochapter\@nochaptertrue
+\setcounter{secnumdepth}{0}
 
-\ifcsdef{chapter}%
-	{\@nochapterfalse}%
-	{}
-
-
-% Title section formatting (including chapter)
-
-\RequirePackage[compact]{titlesec}
-
-\titleformat{\chapter}[display]%
-	{\normalfont\bfseries\normalsize\singlespacing\centering}%
-	{Chapter \thechapter}%
-	{0.833\baselineskip}%
-	{}
-\titlespacing*{\chapter}%
-	{0em}%
-	{-1.2\baselineskip}%
-	{0.833\baselineskip}
-\titlespacing*{name=\chapter,numberless}%
-	{0em}%
-	{-1.2\baselineskip}%
-	{0.833\baselineskip}
-
-\titleformat{\section}[block]%
-	{\normalfont\bfseries\normalsize\singlespacing\centering}%
-	{}%
-	{0pt}%
-	{}
-\titlespacing*{\section}%
-	{0em}%
-	{0.5\baselineskip}%
-	{0pt}
-% Two lines separating \section* heading from text if \chapter not defined
-\if@nochapter
-	\titlespacing*{name=\section,numberless}%
-		{0em}%
-		{0.5\baselineskip}%
-		{0.833\baselineskip}
-\fi
-
-\titleformat{\subsection}[block]%
-	{\normalfont\mdseries\normalsize\singlespacing\centering}%
-	{}%
-	{0pt}%
-	{}
-\titlespacing*{\subsection}%
-	{0em}%
-	{0.5\baselineskip}%
-	{0pt}
-
-\titleformat{\subsubsection}[block]%
-	{\normalfont\bfseries\normalsize\singlespacing\raggedright}%
-	{}%
-	{0pt}%
-	{}
-\titlespacing*{\subsubsection}%
-	{0em}%
-	{0.5\baselineskip}%
-	{0pt}
-
-
-% Title Page: optional text
-
-\newcommand{\subtitle}[1]{\def\@subtitle{#1}}
-\subtitle{}
-
-\newcommand{\course}[1]{\def\@course{#1}}
-\course{}
-
-\newcommand{\institution}[1]{\def\@institution{#1}}
-\institution{}
-
-% Custom title page command (deprecated command not functional)
-\newcommand{\mytitlepage}{}
-
-% Word-count text on title page (deprecated command)
-\newcommand{\setwordcount}[1]{\def\@wordcount{#1}}
-\setwordcount{}
-
-\newcommand{\@makewordcount}{%
-	\ifthenelse{\equal{\@wordcount}{}}%
-		{}
-		{\hspace*{\fill}\@wordcount}}
-
-
-% Renew \maketitle command if “titlepage” option (based on Research Paper title page).
+% \section formatting
 
+\ifcsdef{chapter}%
+	{%	If \chapter defined...
+		% \chapter formatting
+		\def\@makechapterhead#1{%
+			{	\normalfont\bfseries\normalsize\singlespacing\centering
+				\ifnum \c@secnumdepth >\m@ne
+					\if@mainmatter
+						\@chapapp\space \thechapter
+						\par\nobreak
+						\vspace*{1\baselineskip}%
+					\fi
+				\fi
+				\interlinepenalty\@M
+				#1\par\nobreak
+				\vspace{1\baselineskip}}}
+		% \chapter* formatting
+		\def\@makeschapterhead#1{%
+			{	\normalfont\bfseries\normalsize\singlespacing\centering
+				\interlinepenalty\@M
+				#1\par\nobreak
+				\vspace{1\baselineskip}}}
+	}%
+	{%	If \chapter not defined, differentiate and reformat \section*
+		\newlength\tf@ssectafterskip
+		\setlength\tf@ssectafterskip{1\p@}
+
+		% Flag if differentiate and reformat \section*
+		\newif\if@adjustssection\@adjustssectiontrue
+
+		% Command to disable differentiate and reformat \section*
+		\gdef\noadjustssect{\@adjustssectionfalse}
+
+		% Set length of space after \section*
+		\newlength\tf@ssectionafterskip
+		\setlength\tf@ssectionafterskip{\tf@singlelineskip}
+
+		\def\@startsection#1#2#3#4#5#6{%
+			\if@noskipsec \leavevmode \fi
+			\par
+			\@tempskipa #4\relax
+			\@afterindenttrue
+			\ifdim \@tempskipa <\z@
+				\@tempskipa -\@tempskipa \@afterindentfalse
+			\fi
+			\if@nobreak
+				\everypar{}%
+			\else
+				\addpenalty\@secpenalty\addvspace\@tempskipa
+			\fi
+			\setlength\tf@ssectafterskip{#5}
+			\if@adjustssection
+				\ifstrequal{#1}{section}%
+					{\setlength\tf@ssectafterskip{\tf@ssectionafterskip}}%
+					{}%
+			\fi
+			\@ifstar
+				{\@ssect{#3}{#4}{\tf@ssectafterskip}{#6}}%
+				{\@dblarg{\@sect{#1}{#2}{#3}{#4}{#5}{#6}}}}
+	}
+
+% \subsection and \subsubsection formatting
+
+\renewcommand{\section}{%
+	\@startsection{section}{1}%
+		{\z@}%
+		{-\tf@singlelineskip}%
+		{1\p@}%
+		{\normalfont\bfseries\normalsize\singlespacing\centering}}
+
+\renewcommand{\subsection}{%
+	\@startsection{subsection}{2}%
+		{\z@}%
+		{-\tf@singlelineskip}%
+		{1\p@}%
+		{\normalfont\mdseries\normalsize\singlespacing\centering}}
+
+\renewcommand{\subsubsection}{%
+	\@startsection{subsubsection}{3}%
+		{\z@}%
+		{-\tf@singlelineskip}%
+		{1\p@}%
+		{\normalfont\bfseries\normalsize\singlespacing\raggedright}}
+
+
+% Title page commands for use with \maketitle
+
+\newcommand{\subtitle}[1]{\gdef\tf@subtitle{#1}}
+\subtitle{\@empty}
+
+\newcommand{\submissioninfo}[1]{\gdef\tf@submissioninfo{#1}}
+\submissioninfo{\@empty}
+
+\newcommand{\course}[1]{\gdef\tf@course{#1}}
+\course{\@empty}
+
+\newcommand{\institution}[1]{\gdef\tf@institution{#1}}
+\institution{\@empty}
+
+\newcommand{\department}[1]{\gdef\tf@department{#1}}
+\department{\@empty}
+
+\newcommand{\location}[1]{\gdef\tf@location{#1}}
+\location{\@empty}
+
+% Renew \maketitle (for research papers default)
 \if@titlepage
+	% Formatting for titlepage option
 	\renewcommand{\maketitle}{%
 		\begin{titlepage}%
-			\newgeometry{margin=1in, ignoreall, noheadfoot}
-			\let\footnotesize\small
+			\tf@setfnpunct{}
+			\renewcommand*{\thefootnote}{\fnsymbol{footnote}}
 			\let\footnoterule\relax
-			\let\footnote\thanks
 			\normalfont\normalsize\centering\singlespacing
-			\vspace*{-1.2\baselineskip}
+			\parskip=1\baselineskip
+			\vspace*{-2\baselineskip}
 			\vspace*{0.333\paperheight}
 			\vspace*{-1in}
-			\ifthenelse{\equal{\@subtitle}{}}%
-				{%
-					{\bfseries\@title}\par%
-				}%
-				{%
-					{\bfseries\@title :}\par
-					\vspace*{0.833\baselineskip}
-					{\bfseries\@subtitle}\par%
-				}
-			\vspace*{\stretch{1}}
-			\parskip=0.833\baselineskip
-			\@author\par
-			\@course\par
-			\@institution\par
+			{	\bfseries\@title\par%
+				\tf@subtitle\par}%
+			\vspace*{2.35in}
+			\@author\@thanks\par
+			\tf@course\par
+			\tf@submissioninfo\par
 			\@date\par
-			\parskip=0pt
-			\vspace*{\stretch{1}
-			\@makewordcount}
+			\parskip=\z@
 		\end{titlepage}%
-
-		\setcounter{footnote}{0}%
-
-		\global\let\thanks\relax
-		\global\let\maketitle\relax
-
-		\global\let\@thanks\@empty
-		\global\let\@author\@empty
-		\global\let\@course\@empty
-		\global\let\@institution\@empty
-		\global\let\@date\@empty
-		\global\let\@title\@empty
-		\global\let\@subtitle\@empty
-		\global\let\@wordcount\@empty
-
-		\global\let\title\relax
-		\global\let\subtitle\relax
-		\global\let\author\relax
-		\global\let\date\relax
-		\global\let\course\relax
-		\global\let\institution\relax
-		\global\let\and\relax
-		\global\let\setwordcount\relax
-		
-		\restoregeometry}
+		\tf@emptymaketitle
+		\cleardoublepage}
+\else
+	% Formatting for notitlepage option
+	\renewcommand{\maketitle}{%
+		\thispagestyle{plain}
+		{	\renewcommand*{\thefootnote}{\fnsymbol{footnote}}
+			\normalfont\normalsize\centering\singlespacing
+			\parskip=1\baselineskip
+			\vspace*{0.5in}
+			\vspace*{-1.5\baselineskip}
+			{	\bfseries\@title\par%
+				\tf@subtitle\par}%
+			\vspace*{1\baselineskip}
+			\@author\@thanks\par
+			\tf@course\par
+			\tf@submissioninfo\par
+			\@date\par
+			\vspace*{0.5in}
+			\vspace*{-1\baselineskip}}
+		\tf@emptymaketitle}
 \fi
 
+% Command for emptying/completing \maketitle
+\newcommand{\tf@emptymaketitle}{%
+	% if not endnotes, reset footnote counter
+	\if@endnotesformat
+	\else
+		\setcounter{footnote}{0}
+	\fi
 
-% Block quotations/quotes formatting
+	% Clear command content at end of \maketitle
+	\global\let\thanks\relax
+	\global\let\maketitle\relax
+
+	\global\let\@thanks\@empty
+	\global\let\@author\@empty
+	\global\let\@date\@empty
+	\global\let\@title\@empty
+	\global\let\tf@subtitle\@empty
+	\global\let\tf@course\@empty
+	\global\let\tf@institution\@empty
+	\global\let\tf@department\@empty
+	\global\let\tf@location\@empty
+	\global\let\tf@submissioninfo\@empty
+
+	\global\let\title\relax
+	\global\let\author\relax
+	\global\let\date\relax
+	\global\let\subtitle\relax
+	\global\let\course\relax
+	\global\let\institution\relax
+	\global\let\department\relax
+	\global\let\location\relax
+	\global\let\submissioninfo\relax}
+
+
+% Block quotation and quote formatting
+
+\renewenvironment{quotation}
+	{	\list{}{%
+			\setlength\listparindent{\parindent}
+			\setlength\itemindent{\listparindent}
+			\setlength\leftmargin{\parindent}
+			% Adjust right margin based on raggedright option
+			\if@optraggedright	
+				\setlength\rightmargin{\z@}
+			\else
+				\setlength\rightmargin{\leftmargin}
+			\fi
+			\setlength\parsep{\z@}
+			% Place line spacing between text and quotation
+			\ifnumequal{\baselinestretch}{1}%
+				{\setlength\topsep{\baselineskip}}%
+				{\setlength\topsep{\z@}}}%
+		\singlespacing%
+		\item\relax}
+	{\endlist}
+
+% Set quote environment to be the same as the quotation environment
+\def\quote{\quotation}
 
-\RequirePackage{quoting}
 
-\renewcommand*{\quotingfont}{\singlespace}
-\quotingsetup{%
-	vskip=0\baselineskip,
-	leftmargin=0.5in,
-	rightmargin=0.5in}
+% Tables and Figures: float positioning
 
-\if@optraggedright	
-	\quotingsetup{rightmargin=0in}
-\fi
+\setlength\textfloatsep{1\baselineskip plus 2pt}
+\setlength\floatsep{1\baselineskip plus 2pt}
+\setlength\intextsep{1\baselineskip plus 2pt}
 
-\renewcommand{\quotation}{\quoting}
-\renewcommand{\quote}{\quoting}
+\def\fps@table{!htb}
+\def\fps@figure{!htb}
 
 
-% Tables and Figures: float positioning
+% Tables and Figures: caption formatting
 
-\renewcommand\fps@table{!htp}
-\renewcommand\fps@figure{!htp}
+\setlength\abovecaptionskip{\z@}
+\setlength\belowcaptionskip{\z@}
 
-\setlength{\textfloatsep}{1\baselineskip plus0.5\baselineskip minus0.5\baselineskip}
-\setlength{\intextsep}{1\baselineskip plus0.5\baselineskip minus0.5\baselineskip}
+\long\def\@makecaption#1#2{%
+	\vskip\abovecaptionskip
+	\if@optraggedright
+		\raggedright%
+	\fi
+	\small#1. #2\par
+	\vskip\belowcaptionskip}
 
-\RequirePackage{flafter}
 
+% Table footnote (deprecated)
 
-\setlength{\abovecaptionskip}{0pt}
-\setlength{\belowcaptionskip}{0pt}
+\newcommand{\tablenote}[1]{%
+	\if@optraggedright
+		\raggedright%
+	\fi
+	\vspace{1\baselineskip}
+	#1\par}
 
 
-% Tables and Figures: caption formatting
+% Table footnote source line (deprecated)
 
-\RequirePackage{caption}
+\newcommand{\tablesource}{\tablenote}
 
-\captionsetup{%
-	format=plain,
-	font=small,
-	singlelinecheck=false,
-	justification=justified,
-	labelsep=period,
-	skip=0.167\baselineskip}
 
-\if@optraggedright
-	\captionsetup{justification=raggedright}
-\fi
+% thebibliography environment formatting (adjust \@openbib@code hook default)
 
-\captionsetup[table]{position=top}
+\setlength\bibindent{\parindent}
 
-\captionsetup[figure]{position=bottom}
+\renewcommand\@openbib@code{%
+	\singlespacing
+	\setlength\leftmargin{\bibindent}
+	\setlength\itemindent{-\bibindent}
+	\addtolength\itemindent{\labelsep}
+	\addtolength\itemindent{\labelwidth}
+	\setlength\itemsep{\tf@singlelineskip}
+	\setlength\parsep{\z@}}
 
 
-% Tables: table footnote formatting command
+% biblatex-chicago: set formatting defaults
 
-\newcommand{\tablenote}[1]{%
-	\if@optraggedright
-		\raggedright%
-	\fi
-	\vspace{1\baselineskip}
-	#1\par}
+% Provide warning if biblatex-chicago loaded before turabian-formatting
+\@ifpackageloaded{biblatex-chicago}%
+	{%
+		\PackageWarningNoLine{turabian-formatting}{Consider loading the biblatex-chicago package after the turabian-formatting package. See documentation for more information}%
+	}%
+	{}
 
-% Table footnote source line (deprecated command made same as \tablenote)
-\newcommand{\tablesource}{\tablenote}
+\PassOptionsToPackage%
+	{isbn=false, autolang=other, footmarkoff, backend=biber}%
+	{biblatex-chicago}
+
+\if@appendbibformat
+	\AtEndPreamble{%
+		\@ifpackageloaded{biblatex}%
+			{%
+				\renewcommand{\bibsetup}{\singlespacing}
+				\renewcommand{\bibitemsep}{1\baselineskip}
+				\renewcommand{\bibhang}{0.5in}
+			}%
+			{}}
+\fi
 
 
 % endnotes package support: formatting
-% Note: endnotes package causes error when cite keys contain “_”.
+% Note: endnotes package causes error when cite keys contain "_".
 
 \if@endnotesformat
 
-	\RequirePackage{endnotes, chngcntr, xparse}
+	\RequirePackage{endnotes, xparse}
 
 	% Changes footnote marker type and formatting
-	\setfnsymbol{chicago}
+	\tf@setfnpunct{}
 	\renewcommand*{\thefootnote}{\fnsymbol{footnote}}
-	\renewcommand{\@makefntext}[1]{%
-		\if@optraggedright
-			\raggedright%
-		\fi
-		\setlength{\parindent}{\footnotemargin}%
-		\@thefnmark\,\,#1}
 
 	\PassOptionsToPackage{notetype=endonly}{biblatex-chicago}
 
-	% Endnotes layout and formatting
-	\if@nochapter
-		\renewcommand{\enoteheading}{%
-			\section*{\notesname}%
-			\@mkboth{\notesname}{\notesname}%
-			\mbox{}\par%
-			\vspace*{-1.833\baselineskip}%
-			\let\@afterindentfalse\@afterindenttrue
-			\singlespacing}%
-	\else
-		\let\latexchapter\chapter
-
-		\counterwithin*{endnote}{chapter}
-		\renewcommand{\enoteheading}{%
-			\latexchapter*{\notesname}%
-			\@mkboth{\notesname}{\notesname}%
-			\mbox{}\par%
-			\vspace*{-1.833\baselineskip}%
-			\let\@afterindentfalse\@afterindenttrue
-			\singlespacing}%
-
-		% Insert chapter subheadings in \theendnotes
-		\RenewDocumentCommand{\chapter}{som}{%
-			\IfBooleanTF{#1}%
-				{%
-					\latexchapter*{#3}%
-					\setcounter{endnote}{0}%
-					\addtoendnotes{%
-						\noexpand\enotedivision{\noexpand\section*}%
-							{\unexpanded{#3}}}%
-				}%
-				{%
-					\IfNoValueTF{#2}%
-						{\latexchapter{#3}}%
-						{\latexchapter[#2]{#3}}%
-					\addtoendnotes{%
-						\noexpand\enotedivision%
-							{\noexpand\section*}%
-							{\chaptername\ \thechapter}}%
-				}}
-		\def\enotedivision#1#2{\@ifnextchar\enotedivision{}{#1{#2}}}
-	\fi
+	% Endnotes layout and formatting (based on if chapter is defined)
+	\ifcsdef{chapter}%
+		{%	If \chapter defined...
+			\let\tf@chapter\chapter
+
+			% Renew Notes heading formatted as \chapter* (also added to Table of Content)
+			\@addtoreset{endnote}{chapter}
+			\renewcommand{\enoteheading}{%
+				\tf@chapter*{\notesname}%
+				\@mkboth{\notesname}{\notesname}%
+				\addcontentsline{toc}{chapter}{\notesname}%
+				\mbox{}\par%
+				\vspace{-1.5\baselineskip}%
+				\let\@afterindentfalse\@afterindenttrue
+				\singlespacing}%
+
+			% Renew \chapter command to: (1) reset endnotes counter at each chapter, and (2) add subheadings for each chapter in \endnotes formatting.
+			\RenewDocumentCommand{\chapter}{som}{%
+				\IfBooleanTF{#1}%
+					{%
+						\tf@chapter*{#3}%
+						\setcounter{endnote}{0}%
+						\addtoendnotes{%
+							\noexpand\enotedivision%
+								{\noexpand\section*}%
+								{\unexpanded{#3}}}%
+					}%
+					{%
+						\IfNoValueTF{#2}%
+							{\tf@chapter{#3}}%
+							{\tf@chapter[#2]{#3}}%
+						\addtoendnotes{%
+							\noexpand\enotedivision%
+								{\noexpand\section*}%
+								{\chaptername\ \thechapter}}%
+					}}
+			\def\enotedivision#1#2{\@ifnextchar\enotedivision{}{#1{#2}}}%
+		}%
+		{%	If \chapter not defined, Notes heading formatted as \section*
+			\renewcommand{\enoteheading}{%
+				\section*{\notesname}%
+				\markboth{\notesname}{\notesname}%
+				\addcontentsline{toc}{section}{\notesname}%
+				\mbox{}\par%
+				\vspace{-1.5\baselineskip}%
+				\let\@afterindentfalse\@afterindenttrue
+				\singlespacing}%
+		}%
+
+	% Set default endnotes formatting
 	\renewcommand{\enotesize}{\normalsize}
 	\renewcommand{\enoteformat}{%
 		\if@optraggedright
 			\raggedright%
 		\fi
-		\setlength{\parindent}{\footnotemargin}
-		\vspace*{1\baselineskip}
+		\setlength\parindent{\footnotemargin}
+		\vspace{1\baselineskip}
 		\theenmark.\,\,}
 
 \fi
 
 
-% biblatex-chicago: citation formatting defaults
+% emptymargins option (deprecated)
 
-\PassOptionsToPackage%
-	{isbn=false, autolang=other, footmarkoff, backend=biber}%
-	{biblatex-chicago}
+\if@optemptymargins
+
+	% Adjust top margin height by 0.5in
+	\addtolength\textheight{-0.5in}
+	\addtolength\topmargin{0.5in}
+
+	\newlength\tf@headsep
+	\setlength\tf@headsep{\headsep}
+
+	% Load geometry if needed
+	\@ifpackageloaded{geometry}%
+		{}%
+		{\RequirePackage{geometry}}
+
+	% Set geometry package defaults to match default layout
+	\geometry{margin=1in, ignoreall, onecolumn}
+	\geometry{headheight=14.5pt}
+	\geometry{footskip=0.5in}
+	\geometry{includehead}
+
+	% Adjust plain page style formatting
+	\appto{\ps@plain}{%
+		\setlength\headsep{\z@}
+		\setlength\headheight{\z@}}
+
+	\newlength\tf@lmargin
+	\newlength\tf@rmargin
+	\newlength\tf@tmargin
+	\newlength\tf@bmargin
+	\newlength\tf@bindingoffset
+
+	% Adjustments to empty page style layout
+	\newcommand{\tf@emptygeometry}{%
+		\newgeometry{left=\tf@lmargin, right=\tf@rmargin, top=\tf@tmargin, bottom=\tf@bmargin, bindingoffset=\tf@bindingoffset, ignoreall, noheadfoot}}
+		
+	\if@titlepage
+		\preto{\maketitle}{\tf@emptygeometry}
+		\appto{\maketitle}{\restoregeometry}
+	\fi
+
+	\preto{\frontmatter}{\tf@emptygeometry}
+	\preto{\tableofcontents}{\restoregeometry}
+	\preto{\mainmatter}{\restoregeometry}
 
-\if@appendbibformat
 	\AtEndPreamble{%
-		\@ifpackageloaded{biblatex}%
-			{%
-				\AtBeginBibliography{\vspace*{-0.333\baselineskip}}
-				\renewcommand{\bibsetup}{\singlespacing}
-				\renewcommand{\bibitemsep}{1\baselineskip}
-				\renewcommand{\bibhang}{0.5in}
-			}%
-			{}}
+		\setlength\tf@bindingoffset{\oddsidemargin}
+		\geometry{bindingoffset=\tf@bindingoffset, headsep=\tf@headsep}		
+
+		% Preserve lengths for subsequent use with \tf@emptygeometry
+		\setlength\tf@lmargin{\Gm@lmargin}
+		\setlength\tf@rmargin{\Gm@rmargin}
+		\setlength\tf@tmargin{\Gm@tmargin}
+		\setlength\tf@bmargin{\Gm@bmargin}
+		\setlength\tf@bindingoffset{\Gm@bindingoffset}}
+
 \fi
 
 
-- 
cgit v1.2.3

