\ProvidesPackage{JLstyle}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
% <<< FONTS
\usepackage{mathpazo} % math and rm fonts
\usepackage[scaled]{helvet} % sf fonts
\usepackage{courier} % tt fonts
\normalfont
\usepackage[T1]{fontenc}
% >>> FONTS

% <<< number lines for proofreading
%\usepackage[pagewise]{lineno}
%\linenumbers
% >>> number lines for proofreading

\usepackage{multicol}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor} % colors
\usepackage{hyperref} % for cross-reference, URL support etc.
\hypersetup{pdftex,colorlinks=true, citecolor=SteelBlue, linkcolor=darkgray, urlcolor=blue} % custom colors for links generated by hyperref
\PassOptionsToPackage{hyphens}{url}\usepackage{hyperref} %force breaking URLs if crossing line ends
\usepackage{graphicx} %graphics package
\usepackage[noindentafter]{titlesec} %customize chapter titles etc.

% <<< format chapter chapter and section headings:
% chapters:
\titleformat{\chapter}[display]
{\normalfont\mdseries\Huge\filcenter}
{}
{4ex}
{\titlerule
\vspace{2ex}%
\filleft}
\renewcommand{\thechapter}{} % strip chapter number
% sections, subsections etc.:
\renewcommand{\thesection}{\Roman{section}} 
\titlespacing{\section}{0pt}{13ex}{10ex}
\titleformat{\section}[block]{\LARGE\mdseries\filcenter}{\thesection \\}{0.2em}{\titlerule\\[.8ex]\normalfont\LARGE\mdseries} 
\titleformat{\subsection}[hang]{\normalfont\LARGE\mdseries} {\thesubsection .}{0.2em}{\normalfont\LARGE\mdseries} 
\titleformat{\subsubsection}[hang]{\normalfont\Large\mdseries} {\thesubsubsection .}{0.6em}{\normalfont\Large\mdseries} 
\titleformat{\paragraph}[hang]{\normalfont\normalsize\bfseries} {\theparagraph .}{0.6em}{\normalfont\normalsize\bfseries} 
\titleformat{\subparagraph}[runin]{\normalfont\normalsize\bfseries} {}{0em}{\slshape\normalsize\bfseries}[]
% <<< format chapter chapter and section headings:

% <<< add quotes in text
\usepackage[font=itshape]{quoting}
% >>> add quotes in text

