%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% bamv-ing.cls This is the style file for articles
%% submitted in English for the Boletin AMV
%%
%% This file sets the dimensions of the page and size
%% of letters in titles and text. 
%% It also contains a macro useful for inserting pictures
%% which have been save as .epsf files. See the end of the
%% file bamv-demo.tex for instructions on how to use it.
%%
%% If you need extra macros (e.g. AMS: amssymb, amsfonts, amsmath, etc)
%% include them with the instruction:
%%\usepackage{amssymb, amsfonts, amsmath}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\LoadClass[twoside]{article}

\date{}

\renewcommand\section{\@startsection{section}{1}{\z@}%
                       {-18\p@ \@plus -4\p@ \@minus -4\p@}%
                       {12\p@ \@plus 4\p@ \@minus 4\p@}%
                       {\normalfont\large\bfseries\boldmath
                        \rightskip=\z@ \@plus 8em\pretolerance=10000 }}
\renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
                       {-18\p@ \@plus -4\p@ \@minus -4\p@}%
                       {8\p@ \@plus 4\p@ \@minus 4\p@}%
                       {\normalfont\normalsize\bfseries\boldmath
                        \rightskip=\z@ \@plus 8em\pretolerance=10000 }}  
\renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}%
                       {-18\p@ \@plus -4\p@ \@minus -4\p@}%
                       {-0.5em \@plus -0.22em \@minus -0.1em}%
                       {\normalfont\normalsize\bfseries\boldmath}} 


%%We use for our headings the folowing macros:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% fancyheadings.sty version 1.98
% Fancy headers and footers.
% Piet van Oostrum, Dept of Computer Science, University of Utrecht
% Padualaan 14, P.O. Box 80.089, 3508 TB Utrecht, The Netherlands
% Telephone: +31 30 2531806. Email: piet@cs.ruu.nl
% Sep 16, 1994
%% After a series of 98 corrections (see original) we end with this.
% May 7, 1996:
% version 1.98:
% Added % after the line  \def\nouppercase
% BY THE WAY, THIS IS THE LAST RELEASE OF VERSION 1.

