\RequirePackage[a4paper,top=5cm,left=4cm,right=4cm,bottom=4.5cm]{geometry}
\usepackage{pdfpages}
\usepackage{ifthen}

\usepackage{babel}
%lsb  \usepackage[latin1]{inputenc}
\usepackage{ucs}
\usepackage[utf8x]{inputenc}

\usepackage{url}
\usepackage{graphicx}
\usepackage{fancyvrb}
\usepackage{color}
\usepackage{fancyhdr}
\usepackage{enumitem}
\usepackage{makeidx}
\usepackage{hyperref}
\hypersetup{
    colorlinks,
    citecolor=black,
    filecolor=black,
    linkcolor=black,
    urlcolor=black
}

\pagestyle{fancy}
\newcounter{artigo}

\fancyhead{}
\fancyfoot{}
\fancyhead[LO]{Actas}
\fancyhead[RO]{\thepage}

\newcommand{\conf}[2][NO]{
 \ifthenelse{\equal{#1}{NO}}{ 
    \gdef\@conf{{\sc #2}}
    \gdef\@conffoot{#2}
 }{ 
    \gdef\@conf{{\sc #2}}
    \gdef\@conffoot{#1}
 }
}

\renewcommand{\author}[1]{\index{#1}}

\renewcommand{\headrulewidth}{0.1pt}
\newcommand{\article}[4][NO]{
\cleardoublepage
%  \addcontentsline{toc}{section}{\\[1mm]\textbf{#2}\\{\textit{#3}}}
% \refstepcounter{section}%

\addtocounter{artigo}{1}
\phantomsection 
 \addcontentsline{toc}{section}{\textbf{#2}\\{\textit{#3}}}
 \label{inicio\theartigo}

 \renewcommand{\headrulewidth}{0pt}
 \fancyhead{}
%  \fancyfoot[RO]{{\bf\@conf}}
 \fancyfoot[RO]{}
 \fancyfoot[C]{}
 \fancyfoot[LO]{\@conffoot, pp. \pageref{inicio\theartigo}--\pageref{fim\theartigo}}
 \includepdf[pagecommand={\thispagestyle{fancy}},pages=1]{#4}

% \renewcommand{\headrulewidth}{0.1pt}
% \ifthenelse{\equal{#1}{NO}}{ \fancyhead[LO]{\it #2}}{ \fancyhead[LO]{\it
%#1}}
% \fancyhead[RE]{\it #3}
% \fancyhead[LE]{\thepage \ \  {\bf \@conf}}
% \fancyhead[RO]{{\bf \@conf} -- \thepage}
% \fancyfoot{}
% \includepdf[pagecommand={\thispagestyle{fancy}\label{fim\theartigo}},pages=2-]{#4}

% \renewcommand{\footrulewidth}{0pt}
  \renewcommand{\footrulewidth}{0.1pt}
 \ifthenelse{\equal{#1}{NO}}{ \fancyfoot[LO]{\it #2}}{ \fancyfoot[LO]{\it #1}}
 \fancyfoot[RE]{\it #3}
 \fancyfoot[LE]{\thepage \ \  {\bf \@conf}}
 \fancyfoot[RO]{{\sf \@conf} -- \thepage}
%\ifthenelse{\equal{#1}{NO}}{ \fancyfoot[C]{{\it #2} -- \thepage}}{ \fancyfoot[C]{{\it #1} -- \thepage }}
 \fancyhead{}
 \includepdf[pagecommand={\thispagestyle{fancy}\label{fim\theartigo}},pages=2-]{#4}
}

\def\makeautindex#1{
 \def\indexname{#1}
%% \addcontentsline{toc}{chapter}{#1}
 \printindex
}

\newcommand{\mytitle}[3]{%

  \thispagestyle{empty}
  \setlength{\parindent}{0mm}
  \setlength{\parskip}{0mm}
  \vspace*{\stretch{1}}
  \rule{\linewidth}{1mm}
  \begin{flushright}
  {\Huge #1}
  \\[8mm]
  {\LARGE #2}
  \end{flushright}
  \rule{\linewidth}{1mm}
  \vspace*{\stretch{2}}
  \begin{center}
  \Large \textsf{#3}
  \end{center}
%   \setlength{\parskip}{1mm}
%   \setlength{\parindent}{8mm}
}

\makeindex

\newcommand{\artic}[5][NO]{
  \cleardoublepage
%  \addcontentsline{toc}{section}{\\[1mm]\textbf{#2}\\{\textit{#3}}}

  \addtocounter{artigo}{1}
  \phantomsection 
  \addcontentsline{toc}{section}{\textbf{#2}\\{\textit{#3}}}
  \label{inicio\theartigo}

  \renewcommand{\headrulewidth}{0pt}
  \fancyhead{}
%  \fancyfoot[RO]{{\bf\@conf}}
  \fancyfoot[RO]{}
  \fancyfoot[C]{}
%  \fancyfoot[LO]{pp. \pageref{inicio\theartigo}--\pageref{fim\theartigo}}
  \fancyfoot[LO]{\@conffoot, pp. \pageref{inicio\theartigo}--\pageref{fim\theartigo}}
  \includepdf[offset=#5,pagecommand={\thispagestyle{fancy}},pages=1]{#4}


% \renewcommand{\footrulewidth}{0pt}
  \renewcommand{\footrulewidth}{0.1pt}
 \ifthenelse{\equal{#1}{NO}}{ \fancyfoot[LO]{\it #2}}{ \fancyfoot[LO]{\it #1}}
 \fancyfoot[RE]{\it #3}
 \fancyfoot[LE]{\thepage \ \  {\bf \@conf}}
 \fancyfoot[RO]{{\sf \@conf} -- \thepage}
%\ifthenelse{\equal{#1}{NO}}{ \fancyfoot[C]{{\it #2} -- \thepage}}{ \fancyfoot[C]{{\it #1} -- \thepage }}
 \fancyhead{}
 \includepdf[offset=#5,pagecommand={\thispagestyle{fancy}\label{fim\theartigo}},pages=2-]{#4}
}

