%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% RRI template for TechDocs
%
% Original author:
% Juan Tomas Sayago
%
% Instructions for using this template:
% This title page compiles as is. If you wish to include this title page in 
% another document, you will need to copy everything before 
% \begin{document} into the preamble of your document. The title page is
% then included using \titleAT within your document.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%----------------------------------------------------------------------------------------
%	PACKAGES AND OTHER DOCUMENT CONFIGURATIONS
%----------------------------------------------------------------------------------------
\documentclass[12pt]{article}
\usepackage{amsmath,amsthm}
\usepackage{amssymb}
\usepackage[english]{babel}
\usepackage{latexsym}
\usepackage{amsfonts}
\usepackage{graphicx}
\usepackage{float}
\usepackage{graphics}
\usepackage{epsfig}
\usepackage[]{mcode}
\usepackage{xcolor} % Required to specify font color
\usepackage{listings}
\lstnewenvironment{R}
  {\lstset{ language=R,                     % the language of the code
  basicstyle=\small,       % the size of the fonts that are used for the code
  numbers=left,                   % where to put the line-numbers
  numberstyle=\tiny\color{gray},  % the style that is used for the line-numbers
  stepnumber=1,                   % the step between two line-numbers. If it's 1, each line
                                  % will be numbered
  numbersep=6pt,                  % how far the line-numbers are from the code
  backgroundcolor=\color{white},  % choose the background color. You must add \usepackage{color}
  showspaces=false,               % show spaces adding particular underscores
  showstringspaces=false,         % underline spaces within strings
  showtabs=false,                 % show tabs within strings adding particular underscores
  frame=single,                   % adds a frame around the code
  rulecolor=\color{black},        % if not set, the frame-color may be changed on line-breaks within not-black text (e.g. commens (green here))
  tabsize=2,                      % sets default tabsize to 2 spaces
  captionpos=b,                   % sets the caption-position to bottom
  breaklines=true,                % sets automatic line breaking
  breakatwhitespace=false,        % sets if automatic breaks should only happen at whitespace
  title=\lstname,                 % show the filename of files included with \lstinputlisting;
  % also try caption instead of title
  keywordstyle=\color{blue},      % keyword style
  commentstyle=\color{dkgreen},   % comment style
  stringstyle=\color{mauve},      % string literal style
  escapeinside={\%*}{*)},         % if you want to add a comment within your code
  morekeywords={*,...}            % if you want to add more keywords to the set
  }}
  {}
  \usepackage{color} %red, green, blue, yellow, cyan, magenta, black, white
