% $Id: macros.tex,v 1.1 2004/12/18 12:15:06 gtrombetti Exp $
% Defines several useful LaTeX macros.

%%%% \widen and \lengthen
\newcommand{\widen}[1]{%
\newlength{\widening}\setlength{\widening}{#1}%
\addtolength{\oddsidemargin}{-.5\widening}%
\addtolength{\evensidemargin}{-.5\widening}%
\addtolength{\textwidth}{\widening}%
}
\newcommand{\lengthen}[1]{%
\newlength{\lengthening}\setlength{\lengthening}{#1}%
\addtolength{\topmargin}{-.75\lengthening}%
\addtolength{\textheight}{\lengthening}%
}

%%%% \sectionl, \subsectionl, \subsubsectionl
%%%% Combine, in case of \sectionl, \section and \label.
\newcommand{\sectionl}[1]{\section{#1}\label{#1}}
\newcommand{\subsectionl}[1]{\subsection{#1}\label{#1}}
\newcommand{\subsubsectionl}[1]{\subsubsection{#1}\label{#1}}

\def\gets{\leftarrow}

\newcommand{\ls}[1]
   {\dimen0=\fontdimen6\the\font
    \lineskip=#1\dimen0
    \advance\lineskip.5\fontdimen5\the\font
    \advance\lineskip-\dimen0
    \lineskiplimit=.9\lineskip
    \baselineskip=\lineskip
    \advance\baselineskip\dimen0
    \normallineskip\lineskip
    \normallineskiplimit\lineskiplimit
    \normalbaselineskip\baselineskip
    \ignorespaces
   }

\def\sqzhuge{\vspace{-14pt}}
\def\sqzlarge{\vspace{-12pt}}
\def\sqzsub{\vspace{-10pt}}
\def\sqzpar{\vspace{-10pt}}
\def\sqzsmall{\vspace{-7pt}}
\def\sqztiny{\vspace{-5pt}}
\def\sqz{\vspace{-10pt}}

% \qed modified 1) to produce open boxes and 2) by removing
% \hskip 2em, so that box can be squeezed up against text
% 18 Aug 89 dll
\def\qed{\ifmmode
        \raisebox{0.6ex}{\fbox{}}
    \else
        {\unskip\nobreak\hfil\penalty50
        \hbox{}\nobreak\hfil\raisebox{0.6ex}{\fbox{}}
        \parfillskip=0pt\par}
    \fi}

%\def\qed{\ifmmode
%       \vrule height 7pt width 7pt depth 0pt
%    \else
%       {\unskip\nobreak\hfil\penalty50
%       \hskip 2em\hbox{}\nobreak\hfil\vrule height 7pt width 7pt depth 0pt
%       \parfillskip=0pt\par}
%    \fi}

\def\uncatcodespecials{\def\do##1{\catcode`##1=12 } \dospecials}

\def\setupmyverbatim{\par\obeylines\obeyspaces\myverbatimdefs
}

\def\code{\begingroup \parskip=1pt \medskip \setupmyverbatim
   \parindent=2\parindent
   \catcode`\ =13 \catcode`\^^M=13 \catcode`\\=0
   }
\def\endcode{\medskip\endgroup}

\def\myverbatim{\begingroup \setupmyverbatim \tt
  \parindent=0\parindent\smallskip
   \catcode`\ =13 \catcode`\^^M=13 \catcode`\\=0 \catcode`\$=3
   \catcode`\{=12 \catcode`\}=12
   \myverbatimgobble}

{\catcode`\^^M=13{\catcode`\ =13\gdef\myverbatimdefs{\def^^M{\ \par}\let =\ }}
  \gdef\myverbatimgobble#1^^M{#1}}

\def\endmyverbatim{\smallskip\endgroup}

\newcommand{\crunchlist}{
        \setlength{\itemsep}{-0.05in}
        \setlength{\partopsep}{0in}
        \setlength{\topsep}{0in}}

\newcommand{\cramplist}{
        \setlength{\itemsep}{0in}
        \setlength{\partopsep}{0in}
        \setlength{\topsep}{0in}}
\newcommand{\cramp}{\setlength{\parskip}{.5\parskip}}

\newcommand{\singlespace}{\def\baselinestretch{1.0}\large\normalsize}

\def\b#1{{\bf #1}}
\let\strong=\b

% Draw a box around a TeX box
% Usage:     \boxit\somebox{dimen}
% outputs the contents of ``somebox'' with a rule on all four sides.
% The space between ``somebox'' and the rule is ``dimen''.
\def\boxit#1#2{\vbox{\hrule\hbox{\vrule\kern#2
              \vbox{\kern#2 \copy#1\kern#2}\kern#2\vrule}\hrule}}

\newcommand{\eg}{\mbox{\em e.g.}}
\newcommand{\etal}{\mbox{\em et al.}}
\newcommand{\etc}{\mbox{\em etc.}}
\newcommand{\ie}{\mbox{\em i.e.}}

%% \bfverbatim makes all verbatim environments use bold font
\newcommand{\bfverbatim}{\renewcommand{\normalfont}{\bfseries}}

%% \bfcaption prints a \bf caption, but normal font in lists of tables/figures
\def\bfcaption#1{\caption[#1]{\bf #1}}

%%%% Default expansions for \par* and \subpar* commands.  An
%%%% individual document can override these defaults by providing
%%%% definitions _before_ inputting the macros file.
\providecommand{\parbullet}[1]{\sqzpar\paragraph{#1}}
\providecommand{\parbulletbegin}{}
\providecommand{\parbulletend}{}
\providecommand{\subparbullet}[1]{\sqzsub\subparagraph{#1}}
\providecommand{\subparbulletbegin}{}
\providecommand{\subparbulletend}{}

% Trademark and Registered Trademark.  The negative raisebox argument
% lowers the TM a bit, to align with the top of the text.
\DeclareTextCommandDefault{\tm}{\raisebox{-0.4ex}{$^\mathrm{TM}$}}
\DeclareTextCommandDefault{\rtm}{{\textcircled{\footnotesize R}}}
% Superscript Registered Trademark symbol.
\DeclareTextCommandDefault{\srtm}{$^{\rtm}$}

% OMG trademarks
\DeclareTextCommandDefault{\CORBA}{\mbox{CORBA\rtm}}
\DeclareTextCommandDefault{\ObjectManagementGroup}
  {\mbox{Object Management Group\rtm}}
\DeclareTextCommandDefault{\OMG}{\mbox{OMG}\tm}
\DeclareTextCommandDefault{\ORB}{\mbox{ORB}\tm}
\DeclareTextCommandDefault{\ObjectRequestBroker}
  {\mbox{Object Request Broker}\tm}
\DeclareTextCommandDefault{\IIOP}{\mbox{IIOP}\tm}
\DeclareTextCommandDefault{\OMGInterfaceDefinitionLanguage}
  {\mbox{OMG Interface Definition Language}\tm}
\DeclareTextCommandDefault{\UnifiedModelingLanguage}
  {\mbox{Unified Modeling Language}\tm}
\DeclareTextCommandDefault{\UML}{\mbox{UML}\tm}
\DeclareTextCommandDefault{\CORBAservices}{\mbox{CORBAservices}\tm}
\DeclareTextCommandDefault{\CORBAfacilities}{\mbox{CORBAfacilities}\tm}
\DeclareTextCommandDefault{\OMGTMStatement}{CORBA is a trademark or
   registered trademark of Object Management Group, Inc., in the U.S.
   and other countries.}
