From 1ed5d9b695419abb03e5a2e9d7b50fbf1be8fe34 Mon Sep 17 00:00:00 2001
From: Karl Berry <karl@freefriends.org>
Date: Sun, 15 Nov 2015 23:39:02 +0000
Subject: turabian-formatting (15nov15)

git-svn-id: svn://tug.org/texlive/trunk@38863 c570f23f-e606-0410-a88d-b1316a301751
---
 .../turabian-formatting/turabian-formatting.sty    | 451 ++++++++++++---------
 1 file changed, 249 insertions(+), 202 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 786475d0935..4721c0e9db4 100644
--- a/Master/texmf-dist/tex/latex/turabian-formatting/turabian-formatting.sty
+++ b/Master/texmf-dist/tex/latex/turabian-formatting/turabian-formatting.sty
@@ -1,6 +1,7 @@
 % Turabian Formatting for LaTeX
 %
-% Based on the Chicago Manual of Style (16th edition) and Kate Turabian's A Manual for Writers of Research Papers, Theses, and Dissertations (8th edition)
+% Based on the Chicago Manual of Style (16th edition) and Kate Turabian's A
+% Manual for Writers of Research Papers, Theses, and Dissertations (8th edition)
 %
 % ==============================
 % Copyright 2013 Omar Abdool
@@ -17,49 +18,38 @@
 % LPPL Maintenance Status: maintained (by Omar Abdool)
 %
 % This work consists of the files: turabian-formatting.sty,
-% turabian-researchpaper.cls, turabian-thesis.cls, turabian-formatting-doc.tex, % and turabian-formatting-doc.pdf (in addition to this README file).
+% turabian-researchpaper.cls, turabian-thesis.cls, turabian-formatting-doc.tex,
+% and turabian-formatting-doc.pdf (in addition to the README file).
 %
 % ==============================
 %
-% Documented errors from required packages (ignore):
-%	- LaTeX warning: "xparse/redefine-command"
-%	  Redefining document command \oldstylenums with arg. spec. 'm' on line 128.
-%
-% Implementation notes:
-%	- package must be loaded before biblatex-chicago to work properly;
-%	- known bug: use of geometry showframe option and plain page style with emptymargins option
-%
 %
 
 
 \NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{turabian-formatting}[2014/12/27 Turabian Formatting]
+\ProvidesPackage{turabian-formatting}[2015/11/14 Turabian Formatting]
 
 
 % Flags adjusted with package options
 
-\newif\if@draftwork\@draftworkfalse
-
 \newif\if@optraggedright\@optraggedrightfalse
 
 \newif\if@optemptymargins\@optemptymarginsfalse
 
-\newif\if@maketitlepage\@maketitlepagetrue
+\newif\if@appendbibformat\@appendbibformattrue
 
-\newif\if@appendrefformat\@appendrefformattrue
+\newif\if@endnotesformat\@endnotesformatfalse
 
 
 % Options for package
 
-\DeclareOption{draft}{\@draftworktrue}
-
 \DeclareOption{raggedright}{\@optraggedrighttrue}
 
 \DeclareOption{emptymargins}{\@optemptymarginstrue}
 
-\DeclareOption{notitlepage}{\@maketitlepagefalse}
+\DeclareOption{endnotes}{\@endnotesformattrue}
 
-\DeclareOption{noadjustbib}{\@appendrefformatfalse}
+\DeclareOption{noadjustbib}{\@appendbibformatfalse}
 
 \ProcessOptions\relax
 
@@ -100,42 +90,38 @@
 \urlstyle{same}
 
 
-% Footnote layout and formatting
+% Notes layout and formatting
+
+\if@endnotesformat
+	\PassOptionsToPackage{perpage}{footmisc}
+\fi
 
-\RequirePackage[bottom,marginal]{footmisc}
+\RequirePackage[bottom, marginal]{footmisc}
 
 \setlength{\skip\footins}{12pt}
-\setlength{\footnotesep}{1\baselineskip}
+\setlength{\footnotesep}{0.833\baselineskip}
 
 \renewcommand{\footnoterule}{%
 	\vspace*{-3pt}
 	\hrule width 2in height 0.4pt
-	\vspace*{-10.4pt}
-}
+	\vspace*{-10.4pt}}
 
-% Footnote marker indent
+% Footnote marker formatting: adjust \parindent and raggedright option
 \setlength{\footnotemargin}{0.5in}
 
