%!TEX TS-program = pdflatex
% dissertation.tex -- main dissertation file
%
% Wisconsin dissertation template
% Copyright (c) 2008-2009 William C. Benton.  All rights reserved.
%
% This program can redistributed and/or modified under the terms
% of the LaTeX Project Public License Distributed from CTAN
% archives in directory macros/latex/base/lppl.txt; either
% version 1 of the License, or (at your option) any later version.
%
% This program includes other software that is licensed under the
% terms of the LPPL and the Perl Artistic License; see README for details.
%
% You, the user, still hold the copyright to any document you produce
% with this software (like your dissertation).
%

%%% You'll want ``oneside'' for the deposit version, but probably not for any versions that don't need to meet the UW requirements
\documentclass[10pt, twoside]{memoir}
\usepackage{geometry}
%\geometry{paperheight=10in, paperwidth=8in, inner=.75in, outer=.75in, top=.75in, bottom=.75in, bindingoffset=0mm, portrait}
\setstocksize{10in}{8in}
\settrimmedsize{10in}{8in}{*}
\setlrmarginsandblock{0.875in}{0.625in}{*} % Inner & outer margins
\setulmarginsandblock{0.625in}{0.625in}{*} % Top & bottom margins
\setheadfoot{12pt}{20pt} % Header & footer space
\setlength{\textheight}{8.75in} % Force text block size
\checkandfixthelayout
\newcommand{\First}{Your labmate\;}
\newcommand{\first}{your labmate\;}

\input{includes/preamble}
\input{includes/defs}
\input{includes/thesisdefs}

