%%%% jeosman.sty   
%    Journal of the European Optical Society - manuscript submission
%
% Carl Paterson  May 2006
% Preliminary version 0.1 
%
% %USAGE:
% % 1) To prepare a manuscript for submission:
% \documentclass[12pt]{article}                  
% \usepackage{jeosman}
%   ...
%
% % To use twocolumn format to estimate page length:
% \documentclass[twocolumn,12pt]{article}
% \usepackage{jeosman}
%   ...
% \begin{document}
% \twocolumn[
%   % Title,authors,abstract for single column formatting
%      ...
% ]
%   ...
% 
%%%%

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{jeosman}[15/05/2006 LaTeX package for manuscripts for JEOS ]

\RequirePackage{geometry}
%\RequirePackage[colorlinks=true, linkcolor=blue, citecolor=blue, urlcolor=blue]{hyperref}
\RequirePackage{graphicx}
\RequirePackage{color}
\RequirePackage{cite}

\if@twocolumn
%twocolumn is used to estimate the length of the article in the journal
%the style is based on the jeos production style.

\RequirePackage{titlesec}
\RequirePackage{fancyhdr}
\RequirePackage{url}
\RequirePackage{soul}
\RequirePackage[frame,a4,center]{crop}

\geometry{a4paper, lmargin=3.5pc, rmargin=2.5pc, 
  tmargin=2.667cm, bmargin=2.5cm}

\def\jeosfont{cmr}


% Spacing and break control
\frenchspacing
\flushbottom
\widowpenalty=10000
\clubpenalty=250
\makeindex

% Set various dimensions
\setlength{\parindent}{0pc}
\parskip=\baselineskip
\setlength{\columnsep}{15pt}


\renewcommand*{\ttdefault}{\jeosfont}
\renewcommand*{\sfdefault}{\jeosfont}

\sodef\sotitle{\fontsize{19}{24}\usefont{T1}{\jeosfont}{b}{n}}{.133em}
  {1em plus .1em}{0pt}