-% footnotemark
-\newcommand{\@turabianfnmarkformat}{%
-	\renewcommand{\@makefntext}[1]{%
-		\if@optraggedright
-			\raggedright%
-		\fi
-		\setlength{\parindent}{\footnotemargin}%
-		\@thefnmark.\,\,##1%
-	}
-}
-
-% keep footnote lines together
-\interfootnotelinepenalty=10000
+\renewcommand{\@makefntext}[1]{%
+	\if@optraggedright
+		\raggedright%
+	\fi
+	\setlength{\parindent}{\footnotemargin}%
+	\@thefnmark.\,\,#1}
 
 
 % Header and footer style layouts
 
 \RequirePackage{fancyhdr}
 
-% Page identifier (author name, title, etc.)
+% Other identifier accompanying page number (deprecated formatting command)
 \newcommand{\pageidentifier}{}
 
 \newlength{\@pageidentifierspace}
@@ -144,94 +130,105 @@
 \newcommand{\setpageidentifier}[2][3ex]{%
 	\setlength{\@pageidentifierspace}{#1}
 	\renewcommand{\pageidentifier}{%
-		#2\hspace*{\@pageidentifierspace}}
-}
-\setpageidentifier{}
+		#2\hspace*{\@pageidentifierspace}}}
 
-% draft option: draft indicator text
-\newcommand{\draftindicator}{}
+\setpageidentifier{}
 
-\newcommand{\setdraftindicator}[1]{%
-	\if@draftwork
-		\renewcommand{\draftindicator}{#1}
-	\fi
-}
-\setdraftindicator{Draft (\today)}
+% Draft indicator text (deprecated command not functional)
+\newcommand{\setdraftindicator}[1]{}
 
 % fancyhdr: page styles
 \fancyhf{}
-\fancyhead[R]{\normalfont\singlespace \pageidentifier\thepage}
-\fancyhead[L]{\normalfont\singlespace \small\draftindicator}
+
 \renewcommand{\headrulewidth}{0pt}
 \renewcommand{\footrulewidth}{0pt}
 
 \fancypagestyle{plain}{%
 	\fancyhf{}
 	\fancyfoot[C]{\normalfont\singlespace \thepage}
-	\fancyfoot[R]{\normalfont\singlespace \small\draftindicator}
 	\if@optemptymargins
 		\setlength{\headheight}{0pt}
 		\setlength{\headsep}{0pt}
-	\fi
-}
+	\fi}
+
 \renewcommand{\plainheadrulewidth}{0pt}
 \renewcommand{\plainfootrulewidth}{0pt}
 
 \fancypagestyle{headings}{%
 	\fancyhf{}
-	\fancyhead[R]{\normalfont\singlespace \pageidentifier\thepage}
-	\fancyhead[L]{\normalfont\singlespace \small\draftindicator}
-}
+	\fancyhead[R]{\normalfont\singlespace \pageidentifier\thepage}}
 
 % fancy page style: allow customization of geometry first
 \AtEndPreamble{%
-	\pagestyle{fancy}
-}
+	\pagestyle{headings}}
 
 % 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}}
+
 \appto{\frontmatter}{%
 	\singlespacing
-	\newgeometry{margin=1in, bindingoffset=\@bindingoffsetfm, ignoreall, noheadfoot}
-	\pagestyle{empty}
-}
+	\newgeometry{left=\@lmarginfm, right=\@rmarginfm, top=\@tmarginfm, bottom=\@bmarginfm, bindingoffset=\@bindingoffsetfm, ignoreall, noheadfoot}
+	\pagestyle{empty}}
+
 \if@optemptymargins
 	\preto{\tableofcontents}{%
 		\renewcommand{\contentsname}{Table of Contents}
-		\newgeometry{margin=1in, bindingoffset=\@bindingoffsetfm, ignoreall, nohead, includefoot, bottom=1in+\headheight}
-		\pagestyle{plain}
-	}
+		\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}
-	}
+		\pagestyle{plain}}
 \fi
+
 \appto{\mainmatter}{%
 	\doublespacing
 	\restoregeometry
-	\pagestyle{headings}
-}
+	\pagestyle{headings}}
 
 
-% Title section formatting (including chapter)
+% Test if \chapter is defined by document class
+% Note: Important to test before titlesec defines \chapter
 
-\PassOptionsToPackage{compact}{titlesec}
+\newif\if@nochapter\@nochaptertrue
+
+\ifcsdef{chapter}%
+	{\@nochapterfalse}%
+	{}
 
-\RequirePackage{titlesec}
+
+% Title section formatting (including chapter)
+
+\RequirePackage[compact]{titlesec}
 
 \titleformat{\chapter}[display]%
 	{\normalfont\bfseries\normalsize\singlespacing\centering}%
 	{Chapter \thechapter}%
