%%Author: Justin Cawood
%%License: LPPL 1.3c

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{practicalreports}[071/10/2019  v2.0.3 Practical Report Package]
\RequirePackage{mathtools, array, longtable, scrextend, float, fancyhdr, lastpage, tikzducks, pdfpages, pgffor}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcommand{\shift}[2]{
\begin{addmargin}[#1cm]{0cm}
\begin{minipage}{\textwidth}
#2
\end{minipage}
\end{addmargin}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%Create a new title page
%\newtitlepage{Title}{Author}{Date}
\newcommand*{\newtitlepage}[3]{
\begin{titlepage}
    \vspace*{\fill}
    \begin{center}
      {\Huge #1}\\[0.5cm]
      {\Large #2}\\[0.4cm]
      {\small #3}
    \end{center}
    \vspace*{\fill}
 	\end{titlepage}
}

%Add a new figure
\newcommand*{\newfigure}[4]{
\begin{figure}[H]
    \centering \textbf{#1} \par\medskip
    \center{\includegraphics[width=\textwidth]
    {#3}}
	\caption{#2}
	\label{fig:#4}
\end{figure}
}

%Add a new scalable figure
\newcommand*{\newsfigure}[5]{
\begin{figure}[H]
    \centering \textbf{#1} \par\medskip
    \center{\includegraphics[scale=#5]
    {#3}}
	\caption{#2}
	\label{fig:#4}
\end{figure}
}

%Reference a labeled figure
\newcommand*{\reffigure}[1]{Figure~\ref{fig:#1}}

%Create a table
%\newtable{Caption}
%{Columns and Alignment}
%{Column Headings}
%{Table Data}
\newcommand*{\newtable}[5]{
\begin{table}[H]
\begin{center}
\caption{#1}
\vspace*{5mm}
\begin{tabular}{#2}
\hline
#3\\
\hline
#4\\
\hline
\end{tabular}
\label{table:#5}
\end{center}
\end{table}
}

%Create a long table
%\newlongtable{Caption}
%{Columns and Alignment}
%{Column Headings}
%{Table Data}
\newcommand{\newlongtable}[5]{
\begin{center}
\begin{longtable}{#2}
\label{table:#5} \\
\caption{#1} \\
\hline
#3 \\
\hline
\endfirsthead
\caption{\textit{Continued}} \\
\hline
#3 \\
\hline
\endhead
\hline\\
\endfoot
\hline
\endlastfoot
#4
\end{longtable}
\end{center}
}

%Reference a labeled table
\newcommand*{\reftable}[1]{Table~\ref{table:#1}}

%Box and solotion or multiple lines of solutions
\newcommand*{\boxanswer}[1]{
\begin{equation*}
   \addtolength{\fboxsep}{5pt}
    \boxed{
    \begin{gathered}
       #1
    \end{gathered}
    }
\end{equation*}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%Multipleys a number by 10^{user input}
\newcommand*{\E}[1]{$\times10^{#1}$}

%Multipleys a number by 10^{user input}
\newcommand*{\e}[1]{\times10^{#1}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcommand{\setpagefancy}{
\pagestyle{fancy}
\fancyhf{}
}

%Add a header to all pages
\newcommand*{\header}[3]{
\lhead{#1}
\chead{#2}
\rhead{#3}
}

%Add a footer to all pages
\newcommand*{\footer}[3]{
\lfoot{#1}
\cfoot{#2}
\rfoot{#3}
}

%Add a footer to all pages
\newcommand*{\goodfoot}{
\cfoot{Page \thepage \ of \pageref{LastPage}}

\newcommand{\duckfoot}{
\cfoot{
\begin{tikzpicture}[scale=0.6]
\duck[lightsaber=red,cape=black!85!white,
body=black!70!white,darthvader=black!85!white, speech={Page},bubblecolour=cyan!20!white,laughing]
\end{tikzpicture}
\begin{tikzpicture}[scale=0.6]
\duck[parting=brown!70!black, squareglasses,
tshirt=teal!50!white, jacket=white,
buttons=gray!50!white, stethoscope, signpost={\thepage}]
\end{tikzpicture}
\begin{tikzpicture}[scale=0.6]
\colorlet{skin}{white!45!gray!80!green}
\duck[lightsaber=green, body=skin, bill=gray!80!green,
tshirt=brown!50!black, jacket=brown!30!gray, speech={of},bubblecolour=cyan!20!white,laughing]
\fill[skin,rounded corners=3] (0.44,1.70) -- (0.25,2)
-- (0.6,1.95);
\fill[skin,rounded corners=3] (1.34,1.60) --
(1.53,1.9) -- (1.16,1.85);
\end{tikzpicture}
\begin{tikzpicture}[scale=0.6]
\begin{scope}[yshift=-6]
\clip[rotate=-5] (0.68,2.38) ellipse (0.3 and 0.4);
\fill[brown,rotate=-5](0.28,2.26)ellipse (0.3 and 0.4);
\end{scope}
\duck[body=brown,mohican=brown!50!black,horsetail, signpost={\pageref{LastPage}}]
\begin{scope}[yshift=-5,xshift=1]
\clip[rotate=-5] (0.68,2.38) ellipse (0.3 and 0.4);
\fill[brown,rotate=-5](1.06,2.2) ellipse (0.3 and 0.4);
\end{scope}
\end{tikzpicture}
}
}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Make sure yor filenames are all one word, this can include underscores and each report is separated by a comma. 
\newcommand{\joinpdfs}[1]{
\foreach \report in {#1} {
\includepdfmerge{\report, -}
}
}