Skip to content

Instantly share code, notes, and snippets.

@dansheffler
Last active June 26, 2019 17:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dansheffler/f7957b0aa0fe2a0d02cb to your computer and use it in GitHub Desktop.
Save dansheffler/f7957b0aa0fe2a0d02cb to your computer and use it in GitHub Desktop.
default.latex
%!TEX TS-program = xelatex
%!TEX encoding = UTF-8 Unicode
\RequirePackage{etoolbox}
% $if(documentclass)$
% $if(classoption)$
% \documentclass[$for(classoption)$$classoption$$sep$,$endfor$)]{$documentclass$}
% $else$
% \documentclass[12pt,oneside]{$documentclass$}
% $endif$
% $else$
% \documentclass[12pt,oneside]{article}
% $endif$
\documentclass[12pt,oneside]{book}
\usepackage{amsmath,amssymb}
\usepackage{ctable}
\setupctable{width=2in}
\usepackage{placeins}
% Diagrams
\usepackage{tikz}
\usetikzlibrary{arrows}
\usepackage{subcaption}
% Use fonts from system fonts.
\usepackage{fontspec,xunicode}
\defaultfontfeatures{Mapping=tex-text}
\setmainfont[Mapping=tex-text]{Palatino Linotype}
%\settitlefont[Mapping=tex-text]{OFL Sorts Mill Goudy}
%\setsansfont[Scale=MatchLowercase,Mapping=tex-text]{Helvetica Neue}
%\setmonofont[Scale=MatchLowercase]{Consolas}
\newfontfamily\greekfont[Scale=1]{GFS Porson}
% Ostensibly Spaces will typeset in mathmode.
% Doesn't seem to work, us \textrm{} instead.
{\catcode`\ =\active{\global\let =\ }}
\everymath{\catcode`\ =\active}
% Get \boxright from txfonts without changing math font face.
% \boxright can only be used in mathmode.
\DeclareSymbolFont{symbolsC}{U}{txsyc}{m}{n}
\DeclareMathSymbol{\boxright}{\mathrel}{symbolsC}{128}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Get Greek to work automatically.
% Just type Greek unicode in the body of the text and this will detect when the switch has been made.
\usepackage{polyglossia}
\setdefaultlanguage{english}
\setotherlanguage[variant=ancient]{greek}
\input{C:/Users/Dan/texmf/tex/greektokens}
\XeTeXinterchartoks 0 \greekLetter = {\begin{otherlanguage*}{greek}}
\XeTeXinterchartoks \greekLetter 0 = {\end{otherlanguage*}}
\XeTeXinterchartoks 255 \greekLetter = {\begin{otherlanguage*}{greek}}
\XeTeXinterchartoks \greekLetter 255 = {\end{otherlanguage*}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Pandoc's Meta-data handling
% \newcommand{\mytitle}{testing}
% \newcommand{\Originaltitle}{}
% \let\Originaltitle\title
% \renewcommand*{\title}[1]{%
% \Originaltitle{#1}%
% \renewcommand*{\mytitle}{#1}%
% }
% \newcommand{\myauthor}{testing}
% \newcommand{\Originalauthor}{}
% \let\Originalauthor\author
% \renewcommand*{\author}[1]{%
% \Originalauthor{#1}%
% \renewcommand*{\myauthor}{#1}%
% }
% \newcommand{\mydate}{testing}
% \newcommand{\Originaldate}{}
% \let\Originaldate\date
% \renewcommand*{\date}[1]{%
% \Originaldate{#1}%
% \renewcommand*{\mydate}{#1}%
% }
% % Give some default values.
% \def\myauthor{}
% \def\mydate{}
% \def\teacher{}
% \def\class{}
% \def\semester{}
% \def\dearline{To whom it may concern,}
%Pandoc subscript command
\newcommand{\textsubscr}[1]{\textsubscript{#1}}
% My finicky block quote formating
\usepackage[leftmargin=0.5in,rightmargin=0.5in,noorphans,indentfirst=false]{quoting}
% Special No Indent Command
\makeatletter
\newcommand*{\@doendeq}{%
\everypar{{\setbox\z@\lastbox}\everypar{}}%
}
\renewenvironment{quote}{%
\singlespacing\begin{quoting}%
}{%
\end{quoting}\ignorespacesafterend\par\noindent\aftergroup\@doendeq%
}
\makeatother
% Make Footnote fontsize the same as the body text.
\let\origfootnotesize\footnotesize
\let\footnotesize\normalsize
% Chicago style footnotes (full citation in first note)
\usepackage[notes,isbn=false,url=false]{biblatex-chicago}
\addbibresource{mybib.bib}
% Fix footnote number indentation
\usepackage{footmisc}
\makeatletter
\renewcommand\@makefntext[1]{%
\parindent 0.5in%
\@thefnmark.~#1}
\makeatother
%Automatic Links
\usepackage[xetex, bookmarks, colorlinks=false, pdftitle={$if(title)$$title$$endif$}, pdfauthor={$if(author)$$for(author)$$author$$sep$ \and $endfor$$endif$}, pdfsubject={$if(class)$$class$$endif$}]{hyperref}
% Pandoc's expected environment for lists
\usepackage[shortlabels]{enumitem}
\setlistdepth{20}
\usepackage{afterpage}
%%%%%%%%%%%%%%%%%% Pandoc's Presets %%%%%%%%%%%%%%%%%%%%%%%%%%%
% use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
% use microtype if available
\IfFileExists{microtype.sty}{%
\usepackage{microtype}
\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
$if(geometry)$
\usepackage[$for(geometry)$$geometry$$sep$,$endfor$]{geometry}
$endif$
$if(natbib)$
\usepackage{natbib}
\bibliographystyle{$if(biblio-style)$$biblio-style$$else$plainnat$endif$}
$endif$
$if(biblatex)$
\usepackage{biblatex}
$if(biblio-files)$
\bibliography{$biblio-files$}
$endif$
$endif$
$if(listings)$
\usepackage{listings}
$endif$
$if(lhs)$
\lstnewenvironment{code}{\lstset{language=Haskell,basicstyle=\small\ttfamily}}{}
$endif$
$if(highlighting-macros)$
$highlighting-macros$
$endif$
$if(verbatim-in-note)$
\usepackage{fancyvrb}
$endif$
$if(tables)$
\usepackage{longtable,booktabs}
$endif$
$if(graphics)$
\usepackage{graphicx}
\makeatletter
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
\def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}
\makeatother
% Scale images if necessary, so that they will not overflow the page
% margins by default, and it is still possible to overwrite the defaults
% using explicit options in \includegraphics[width, height, ...]{}
\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
$endif$
$if(links-as-notes)$
% Make links footnotes instead of hotlinks:
\renewcommand{\href}[2]{#2\footnote{\url{#1}}}
$endif$
$if(strikeout)$
\usepackage[normalem]{ulem}
% avoid problems with \sout in headers with hyperref:
\pdfstringdefDisableCommands{\renewcommand{\sout}{}}
$endif$
$if(verbatim-in-note)$
\VerbatimFootnotes % allows verbatim text in footnotes
$endif$
%%%% Important Metadata %%%%
$if(title)$
\title{$title$$if(subtitle)$\\\vspace{0.5em}{\large $subtitle$}$endif$}
$endif$
$if(author)$
\author{$for(author)$$author$$sep$ \and $endfor$}
$endif$
\date{$date$}
$for(header-includes)$
$header-includes$
$endfor$
%%%%%%%%%% Chicago %%%%%%%%%%%%%
% Page layout
\usepackage[right=1in,left=1in,top=1in,bottom=1in,includehead]{geometry}
\usepackage{setspace}
\parindent 0.5in
% List Environments
\setlist[enumerate]{%
labelindent=0.5in,%
leftmargin=*,%
rightmargin=0.5in,%
nosep%
}
\setlist[itemize]{%
labelindent=0.5in,%
leftmargin=*,%
rightmargin=0.5in,%
labelsep=*%
}
\setlist[description]{%
labelindent=0.5in,%
leftmargin=0.5in,%
rightmargin=0.5in,%
itemsep=12pt%
}
% Put a colon after description labels
\renewcommand{\descriptionlabel}[1]{%
\hspace\labelsep \upshape\textbf{#1}:%
}
% Get rid of the explicit \itemsep declaration in Pandoc's
% \tightlist command
\providecommand{\tightlist}{\setlength{\parskip}{0pt}}
% Get single-spacing for paragraphs in lists
% and no indent on the paragraph after
\makeatletter
\let\oldenumerate=\enumerate
\renewenvironment{enumerate}{%
\singlespacing\begin{oldenumerate}
}{%
\end{oldenumerate}\ignorespacesafterend\par\noindent\aftergroup\@doendeq}
\makeatother
\makeatletter
\let\olditemize=\itemize
\renewenvironment{itemize}{%
\singlespacing\begin{olditemize}
}{%
\end{olditemize}\ignorespacesafterend\par\noindent\aftergroup\@doendeq}
\makeatother
\makeatletter
\let\olddescription=\description
\renewenvironment{description}{%
\singlespacing\begin{olddescription}
}{%
\end{olddescription}\ignorespacesafterend\par\noindent\aftergroup\@doendeq}
\makeatother
%Title, Section, etc. Subsubsections blank in the text body (paragraph labels), but the text *is* included in the TOC.
\usepackage[bottomtitles,explicit]{titlesec}
\titleformat{\chapter}[display]{\vspace{1in}\bfseries\Huge}{Chapter \thechapter \LARGE\newline #1}{0.2in}{}[\vspace{-1in}]
\titleformat{\section}[hang]{\bfseries\large}{\Roman{section}~~--~~#1}{0in}{}
\titleformat{\subsection}[hang]{\bfseries\normalsize}{#1}{0in}{}
\titleformat{name=\section,numberless}[hang]{\bfseries\large}{#1}{0in}{}
% \titleformat{\subsection}[runin]{}{}{.5in}{}
\titleformat{\subsubsection}[runin]{\normalsize}{}{0.5in}{\hspace{0.5in}}
\titlespacing*{\subsubsection}{0.5in}{0in}{0in}
% \makeatletter
% \newcommand*{\@doendeq}{%
% \everypar{{\setbox\z@\lastbox}\everypar{}}%
%}
% Reset subsubsection counters even if levels are skipped.
\makeatletter
\@addtoreset{subsubsection}{section}
\makeatother
% Page Header Formating
\usepackage{fancyhdr}
\setlength{\headheight}{15.2pt}
\usepackage{lastpage}
\fancypagestyle{plain}{%
\fancyhf{} % clear all header and footer fields
\fancyfoot[C]{\thepage} % except the center
\renewcommand{\headrulewidth}{0pt}%
\renewcommand{\footrulewidth}{0pt}%
\newgeometry{top=1in,left=1in,right=1in,bottom=1in}
}
\fancypagestyle{none}{%
\fancyhf{} % clear all header and footer fields
\renewcommand{\headrulewidth}{0pt}%
\renewcommand{\footrulewidth}{0pt}%
\newgeometry{top=1in,left=1in,right=1in,bottom=1in}
}
\fancypagestyle{myheading}{%
\lhead{\rightmark}\chead{}\rhead{Sheffler \thepage}
\fancyfoot[C]{}%
\renewcommand{\headrulewidth}{1pt}%
\renewcommand{\footrulewidth}{0pt}%
\restoregeometry%
}
\clubpenalty=1000
\widowpenalty=1000
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
%Fixes for sections in the header.
\pagestyle{myheading}
\renewcommand{\chaptermark}[1]{\markright{\chaptername\ \thechapter\ -\ #1}}
\renewcommand{\sectionmark}[1]{\markright{\Roman{section}\ -\ #1}}
% Exclude header from first page
\thispagestyle{plain}
%Class information
\noindent $if(author)$$author$$endif$\\
$if(class)$$class$$endif$\\
$if(semester)$$semester$$endif$\\
% Title
$if(title)$
\vspace{-0.25in}
\begin{center}\bfseries\large\underline{$title$}
\par\end{center}
\vspace{.1in}
$endif$
% The rest of the paper
\doublespace
%%%%%%% Pandoc Presets %%%%%%%
$body$
$if(natbib)$
$if(biblio-files)$
$if(biblio-title)$
$if(book-class)$
\renewcommand\bibname{$biblio-title$}
$else$
\renewcommand\refname{$biblio-title$}
$endif$
$endif$
\bibliography{$biblio-files$}
$endif$
$endif$
$if(biblatex)$
\printbibliography$if(biblio-title)$[title=$biblio-title$]$endif$
$endif$
$for(include-after)$
$include-after$
$endfor$
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment