% All the pakages used below are already installed with a full
% installation of MiKTeX, except for "lyxfig".  The "mathtime"
% package is included with MiKTeX, but the mathtime fonts required
% by the package are a separate purchase.

% Use Mathtime (Times fonts in math mode)
% \usepackage{mathtime} % <---- Requires mathtime fonts

% Packages for psfrag
\usepackage{psfrag}
\usepackage{lyxfig} % <--- Requires separate installation into MiKTeX

% Define various math operators 
% The first parameter is the new math-command and the second one the text which will be printed.
% Usage, e.g., the error function "erf":  $\erf$ in red text
%                                         \erf in math mode
\usepackage{amsopn}
\DeclareMathOperator{\erf}{erf} % error function
\DeclareMathOperator{\Ei}{E_{i}} % exponential integral function
\DeclareMathOperator{\signum}{signum} % signum function
\DeclareMathOperator{\E}{\mathit{E}} % expectation operator
\DeclareMathOperator{\Q}{\mathit{Q}} % Q function
\DeclareMathOperator{\ceil}{ceil} % ceiling function
\DeclareMathOperator{\floor}{floor} % floor function
\DeclareMathOperator{\I0}{\mathit{I}_{0}} % zero order modified Bessel function of the first kind
\DeclareMathOperator{\gam}{\Gamma} % Gamma function
\DeclareMathOperator{\thet}{\theta} % Full period (even) correlation
\DeclareMathOperator{\thethat}{\hat\theta} % Odd correlation
\DeclareMathOperator{\C}{\mathit{C}} % Aperiodic correlation
\DeclareMathOperator{\Thet}{\Theta} % Multirate correlation
\DeclareMathOperator{\rect}{\mathit{P}} % Rectangular pulse
\DeclareMathOperator{\fx}{\mathit{x}} % The function x
\DeclareMathOperator{\fy}{\mathit{y}} % The function y
\DeclareMathOperator{\fd}{\mathit{d}} % The function d
\DeclareMathOperator{\ff}{\mathit{f}} % The function f
\DeclareMathOperator{\fF}{\mathit{F}} % The function F
\DeclareMathOperator{\ft}{\mathit{t}} % The function t
\DeclareMathOperator{\fs}{\mathit{s}} % The function s
\DeclareMathOperator{\fc}{\mathit{c}} % The function c
\DeclareMathOperator{\fw}{\mathit{w}} % The function w
\DeclareMathOperator{\fr}{\mathit{r}} % The function r
\DeclareMathOperator{\fD}{\mathit{D}} % The function D
\DeclareMathOperator{\fn}{\mathit{n}} % The function n
\DeclareMathOperator{\fm}{\mathit{m}} % The function m
\DeclareMathOperator{\fMAI}{\mathit{MAI}} % The function MAI
\DeclareMathOperator{\fPsi}{\Psi} % The function Psi
\DeclareMathOperator{\fnu}{\nu} % The function nu
\DeclareMathOperator{\fg}{\mathit{g}} % The function g
\DeclareMathOperator{\fdelta}{\delta} % The function delta
\DeclareMathOperator{\fu}{\mathit{u}} % The function u
\DeclareMathOperator{\fP}{\mathit{P}} % The function P
\DeclareMathOperator{\fPr}{Pr} % The Probability operator

% Control caption format and enable definition of caption delimiter
% in red text.
% Hanging indent, centered text, normal font size, 0.5-inch margin
\usepackage[hang,center,normalsize]{caption2}
\setlength{\captionmargin}{0.5in}%  <-- can be changed to any valid value

% Hanging indent in footnotes
\usepackage[flushmargin]{footmisc}

% The footmisc package (above) causes the footnote number to extend
% into the left margin.  The following code fragment fixes it:
\newlength{\myFootnoteWidth}
\newlength{\myFootnoteLabel}
\setlength{\myFootnoteLabel}{0.6em}%  <-- can be changed to any valid value
\renewcommand{\@makefntext}[1]{%
  \setlength{\myFootnoteWidth}{\columnwidth}%
  \addtolength{\myFootnoteWidth}{-\myFootnoteLabel}%
  \noindent\makebox[\myFootnoteLabel][r]{\@makefnmark\ }%
  \parbox[t]{\myFootnoteWidth}{#1}%
}

% Create nice fractions 
% Usage: \nicefrac{3}{5} in red text
%        \nicefrac{3}5 in math mode
\usepackage[nice]{nicefrac}

% Change multiple citation references from [1,2,3,4,5] to [1-5] (IEEE format)
\input{cite.sty}
\def\citedash{\hbox{]--}\penalty\@m \hbox{[}}

% Create special symbols such as registered, trademark, copyright, etc.
% usage in red text: \textregistered  for the circumscribed R
%                    \texttrademark for the superscripted TM
%                    \textcopyright  for the circumscribed C
%                    \textdegree  for the degree symbol
%                    \textcelsius  for degree C
\usepackage{textcomp}

% Define symbol for the set of complex numbers
% Usage in math mode: \Cplx
\newfont{\Bb}{msbm5 scaled 1800} % <---- Change scale to whatever value provides proper sizing, e.g., 1800
\def\Cplx{\mbox{\Bb C}}

% Superscript and subscript
% usage in red text: 8\sups{th} floor  gives "8th floor"; "\sups{th}" is in red text
%                    x\subs{01}  gives "x_01"; "\subs{01}" is in red text
\newcommand\sups[1]{\raisebox{1ex}{\small #1}}
\newcommand\subs[1]{\raisebox{-1ex}{\small #1}}


% Write math in bold italics
% Usage: \bm{A}
\usepackage{bm}

% Specify format of Table of Contents (TOC), List of Figures (LOF), and List of Tables (LOT)
% Will not start a new page between TOC, LOF, and LOT.  Use \clearpage command as follows:
% TOC ...
% \clearpage
% LOT ...
% \clearpage
% LOF ...
\usepackage{tocloft}
\renewcommand\cftsubsecfont{\renewcommand\bm{}} % Bold math (\bm) was used in several subsection
                                                % headings, which shows up as bold font in the TOC.
                                                % This tells LaTeX to remove the \bm command
                                                % from these headings before placing them into
                                                % the TOC.  This way the font in the TOC for these 
                                                % headings is not bold.
% \renewcommand\cftsecfont{\renewcommand\newline{}} % Forced linefeeds (\newline) within section
                                                  % headings.  This removes those linefeeds prior
                                                  % to inserting section headings into TOC. 
 
% Set vertical spacing between table caption placed at top 
% of table and the table
\newcommand{\@ldtable}{}
\let\@ldtable\table
\renewcommand{\table}{%
                 \setlength{\@tempdima}{\abovecaptionskip}%
                 \setlength{\abovecaptionskip}{\belowcaptionskip}%
                 \setlength{\belowcaptionskip}{2pt}%  <-- can be changed to any valid value
                 \@ldtable}%

% fix spacing around = in displayed eqnarray
\gdef\eqnarr@ysep{0.28em\relax}
\def\eqnarray{%
   \stepcounter{equation}%
   \def\@currentlabel{\p@equation\theequation}%
   \global\@eqnswtrue
   \m@th
   \global\@eqcnt\z@
   \tabskip\@centering
   \let\\\@eqncr
   $$\everycr{}\halign to\displaywidth\bgroup
       \hskip\@centering$\displaystyle\tabskip\z@skip{##}$\@eqnsel
      &\global\@eqcnt\@ne\hskip \eqnarr@ysep\hfil${##}$\hfil
      &\global\@eqcnt\tw@ \hskip \eqnarr@ysep
         $\displaystyle{##}$\hfil\tabskip\@centering
      &\global\@eqcnt\thr@@ \hb@xt@\z@\bgroup\hss##\egroup
         \tabskip\z@skip
      \cr
}
\def\endeqnarray{%
      \@@eqncr
      \egroup
      \global\advance\c@equation\m@ne
   $$\@ignoretrue
}

% fix spacing around = in text
\everymath{\thinmuskip=2mu plus 1mu
        \medmuskip=3mu plus 1mu minus 2mu
        \thickmuskip=4mu plus 2mu\relax}