\newcommand\keywords[1]{\def\thekeywords{#1}}
\newcommand\keywordline[1]{{\bf Keywords}: {#1}}
\renewenvironment{abstract}%%  
{ \vspace{\baselineskip}\vspace{-11pt}\noindent\begin{center}\begin{minipage}{\textwidth}
    \noindent \usefont{T1}{\jeosfont}{m}{n} }
{ \end{minipage} \end{center}
{
\vspace{\baselineskip}
\vspace{-6pt} \usefont{T1}{\jeosfont}{m}{n} 
  \keywordline \thekeywords 
}
\vspace{\baselineskip}
\vspace{24pt}
}
\def\FirstSection#1{\vspace{12pt} \begin{multicols}{2}[\section{#1}]}

\newcommand\mytitle[1]{ 
{{\vtop to
    5.5pc{\hspace*{24pt}\parbox{.9\linewidth}{\raggedright\sotitle{#1}\vrule
        width 0pt height 20pt}}}}}

\newcommand\myauthor[1]{\vspace{-\baselineskip}
  \makebox[11.6pc][l]{\fontsize{10.6}{13}\selectfont\textbf{#1}}}
\newcommand\myaddress[1]{
  {\fontsize{8}{12}\selectfont#1}\par\vspace{12pt}}
\newcommand\myemail[1]{ 
  \vspace{-12pt}% \vspace{-\baselineskip}
  {\fontsize{7}{10}\usefont{T1}{\jeosfont}{b}{n}{#1}
   \vspace{2pt}}\par}

\let\title\mytitle
\let\author\myauthor
\let\address\myaddress
\let\email\myemail


\renewcommand\normalsize{%
   \@setfontsize\normalsize{9.4pt}{12.4pt}
   \abovedisplayskip 10\p@ \@plus2\p@ \@minus5\p@
   \abovedisplayshortskip \z@ \@plus3\p@
   \belowdisplayshortskip 6\p@ \@plus3\p@ \@minus3\p@
   \belowdisplayskip \abovedisplayskip
   \let\@listi\@listI}
\renewcommand\footnotesize{%
   \@setfontsize\footnotesize{7.6pt}{9.8pt}
   \abovedisplayskip 10\p@ \@plus2\p@ \@minus5\p@
   \abovedisplayshortskip \z@ \@plus3\p@
   \belowdisplayshortskip 6\p@ \@plus3\p@ \@minus3\p@
   \belowdisplayskip \abovedisplayskip
   \let\@listi\@listI}
\renewcommand\small{%
   \@setfontsize\small{6.667pt}{9.1pt}
   \abovedisplayskip 10\p@ \@plus2\p@ \@minus5\p@
   \abovedisplayshortskip \z@ \@plus3\p@
   \belowdisplayshortskip 6\p@ \@plus3\p@ \@minus3\p@
   \belowdisplayskip \abovedisplayskip
   \let\@listi\@listI}
\renewcommand\Large{%
   \@setfontsize\Large{14pt}{14pt}
   \abovedisplayskip 10\p@ \@plus2\p@ \@minus5\p@
   \abovedisplayshortskip \z@ \@plus3\p@
   \belowdisplayshortskip 6\p@ \@plus3\p@ \@minus3\p@
   \belowdisplayskip \abovedisplayskip
   \let\@listi\@listI}
\renewcommand\huge{%
   \@setfontsize\huge{24pt}{24pt}
   \abovedisplayskip 10\p@ \@plus2\p@ \@minus5\p@
   \abovedisplayshortskip \z@ \@plus3\p@
   \belowdisplayshortskip 6\p@ \@plus3\p@ \@minus3\p@
   \belowdisplayskip \abovedisplayskip
   \let\@listi\@listI}
\renewcommand\Huge{%
   \@setfontsize\Huge{20pt}{22pt}
   \abovedisplayskip 10\p@ \@plus2\p@ \@minus5\p@
   \abovedisplayshortskip \z@ \@plus3\p@
   \belowdisplayshortskip 6\p@ \@plus3\p@ \@minus3\p@
   \belowdisplayskip \abovedisplayskip
   \let\@listi\@listI}

\titleformat{\section}[hang]
  {\fontsize{14}{14}\usefont{T1}{\jeosfont}{b}{n}}
  {\thesection}
  {0.66em}
  {}
\titleformat{\section}[hang]
  {\fontsize{14}{14}\usefont{T1}{\jeosfont}{b}{n}}
  { \thesection}
  {0.66em}
  {}
\titlespacing{\section}{0pt}{*3.0}{*-0.5}
\titleformat{\subsection}[hang]
  {}
  {\thesubsection}
  {0.66em}
  {}
\titlespacing{\subsection}{0pt}{*1.5}{*-1.0}
\titleformat{\subsubsection}[hang]
  {\fontsize{10}{12}\usefont{T1}{\jeosfont}{b}{n}}
  {\thesubsubsection}
  {0.33em}
  {}
\titlespacing{\subsubsection}{0pt}{*1.5}{*-1.3}

\long\def\@makecaption#1#2{%
  \vskip\abovecaptionskip
  \sbox\@tempboxa{\fontsize{7.4}{8}\usefont{T1}{\jeosfont}{m}{n}#1: #2}%
  \ifdim \wd\@tempboxa >\hsize
    \fontsize{7.4}{8}\usefont{T1}{\jeosfont}{m}{n}#1: #2\par
  \else
    \global \@minipagefalse
    \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
  \fi
  \vskip\belowcaptionskip}

\def\bibtitle{\vspace{-42pt}}
\def\bibheadtitle{}
 

\renewenvironment{thebibliography}[1]
     {\fontsize{9}{11}\usefont{T1}{\jeosfont}{m}{n}
      \section*{REFERENCES}%
      \@mkboth{\MakeUppercase\refname}{\MakeUppercase\refname}%
      \list{\@biblabel{\@arabic\c@enumiv}}%
           {\settowidth\labelwidth{\@biblabel{#1}}%
            \leftmargin\labelwidth
            \advance\leftmargin\labelsep
            \setlength\itemsep{3pt}
            \setlength\parsep{3pt}
            \@openbib@code
            \usecounter{enumiv}%
            \let\p@enumiv\@empty
            \renewcommand\theenumiv{\@arabic\c@enumiv}}%
      \sloppy
      \clubpenalty4000
      \@clubpenalty \clubpenalty
      \widowpenalty4000%
      \sfcode`\.\@m}
     {\def\@noitemerr
       {\@latex@warning{Empty `thebibliography' environment}}%
      \endlist}


\else

%Format as a manuscript for peer review

\ifx\pdfoutput\undefined
  \usepackage{graphicx}
\else 
  \ifx\pdfoutput
    \usepackage[pdftex]{graphicx}
  \else
    \usepackage{graphicx}
  \fi
\fi

\RequirePackage{geometry}
\geometry{a4paper,nohead,margin=2.5cm} 
\parindent0pc  
\parskip 0.75em 
\linespread{1.2}
\pagestyle{plain}
\sloppy

\newcommand\mytitle[1]{ {\LARGE \bf 
  \begin{center} #1 \end{center}}\vskip-0.5cm }
\newcommand\myauthor[1]{ {\vskip0.1cm\noindent{
  \large\begin{center} \bf #1 \end{center}}\vskip-0.4cm}}
\newcommand\myaddress[1]{ {\vskip-0.5cm\noindent
  \begin{center} {\it #1} \end{center} \vskip-0.4cm} }
\newcommand\myemail[1]{ {\vskip-0.5cm\noindent
  \begin{center}{ \rm #1 } \end{center} \vskip-0.5cm} }
\let\title\mytitle
\let\author\myauthor
\let\address\myaddress
\let\email\myemail

\newcommand\keywords[1]{\def\thekeywords{#1}}
\newcommand\keywordline[1]{{{\bf Keywords}: {#1}}}

\renewenvironment{abstract}%%  
  {\vskip0.75pc\noindent\begin{center}\begin{minipage}{\textwidth}
     \noindent \rm}
  { \end{minipage} \end{center} {\keywordline \thekeywords } }
   
\newenvironment{abstract*}%%  
  {\vskip0.75pc\noindent\begin{minipage}{\textwidth} \noindent \rm}
  { \end{minipage} {\keywordline \thekeywords }}
   
\renewcommand\maketitle{\vskip0pt} %%deactivates \maketitle in LaTeX

\renewcommand\figurename{Figure}
\renewcommand\tablename{Table}
\renewcommand\refname{\large \bf REFERENCES \rm} 

\renewcommand\section{\@startsection {section}{1}{0pt}%
                                    {-2.5ex plus -0.5ex minus -.2ex}%
                                    {0.1ex plus .1ex}%
                                    {\large\bfseries}}
\renewcommand\subsection{\@startsection{subsection}{2}{0pt}%
                                      {-2.0ex plus -0.5ex minus -.2ex}%
                                      {0.1ex plus .1ex}%
                                      {\normalsize\bfseries}}
\renewcommand\subsubsection{\@startsection{subsubsection}{3}{0pt}%
                                      {-2.0ex plus -0.5ex minus -.2ex}%
                                      {0.1ex plus .1ex}%
                                      {\normalsize\it}}

\DeclareOption{copyedit}{\linespread{2.0}}
\ProcessOptions\relax

\fi

%% end jeosman.sty
