%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                  File: opteng.sty                       %
%                      VERSION: 1.1                       %
%                 Date: June 01, 2006                     %
%                                                         %
%                                                         %
%                 LaTeX style file for                    %
%          length check and submission of SPIE            %
%              Optical Engineering Letters                %
%                                                         %
%                                                         %
% \documentclass[10pt,letterpaper,optengjnl]{article}     %
% or                                                      %
% \documentclass[10pt,letterpaper,optenglett]{article}    %
% or                                                      %
% \documentclass[12pt,letterpaper,optengsubmit]{article}  %
%                                                         %
% \usepackage{opteng}                                     %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newif\ifo@lett \o@lettfalse            % true if "OE Letters" mode.
\newif\ifo@jnl \o@jnlfalse              % true if "Optical Engineering Journal" mode.


\NeedsTeXFormat{LaTeX2e}%
\ProvidesPackage{opteng}[2006/05/01 LaTeX package for length check
and submission of SPIE Optical Engineering Manuscripts]

\usepackage{overcite}
\usepackage{geometry}
\usepackage{amsmath}
\usepackage{fancybox}
\usepackage{pstricks}
\usepackage{graphicx}

\definecolor{MyGray}{rgb}{0.9,0.9,0.9}

\newcommand\@subjterm{}
\newcommand\@loginfo{Paper 000000R compiled \today.}
\newcommand\@doi{DOI:~10.0000/000.000}
\newcommand\@spiecopyright{\copyright\hskip6pt\number\year\hskip.05in Society of Photo-Optical Instrumentation Engineers}%
\newcommand\@issncopyright{0000 - 0000/\year/\$22.00 \copyright\ \year SPIE}%