\svnidlong{$LastChangedBy$}{$LastChangedRevision$}{$LastChangedDate$}{$HeadURL: http://freevariable.com/dissertation/branches/diss-template/dissertation.tex $} 

\usepackage{soul} % for better underlinging command = \ul
\usepackage{enumitem}
\setlist{nosep}



%%%
% INDEXING THINGS
%%%
%\newcommand{\ii}[1]{\textbf{\texttt{#1}}}



%%%%%
% CODE ENVIRONMENTS
%%%%%%%



\usepackage[x11names]{xcolor}
% Define colors to be used in the listing environment
\definecolor{codecomments}{HTML}{888888}
\definecolor{codestring}{HTML}{008000}
\definecolor{codekeyword}{HTML}{AA00AA}


\definecolor{codegreen}{rgb}{0,0.6,0}
\definecolor{codegray}{rgb}{0.5,0.5,0.5}
\definecolor{codepurple}{rgb}{0.58,0,0.82}
\definecolor{backcolour}{rgb}{0.95,0.95,0.95}
\definecolor{black}{rgb}{0,0,0}



% OK, if you end up not using Luala, then you need to delete this thorugh the next comment line
\usepackage{fontspec}
\newfontfamily\hackfont{Hack} % Hack
\usepackage{listings}
\lstset{
  basicstyle=\hackfont\footnotesize,  % or \small, \scriptsize, etc.
  columns=fullflexible,
  keepspaces=true
}
% Delete to here, but keep the usepackage listing

\lstdefinestyle{mystyle}{
    backgroundcolor=\color{backcolour},   
    commentstyle=\color{codecomments},
    keywordstyle=\bfseries\color{codekeyword},
    numberstyle=\tiny\color{codegray},
    stringstyle=\itshape\color{codestring},
    basicstyle=\hackfont\footnotesize,
    breakatwhitespace=false,         
    breaklines=true,                 
    captionpos=b,                    
    keepspaces=true,                 
    numbers=left,                    
    numbersep=5pt,                  
    showspaces=false,                
    showstringspaces=false,
    showtabs=false,                  
    tabsize=2
    lineskip=0pt, % Adjust the line spacing
}
\lstset{
style=mystyle,
language=Python, % was throwing an error
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Environment
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{minted}

\newminted{python}{linenos, breaklines, python3, fontsize=\footnotesize, baselinestretch=0.8}
\usemintedstyle{emacs}
\usepackage{subfiles}
\usepackage{wrapfig}
\usepackage{longtable}
\usepackage{forest}

\usepackage{lineno}
\usepackage[framemethod=TikZ]{mdframed}
\mdfdefinestyle{CodeFrame}{%
    linecolor=gray!5!white,
    outerlinewidth=0.1pt,
    roundcorner=0pt,
    innertopmargin=\baselineskip,
    innerbottommargin=\baselineskip,
    innerrightmargin=3pt,
    innerleftmargin=15pt,
    backgroundcolor=gray!5!white}


\usepackage{xcolor}
% Define a custom lighter gray color
\definecolor{lightergray}{rgb}{0.9, 0.9, 0.9}
\usepackage{amsmath}
\usepackage{siunitx}
\usepackage{graphicx}
\usepackage{wrapfig}
\usepackage[inkscapelatex=false]{svg}
\usepackage[version=4]{mhchem}
\usepackage{esdiff}

\definecolor{codegreen}{rgb}{0,0.6,0}
\definecolor{codegray}{rgb}{0.6,0.6,0.6}
\definecolor{codepurple}{rgb}{0.58,0,0.82}
\definecolor{backcolour}{rgb}{0.95,0.95,0.92}

\lstdefinestyle{mystyle}{
    %\scriptsize,
    \footnotesize,
    \linespread{0.85},
    %backgroundcolor=\color{backcolour}, 
    language = python,
    commentstyle=\color{codegray}\slshape,
    keywordstyle=\color{magenta},
    numberstyle=\tiny\color{codegray},
    stringstyle=\color{codepurple},
    basicstyle=\hackfont,%\footnotesize,
    %breakatwhitespace=false,         
    breaklines=true,                 
    captionpos=b,                    
    keepspaces=true,                 
    numbers=left,                    
    numbersep=5pt,                  
    showspaces=false,                
    showstringspaces=false,
    %showtabs=false,                  
    tabsize=2,
    aboveskip=-1em,
    belowskip=-1.em,
}


\lstnewenvironment{code}[1][]
{\lstset{
style=mystyle,
#1}
\mdframed[style=CodeFrame]}
{\endmdframed}

\newenvironment{code_OG}
    {
    \parindent 0pt %make it so there is no indentation
    \ttfamily
    \begin{mdframed}[style=CodeFrame]
    \resetlinenumber[1]
    \begin{internallinenumbers}
    %\begin{lstlisting}[language=Python]
    }
    {
    %\end{lstlisting}
    \end{internallinenumbers}
    \end{mdframed}
    }

\mdfdefinestyle{PyInFrame}{%
    linecolor=gray!20!white,
    outerlinewidth=0pt,
    skipabove = 2em,
    skipbelow = 0em,
    roundcorner=0pt,
    innertopmargin=0.5em,
    innerbottommargin=0.5em,
    innerrightmargin=40pt,
    innerleftmargin=20pt,
    backgroundcolor=gray!5!white}

%%%% TRYING TO MAKE BETTER PYIN
\usepackage{xcolor}
\usepackage{mdframed}
\usepackage{listings}
\usepackage{newverbs}

\definecolor{ingray}{gray}{0.95} % Define light grey color

% \mdfdefinestyle{PyInFrame}{%
%     linecolor=gray!20!white,
%     outerlinewidth=0pt,
%     skipabove = 2em,
%     skipbelow = 0em,
%     roundcorner=0pt,
%     innertopmargin=0.5em,
%     innerbottommargin=0.5em,
%     innerrightmargin=40pt,
%     innerleftmargin=20pt,
%     backgroundcolor=ingray
% }

% \newenvironment{pyin}{%
%     \Collectverb{\pyinVerb}%
% }{}
% \newcommand{\pyinVerb}[1]{%
% \vspace{0em}
%     \noindent\colorbox{ingray}{%
%         \makebox[\dimexpr\linewidth-2\fboxsep][l]{\lstinline|>>> #1|}%
%         \vspace{-1em}
%     }
% }





% \mdfdefinestyle{PyoutFrame}{%
%     linecolor=gray!20!white,
%     outerlinewidth=0pt,
%     skipabove = 0em,
%     skipbelow = 0em,
%     roundcorner=0pt,
%     innertopmargin=0.5em,
%     innerbottommargin=0.5em,
%     innerrightmargin=40pt,
%     innerleftmargin=20pt,
%     backgroundcolor=gray!20!white}


% \definecolor{outgray}{gray}{0.85} % Define light grey color
% \newenvironment{pyout}{%
%     \Collectverb{\pyoutVerb}%
% }{}
% \newcommand{\pyoutVerb}[1]{%
%     \noindent\colorbox{outgray}{%
%         \makebox[\dimexpr\linewidth-2\fboxsep][l]{\lstinline|Out: #1|}%
%         \vspace{-1}
%     }
% }


% a solution to showing >>> at the start of pyin lst.  Taken from: https://tex.stackexchange.com/questions/82957/how-to-better-control-the-number-display-of-listings
\newcommand*{\replaceWithArrow}[1]{{>}>{>}} % a command that takes arguments and replaces them with >>>  Basically, any arguments are ignored (becuase ehtere is no {#1} or anything.  Then it just writes >>>
\lstnewenvironment{pyin}
  {
  \vspace{0pt} %  space before the environment
    \lstset{
      backgroundcolor=\color{gray!15!white},
      basicstyle=\hackfont\footnotesize,   
      frame=none,
      numberfirstline=false,
      firstnumber=1,
    numberstyle=\ttfamily\footnotesize\color{black}\replaceWithArrow, % replaces the incoming number with >>>
      breaklines=true,
      prebreak=\raisebox{0ex}[0ex][0ex]{\ensuremath{\hookleftarrow}},
      postbreak=\raisebox{0ex}[0ex][0ex]{\ensuremath{\hookrightarrow}},
      breakatwhitespace=true,
      escapeinside={(*@}{@*)},
      %numbers=none,  % need the numbers shown, because that is what the delim uses
      moredelim=[l][\color{blue}]{>>> },
    }
  }
  {
    \vspace{-1em} %  space after the environment
  }
{}

\lstnewenvironment{pyout}
  {
  \vspace{0pt} %  space before the environment
    \lstset{
      backgroundcolor=\color{gray!40!white},
      basicstyle=\hackfont\footnotesize,
      commentstyle=\color{black},
    keywordstyle=\color{black},
    numberstyle=\tiny\color{black},
    stringstyle=\color{black},
      frame=none,
      numbers = none,
      breaklines=true,
      prebreak=\raisebox{0ex}[0ex][0ex]{\ensuremath{\hookleftarrow}},
      postbreak=\raisebox{0ex}[0ex][0ex]{\ensuremath{\hookrightarrow}},
      breakatwhitespace=true,
      escapeinside={(*@}{@*)},
      moredelim=**[is][\color{black}\bfseries]{@}{@},
    }
  }
  {
    \vspace{0em} %  space after the environment
  }
{}


\lstnewenvironment{multiout}
  {
    \lstset{
      backgroundcolor=\color{gray!40!white},
      basicstyle=\hackfont\footnotesize,
      commentstyle=\color{black},
    keywordstyle=\color{black},
    numberstyle=\tiny\color{black},
    stringstyle=\color{black},
      frame=none,
      numbers = none,
      breaklines=true,
      prebreak=\raisebox{0ex}[0ex][0ex]{\ensuremath{\hookleftarrow}},
      postbreak=\raisebox{0ex}[0ex][0ex]{\ensuremath{\hookrightarrow}},
      breakatwhitespace=true,
      escapeinside={(*@}{@*)},
      moredelim=**[is][\color{black}\bfseries]{@}{@},
    }
  }
{}








\usepackage{hyperref}
\newcommand{\website}{\href{https://www.codingforchemistsbook.com/}{https://www.codingforchemistsbook.com/}}
\newcommand{\websitefootnote}{\footnote{See \website for detailed instructions.}}
%%%%%%
% END CODE ENVIRONMENTS
%%%%%

\clearpage\pagenumbering{roman}  % This makes the page numbers Roman (i, ii, etc)

\title{Coding for Chemists: Saving Time and Solving Problems with Python}
\author{Christopher J. Johnson and Benjamin J. Lear}
\department{Department of Chemistry, Stony Brook University and Department of Chemistry, The Pennsylvania State University}

\date{2024}



% \usepackage{imakeidx}
% \makeindex
\begin{document}


%%% Uncomment the following if your .bib contains references that you will not 
%%% explicitly cite, but that should be in the final bibliography:
% \nocite{*}

\ifpdf
\DeclareGraphicsExtensions{.pdf, .jpg, .tif}
\else
\DeclareGraphicsExtensions{.eps, .jpg}
\fi

\maketitle

%% Add \part declarations if you want, but it's not necessary
%\part{Preliminaries}

\include{frontmatter/frontmatter}


%Front matter chapters
%\subfile{frontmatter/WhoFor}
%\subfile{frontmatter/HowToUse}


%
% NARRATIVE SECTION
%
%\book{Narrative}

\setcounter{secnumdepth}{3} % how far into the section, subsection, subsub... to provide numbers
% Set section and subsection counters to start from -1
\setcounter{chapter}{-1}  % Start chapters from 0

% Part I
\part{Saving time and aggravation}
\subfile{ChapNarrative/00aExpDes/ExpDes} %0
\subfile{ChapNarrative/00bArrays/Arrays} %1
\subfile{ChapNarrative/01OnePlot/OnePlot} %2
\subfile{ChapNarrative/02ManyPlots/ManyPlots} %3
\subfile{ChapNarrative/03DrawMol/DrawMol} %4

% Part II
\part{Modeling and fitting data}
\subfile{ChapNarrative/04EqFit/EqFit} %5
\subfile{ChapNarrative/05CompFit/CompFit} %6
\subfile{ChapNarrative/06AnalFit/AnalFit} %7
\subfile{ChapNarrative/07SimKin/SimKin} %8

\part{Analyzing Numerical Data}
\subfile{ChapNarrative/10NumInt/NumInt} %9
\subfile{ChapNarrative/11SmoothCrim/SmoothCrim} %10
\subfile{ChapNarrative/12Interp/Interp} %11
\subfile{ChapNarrative/13PeakFind/PeakFind} %12
\subfile{ChapNarrative/14NumDer/NumDer} %13

\part{Reporting and Sharing Results}
\subfile{ChapNarrative/08Report/Report} %14
\subfile{ChapNarrative/09Excel/Excel} %15
\subfile{ChapNarrative/15Pillow/Pillow} %16

\part{Moving beyond this book}
\subfile{ChapNarrative/16Beyond/Beyond} %17


%
% TECHNICAL SECTION
%
%\book{Technical}

\part{Technical Details}

\renewcommand{\thechapter}{\Alph{chapter}}
\setcounter{chapter}{0}


\subfile{ChapTechnical/Computers/Computers}
\subfile{ChapTechnical/DataTypes/DataTypes}
\subfile{ChapTechnical/Text/Text}
\subfile{ChapTechnical/Files/Files}
\subfile{ChapTechnical/Pathlib/Pathlib}
\subfile{ChapTechnical/FlowControl/FlowControl}
\subfile{ChapTechnical/Functions/Functions}
\subfile{ChapTechnical/Errors/Errors}
\subfile{ChapTechnical/Plotly/Plotly}
%\subfile{ChapTechnical/Datetime/Datetime}
%\subfile{ChapTechnical/Libraries/Libraries}

%% etc, etc.

%% Do you have appendices?  If so, add them here, just like chapters.
\begin{appendices}
\printbibliography[title={Glossary}]

%\subfile{backmatter/glossary}
\end{appendices}

%% Are you a big nerd with a colophon?  Add it here.
%\begin{colophon}
%\input{backmatter/colophon}
%\end{colophon}

%% McBride is a very nice style (some version is included in this distribution)
%\bibliographystyle{mcbride}
%\bibliography{your-bib-file}

%% Want an index?  Neither did I.
%\printindex

\end{document}
