%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This document was created using TeXShop, BibTex and MakeIndex. It should compile using pdflatex and bib latex as well.
%To compile correctly you must compile it a total of five times in TeXShop:
%                            Typset (LaTex), Typset(MakeIndex) Typset (BibTex), Typset (LaTex), Typset (LaTex).
% The bibliography is stored as a BibTex document called thebib.bib. You can add entries easily by creating a bibtex item at the 
% ADS website but the file needs an additional field in order to generate the [ADS] link button. See thebib.bib header. This file also uses the 
% bibliography style file called myaa.sty
% Websites and figures are linked using the hyperref package.
%
%
% You must compile this main document with the chapters included. If you attempt to compile a chapter file by itself
% it will barf.
% If an error occurs in the .aux document file, delete it and recompile.
%
% The files XAG.idx & XAG.ms may not be straightforward to get so if you can get the current files it may be easier. I didn't check if you could
% create empty files and see if MakeIndex would write to them. 

% Last Updated June-2018 by P. R. Jibben (SAO)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% I want a list of URLs in the beginning, just like the list of tables and figures. -PRJ
% 
%
% The command that prints the list of urls is defined in the preamble below and the command name is \printurls.
% I found this bit of code off the interweb.
\RequirePackage{filecontents}
%\begin{filecontents*}{\jobname-url.mst}
\begin{filecontents*}{\jobname.mst}
% Input style specifiers
keyword "\\urlentry"
% Output style specifiers
preamble "\\begin{theurls}"
postamble "\\end{theurls}\n"
group_skip ""
headings_flag 0  
item_0 "\n\\urlitem{"
delim_0 "}{"
delim_t "}"
line_max 500
\end{filecontents*}

\documentclass[12pt,oneside]{book} %Use draft mode to compile quickly and see overfull \hboxes.

\usepackage[table]{xcolor}

\usepackage{geometry}

% This package allows users to control the white space between titles, chapter titles, sections, etc...
\usepackage{setspace}

% This is useful for adding figures
\usepackage{graphicx}

% This package allows users to place figures EXACTLY where they want them.
\usepackage{float}

% Easily build figures with multiple images and sub captions. 
\usepackage{subcaption}

% I don't remember why I added this. 
\usepackage{titlesec}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% How to create url and hyperlinks in your PDF. 
% When adding/updating a url using the hyperref package you must use \url{website} and it will generate a clickable link.
% When creating a link inside the document that will link to another location in the document. Use the two commands. 
% \hypertarget{targetname}{}
% \hyperlink{target name}{text to click}
\definecolor{dkgray}{rgb}{0,.2,.4}
\usepackage[hidelinks,colorlinks]{hyperref}  %Many options exist to color links
\hypersetup{
linkcolor=dkgray,
menucolor=black,
anchorcolor=dkgray,
filecolor=black,
urlcolor=dkgray,
citecolor=dkgray,
}
% Turn off all colors
%\usepackage[hidelinks]{hyperref}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{booktabs}


%\usepackage{array}
% This package allows to change the cell colors in a table. It allows for the gray and white format for the table. 
\usepackage{colortbl}

% This package is used to format the bibliography and defines the punctation for the references. The style is based on A&A
\usepackage{natbib}
\bibpunct{(}{)}{;}{a}{}{,}

% This is a package that allows drawing pictures. 
\usepackage{tikz}

% Using footnote symbols
\renewcommand{\thefootnote}{\fnsymbol{footnote}}

% This is for the appendix
\usepackage[titletoc]{appendix}
% This changes the chapter titles to remove the giant chapter numbers in the text. Want the "book" to look more like an article. 
\titleformat{\chapter}
  {\Large\bfseries} % format
  {}                % label
  {0pt}             % sep
  {\huge}           % before-code


% dingbats
\usepackage{bbding}

