%%
%% This is file `navydocs.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% navydocs.dtx  (with options: `package')
%% 
%% Copyright (C) 2016 Peter Andrew Rochford.
%% 
%% This file is NOT the source for navydocs, because almost all comments
%% have been stripped from it.  It is NOT the preferred form of navydocs for
%% making modifications to it.
%% 
%% Therefore you can NOT redistribute and/or modify THIS file.  You can
%% however redistribute the complete source package (Makefile, navydocs.dtx
%% and navydocs.ins) and/or modify it under the terms of the LaTeX Project
%% Public License, either version 1.3c of this license or (at your option)
%% any later version. The latest version of this license can be found at:
%% https://latex-project.org/lppl/
%% 
%% The navydocs package is distributed in the hope that it will be useful,
%% but `as is', WITHOUT WARRANTY OF ANY KIND, either expressed or
%% implied, including, but not limited to, the implied warranties of
%% MERCHANTABILITY and FITNESS FOR A PARTICULAR PURPOSE.  See the LaTeX
%% Project Public License for more details.
%% 
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{navydocs}[2016/06/22 Navy Documents]
\typeout{Package: navydocs 2016/07/01 v1.1)}
\providecommand{\eg}{{\it e.g.\/\ }}
\newcommand{\MONTH}{%
  \ifcase\the\month
  \or January% 1
  \or February% 2
  \or March% 3
  \or April% 4
  \or May% 5
  \or June% 6
  \or July% 7
  \or August% 8
  \or September% 9
  \or October% 10
  \or November% 11
  \or December% 12
  \fi}
\IfFileExists{eso-pic.sty}{%
  \usepackage{eso-pic, rotating}}
  {\PackageError {navydocs}{The eso-pic package was not found.}
  {Install the eso-pic package on your system.}}
\IfFileExists{mdframed.sty}{%
\usepackage[
linewidth=4pt,
middlelinecolor= black,
middlelinewidth=0.4pt,
roundcorner=1pt,
topline = false,
rightline = false,
bottomline = false,
rightmargin=0pt,
skipabove=0pt,
skipbelow=0pt,
leftmargin=0cm,
innerleftmargin=1cm,
innerrightmargin=0pt,
innertopmargin=0pt,
innerbottommargin=0pt,
]{mdframed}}
  {\PackageError {mdframed}{The mdframed package was not found.}
  {Install the mdframed package on your system.}}
\IfFileExists{fancyhdr.sty}{%
  \usepackage{fancyhdr}}
  {\PackageError {navydocs}{The fancyhdr package was not found.}
  {Install the fancyhdr package on your system.}}
\IfFileExists{relsize.sty}{%
  \usepackage{relsize}}
  {\PackageError {navydocs}{The relsize package was not found.}
  {Install the relsize package on your system.}}
\IfFileExists{setspace.sty}{%
  \usepackage{setspace}}
  {\PackageError {navydocs}{The setspace package was not found.}
  {Install the setspace package on your system.}}
\IfFileExists{xparse.sty}{%
  \usepackage{xparse}}
  {\PackageError {navydocs}{The xparse package was not found.}
  {Install the xparse package on your system.}}
\newcommand\NavyDivision[1]{\renewcommand\navy@Division{#1\hfill}}
\newcommand\navy@Division{\relax}
\newcommand\NavyDivisionLocation[1]{\renewcommand\navy@Location{#1\hfill}}
\newcommand\navy@Location{\relax}
\newcommand\NavyReportNumber[1]{
  \ifx&#1&%
     % Empty argument so use existing report number
     \navy@ReportNumber
  \else
     % Use argument for report number
     \renewcommand\navy@ReportNumber{#1}
  \fi
}
\newcommand\navy@ReportNumber{\relax}
\newcommand\NavyReportDate[1]{\renewcommand\navy@ReportDate{#1\hfill}}
\newcommand\navy@ReportDate{\number\day~\MONTH~\number\year}
\newcommand\NavyReportType[1]{\renewcommand\navy@ReportType{#1\hfill}}
\newcommand\navy@ReportType{\relax}
\newcommand\NavyReportTitle[1]{\renewcommand\navy@ReportTitle{#1\hfill}}
\newcommand\navy@ReportTitle{\relax}
\newcommand\NavyAuthor[1]{\renewcommand\navy@Author{#1\hfill}}
\newcommand\navy@Author{\relax}
\newcommand\NavyDistributionStatement[1]
{\renewcommand\navy@DistributionStatement{#1\hfill}}
\newcommand\navy@DistributionStatement{
Approved for public release; distribution is unlimited.\hfill
}
\newcommand\countlines[1]{
   {\setbox0\vbox{\noindent{#1}\par
   \count@\z@
   \loop
   \unskip\unpenalty\unskip\unpenalty\unskip
   \setbox0\lastbox
   \ifvoid0
       \xdef\numlines{\the\count@}
   \else
       \advance\count@\@ne
   \repeat}}
}
\newcommand\getmargintextheight[1]{
  \newdimen\margintextheight
  \setbox0=\vbox{#1}
  \margintextheight=\ht0 \advance\margintextheight by \dp0
  % count number of lines so height of each line can be found
  \countlines{#1}
  % now determine height of each line
  \margintextheight=\the\dimexpr \margintextheight / \numlines
}
\newif\ifmargin
\margintrue

\def\marginoffset{\the\dimexpr -\margintextheight*(\numlines - 1)  +
\margintextheight*(\numlines - 1)/2}

\def\navy@xmargin{
\LenToUnit{\leftmargin - \oddsidemargin + \marginparwidth/2
+ \marginoffset}}
\def\navy@ymargin{\LenToUnit{\paperheight - \textheight + \topmargin}}
\newcommand\xmargin{\navy@xmargin}
\newcommand\ymargin{\navy@ymargin}

\DeclareDocumentCommand{\NavyMarginTitle}
{
O{ \LenToUnit{\leftmargin - \oddsidemargin + \marginparwidth/2
+ \marginoffset} }
O{ \LenToUnit{\paperheight - \textheight + \topmargin} } m }{
  \renewcommand\xmargin{#1}
  \renewcommand\ymargin{#2}
  \ifx&#3&%
     % Empty argument so suppress margin title
     \marginfalse
  \else
     % Use mandatory argument for margin title

     % get height of each line for margin offset calculation
     \getmargintextheight{#3}

     \renewcommand\navy@MarginTitle{#3}
  \fi
}
\newcommand\navy@MarginTitle{\relax}
\newcommand\NavyFormID[1]{
\fancypagestyle{NavyFormIDStyle}
{\fancyhf{}\renewcommand{\headrulewidth}{0pt}
\fancyfoot[L]{\scriptsize #1}} }
\newif\ifnavy@undef
\navy@undeffalse
\newcommand{\navy@undefined}[1][\@empty]{%
  \ifx \@empty#1\relax
    \ifnavy@undef
       \typeout{^^J%
                navydocs Warning: There are required fields that are
                undefined.%
                ^^J}%
     \fi
  \else
    \navy@undeftrue
    \typeout{^^J%
             navydocs Warning: \expandafter\string\csname #1
             \endcsname\space is undefined.%
             ^^J}%
  \fi}
\newcommand{\navy@checkfield}[1]{%
  \setbox\@tempboxa\vbox{\csname navy@#1\endcsname}%
  \ifdim \wd\@tempboxa =0pt
    \navy@undefined[#1]
  \fi}
\AtEndDocument{\navy@undefined}
\newcommand{\NavyTitlePage}{%
   \global\let\thanks\@gobble
   \MakeNavyTitlePage
   \global\let\thanks\relax}
\newcommand\MakeNavyTitlePage{%
  \newpage
  \if@twoside\ifodd\c@page\else
    \null
    \thispagestyle{empty}%
    \newpage
  \fi\fi
  \navy@checkfield{Division}
  \navy@checkfield{Location}
  \navy@checkfield{ReportNumber}
  \navy@checkfield{ReportDate}
  \navy@checkfield{ReportType}
  \navy@checkfield{ReportTitle}
  \navy@checkfield{Author}
  \navy@checkfield{DistributionStatement}
\ifmargin
\AddToShipoutPicture*{\put(\xmargin,\ymargin)
 {\rotatebox{90}
 {\scalebox{1}{\parbox[t]{\textheight}
 {\textbf{\small \navy@MarginTitle}}
 }}}}
 \fi
 \begin{titlepage}

 \noindent
 \begin{minipage}[t]{\textwidth}
 \begin{mdframed}
 \parbox[t][0.98\textheight][t]{\textwidth}{
 \noindent\textbf{\large \navy@Division}
 \vskip3mm
 \noindent\textbf{\small \navy@Location}
 \vskip3mm
 \noindent\rule{\textwidth}{4pt} % thick line across page
 \vskip-8pt
 \noindent\rule{\textwidth}{2pt} % thinner line across page
\vspace{4mm}\\
\noindent
\navy@ReportNumber \ \navy@ReportDate \\ \navy@ReportType \\
\vspace{1.7cm}\\
{\Large \textbf{\navy@ReportTitle}
\vspace{1cm}\\
\normalsize
\noindent
by \\ \navy@Author
}\\
\vfill
\noindent
\includegraphics[width=21mm]{graphics/navy-logo-102.png}
\hspace{0.6in}
\begin{minipage}{0.75\textwidth}
\vspace{-0.8cm}
\hrule height 4pt
\vspace{4pt}
\noindent
\parbox[c]{\textwidth}{
\vspace{4pt}
\textbf{\small \navy@DistributionStatement}
\vspace{4pt}
}
\hrule height 4pt
\end{minipage}}
 \end{mdframed}
 \end{minipage}
 \end{titlepage}

  \global\let\NavyDivision\relax
  \global\let\navy@Division\relax
  \global\let\Location\relax
  \global\let\navy@Location\relax
  \global\let\ReportNumber\relax
  \global\let\navy@ReportNumber\relax
  \global\let\NavyReportDate\relax
  \global\let\navy@ReportDate\relax
  \global\let\NavyReportType\relax
  \global\let\navy@ReportType\relax
  \global\let\ReportTitle\relax
  \global\let\navy@ReportTitle\relax
  \global\let\NavyAuthor\relax
  \global\let\navy@Author\relax
  \global\let\NavyRelease\relax
  \global\let\navy@DistributionStatement\relax
  \global\let\MarginTitle\relax
  \global\let\navy@MarginTitle\relax

  \global\let\MakeNavyCoverPage\relax} % end of \MakeNavyCoverPage
\newcommand\MakeCarderockDivPage{%
  \thispagestyle{NavyFormIDStyle} % insert document code in footer
  \section*{ \sffamily\colorbox{black}{\bfseries\textcolor{white}
  {\large MAJOR CARDEROCK DIVISION TECHNICAL COMPONENTS}} }
  \vspace{8ex}

  \doublespace
  \begin{tabular}{lrl}
  CODE & 011 & Director of Technology \\
  & 10 & Machinery Systems/Programs and Logistics Directorate \\
  & 20 & Ship Systems \& Programs Directorate \\
  & 50 & Hydromechanics Directorate \\
  & 60 & Survivability, Structures and Materials Directorate \\
  & 70 & Signatures Directorate \\
  & 80 & Machinery Research \& Development Directorate \\
  & 90 & Machinery In-Service Engineering Directorate
  \end{tabular}
  \singlespace
  \vfill % push minipage to bottom of page

  \noindent
  \fbox{\begin{minipage}{\textwidth}
  \vspace{2ex}
  \begin{center}
  CARDEROCK DIVISION, NSWC, ISSUES THREE TYPES OF REPORTS:
  \end{center}

  \parbox{0.97\textwidth}{
  \begin{enumerate}
  \item \textbf{CARDEROCKDIV reports, a formal series,} contain information
  of permanent technical value. They carry a consecutive numerical
  identification regardless of their classification or the originating
  directorate.
  \item \textbf{Directorate reports, a semiformal series,} contain
  information of a preliminary, temporary, or proprietary nature or of
  limited interest or significance. They carry an alpha numeric
  identification issued by the originating directorate.
  \item \textbf{Technical memoranda, an informal series,} contain
  technical documentation of limited use and interest. They are primarily
  working papers intended for internal use. They carry an identifying
  number which indicates their type and the numerical code of the
  originating directorate. Any distribution outside CARDEROCKDIV must be
  approved by the head of the originating directorate on a case-by-case
  basis.
  \end{enumerate}
  }
  \vspace{1ex}

  \end{minipage}}
  \newpage
  \global\let\MakeCarderockDivPage\relax} % end of \MakeCarderockDivPage
\endinput
%%
%% End of file `navydocs.sty'.