\definecolor{mygreen}{RGB}{28,172,0} % color values Red, Green, Blue
\definecolor{mylilas}{RGB}{170,55,241}
%\lstnewenvironment{Matlab}
%  {\lstset{language=Matlab,%
%    %basicstyle=\color{red},
%    breaklines=true,%
%    morekeywords={matlab2tikz},
%    keywordstyle=\color{blue},%
%    morekeywords=[2]{1}, keywordstyle=[2]{\color{black}},
%    identifierstyle=\color{black},%
%    stringstyle=\color{mylilas},
%    commentstyle=\color{mygreen},%
%    showstringspaces=false,%without this there will be a symbol in the places where there is a space
%    numbers=left,%
%    numberstyle={\tiny \color{black}},% size of the numbers
%    numbersep=9pt, % this defines how far the numbers are from the text
%    emph=[1]{for,end,break},emphstyle=[1]\color{red}, %some words to emphasise
%    %emph=[2]{word1,word2}, emphstyle=[2]{style},  
%    }}
\newcommand*{\Doctitle}{Document Title} % Generic publisher logo
\newcommand*{\Docstitle}{Document subtitle} % Generic publisher logo
\newcommand*{\Author}{Insert Author(s) name(s) here} % Generic publisher logo
\title{\Doctitle} % Article title
\pagenumbering{arabic}
\author{} % Authors
\date{}
\newcommand*{\plogo}{2014-01} % Generic publisher logo
\newcommand*{\keywords}{Regional economics; R1} % Generic publisher logo
\definecolor{wvublue}{HTML}{003366}
\definecolor{wvugold}{HTML}{FFCC00}
%----------------------------------------------------------------------------------------------------
% ---------------------------------------------------------------------
\RequirePackage{fancyhdr}  % Needed to define custom headers/footers
\RequirePackage{lastpage}  % Number of pages in the document
\pagestyle{fancy}          % Enables the custom headers/footers
% Headers
\lhead{\includegraphics[width=1.5cm]{RRI_logo.png} }%
\chead{}%
\rhead{ \thepage/\pageref{LastPage}} %Logo MEI to include
% Footers
\lfoot{}%
\cfoot{}%
\rfoot{}%
\renewcommand{\headrulewidth}{0pt}% % No header rule
\renewcommand{\footrulewidth}{0pt}% % No footer rule
% ---------------------------------------------------------------------
%----------------------------------------------------------------------------------------
%	TITLE PAGE
%----------------------------------------------------------------------------------------
\newcommand*{\titleRRITD}{\begingroup % Create the command for including the title page in the document
\thispagestyle{empty}
\centering % Center all text
{\huge \textbf{Regional Research Institute}}\\[0.5\baselineskip] % RRI 
{\Huge \textbf{West Virginia University}}\\[1.5\baselineskip] % RRI 
{\large \textbf{Technical Document Series}}\\[0.75\baselineskip] % Series name
\vspace{0.5cm}
\begin{figure}[h]
\centering
\includegraphics[scale=0.8]{RRI_logo.png}
\end{figure}
\vspace{0.8cm} % Whitespace between the title and short horizontal line
\centering % Center all text
{\Large \textcolor{wvublue}{\textbf{\Doctitle}}}\\[0.5\baselineskip] % Document title 
{\large \textcolor{wvublue}{\textbf{\Docstitle}}}\\[0.75\baselineskip] %Document subtitle
\vspace{1.4cm}
{\large \textsc{\Author}}\par % Author(s) name(s)
\vfill % Whitespace between the author name and publisher text
{\Large RRI TechDoc \plogo}\\[0.5\baselineskip] %[Enter TechDoc number here.  20XX-XX format <year-number>.  Add R# if revised, e.g., 2013-01R3 for revision 3. Obtain TechDoc number from RRI Office Admin] 
{\large Date submitted: }\\ % Publisher
{\large Date revised: }\\ %
{\large Key words/Codes: \keywords}
\endgroup}
%----------------------------------------------------------------------------------------
%	BLANK DOCUMENT
%----------------------------------------------------------------------------------------
\begin{document} 
\pagenumbering{gobble}
% Removes page numbers
\titleRRITD % This command includes the title page
\newpage
\pagenumbering{arabic}
\maketitle
\thispagestyle{empty}
\begin{abstract}.  
Click here to enter a concise, 1-2 sentence description
\end{abstract}
Place text and mathematical description here. Add citation example \cite{Figueredo:2009dg}
\begin{equation}
    \beta=(X'X)^{-1}X'Y
\end{equation}
\section*{Supporting Algorithm(s)/Code}
Matlab (or other) Code here.  Not all TechDocs will have code or supporting algorithms. Those that do not should delete this heading and section.  Code should be self-documenting and in the form of a function if and when possible.
\subsection*{Sample of matlab code:} %Using package mcode
\begin{lstlisting} 
a = 1; % MATLAB comment 
b = 2; 
c = a^2 + b^2; 
\end{lstlisting}
\subsection*{Sample R code:}
\lstinputlisting{RRIWS_sample.R}
\bibliographystyle{apalike}
\bibliography{sample}
References go here unless included in footnotes.  Footnotes should be kept to a minimum, however, so if there are many references, a reference section is preferred.  
Not all TechDocs will have code or references. Those that do not should delete or comment this heading and section.
\end{document}