% This will indent the description environment a little more and leave it in block form. 
\renewenvironment{description}[1][12pt]
  {\list{}{\labelwidth=12pt \leftmargin=#1
   \let\makelabel\descriptionlabel}}
  {\endlist}

% This bit changes the size of the margins as well as the area on the sheet dedicated to text.
%\addtolength{\voffset}{-.5cm}
\setlength{\textheight}{22cm}
\addtolength{\hoffset}{-0.5cm}
\setlength{\textwidth}{15.5cm}

% These commands to add space to the tables so they aren't so crowded.
\newcommand\T{\rule{0pt}{2.5ex}}
\newcommand\B{\rule[-1.5ex]{0pt}{0pt}}


% Some of the bibliography entries given at ADS include shortcut commands to common journals, I didn't want to include
% the packages required to define these shortcuts so I generated the shortcuts needed for the text here. You will need to 
% create new commands for each type of journal. It will not compile in BibTex if there is an unknown journal command.
\newcommand\physscr{Physica Scripta}
\newcommand\solphys{Sol. Phys.}
\newcommand\pasj{PASJ}
\newcommand\aj{AJ}

% I want a list of URLs in the beginning, just like the list of tables and figures. -PRJ
\usepackage{pdfescape}
\usepackage{xstring}

\makeatletter
\newwrite\file@url
\openout\file@url=\jobname.idx\relax