% <<< add TODO notes (https://tex.stackexchange.com/questions/9796/how-to-add-todo-notes)
\usepackage{xargs}                      % Use more than one optional parameter in a new commands
\usepackage[colorinlistoftodos,prependcaption,textsize=small]{todonotes}
% >>> add TODO notes (https://tex.stackexchange.com/questions/9796/how-to-add-todo-notes)

% <<< Customize titles of TOCs, list of figures etc.
\addto\captionsenglish{%
  \renewcommand{\contentsname}{} % empty TOC title (useful if already present as a chapter title)
  \renewcommand{\listfigurename}{}
  \renewcommand{\listtablename}{}
}
% >>> Customize titles of TOCs, list of figures etc.

% <<< custom itemize environment with less line spacing
\newenvironment{myitemize}
{ \begin{itemize}
    \setlength{\itemsep}{-0.5ex}
}
{ \end{itemize}} 
% >>> custom itemize environment with less line spacing


\usepackage[font=small,labelfont=bf]{caption} % for figure/table captions
\captionsetup{width=0.8\linewidth} %figure/table caption width
\usepackage{hypcap} %better captions
\usepackage{gensymb} % accept degreee symbols etc
\usepackage{textcomp} % extra fonts and text symbols
%\usepackage{indentfirst} %indent even first paragraph of each section
%\setlength{\parindent}{1em} % length of indentation
\setlength{\parskip}{1ex} % spacing of paragraphs within sections
\linespread{1.2} %line spacing factor

% <<< Bibliography
\usepackage[
    backend=biber,
    style=nature,
    autocite=superscript,
    doi=false,isbn=false,url=false
  ]{biblatex} % for bibliography management
  
% < Make \cite use \autocite formatting
\renewcommand{\cite}{\autocite}
% > Make \cite use \autocite formatting

% Make bibliography fonts smaller:
\renewcommand*{\bibfont}{\scriptsize}

% >>> Bibliography

\usepackage{booktabs} % table handling
\usepackage{multirow} % table multirows
\usepackage{tabulary} % table handling
\setlength\extrarowheight{1ex} % add some vertical padding between table cells
\usepackage{array} %table handling
\usepackage{floatrow} %to handle floats (figures and tables
\floatsetup[table]{font=footnotesize} % size of fonts within tables

% <<< TOC setup
\usepackage{tocloft} % for better TOCs, LOTs and LOFs
% indentation and margins:
\cftsetindents{chapter}{0em}{0em}
\cftsetindents{section}{0.5em}{1.5em}
\cftsetindents{subsection}{2em}{2.5em}
\cftsetindents{subsubsection}{3.5em}{3em}
\cftsetindents{paragraph}{4.5em}{4em}
\cftsetindents{subparagraph}{5.5em}{2em}
% TOC depth and section numbering
\setcounter{secnumdepth}{4}
\setcounter{tocdepth}{5}
% >>> TOC setup

% <<< Page format

% << US Letter format:         

%\usepackage[%includemp,
%			includehead,
%			includefoot,
%            paperwidth=22.2cm, %us letter + bleed
%            paperheight=28.6cm, % us letter + bleed
%            layoutwidth=21.6cm, % us letter
%            layoutheight=27.9cm, % us letter
%%            layouthoffset=0.318cm, % bleed
%%            layoutvoffset=0.318cm, % bleed            paperwidth=22.2cm, %us letter + bleed
%%            paperwidth=21.91cm, %us letter + bleed
%%            paperheight=28.58cm, % us letter + bleed
%%            layoutwidth=21.59cm, % us letter
%%            layoutheight=27.94cm, % us letter
%%            layouthoffset=0.318cm, % bleed
%%            layoutvoffset=0.318cm, % bleed
%            top=1.57cm,
%            bottom=1.57cm,
%            inner=3.1835cm,
%            outer=3.5835cm,
%%			width=14.1cm,
%			height=23.4cm]{geometry}
%%            marginparwidth=4cm,
%%            marginparsep=0.4cm]{geometry}

% >> US Letter format:         

% << Crown Quarto format:         
\usepackage[%includemp,
            includehead,
            includefoot,
            paperwidth=19.5cm,
            paperheight=25.2cm,
            layoutwidth=18.90cm,
            layoutheight=24.6cm,
            layouthoffset=0.32cm,
            layoutvoffset=0.32cm,
            top=1.4cm,
            bottom=2cm,
            inner=3cm,
            outer=2.8cm]{geometry}
%            marginparwidth=2cm, % width of the margin notes
%            marginparsep=0.4cm]{geometry}
% >> Crown Quarto format

% >>> Page format

% <<< Headers/footers:

\usepackage{fancyhdr} % customize page headers/footers
\fancyhf{} %reset all header/footer params
\pagestyle{fancy}
\setlength{\headheight}{26pt} % space between fancyhdr header and body text so they don't clash
\renewcommand{\chaptermark}[1]{\markboth{\MakeUppercase{#1}}{}} % remove "Chapter" and chapter number from "leftmark" in header. Make chapter title uppercase
\renewcommand{\sectionmark}[1]{\markright{\thesection.\ #1}} 
\fancyhead[CE]{\textsl{\leftmark}} % see https://www.sharelatex.com/learn/Headers_and_footers#!#Reference_guide
\fancyhead[CO]{\textsl{\rightmark}} % see https://www.sharelatex.com/learn/Headers_and_footers#!#Reference_guide
\fancyhead[RO,LE]{\thepage} % see https://www.sharelatex.com/learn/Headers_and_footers#!#Reference_guide
\renewcommand\headrulewidth{0pt} % line separator for header

% >>> Headers/footers



\renewcommand{\thefigure}{\arabic{figure}} % avoid chapter prefix numbering of figures 
\renewcommand{\thetable}{\arabic{table}} % avoid chapter prefix numbering of tables

%embed PDFs:
\usepackage{pdfpages}

% <<< Allow continuous figure enumbering across chapters and sections:
\usepackage{chngcntr}
\counterwithout{figure}{chapter}
% >>> Allow continuous figure numbering across chapters and sections

% numbering of supplementary figures and tables (from http://bytesizebio.net/2013/03/11/adding-supplementary-tables-and-figures-in-latex/)
\newcommand{\beginsupplement}{%
        \setcounter{table}{0}
        \renewcommand{\thetable}{S\arabic{table}}%
        \setcounter{figure}{0}
        \renewcommand{\thefigure}{S\arabic{figure}}%
     }

