% \iffalse meta-comment
%
% Copyright (C) 2011 by Dag Langmyhr
%
% This file may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, see
% http://www.latex-project.org/lppl.txt
%
% \fi
%
% \iffalse
%<*driver>
\ProvidesFile{elbioimp.dtx}
%</driver>
%<class>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<class>\ProvidesClass{elbioimp}
%<*class>
    [2011/03/02 v1.2 Document class for Journal of Electrical Bioimpedance]
%</class>
%
%<*driver>
\documentclass{elbioimp}
\usepackage[T1]{fontenc}
\usepackage{doc,textcomp,varioref}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\keywords{\LaTeX{} document class, journal document style}

\begin{document}
\DocInput{elbioimp.dtx}
\end{document}
%</driver>
% \fi
%
% \CharacterTable
%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%   Digits        \0\1\2\3\4\5\6\7\8\9
%   Exclamation   \!     Double quote  \"     Hash (number) \#
%   Dollar        \$     Percent       \%     Ampersand     \&
%   Acute accent  \'     Left paren    \(     Right paren   \)
%   Asterisk      \*     Plus          \+     Comma         \,
%   Minus         \-     Point         \.     Solidus       \/
%   Colon         \:     Semicolon     \;     Less than     \<
%   Equals        \=     Greater than  \>     Question mark \?
%   Commercial at \@     Left bracket  \[     Backslash     \\
%   Right bracket \]     Circumflex    \^     Underscore    \_
%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%   Right brace   \}     Tilde         \~}
%
% % \CheckSum{224}
%
% \newcommand{\cmd}[1]{\texttt{\textbackslash #1}}
% \newcommand{\Cname}{\textsf{elbioimp}}
% \newcommand{\Jname}{\emph{Journal of Electrical Bioimpedance}}
%
% \changes{v1.0}{2010/01/20}{Initial version}
% \changes{v1.1}{2010/11/02}{Line spacing modified}
% \changes{v1.2}{2011/03/01}{Added \cmd{subsection},
%   \cmd{affiliation}, and \cmd{sameaffiliation}}
%
% \GetFileInfo{elbioimp.dtx}
%
% \DoNotIndex{\,}
% \DoNotIndex{\abstractname,\addtocounter,\arabic,\AtBeginDocument,\@author}
% \DoNotIndex{\baselineskip,\begin,\bf,\bibliographystyle}
% \DoNotIndex{\captionsetup,\ClassWarningNoLine,\columnwidth,\CurrentOption}
% \DoNotIndex{\DeclareCaptionLabelFormat,\DeclareMathSizes,\DeclareOption,\def}
% \DoNotIndex{\end,\equal}
% \DoNotIndex{\footnote,\footnoterule}
% \DoNotIndex{\ifthenelse,\@ifundefined,\ignorespaces,\it,\itemsep}
% \DoNotIndex{\leftmargin,\leftmargini,\let,\@listi,\@listI,\LoadClass}
% \DoNotIndex{\@makefnmark,\@makefntext}
% \DoNotIndex{\newcommand,\newenvironment,\noindent,\normalfont}
% \DoNotIndex{\pagestyle,\par,\parindent,\parsep,\ProcessOptions}
% \DoNotIndex{\relax,\renewcommand,\renewenvironment,\RequirePackage,\rule}
% \DoNotIndex{\setcounter,\@setfontsize,\setlength,\space,\@startsection}
% \DoNotIndex{\textbf,\@textsuperscript,\textwidth,\@thefnmark,%
%  \thempfootnote,\@title,\topsep,\twocolumn}
% \DoNotIndex{\urlstyle}
% \DoNotIndex{\vspace}
%
% \title{The \Cname{} class}
% \author{Dag Langmyhr\affiliation{Department of Informatics,
%   University of Oslo, \textsf{dag@ifi.uio.no}}}
%
% \maketitle
%
% \begin{abstract}
%   \noindent
%   This paper describes the implementation of the document class
%   \Cname{} which has been designed for writing articles in the \Jname.
%   It corresponds to \Cname{}~\fileversion, dated \filedate.
% \end{abstract}
% 
%
% \section{Introduction}
% The \Jname{} (see its web page at
% \url{https://www.journals.uio.no/index.php/bioimpedance}) has
% defined a typographic style for its publication, to some extent
% based on recommendations from the \emph{US National institute of
% health}\cite{NIH}. The \LaTeX{} document class \Cname{} implements
% this style.
% As an example, this documentation uses the \Cname{} class.
%
% This \LaTeX{} code is published with a \textbf{\LaTeX{} project
% public license}, as described in
% \url{http://www.latex-project.org/lppl/}. 
%
%
% \section{Usage}
% To use this document class, you must first put the
% \url{elbioimp.cls} file somewhere that \LaTeX{} can find
% it.\footnote{If you are not very familiar with your \LaTeX{}
%   installation or your system administrator, you can put the
%   \url{elbioimp.cls} file in the same folder as your \LaTeX{} source
%   files.} 
% Then you can write your \LaTeX{} document starting with
% \begin{verbatim}
%\documentclass{elbioimp}
% \end{verbatim}
% The document class is based on the standard \emph{article} class and
% is used just like that class, with three exceptions:
% \begin{enumerate}
% \item The authors' affiliations (to companies or academic institutions)
%   are given with the \verb:\affiliation: command:
%   \begin{verbatim}
%\author{My name\affiliation{My univerisity, 
%    My city, My country}}
%   \end{verbatim}
%   If there is more than one author, their names should be separated
%   by an \verb:\and: command.
% 
%   If two authors have the same affiliation, the latter one may use the
%   \verb:\sameaffiliation: command, as in
%   \begin{verbatim}
%\author{First Author\affiliation{My university, 
%  My city, My country}\and
%  Second Author\sameaffiliation}
%   \end{verbatim}
%
%   In case there should be three or more authors and some have identical
%   affiliations, \verb:\sameaffiliation: may be given a
%   numeric option referencing a previous author; for example, if the
%   first and the third author belong to the same institution, you may
%   write: 
%   \begin{verbatim}
%\author{A Bee\affiliation{Uni A}\and
%    C Dee\affiliation{Uni B}\and
%    E Eff\sameaffiliation[1]}
%   \end{verbatim}
%
% \item The author may indicate keywords by empoying the
% \verb:\keyword: command.
%
% \item The document class will function poorly unless there is an
% \verb:abstract: environment and a \verb:\maketitle: command.
% \end{enumerate}
%
% \StopEventually{\bibliography{elbioimp}%
%   \onecolumn\PrintChanges\PrintIndex}
%
%
% \section{Class headers}
% All \LaTeXe{} class files contain a header with a set of standard
% specifications. 
%
% \subsection{Class options}
% This document class has no options.
%    \begin{macrocode}
\DeclareOption*{\ClassWarningNoLine
  {elbioimp}{Class option \CurrentOption
    \space is illegal in this document class}}
\ProcessOptions \relax
%    \end{macrocode}
%
% \subsection{Base class}
% This document class is based on the standard \emph{article} class.
%
%    \begin{macrocode}
\LoadClass[twocolumn]{article}
%    \end{macrocode}
%
% \section{Required packages}
% A couple of standard packages are necessary to implement this class.
%
% \subsection{The \textsf{ifthen} package}
% The \textsf{ifthen} package makes testing easier.
%    \begin{macrocode}
\RequirePackage{ifthen}
%    \end{macrocode}
%
% \subsection{The \textsf{url} package}
% URLs should be typeset in a \textsf{Sans serif font} rather than a
% \texttt{Teletype font}.
%    \begin{macrocode}
\RequirePackage[T1]{url}  
\urlstyle{sf}
%    \end{macrocode}
%
%
% \section{Document title area}
% The title area has its own particular design.
% It is implemented by redefining the \verb:\maketitle: command.
%    \begin{macrocode}
\AtBeginDocument{\renewcommand{\maketitle}{%
  \twocolumn[\begin{minipage}{\textwidth}
    \renewcommand{\and}{, }
    \let \thanks = \affiliation
    \let \samethanks = \sameaffiliation
    \renewcommand{\footnoterule}{}
    \def \@makefntext ##1{\noindent
      \small \@thefnmark. \it ##1}
    \renewcommand{\thempfootnote}%
      {\arabic{mpfootnote}}
    \parindent = 0pt
    {\huge \@title}\par\vspace{16pt}
    {\large \@author}
  \end{minipage}\par\vspace{14pt}\noindent
  \elb@rule{\textwidth}\vspace{11pt}]}}
\newcommand{\elb@rule}[1]{\rule{#1}{0.6pt}}
%    \end{macrocode}
% (The names \verb:\thanks: and \verb:\samethanks: are kept for
% historic reasons.)
%
% \subsection{Affiliations}
% Affiliations are specified using the \verb:\affiliation: and
% \verb:\sameaffiliation: commands.
%    \begin{macrocode}
\newcommand{\affiliation}[1]{\footnote{#1}}
\newcommand{\sameaffiliation}[1][0]{%
  \addtocounter{mpfootnote}{-1}%
  \ifthenelse{#1<1}
    {\@makefnmark}
    {\@textsuperscript{\normalfont#1}}%
  \addtocounter{mpfootnote}{1}}
%    \end{macrocode}
%
% \subsection{Keywords}
% An additional command \verb:\keywords: makes it possible to specify
% keywords that apply to the document.
%    \begin{macrocode}
\newcommand{\keywords}[1]{\def\elb@keywords{#1}}
%    \end{macrocode}
%
% \subsection{Abstract}
% The abstract is typeset in \verb:\small:, and includes the keywords (if
% any).
%    \begin{macrocode}
\renewenvironment{abstract}
  {\small\noindent
    \textbf{\abstractname}\par\vspace{1pt}
    \noindent\ignorespaces}
  {\par
   \@ifundefined{elb@keywords}{}{%
     \vspace{\baselineskip}\noindent
     \textbf{Keywords:} \elb@keywords\par}
   \vspace{\baselineskip}\noindent
   \elb@rule{\columnwidth}}
%    \end{macrocode}
%
%
% \section{Body text}
%
% \subsection{Text area}
% The text area should be in two columns and fill an A4 paper with
% margins 1.5\,cm (except the top margin, which should be 2.5\,cm). 
% The gutter space should be 1\,cm.
%    \begin{macrocode}
\RequirePackage[a4paper,
  margin=1.5cm,top=2.5cm]{geometry}
\setlength{\columnsep}{1cm}
%    \end{macrocode}
% Since the layout uses double columns, I will increase the tolerance
% for line-breaking.
%    \begin{macrocode}
\pretolerance = 1000
\tolerance = 2000   \hbadness = \tolerance
%    \end{macrocode}
%
%
% \subsection{Headers and footers}
% This document class has neither headers nor footers, presumably
% because the publisher will add them later.
%    \begin{macrocode}
\AtBeginDocument{\pagestyle{empty}}
%    \end{macrocode}
%
%
% \subsection{Text font}
% The specified journal font is \emph{Times Roman}. The
% \emph{mathptmx} packages is one of several packages that can handle this,
% but this particular package has the advantage that it also uses
% \emph{Times Roman} for the math fonts (as much as possible).
%    \begin{macrocode}
\RequirePackage{mathptmx}
%    \end{macrocode}
% The \emph{mathptmx} package retains the \textsf{Computer Modern Sans
%   Serif} and \texttt{Computer Modern Teletype} fonts, but they blend
% reasonably well with \emph{Times Roman} (at least in my opinion) so
% I will keep them. 
%
% \subsection{Text sizes}
% The specified text sizes are shown in Table\vref{tab:sizes}.
% The leading should be 30\%.
% \begin{table}
%   \centering
%   \begin{tabular}{cr}
%     \Huge         \strut\verb:\Huge:&         20\,pt\\
%     \huge         \strut\verb:\huge:&         16\,pt\\
%     \LARGE        \strut\verb:\LARGE:&        14\,pt\\
%     \Large        \strut\verb:\Large:&        12\,pt\\
%     \large        \strut\verb:\large:&        11\,pt\\
%     \normalsize   \strut\verb:\normalsize:&   10\,pt\\
%     \small        \strut\verb:\small:&         9\,pt\\
%     \footnotesize \strut\verb:\footnotesize:&  8\,pt\\
%     \scriptsize   \strut\verb:\scriptsize:&    7\,pt\\
%     \tiny         \strut\verb:\tiny:&          5\,pt\\
%   \end{tabular}
%   \caption{Text sizes in \Cname\label{tab:sizes}}
% \end{table}
%    \begin{macrocode}
\renewcommand{\Huge}{\@setfontsize
  \Huge {20}{26}}
\renewcommand{\huge}{\@setfontsize
  \huge {16}{20.8}}
\renewcommand{\LARGE}{\@setfontsize
  \LARGE {14}{18.2}}
\renewcommand{\Large}{\@setfontsize
  \Large {12}{15.6}}
\renewcommand{\large}{\@setfontsize
  \large {11}{14.3}}
\renewcommand{\normalsize}{%
   \@setfontsize \normalsize {10}{13}%
   \abovedisplayskip =
     10pt plus 2pt minus 5pt
   \abovedisplayshortskip =
     0pt plus 3pt
   \belowdisplayshortskip =
     6pt plus 3pt minus 3pt
   \belowdisplayskip = \abovedisplayskip
   \def\@listi{\leftmargin = \leftmargini
     \topsep = 5pt plus 2pt minus 2pt
     \parsep = 3pt plus 1pt minus 1pt
     \itemsep = \topsep}}
\renewcommand{\small}{%
   \@setfontsize \small {9}{11.7}%
   \abovedisplayskip =
     8.5pt plus 3pt minus 4pt
   \abovedisplayshortskip =
     0pt plus 2pt
   \belowdisplayshortskip = 
     4pt plus 2pt minus 2pt
   \def\@listi{\leftmargin = \leftmargini
     \topsep = 4pt plus 2pt minus 2pt
     \parsep = 2pt plus 1pt minus 1pt
     \itemsep = \topsep}%
   \belowdisplayskip = \abovedisplayskip}
\renewcommand{\footnotesize}{%
   \@setfontsize \footnotesize {8}{10.4}%
   \abovedisplayskip =
     6pt plus 2pt minus 4pt
   \abovedisplayshortskip =
     0pt plus 1pt
   \belowdisplayshortskip =
     3pt plus 1pt minus 2pt
   \def\@listi{\leftmargin = \leftmargini
     \topsep = 3pt plus 1pt minus 1pt
     \parsep = 1.5pt plus 1pt minus 1pt
     \itemsep = \topsep}%
   \belowdisplayskip = \abovedisplayskip}
\renewcommand{\scriptsize}{\@setfontsize
  \scriptsize {7}{9.1}}
\renewcommand{\tiny}{\@setfontsize
  \tiny {5}{6.5}}
%    \end{macrocode}
% As expected, \verb:\normalsize: is the default.
%    \begin{macrocode}
\normalsize
%    \end{macrocode}
% Since the class uses some non-standard sizes (i.e., not in the
% $1{.}2^n$-series) it must signal \LaTeX{} that font
% scaling may be used.\footnote{These days, all decent \LaTeX{} installations
% should provide scalable fonts.}
%    \begin{macrocode}
\RequirePackage{type1cm,type1ec}
%    \end{macrocode}
% The class must also define some math sizes.
%    \begin{macrocode}
\DeclareMathSizes{11}{11}{8}{6}
\DeclareMathSizes{14}{14}{11}{8}
\DeclareMathSizes{16}{16}{12}{10}
\DeclareMathSizes{20}{20}{14}{12}
%    \end{macrocode}
%
%
% \section{Sectioning}
% The section headers in this class have a different look from the
% standard \LaTeX{} classes.
%    \begin{macrocode}
\renewcommand{\section}{\@startsection
  {section}{1}{0pt}%
  {-11pt plus -6pt minus -2pt}%
  {11pt plus 6pt minus 2pt}%
  {\normalfont\normalsize\bf}}
\renewcommand{\subsection}{\@startsection
  {subsection}{2}{0pt}%
  {-11pt plus -6pt minus -2pt}%
  {11pt plus 6pt minus 2pt}%
  {\normalfont\normalsize\it}}
\renewcommand{\subsubsection}{\@startsection
  {subsubsection}{3}{0pt}%
  {-11pt plus -6pt minus -2pt}%
  {11pt plus 6pt minus 2pt}%
  {\normalfont\normalsize}}
%    \end{macrocode}
% The default definitions of \verb:\paragraph: and
% \verb:\subparagraph: are retained.
%
% \subsection{Section numbering}
% No sections should be numbered.
%    \begin{macrocode}
\setcounter{secnumdepth}{-2}
%    \end{macrocode}
%
%
% \section{Floats}
% Formating of float captions is best handled using the
% \textsf{caption} package. This style wants them
% \begin{itemize}
% \item indentend 0.5\,cm on each side
% \item 8\,pt type size
% \item numbering should use ``Fig.~1'' or ``Tab.~1''.
% \end{itemize}
%    \begin{macrocode}
\RequirePackage[margin=0.5cm,font=footnotesize,
  aboveskip=5pt]{caption}
\DeclareCaptionLabelFormat{fig}
  {\ifthenelse{\equal{#1}%
    {Figure}}{Fig}{Tab}.~#2}
\captionsetup{labelformat=fig}
%    \end{macrocode}
% We also adjust the spacing around the floats, and we do not want
% half-empty float-columns.
%    \begin{macrocode}
\setlength{\floatsep}{6pt plus 3pt}
\setlength{\textfloatsep}{\floatsep}
\renewcommand{\floatpagefraction}{0.8}
%    \end{macrocode}
% 
%
% \section{Document reference list}
% The reference list should be according to the Vancouver style:
%    \begin{macrocode}
\bibliographystyle{vancouver}
%    \end{macrocode}
% but the bibliography should be set in 9\,pt type size with 3\,pt vertical
% space. 
%    \begin{macrocode}
\renewcommand{\@openbib@code}{\small
  \setlength{\itemsep}{3pt}%
  \setlength{\parsep}{1pt plus 1pt}}
%    \end{macrocode}
% In the bibliography, citations will be indicated as ``1.''
% rather than as ``[1]''.
%    \begin{macrocode}
\renewcommand\@biblabel[1]{#1.}
%    \end{macrocode}
%
% \Finale
\endinput