\newcommand*{\write@url}[1]{%
  \begingroup
    \EdefEscapeHex\@tmp{#1}%
    \protected@write\file@url{}{%
      \protect\urlentry{\@tmp}{\thepage}%
    }%
  \endgroup
}
\let\saved@hyper@linkurl\hyper@linkurl
\renewcommand*{\hyper@linkurl}[2]{%
  \write@url{#2}%
  \saved@hyper@linkurl{#1}{#2}%
}
\newcommand*{\listurlname}{\huge{List of URLs}}
\newcommand*{\printurls}{%
  \InputIfFileExists{\jobname.ind}{}{}%
}
\newenvironment{theurls}{%
  \section*{\listurlname}%
  \@mkboth{\listurlname}{\listurlname}%
  \let\write@url\@gobble  
  \ttfamily
  \raggedright
  \setlength{\parfillskip}{0pt}%
}{%
  \par
}
\newcommand*{\urlitem}[2]{%
  \hangindent=1em
  \hangafter=1   
  \begingroup    
    \EdefUnescapeHex\@tmp{#1}%
    \expandafter\url\expandafter{\@tmp}%
  \endgroup
  \urlindex@pfill
  \IfSubStr{#2}{,}{}{%
    \IfSubStr{#2}{-}{}{}%
  }\@\space\ignorespaces
  #2%
  \par
}
\newcommand*{\urlindex@pfill}{% from \pfill of package `doc'
  \unskip~\urlindex@dotfill
  \penalty500\strut\nobreak
  \urlindex@dotfil~\ignorespaces
}
\newcommand*{\urlindex@dotfill}{% from \dotfill of package `doc'
  \leaders\hbox to.8em{\hss .\hss}\hskip\z@ plus  1filll\relax
}
\newcommand*{\urlindex@dotfil}{% from \dotfil of package `doc'
  \leaders\hbox to.8em{\hss .\hss}\hskip\z@ plus 1fill\relax%\hfil
}
\makeatother

% I like this font package
\usepackage[varg]{txfonts}

%Create the TITLE, this is just defining the command. It is issued later in the document.
 \newcommand*{\titleSW}{\begingroup
 \raggedleft
 \vspace*{\baselineskip}
 {\Huge\itshape SolarSoft XRT Analysis Guide } \\ [\baselineskip]
 {\large\itshape Hinode X-Ray Telescope}\\[.2\textheight]
 {\Large Revised by Lucas Guliano}\\
 \vspace*{\baselineskip}
  \large July 2023 \par
 \vfill
 \raggedright
 {\large \emph{Prepared at:}}\\
 \vspace*{\baselineskip}
 \includegraphics[height=.75in]{CfA_Horizontal_CMYK.png}%{\Large \includegraphics[width=1cm]{harvard-logo.pdf} \includegraphics[width=1cm]{si-logo.pdf} \sffamily Harvard-Smithsonian Center for Astrophysics}
 \vspace*{\baselineskip}
 \endgroup}
 
 % Create a copyright page that is really an acknowledgment page. Again this is just the command, it is issued later in the document.
 \newcommand*{\ackpage}{\begingroup
 \raggedright
 
 \textbf{July 2023 Revision}: \\
 \begin{description}
 \item Updated \emph{Using xrt cat.pro} section
 \end{description}
 
 \textbf{March 2022 Revision}: \\
 \begin{description}
 \item Updated \emph{Stray Light Overview} section
 \item Added \emph{Stray Light Correction} section
 \end{description}
 
 \textbf{November 2019 Revision}: \\
 \begin{description}
 \item Updated the \emph{Coaligning XRT} section
 \item Updated the \emph{Known Issues} section
 \item Updated the \emph{Contamination} section
 \item Updated \emph{Stray Light Section} section
 \end{description}
 
 \textbf{June 2018 Revision}: \\
 \begin{description}
 \item Added list of URLs after Table of Contents.
 \item Added section: \emph{Browsing Data} to Chapter 2.
 \item Added section: \emph{Known Issues} to Chapter 2.
  \item Added \textbf{xrt\_teem\_ch.pro} to Section 2.11.
 \item Added subsection: Using \textbf{xrt\_dem\_iterative2.pro} to Chapter 2.
 \end{description}
 \textbf{May 2017 Revision}: \\
 \begin{description}
 \item Added section about the Point Spread Function.
 \item Added link to the XRT Level 0 MPEG archive in Table 2.1.
% \item Added section about known issues with calibration routines.
 \end{description}
 
  \textbf{October 2016 Revision}: \\
 \begin{description}
 \item Added information about the 14 June 2015 light leak to Section 2.4.4 \emph{Light Leak}.
 \item Updated the XRT paper references in Table 1.2.
 \item Corrected the fits keyword definitions of {\tt CRPIX1} and {\tt CRPIX2} in the Appendix.
 \end{description}

% \textbf{December 2014 Revision}: \\
% \begin{description}
%\item Added subsection: Using \textbf{xrt\_read\_coaldb.pro} to Chapter 2 Section \emph{Coaligning XRT Data}.
%\item Edited Section 2.4.1: Using \textbf{xrt\_prep\_.pro}.
%\end{description}
 
 
 \raggedleft
\null
\vfill
 {\Large Previous revisions by:}\\
 \vspace*{\baselineskip}
 {\large Patrick McCauley, Paola Testa, and P. R. Jibben}\\
 \vspace*{\baselineskip}
 {\Large Originally written by:}\\
 \vspace*{\baselineskip}
 {\large Monica Bobra \& Mark Weber}\\
 {\large and other members of the XRT team}\\
 \endgroup}
 
% This removes A LOT of white space from the document. It is the space between figures and text and titles and text ect.
\setlength{\textfloatsep}{12pt}
%
%
% BEGIN DOCUMENT
\begin{document}

% Title Page
\clearpage % No page number on this page.
\thispagestyle{empty}
\titleSW

% Copyright page
\clearpage % No page number on this page.
\thispagestyle{empty}
\ackpage

% Table of Contents
\tableofcontents
\listoffigures
\listoftables

% List of URLS
\newpage
\clearpage
\thispagestyle{empty}
\printurls

% Need to return tt font to normal
% Chapter 1
\include{chap1}

% Chapter 2
\include{chap2}

% Chapter 3
\include{chap3} % X-ray Telescope Instrument Guide

\let\cleardoublepage\clearpage
% Appendix
\include{appendixA} % Level 0 Keywords

% Bibliography
\bibliographystyle{myaa}
\bibliography{thebib}

\end{document}