-	{1\baselineskip}%
+	{0.833\baselineskip}%
 	{}
 \titlespacing*{\chapter}%
 	{0em}%
 	{-1.2\baselineskip}%
-	{1\baselineskip}
+	{0.833\baselineskip}
+\titlespacing*{name=\chapter,numberless}%
+	{0em}%
+	{-1.2\baselineskip}%
+	{0.833\baselineskip}
 
 \titleformat{\section}[block]%
 	{\normalfont\bfseries\normalsize\singlespacing\centering}%
@@ -242,9 +239,16 @@
 	{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\itshape\normalsize\singlespacing\centering}%
+	{\normalfont\mdseries\normalsize\singlespacing\centering}%
 	{}%
 	{0pt}%
 	{}
@@ -254,7 +258,7 @@
 	{0pt}
 
 \titleformat{\subsubsection}[block]%
-	{\normalfont\mdseries\normalsize\singlespacing\raggedright}%
+	{\normalfont\bfseries\normalsize\singlespacing\raggedright}%
 	{}%
 	{0pt}%
 	{}
@@ -266,8 +270,6 @@
 
 % Title Page: optional text
 
-\newcommand{\mytitlepage}{}
-
 \newcommand{\subtitle}[1]{\def\@subtitle{#1}}
 \subtitle{}
 
@@ -277,57 +279,76 @@
 \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{}
 
-
-% Title Page default: reformat \maketitle (Research Paper)
-
 \newcommand{\@makewordcount}{%
 	\ifthenelse{\equal{\@wordcount}{}}%
 		{}
-		{\hspace*{\fill}\@wordcount}
-}
+		{\hspace*{\fill}\@wordcount}}
 
-\if@maketitlepage
 
-	\renewcommand{\thanks}[1]{\def\@thanks{#1}}
-	\thanks{}
+% Renew \maketitle command if “titlepage” option (based on Research Paper title page).
 
-	\renewcommand{\mytitlepage}{%
-		\vspace*{-1.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
-		\@thanks\par
-		\@course\par
-		\@institution\par
-		\@date\par
-		\parskip=0pt
-		\vspace*{\stretch{1}}
-		\@makewordcount%
-	}
+\if@titlepage
 	\renewcommand{\maketitle}{%
-		\clearpage
-		\newgeometry{margin=1in, ignoreall, noheadfoot}
-		\thispagestyle{empty}
-		{\normalfont\normalsize\centering\singlespacing
-			\mytitlepage}
-		\clearpage
-		\restoregeometry
-		\setcounter{page}{1}
-	}
+		\begin{titlepage}%
+			\newgeometry{margin=1in, ignoreall, noheadfoot}
+			\let\footnotesize\small
+			\let\footnoterule\relax
+			\let\footnote\thanks
+			\normalfont\normalsize\centering\singlespacing
+			\vspace*{-1.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
+			\@date\par
+			\parskip=0pt
+			\vspace*{\stretch{1}
+			\@makewordcount}
+		\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}
 \fi
 
 
@@ -337,7 +358,7 @@
 
 \renewcommand*{\quotingfont}{\singlespace}
 \quotingsetup{%
-	vskip=0pt,
+	vskip=0\baselineskip,
 	leftmargin=0.5in,
 	rightmargin=0.5in}
 
@@ -354,17 +375,18 @@
 \renewcommand\fps@table{!htp}
 \renewcommand\fps@figure{!htp}
 
-\setlength{\textfloatsep}{1\baselineskip}
-\setlength{\intextsep}{0.5\baselineskip}
+\setlength{\textfloatsep}{1\baselineskip plus0.5\baselineskip minus0.5\baselineskip}
+\setlength{\intextsep}{1\baselineskip plus0.5\baselineskip minus0.5\baselineskip}
 
 \RequirePackage{flafter}
 
 
-% Tables and Figures: caption formatting
-
 \setlength{\abovecaptionskip}{0pt}
 \setlength{\belowcaptionskip}{0pt}
 
+
+% Tables and Figures: caption formatting
+
 \RequirePackage{caption}
 
 \captionsetup{%
@@ -375,92 +397,117 @@
 	labelsep=period,
 	skip=0.167\baselineskip}
 
-\captionsetup[table]{%
-	position=top}
-
-\captionsetup[figure]{%
-	position=bottom}
-
-
-% Tables: source and note formatting commands
-
-\newcommand{\tablesource}[1]{\vspace{1\baselineskip}#1\par}
-
-\newcommand{\tablenote}[1]{\vspace{1\baselineskip}#1\par}
-
-
-% endnotes: formatting support
-% 	Note: Error when cite keys contain “_”
-
-\newcommand{\@turabianendnoteformat}{%
-	\@ifpackageloaded{endnotes}%
-		{%
-			\renewcommand{\enoteformat}{%
-				\if@optraggedright
-					\raggedright%
-				\fi
-				\setlength{\parindent}{\footnotemargin}
-				\vspace*{1\baselineskip}
-				\theenmark.\,\,%
-			}
-			\preto{\theendnotes}{%
-				\clearpage
-				\begingroup
-					\singlespacing
-					\def\enotesize{\normalsize}
-					\setlength{\parskip}{0pt}
-			}
-			\appto{\theendnotes}{%
-				\endgroup
-			}
-		}%
-		{}
-}
+\if@optraggedright
+	\captionsetup{justification=raggedright}
+\fi
+
+\captionsetup[table]{position=top}
+
+\captionsetup[figure]{position=bottom}
+
+
+% Tables: table footnote formatting command
+
+\newcommand{\tablenote}[1]{%
+	\if@optraggedright
+		\raggedright%
+	\fi
+	\vspace{1\baselineskip}
+	#1\par}
+
+% Table footnote source line (deprecated command made same as \tablenote)
+\newcommand{\tablesource}{\tablenote}
+
 
+% endnotes package support: formatting
+% Note: endnotes package causes error when cite keys contain “_”.
 
-% biblatex-chicago: references formatting
+\if@endnotesformat
 
-\PassOptionsToPackage{%
-	notes, isbn=false, autolang=other, backend=biber}{biblatex-chicago}
+	\RequirePackage{endnotes, chngcntr, xparse}
 
-\newcommand{\@turabianbibformat}{%
-	\@ifpackageloaded{biblatex-chicago}%
-		{%
-			\@ifclassloaded{article}%
+	% Changes footnote marker type and formatting
+	\setfnsymbol{chicago}
+	\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}%
 				{%
-					\defbibheading{bibliography}[\bibname]{%
-						\clearpage
-						\section*{##1}
-						\singlespacing}
-		
-					\defbibheading{subbibliography}[\bibname]{%
-						\subsection*{##1}
-						\singlespacing}
+					\latexchapter*{#3}%
+					\setcounter{endnote}{0}%
+					\addtoendnotes{%
+						\noexpand\enotedivision{\noexpand\section*}%
+							{\unexpanded{#3}}}%
 				}%
 				{%
-					\defbibheading{bibliography}[\bibname]{%
-						\chapter{##1}
-						\singlespacing}
-		
-					\defbibheading{subbibliography}[\bibname]{%
-						\section{##1}
-						\singlespacing}
-				}
-			\renewcommand{\bibitemsep}{1\baselineskip}
-			\renewcommand{\bibhang}{0.5in}
-		}%
-		{}
-}
+					\IfNoValueTF{#2}%
+						{\latexchapter{#3}}%
+						{\latexchapter[#2]{#3}}%
+					\addtoendnotes{%
+						\noexpand\enotedivision%
+							{\noexpand\section*}%
+							{\chaptername\ \thechapter}}%
+				}}
+		\def\enotedivision#1#2{\@ifnextchar\enotedivision{}{#1{#2}}}
+	\fi
+	\renewcommand{\enotesize}{\normalsize}
+	\renewcommand{\enoteformat}{%
+		\if@optraggedright
+			\raggedright%
+		\fi
+		\setlength{\parindent}{\footnotemargin}
+		\vspace*{1\baselineskip}
+		\theenmark.\,\,}
 
+\fi
 
-% Append references reformatting at end of preamble (noappends option)
 
-\AtEndPreamble{%
-	\if@appendrefformat
-		\@turabianfnmarkformat
-		\@turabianbibformat
-		\@turabianendnoteformat
-	\fi
-}
+% biblatex-chicago: citation formatting defaults
+
+\PassOptionsToPackage%
+	{isbn=false, autolang=other, footmarkoff, backend=biber}%
+	{biblatex-chicago}
+
+\if@appendbibformat
+	\AtEndPreamble{%
+		\@ifpackageloaded{biblatex}%
+			{%
+				\AtBeginBibliography{\vspace*{-0.333\baselineskip}}
+				\renewcommand{\bibsetup}{\singlespacing}
+				\renewcommand{\bibitemsep}{1\baselineskip}
+				\renewcommand{\bibhang}{0.5in}
+			}%
+			{}}
+\fi
 
 
-- 
cgit v1.2.3