\newcommand\address[1]{}
\newcommand\email[1]{}
\newcommand\subjterm[1]{\renewcommand\@subjterm{#1}}
\newcommand\loginfo[1]{\renewcommand\@loginfo{#1}}
\newcommand\doi[1]{\renewcommand\@doi{DOI:~#1}}
\newcommand\SPIEmember{, \sf\footnotesize{MEMBER SPIE}}

\newenvironment{eqnfloat*}%%
{}{}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Optical Engineering Letters
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DeclareOption{optenglett}{%
\linespread{0.925}\twocolumn
\geometry{letterpaper,hcentering,height=60pc,top=2cm,bottom=2cm,left=1.5cm,right=2.4cm}
\columnsep0.8cm
\parindent1em
\parskip0pc
\flushbottom

%%Title page elements
\renewcommand\title[1]{\noindent\huge\bf\textsf{#1}\rm\normalsize}%
\renewcommand\author[1]{\vskip1pc\noindent\normalsize\bf\textsf{#1}\rm}
\renewcommand\address[1]{\noindent\textsf{#1}}%
\renewcommand\email[1]{\noindent\textsf{E-mail:~#1}}%

\renewenvironment{abstract}{\vskip1pc\noindent\sf\textbf{Abstract.}}%
{\scriptsize\textit{\@spiecopyright. \\ \@doi}\footnotesize%
\vskip0.5pc\noindent Subject terms:~\@subjterm%
\vskip0.5pc\noindent \@loginfo \normalsize\vskip1pc}%

}%



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Optical Engineering
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DeclareOption{optengjnl}{%
\linespread{0.925}\twocolumn
\geometry{letterpaper,hcentering,height=55pc,top=2cm,bottom=2cm,left=1.5cm,right=2.4cm}
\columnsep0.8cm
\parindent1em
\parskip0pc
\flushbottom

%%Title page elements
\renewcommand\title[1]{\noindent\huge\bf\textsf{#1}\rm\normalsize}%
\renewcommand\author[1]{\vskip1pc\noindent\bf\textsf{#1}\rm}
\renewcommand\address[1]{\noindent\textsf{#1}}
\renewcommand\email[1]{\noindent\textsf{E-mail:~#1}}

\renewenvironment{abstract}%%
{\vskip1pc\noindent\small\sf\textbf{Abstract.} } {
\footnotesize\textit{\@spiecopyright~~\@doi}\normalsize%
\vskip1pc\noindent Subject terms:~\@subjterm%
\vskip1pc\noindent \@loginfo}%

}%


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Submittal
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DeclareOption{optengsubmit}{%
\linespread{1.2}
\geometry{letterpaper,hcentering,height=60pc,top=2.5cm,bottom=2.5cm,left=2.5cm,right=2.5cm}
\parindent1em
\parskip0pc
\flushbottom

%%Title page elements
\renewcommand\title[1]{\Large\begin{center}\textbf{#1}\end{center}\normalsize\vskip-1pc}%
\renewcommand\author[1]{\large\begin{center}\textsf{#1}\end{center}\normalsize}%
\renewcommand\address[1]{\begin{center}\textit{#1}\end{center}}%
\renewcommand\email[1]{\begin{center}\texttt{#1}\end{center}}%

\renewenvironment{abstract}{\vskip1pc\noindent\textbf{Abstract.}}%
{\textit{\@spiecopyright.~~\@doi}%
\vskip1pc\noindent Subject terms:~\@subjterm%
\vskip1pc\noindent \@loginfo}%

}%



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Various customizations
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\renewcommand\maketitle{} %%deactivates \maketitle in LaTeX


%Fig. and Table Labels
\renewcommand\figurename{\footnotesize\sf\textbf{Fig.}}
\def\fps@table{h}%\def\fps@table{!htbp}
\renewcommand\tablename{\footnotesize \sf \textbf{Tab.}}

\def\fnum@figure{\footnotesize\sf\textbf{\figurename\  \textbf{\thefigure}}}

% Captions
\long\gdef\@makecaption#1#2{%
  \vskip\abovecaptionskip
  \sbox\@tempboxa{#1~~#2}%
  \ifdim \wd\@tempboxa >\hsize
    #1~~#2\par
  \else
    \global \@minipagefalse
    \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
  \fi
  \vskip\belowcaptionskip}

%%References
\renewenvironment{thebibliography}[1]
     {\acksect*{\refname
        \@mkboth{\MakeUppercase\refname}{\MakeUppercase\refname}}%
  \list{\@arabic\c@enumiv .}
           {\settowidth\labelwidth{.25in}%
            \leftmargin\labelwidth
  \setlength{\parsep}{0pc}
  \setlength{\labelsep}{0.5em}
  \setlength{\itemsep}{0.05pc}%{-0.06in}
  \setlength{\listparindent}{0in}
  \setlength{\itemindent}{0in}
  \setlength{\leftmargin}{.2in}
  \setlength{\rightmargin}{0in}
            \advance\leftmargin\labelsep
            \@openbib@code
            \usecounter{enumiv}%
            \let\p@enumiv\@empty
            \renewcommand\theenumiv{\@arabic\c@enumiv}}%
      \footnotesize
      \sloppy
      \clubpenalty4000
      \@clubpenalty \clubpenalty
      \widowpenalty4000%
      \sfcode`\.\@m }
     {\def\@noitemerr
       {\@latex@warning{Empty `thebibliography' environment}}%
      \endlist \vskip.2in}
\let\@openbib@code\@empty


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Section parameters
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\renewcommand\@seccntformat[1]{\sf\textbf{\csname the#1\endcsname\quad} }

\renewcommand\section{\@startsection{section}{1}{\z@}%
                                   {-2.5ex plus -1ex minus -.2ex}%
                                   {1.3ex plus .2ex}%
                                   {\sffamily\normalsize\bfseries}}
\renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
                                     {-2.25ex plus -1ex minus -.2ex}%
                                     {1ex plus .2ex}%
                                     {\sffamily\normalsize\itshape}}
\renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}%
                                     {-2.25ex plus -1ex minus -.2ex}%
                                     {1ex plus .2ex}%
                                     {\sffamily\small}}
\newcommand\acksect{\@startsection{acksection}{1}{\z@}%
                                   {-2.5ex plus -1ex minus -.2ex}%
                                   {1.3ex plus .2ex}%
                                   {\sffamily\normalsize\itshape}}




%% Code for floating math suggested by David Carlisle on comp.text.tex.

%\section{Floating Maths}
%
%  \begin{macro}{\fps@eqnfloat}
%    \begin{macrocode}
\def\fps@eqnfloat{!tp}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\ftype@eqnfloat}
% |figure| and |table| are 1 and 2 respectively, so make this type 4.
%    \begin{macrocode}
\def\ftype@eqnfloat{4}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{environment}{eqnfloat}
%  \begin{environment}{eqnfloat*}
%  Nothing special here, Just call |\@float| or |\@dblfloat| as
%  appropriate.
%    \begin{macrocode}
\newenvironment{eqnfloat}
               {\@float{eqnfloat}}
               {\end@float}
%    \end{macrocode}
%
%    \begin{macrocode}
\renewenvironment{eqnfloat*}
               {\@dblfloat{eqnfloat}}
               {\end@dblfloat}
%    \end{macrocode}
%  \end{environment}
%  \end{environment}


% **************************************************************************
% *****   Biography Definitions   ******************************************
% **************************************************************************
% Taken from the ieee.cls by Gregory Plett and Istv\'{a}n Koll\'{a}r, Sept 1997
%
% Counts
\newcount\br \newcount\nb \newcount\tcdsav \newcount\tcl \newcount\tcd
\newcount\tcn \newcount\cumtcl
% Dimens
\newdimen\rtside \newdimen\hpic \newdimen\vpic \newdimen\strutilg
\newdimen\picwd \newdimen\topheight \newdimen\ilg \newdimen\lpic
\newdimen\lwindowsep \newdimen\rwindowsep   % VK 10 Feb 93
\lwindowsep0.5\baselineskip         % "
\rwindowsep0.5\baselineskip         % "
\newdimen\cumpar
% Tokens
\newtoks\twa \newtoks\la \newtoks\ra \newtoks\ha \newtoks\pictoc
% Boxes
\newbox\rawtext \newbox\holder \newbox\windowbox \newbox\wartext
\newbox\finaltext \newbox\aslice \newbox\bslice \newbox\wbox
\newbox\wstrutbox \newbox\picbox \newbox\waslice \newbox\wbslice
\newbox\fslice
 % Another strut
\def\wstrut{\relax\ifmmode\copy\wstrutbox\else\unhcopy\wstrutbox\fi}
%

\def\getpic#1{\sbox{\@tempboxa}{\includegraphics{#1}}%
\newcount\tmpcta \tmpcta=\ht\@tempboxa%
\newcount\tmpctb \tmpctb=\wd\@tempboxa%
\divide\tmpctb by 100%
\divide\tmpcta by\tmpctb%
\ifnum\tmpcta>133%
\typeout{opteng: Biography picture `#1' too tall.}%
\frame{\hbox to 25mm{\hfil\resizebox{!}{32mm}{\usebox{\@tempboxa}}\hfil}}%
\else \ifnum\tmpcta<123%
\typeout{opteng: Biography picture `#1' too wide.}%
\frame{\vbox to 32mm{\vss\hbox{\resizebox{25mm}{!}{\usebox{\@tempboxa}}}\vss}}%
\else%
\resizebox{25mm}{32mm}{\usebox{\@tempboxa}} \fi\fi}

\long\def\biographyLyX#1{}

\long\def\biography{\@ifnextchar
[{\@biographyb}{\@biographya[{\unitlength
1mm\hbox{\framebox(25,32){}}}]}}

\long\def\@biographyb[#1]{\@biographya[\getpic{#1}]}

\long\def\@biographya[#1]#2{\sf\bgroup
\footnotesize\bigskip\bigskip\bigskip\parskip=0pt\par%
\rule{0pt}{35mm}\vspace*{-35mm}\par%   garantees correct page breaking
\begin{main@bio}[{#1}]%
\noindent{\bf \textsf{#2}}%
}
\def\endbiography{\end{main@bio}\egroup}

\long\def\main@bio[#1]{% #1 is the material for setting a graphic box
\vskip\parskip\everypar{} \global\cumpar=0pt \global\cumtcl=0
    \tcd=0
    \rtside=0pt
%    \hpic=\linewidth
    \twa={} \la={} \ra={} \ha={}
\setbox\wbox=\hbox{(} \computeilg \pictoc={#1}
\setbox\windowbox=\vbox{\hbox{#1}} \picwd=\wd\windowbox \hpic=\picwd
\vpic=\ht\windowbox\advance\vpic\dp\windowbox
\rtside=\linewidth\advance\rtside-\picwd
\setbox\picbox=\vbox{\hsize=\hpic\vbox to\vpic{\box\windowbox}}% \vfill}}%

\vpic=\ht\picbox\advance\vpic\dp\picbox
\ifdim\rtside>0pt\advance\rtside-\rwindowsep\fi    % "
\global\br=\rtside \ifnum\picwd=0 \ifdim\vpic>0pt\picwd=\hpic
\else\vpic=\ht\picbox\advance\vpic\dp\picbox \fi \fi
    \global\tcl=0 \lpic=0pt
    \loop\global\advance\tcl by 1 \lpic=\tcl\baselineskip
    \ifdim\lpic<\vpic\repeat
    \vpic=\lpic
    \global\cumtcl=\tcl
%
% Here we know exactly the number of indented lines and
% are able to generate the tokens for the \parshape list
%
    \ifnum\br>0\ra={ 0pt \rtside}\fi
    \ifnum\tcd>0\ha={ 0pt \linewidth}\fi
    \ifnum\tcl<1\global\tcl=1\fi
    \createparshapespec
    \tcd=0                        % restore the lintel
    \global\tcdsav=0
%
% This is a very tricky part of the package. Some day there
% will exist a detailed documentation.
%
\def\par{\\\indent}
%
% This is where we start to pick up the paragraph(s)
%
    \setbox\rawtext=\vbox\bgroup\unvbox\rawtext\unskip
    \clubpenalty=0\widowpenalty=0
    \ifnum\brokenpenalty<\maxdimen\else\brokenpenalty=9999\fi
    \tolerance=1000
    \parshape=\tcn \the\twa }
%
\def\endmain@bio{%
    %\par
    \global\tcd=\tcdsav
    \egroup\vskip\parskip\parshape=0 % reset parshape; end \box\rawtext
    \vbadness=10000
    \splittopskip=0pt
%
% Now we build the boxes beside the window
%
\global\topheight=\tcl\baselineskip
\ifnum\br>0\setbox\holder=\vsplit\rawtext to\topheight\fi \tcn=\tcl
\nb=0 \ifnum\br>0\nb=\tcn\fi
%
% text on the right side
%
\ifnum\nb>0
    \loop\advance\nb -1
    \setbox\bslice=\vsplit\holder to\baselineskip
    \prune\bslice\rtside
    \setbox\wbslice=\vbox{\unvbox\wbslice\hbox
    to\rtside{\box\bslice\hfil}}
    \ifdim\ht\holder>0pt\repeat
\fi
%GLP add fix to make sure bio starts at top of picture
\setbox\wbslice=\vbox to\topheight{\unvbox\wbslice\vfill\vss}
%
% fixing the dimensions of the window part
%
\topheight=\ht\wbslice
%
% ship out the window material to the main vertical list
%
\setbox\windowbox=\vbox{\hbox to\linewidth{%
\vbox to\topheight{\hrule width\picwd height0pt depth0pt\vskip0pt%
\vfill\unvbox\picbox%
\ifnum\picwd>0\vfill\fi%
\vss}\ifnum\br>0\hfill\vbox{\box\wbslice}\fi}}%
%
\unvbox\windowbox%
\loop% lines below picture....
 \setbox\bslice=\vsplit\rawtext to\baselineskip
 \prune\bslice\linewidth
 \setbox\wbslice=\vbox{\hbox to\linewidth{\box\bslice\hfil}}
 \unvbox\wbslice
 \ifdim\ht\rawtext>0pt
\repeat
%GLP
%\ifnum\nb>0\topheight=\nb\baselineskip %\advance\topheight by\ilg
%\vspace*{\topheight}
%\fi
}% FINITO
%
% What else do we need?
%
\def\prune#1#2{
% take a \vbox containing a single \hbox,
% \unvbox it, and cancel the \lastskip
% put in a \hbox of width #2
 \unvbox#1 \setbox#1=\lastbox % \box#1 now is an \hbox
 \ifdim\ht#1=\parskip
 \setbox#1=\hbox to#2{\vrule height\parskip depth0pt width0pt\hfill}
 \else\ifdim\ht#1=0pt\relax
 \else\setbox#1=\hbox to#2{\wstrut\unhbox#1\unskip}\fi\fi}
%
% Here the token \twa is generated.
% It's not so difficult as it looks like.
%
\def\createparshapespec{%
\global\tcn=0 \ifnum\br>0\global\tcn=\tcl\fi \nb=0
\ifnum\br>0\nb=\tcn\fi \global\advance\tcn by\tcd
\global\advance\tcn by1 \ifnum\tcd>0
\loop\twa=\expandafter{\the\twa\the\ha}\advance\tcd -1
\ifnum\tcd>0\repeat \fi \ifnum\nb>0
\loop\twa=\expandafter{\the\twa\the\ra}\advance\nb -1
\ifnum\nb>0\repeat \fi \global\twa=\expandafter{\the\twa 0pt
\the\linewidth}}
%
\def\computeilg{% compute the interline glue
 \tcl=0\ilg=0pt\strutilg=0pt
 \loop\setbox\wbox=\hbox{\char\tcl}
 \ifdim\ht\wbox>\ilg\ilg=\ht\wbox\fi
 \ifdim\dp\wbox>\strutilg\strutilg=\dp\wbox\fi
 \advance\tcl by 1
 \ifnum\tcl<128\repeat
 \ht\wbox=\ilg
 \dp\wbox=\strutilg
 \strutilg=\ht\wbox %\advance\strutilg by\ilg
 \ifdim\strutilg>\baselineskip
  \typeout{character with height greater baselineskip found in font}
  \typeout{baselineskip changed to 1.5 of that height!}
  \baselineskip=1.5\strutilg
 \fi
 \global\ilg=\baselineskip
 \global\advance\ilg-\ht\wbox \global\advance\ilg-\dp\wbox
 \strutilg=\ht\wbox \advance\strutilg by\ilg
 \setbox\wstrutbox=\hbox{\vrule height\strutilg depth\dp\wbox width0pt}}


% the following code from version.sty by Stephen Bellantoni 1990, loosely
% based on "annotation.sty" by Tom Hofmann. Used to exclude "biography" from
% anonymous mode.
\begingroup
\catcode`@=11\relax%
\catcode`{=12\relax\catcode`}=12\relax%
\catcode`(=1\relax \catcode`)=2\relax%
\gdef\glpinclude#1(%
  \expandafter\gdef\csname #1\endcsname%
    ()%
  \expandafter\gdef\csname end#1\endcsname%
    ()%
)%
\gdef\glpexclude#1(%
  \expandafter\gdef\csname #1\endcsname%
    (\@bsphack\catcode`{=12\relax\catcode`}=12\relax\csname #1@NOTE\endcsname)%
  \long\expandafter\gdef\csname #1@NOTE\endcsname ##1\end{#1}%
    (\csname #1END@NOTE\endcsname)%
  \expandafter\gdef\csname #1END@NOTE\endcsname%
    (\@esphack\end(#1))%
)%
\endgroup

\frenchspacing

\hyphenation {ac-cord-ing
           ach-iev-ed
           ad-jus-ted
           al-gor-ithm
           allow
           app-lic-ation
           back-scat-ter
           back-scat-te-ring
           back-scat-tered
           Based based
           beam-splitt-er
           beam-width
           cases
           cen-tered
           changed
           char-acter-istic char-acter-ization
           co-effic-ient
           co-incide
           Co-llab-or-ation
           comp-en-sate
           con-cerning
           con-ven-tional
           con-volv-ed
           de-creased
           de-po-lar-iz-ation
           de-tector de-tectors
           de-vi-ation
           diff-erence
           dis-cussion
           dis-tribu-tion
           dis-tribu-tions
           dis-trib-ute
           dis-trib-uted
           Ehhalt
           extinc-tion
           found
           Found-at-ion
           frin-ges
           Geest-hacht
           ground
           Hink-ley
           il-lus-trated
           il-lus-trate
           inexp-en-sive
           Intro-ducing
           inter-fero-meter inter-fero-metric inter-fero-metry
           Klap-heck
           lati-tude
           meas-ure-ment meas-ure-ments
           meas-ured
           measuring
           met-rol-ogy
           micro-meter
           mixing
           mod-ul-ation
           nano-meter
           nano-scale
           non-linear-ities
           non-ideal
           north-east
           orig-inated
           op-er-ating
           Opt-ical opt-ical
           out-flow
           phos-phor
           pres-ence
           primary
           prof-ilo-metry
           resp-onse
           rather
           rela-tive
           sat-ur-ation
           scat-te-ring
           semi-cond-uctor
           sig-nal
           sig-nals
           solid
           sur-face sur-faces
           tem-pera-ture
           Tem-pera-ture
           trans-ported
           tropo-pause
           Tropo-pause
           tropo-sphere
           Tropo-sphere
           tube
           tubes
           Values
           varies
           wave-length
           Weather}


\ProcessOptions\relax
%% end opteng.sty