%% gretl.sty, written by Allin Cottrell, <2005/11/07>
%% To be used when generating the Gretl manuals
%% from LaTeX source.

\ProvidesPackage{gretl}

\newcommand{\scriptname}{Example}
\newcommand{\GCR}{\textit{Gretl Command Reference}{}}
\newcommand{\GUG}{the \textit{Gretl User's Guide}{}}

\newcommand{\gtitle}[1]{\vspace*{1in}
   {\Huge \sffamily #1}\par
   \vspace{.5in}
  \includegraphics{figures/gretl-logo} 
}

\newcommand{\gsubtitle}[1]{%
   {\Large \sffamily #1}
   \vspace{.5in}
}

\setcounter{secnumdepth}{1}
\setcounter{chapter}{-1}

\newcommand{\app}[1]{\textsf{#1}}
\newcommand{\cmd}[1]{\texttt{#1}}
\newcommand{\varname}[1]{\texttt{#1}}

\newcommand{\ttsl}[1]{\ttfamily{\textsl{#1}}\normalfont}

\newenvironment{code}{\par\small\verbatim}
{\endverbatim\normalsize\vspace{-1ex}}

\newenvironment{textcode}{\par\small\ttfamily}
{\normalfont\normalsize\par}

\renewcommand{\arraystretch}{1.2}

%% Unlike standard book class, running heads not in caps  
%% \renewcommand{\chaptermark}[1]{\markboth{\chaptername\
%%                                         \thechapter. #1}{}}
%% \renewcommand{\sectionmark}[1]{\markright{#1}}

%% add script as float (Example)
\newcounter{script}[chapter]
\renewcommand \thescript
     {\ifnum \c@chapter>\z@ \thechapter.\fi \@arabic\c@script}
\def\fps@script{tbp}
\def\ftype@script{1}
\def\ext@script{los}
\def\fnum@script{\scriptname\nobreakspace\thescript}
\newenvironment{script}
               {\@float{script}}
               {\end@float}
\newenvironment{script*}
               {\@dblfloat{script}}
               {\end@dblfloat}
\newcommand\theHscript{\thechapter.\arabic{script}}
%% \def\toclevel@script{0}

%% Make TOC match revised chapter style
\renewcommand\tableofcontents{%
    \if@twocolumn
      \@restonecoltrue\onecolumn
    \else
      \@restonecolfalse
    \fi
    \chapter*{\contentsname
        \@mkboth{\contentsname}{\contentsname}}%
    \@starttoc{toc}%
    \if@restonecol\twocolumn\fi}

%% offset "tip" text
\newcommand{\tip}[1]{\par\vspace{4pt}
 \ding{43} {\small \sffamily #1}\par}

%% define a very simple bibliography environment
\renewenvironment{thebibliography}
     {\chapter*{\bibname\@mkboth{\bibname}{\bibname}}
      \label{refs}
      \addcontentsline{toc}{chapter}{\bibname}
      \list{}{\itemindent -2em\listparindent\itemindent\leftmargin 2em
      \sloppy
      \clubpenalty4000
      \@clubpenalty \clubpenalty
      \widowpenalty4000%
      \sfcode`\.\@m\item\relax}}
      {\endlist}

%% custom page headings 
\if@twoside
  \def\ps@headings{%
      \let\@oddfoot\@empty\let\@evenfoot\@empty
      \def\@evenhead{\thepage\hfil\sffamily\leftmark}%
      \def\@oddhead{{\sffamily\rightmark}\hfil\sffamily\thepage}%
      \let\@mkboth\markboth
    \def\chaptermark##1{%
      \markboth {{%
        \ifnum \c@secnumdepth >\m@ne
          \if@mainmatter
            \@chapapp\ \thechapter. \ %
          \fi
        \fi
        ##1}}{}}%
    \def\sectionmark##1{%
      \markright {{%
        \ifnum \c@secnumdepth >\z@
          \thesection. \ %
        \fi
        ##1}}}}
\else
  \def\ps@headings{%
    \let\@oddfoot\@empty
    \def\@oddhead{{\sffamily\rightmark}\hfil\sffamily\thepage}%
    \let\@mkboth\markboth
    \def\chaptermark##1{%
      \markright {{%
        \ifnum \c@secnumdepth >\m@ne
          \if@mainmatter
            \@chapapp\ \thechapter. \ %
          \fi
        \fi
        ##1}}}}
\fi


\def\@makechapterhead#1{%
  \vspace*{10\p@}%
  {\parindent \z@ \centering \normalfont
    \ifnum \c@secnumdepth >\m@ne
        \Large\sffamily \@chapapp\space \thechapter
        \par\nobreak
        \vskip 5\p@
    \fi
    \interlinepenalty\@M
    \huge \sffamily #1\par\nobreak
    \vskip 30\p@
  }}

\def\@schapter#1{%
 \if@twocolumn \@topnewpage[\@makeschapterhead{#1}]
 \else \@makeschapterhead{#1} 
 \@afterheading\fi
  \refstepcounter{chapter}
  \if\pdfoutput=1 \@writetorep{#1}{chapter.\theHchapter}{0}\fi 
 }

\def\@makeschapterhead#1{%
  \vspace*{10\p@}%
  {\parindent \z@ \centering
    \normalfont
    \interlinepenalty\@M
    \Large \sffamily  #1\par\nobreak
    \vskip 30\p@
  }}

%% revised caption style
\long\def\@makecaption#1#2{%
  \vskip\abovecaptionskip
  \sbox\@tempboxa{\small {\bfseries #1}: #2}%
  \ifdim \wd\@tempboxa >\hsize
    {\small {\bfseries #1}: #2}\par
  \else
    \global \@minipagefalse
    \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
  \fi
  \vskip\belowcaptionskip}

%% table of contents
\renewcommand{\l@chapter}[2]{%
  \ifnum \c@tocdepth >\m@ne
    \addpenalty{-\@highpenalty}%
    \vskip 1.0em \@plus\p@
    \setlength\@tempdima{2em}%
    \begingroup
      \parindent \z@ \rightskip \@pnumwidth
      \parfillskip -\@pnumwidth
      \leavevmode \bfseries
      \advance\leftskip\@tempdima
      \hskip -\leftskip
      #1\nobreak\hfil \nobreak\hb@xt@\@pnumwidth{\hss #2}\par
      \penalty\@highpenalty
    \endgroup
  \fi}

\renewcommand{\l@section}{\@dottedtocline{1}{1.5em}{2.8em}}
\renewcommand{\l@subsection}{\@dottedtocline{2}{4.3em}{3.2em}}

%% Make section numbers go into left margin:
%% \def\@seccntformat#1{\protect\makebox[0pt][r]{\csname
%%                      the#1\endcsname\quad}}

\renewcommand\section{\@startsection{section}{1}{\z@}%
                                   {-3ex \@plus -1ex \@minus -.2ex}%
                                   {.5ex \@plus.2ex}%
                                   {\normalfont\large\sffamily}}

\renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
                                     {-2.5ex\@plus -1ex \@minus -.2ex}%
                                     {.2ex \@plus .5ex}%
                                     {\normalfont\bfseries}}

\renewcommand\subsubsection{\@startsection{subsubsection}{2}{\z@}%
                                     {-3.0ex\@plus -1ex \@minus -.2ex}%
                                     {1.1ex \@plus .2ex}%
                                     {\normalfont\normalsize\itshape}}

                           
\endinput
%% end of gretl.sty