\let\fancy@def\gdef
\def\lhead{\@ifnextchar[{\@xlhead}{\@ylhead}}
\def\@xlhead[#1]#2{\fancy@def\@elhead{#1}\fancy@def\@olhead{#2}}
\def\@ylhead#1{\fancy@def\@elhead{#1}\fancy@def\@olhead{#1}}

\def\chead{\@ifnextchar[{\@xchead}{\@ychead}}
\def\@xchead[#1]#2{\fancy@def\@echead{#1}\fancy@def\@ochead{#2}}
\def\@ychead#1{\fancy@def\@echead{#1}\fancy@def\@ochead{#1}}

\def\rhead{\@ifnextchar[{\@xrhead}{\@yrhead}}
\def\@xrhead[#1]#2{\fancy@def\@erhead{#1}\fancy@def\@orhead{#2}}
\def\@yrhead#1{\fancy@def\@erhead{#1}\fancy@def\@orhead{#1}}

\def\lfoot{\@ifnextchar[{\@xlfoot}{\@ylfoot}}
\def\@xlfoot[#1]#2{\fancy@def\@elfoot{#1}\fancy@def\@olfoot{#2}}
\def\@ylfoot#1{\fancy@def\@elfoot{#1}\fancy@def\@olfoot{#1}}

\def\cfoot{\@ifnextchar[{\@xcfoot}{\@ycfoot}}
\def\@xcfoot[#1]#2{\fancy@def\@ecfoot{#1}\fancy@def\@ocfoot{#2}}
\def\@ycfoot#1{\fancy@def\@ecfoot{#1}\fancy@def\@ocfoot{#1}}

\def\rfoot{\@ifnextchar[{\@xrfoot}{\@yrfoot}}
\def\@xrfoot[#1]#2{\fancy@def\@erfoot{#1}\fancy@def\@orfoot{#2}}
\def\@yrfoot#1{\fancy@def\@erfoot{#1}\fancy@def\@orfoot{#1}}

\newdimen\headrulewidth
\newdimen\footrulewidth
\newdimen\plainheadrulewidth
\newdimen\plainfootrulewidth
\newdimen\headwidth
\newdimen\footruleskip
\newif\if@fancyplain \@fancyplainfalse
\def\fancyplain#1#2{\if@fancyplain#1\else#2\fi}
\headwidth=-123456789sp %magic constant

% Command to reset various things in the headers:
% a.o.  single spacing (taken from setspace.sty)
% and the catcode of ^^M (so that epsf files in the header work if a
% verbatim crosses a page boundary)
% It also defines a \nouppercase command that disables \uppercase and
% \Makeuppercase. It can only be used in the headers and footers.
\def\fancy@reset{\restorecr
 \def\baselinestretch{1}%
 \def\nouppercase##1{{\let\uppercase\relax\let\MakeUppercase\relax##1}}%
 \ifx\undefined\@newbaseline% NFSS not present; 2.09 or 2e
   \ifx\@normalsize\undefined \normalsize % for ucthesis.cls
   \else \@normalsize \fi
 \else% NFSS (2.09) present
  \@newbaseline%
 \fi}

% Initialization of the head and foot text.

\headrulewidth 0.4pt
\footrulewidth\z@
\plainheadrulewidth\z@
\plainfootrulewidth\z@
\footruleskip .3\normalbaselineskip

\lhead[\fancyplain{}{\sl\rightmark}]{\fancyplain{}{\sl\leftmark}}
\chead{}
\rhead[\fancyplain{}{\sl\leftmark}]{\fancyplain{}{\sl\rightmark}}
\lfoot{}
\cfoot{\rm\thepage} % page number
\rfoot{}

% Put together a header or footer given the left, center and
% right text, fillers at left and right and a rule.
% The \lap commands put the text into an hbox of zero size,
% so overlapping text does not generate an errormessage.

\def\@fancyhead#1#2#3#4#5{#1\hbox to\headwidth{\fancy@reset\vbox{\hbox
{\rlap{\parbox[b]{\headwidth}{\raggedright#2\strut}}\hfill
\parbox[b]{\headwidth}{\centering#3\strut}\hfill
\llap{\parbox[b]{\headwidth}{\raggedleft#4\strut}}}\headrule}}#5}

\def\@fancyfoot#1#2#3#4#5{#1\hbox to\headwidth{\fancy@reset\vbox{\footrule
\hbox{\rlap{\parbox[t]{\headwidth}{\raggedright#2\strut}}\hfill
\parbox[t]{\headwidth}{\centering#3\strut}\hfill
\llap{\parbox[t]{\headwidth}{\raggedleft#4\strut}}}}}#5}

\def\headrule{{\if@fancyplain\let\headrulewidth\plainheadrulewidth\fi
\hrule\@height\headrulewidth\@width\headwidth \vskip-\headrulewidth}}

\def\footrule{{\if@fancyplain\let\footrulewidth\plainfootrulewidth\fi
\vskip-\footruleskip\vskip-\footrulewidth
\hrule\@width\headwidth\@height\footrulewidth\vskip\footruleskip}}

\def\ps@fancy{%
\@ifundefined{@chapapp}{\let\@chapapp\chaptername}{}%for amsbook
% Define \MakeUppercase for old LaTeXen.
% Note: we used \def rather than \let, so that \let\uppercase\relax (from
% the original documentation) will still work.
\@ifundefined{MakeUppercase}{\def\MakeUppercase{\uppercase}}{}
\@ifundefined{chapter}{\def\sectionmark##1{\markboth
{\MakeUppercase{\ifnum \c@secnumdepth>\z@
 \thesection\hskip 1em\relax \fi ##1}}{}}%
\def\subsectionmark##1{\markright {\ifnum \c@secnumdepth >\@ne
 \thesubsection\hskip 1em\relax \fi ##1}}}%
{\def\chaptermark##1{\markboth {\MakeUppercase{\ifnum \c@secnumdepth>\m@ne
 \@chapapp\ \thechapter. \ \fi ##1}}{}}
\def\sectionmark##1{\markright{\MakeUppercase{\ifnum \c@secnumdepth >\z@
 \thesection. \ \fi ##1}}}}%
%\csname ps@headings\endcsname % use \ps@headings defaults if they exist
\ps@@fancy
\gdef\ps@fancy{\@fancyplainfalse\ps@@fancy}%
% Initialize \headwidth if the user didn't
\ifdim\headwidth<0sp
% 
%
    \advance\headwidth123456789sp\advance\headwidth\textwidth\fi}
\def\ps@fancyplain{\ps@fancy \let\ps@plain\ps@plain@fancy}
\def\ps@plain@fancy{\@fancyplaintrue\ps@@fancy}
\def\ps@@fancy{%
\ps@empty % This is for amsbook/amsart, which do strange things with \topskip
\def\@mkboth{\protect\markboth}%
\def\@oddhead{\@fancyhead\@lodd\@olhead\@ochead\@orhead\@rodd}%
\def\@oddfoot{\@fancyfoot\@lodd\@olfoot\@ocfoot\@orfoot\@rodd}%
\def\@evenhead{\@fancyhead\@rodd\@elhead\@echead\@erhead\@lodd}%
\def\@evenfoot{\@fancyfoot\@rodd\@elfoot\@ecfoot\@erfoot\@lodd}%
}
\def\@lodd{\if@reversemargin\hss\else\relax\fi}
\def\@rodd{\if@reversemargin\relax\else\hss\fi}

\let\latex@makecol\@makecol
\def\@makecol{\let\topfloat\@toplist\let\botfloat\@botlist\latex@makecol}
\def\iftopfloat#1#2{\ifx\topfloat\empty #2\else #1\fi}
\def\ifbotfloat#1#2{\ifx\botfloat\empty #2\else #1\fi}
\def\iffloatpage#1#2{\if@fcolmade #1\else #2\fi}

\newcommand{\fancypagestyle}[2]{%
  \@namedef{ps@#1}{\let\fancy@def\def#2\relax\ps@fancy}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Dimension of Boletin
\textwidth 12.1cm
\textheight 18cm
\evensidemargin 2.2cm
\oddsidemargin 2.2cm
\pagestyle{fancyplain} 
\plainheadrulewidth 0.4pt
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%running headers
%%

\newif\ifboldatosUC
\newif\ifauthorUC
\newif\iftitleUC
 
\def\boldatos#1{\def\thedata{\ifboldatosUC\uppercase\fi{#1}}}
\def\autorcorto#1{\def\theauthors{\ifauthorUC\uppercase\fi{#1}}}
\def\titulocorto#1{\def\thetitle{\iftitleUC\uppercase\fi{#1}}} 

\lhead[\fancyplain{\thepage}{\thepage}]%
   {\fancyplain{\thedata}%
        {\centering\sc\thetitle}}
\rhead[\fancyplain{\centering\sc\theauthors}
                  {\centering\sc\theauthors}]
      {\fancyplain{\thepage}{\thepage}}
\cfoot[]{}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%   EPSF.TEX macro file:
%   Written by Tomas Rokicki of Radical Eye Software, 29 Mar 1989.
%   Revised by Don Knuth, 3 Jan 1990.
%   Revised by Tomas Rokicki to accept bounding boxes with no
%      space after the colon, 18 Jul 1990.
%
%%  EPSF.DEF macro file:
%%  Modified from EPSF.TEX by Ari Lehtonen to work with Textures
%%    on Macintoshes, Jan 25, 1991.
%
%   TeX macros to include an Encapsulated PostScript graphic.
%   Works by finding the bounding box comment,
%   calculating the correct scale values, and inserting a vbox
%   of the appropriate size at the current position in the TeX document.
%
%   To use, simply say
%   \input epsf           % somewhere early on in your TeX file
%   \epsfbox{filename.ps} % where you want to insert a vbox for a figure
%
%   The effect will be to typeset the figure as a TeX box, at the
%   point of your \epsfbox command. By default, the graphic will have its
%   `natural' width (namely the width of its bounding box, as described
%   in filename.ps). The TeX box will have depth zero.
%
%%   You can enlarge or reduce the width of the box by saying
%%     \epsfxsize=<dimen> \epsfbox{filename.ps}
%%   instead. Then the width of the TeX box will be \epsfxsize;
%%   its height will be the same.
%%   (The \epsfbox macro resets \epsfxsize to zero after each use.)
%%
%%  You can change the size of the figure by saying
%%    \epsfscale=<num> \epsfbox{filename.ps}
%%   (The \epsfbox macro resets \epsfscale to 1000 after each use.)
%
%   If you want TeX to report the size of the figure (as a message
%   on your terminal when it processes each figure), say `\epsfverbosetrue'.

%
\newread\epsffilein    % file to \read
\newif\iffileok        %% file to \read ok?
\newif\ifepsffileok    % continue looking for the bounding box?
\newif\ifepsfbbfound   % success?
\newif\ifepsfverbose   % report what you're making?
\newdimen\epsfxsize    % horizontal size after scaling
\newdimen\epsfysize    % vertical size after scaling
\newdimen\epsftsize    % horizontal size before scaling
\newdimen\pspoints     % conversion factor
\newcount\epsfscale    %% scaling factor
%
%   This is another modification:  we turn on magnification scaling,
%   and use 1bp instead of the truebp that was here in earlier
%   versions.  This is turned on just by the following procedure
%   existing.
%
%%\special{! /magscale 1 def }
%
\pspoints=1bp          % Adobe points are `big'
\epsfxsize=0pt         % Default value, means `use natural size'
\epsfscale=1000        %% Magnification a la TeX
%

\def\epsfbox#1{%
%
%   The first thing we need to do is to open the
%   PostScript file, if possible.
%
\fileoktrue \openin\epsffilein=#1
\ifeof\epsffilein\message{[Couldn't open #1; using defaults.]}%
\fileokfalse\fi
%
%   Okay, we got it. Now we'll scan lines until we find one that doesn't
%   start with %. We're looking for the bounding box comment.
%
   \iffileok
   {\epsffileoktrue \chardef\other=12
    \def\do##1{\catcode`##1=\other}\dospecials \catcode`\ =10
    \loop
       \read\epsffilein to \epsffileline
       \ifeof\epsffilein\epsffileokfalse\else
%
%   We check to see if the first character is a % sign;
%   if not, we stop reading (unless the line was entirely blank);
%   if so, we look further and stop only if the line begins with
%   `%%BoundingBox:'.
%
          \expandafter\epsfaux\epsffileline:. \\%
       \fi
   \ifepsffileok\repeat
   \ifepsfbbfound\else
      \ifepsfverbose\message{No bounding box comment in #1; using defaults}\fi
      \global\def\epsfllx{0}  \global\def\epsflly{0}%
      \global\def\epsfurx{282}\global\def\epsfury{282}\fi
   }\closein\epsffilein
   \else
      \global\def\epsfllx{0}  \global\def\epsflly{0}%
      \global\def\epsfurx{282}\global\def\epsfury{282}%
   \fi
%
%   Now we have to calculate the scale and offset values to use.
%   First we compute the natural sizes.
%
   \epsfysize=\epsfury\pspoints \advance\epsfysize by-\epsflly\pspoints
   \epsftsize=\epsfurx\pspoints \advance\epsftsize by-\epsfllx\pspoints
%%
%% Scale the figure, if \epsfscale is not 1000.
%% This version is not quite accurate and may lead to overflow
   \ifnum\epsfscale=1000\else
     \divide\epsftsize by 1000 \multiply\epsftsize by \epsfscale
     \divide\epsfysize by 1000 \multiply\epsfysize by \epsfscale
   \fi
%
%  Finally, we make the vbox and stick in a \special that dvips can parse.
%
   \ifepsfverbose\message{#1: width=\the\epsftsize, height=\the\epsfysize}\fi
%
%   If `epsfxsize' is 0, we default to the natural size of the picture.
%%  Otherwise we put the graph to be box of width \epsfxsiz.
%
   \ifnum\epsfxsize=0 \epsfxsize=\epsftsize\fi
   \vbox to \epsfysize{\vfil
     \ifnum\epsfxsize=0 \hbox to \epsftsize
     \else \hbox to \epsfxsize \fi{\hss
       \hbox to \epsftsize{%
         \special{illustration #1 scaled \number\epsfscale}\hfil}%
       \hss}}%
\epsfxsize=0pt \epsfscale=1000 }%

%
%   We still need to define the tricky \epsfaux macro. This requires
%   a couple of magic constants for comparison purposes.
%
{\catcode`\%=12 \global\let\epsfpercent=%\global\def\epsfbblit{%BoundingBox}}%
%
%   So we're ready to check for `%BoundingBox:' and to grab the
%   values if they are found.
%
\long\def\epsfaux#1#2:#3\\{\ifx#1\epsfpercent
   \def\testit{#2}\ifx\testit\epsfbblit
      \epsfgrab #3 . . . \\%
      \epsffileokfalse
      \global\epsfbbfoundtrue
   \fi\else\ifx#1\par\else\epsffileokfalse\fi\fi}%
%
%   Here we grab the values and stuff them in the appropriate definitions.
%
\def\epsfgrab #1 #2 #3 #4 #5\\{%
   \global\def\epsfllx{#1}\ifx\epsfllx\empty
      \epsfgrab #2 #3 #4 #5 .\\\else
   \global\def\epsflly{#2}%
   \global\def\epsfurx{#3}\global\def\epsfury{#4}\fi}%
%
%   Finally, another definition for compatibility with older macros.
%
%%\let\epsffile=\epsfbox

%%%%%%%%%%%%%%FIN de epsf.tex
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%para los graficos
\newcounter{lax}
\newcounter{lay}
\newsavebox{\lafig}
\newsavebox{\lasum}
\newcommand{\insertpicture}[3]{
\setcounter{lax}{0}
\setcounter{lay}{0}
\sbox{\lafig}{
\epsfscale=#2 \epsfbox{#1}
\sbox{\lasum}{
\addtocounter{lax}{\the\epsftsize}
\addtocounter{lay}{\the\epsfysize}
}
}
\begin{picture}(\value{lax},\value{lay})
\put(0,15){\usebox{\lafig}}
\put(15,0){#3}
\end{picture}
}
