% \iffalse
%
%  hilowres.dtx    Version 1.0, 1999/01/07
%  (c) 1999 by Johann Gerell <jogerell@acc.umu.se>
%
%  Please see the information in file `hilowres.ins' on how you
%  may use and (re-)distribute this file. Run LaTeX on the file
%  `hilowres.ins' to get a .sty-file and instructions.
%
%  This file may NOT be distributed if not accompanied by `hilowres.ins'.
%
%<*driver>
\documentclass[a4paper]{ltxdoc}
\widowpenalty 10000
\newcommand{\hilo}{\textsf{hilowres}}
\begin{document}
   \DocInput{hilowres.dtx}
\end{document}
%</driver>
% \fi
%
% \title{The \hilo\ package}
% \author{Johann Gerell\\ jogerell@acc.umu.se}
% \date{1999/01/07}
% \maketitle
% \begin{abstract}
%   This \LaTeX2e\ package defines a new command \cs{hilofig}, which
%   simplifies a global inclusion of low resolution versions of pictures
%   that also exist in high resolution. Perhaps this package is overkill,
%   but it's at least short and it was easy to implement. As a side effect
%   I finally had to take a look at the \textsf{doc}/\textsf{docstrip}
%   world\dots
% \end{abstract}
% ^^A\tableofcontents
%
% \section{Introduction}
%
% Let's say that we have a number of pairs of pictures where one in each
% pair is a low resolution version of the second. For various reasons it
% might be desired to globally include all the low resolution versions
% instead of the high resolution ones. And all of a sudden, when we've
% specified the filenames of about 50 low-res pictures, we feel like
% switching to the high-res pictures. This task can be unnecessarily
% tedious with e.g.``search-and-replace''.
%
% With this package this operation becomes easy as nothing, provided that
% the filenames of the pairs of pictures all follow the scheme
% |basehighext.eps| and |baselowext.eps|, where |highext| in |basehighext|
% defaults to nothing (a zero length string) and |lowext| in |baselowext|
% defaults to |_low|. Using the defaults, one pair of pictures can be e.g.
% |bird.eps| and |bird_low.eps|.
%
% \section{Usage}
%
% First we load the package with
% \cs{usepackage}\oarg{resolution}\marg{filename}, where the optional
% argument \textit{resolution} is |low| if we want to use the low
% resolution pictures\footnote{The pairs of files can of course contain
% completely different pictures\dots}. To use the high resolution version,
% no optional argument should be specified.
%
% \subsection{Load the package}
%
% So, let's use the low resolution pictures:
%\begin{verbatim}
%   \usepackage[low]{hilowres}
%\end{verbatim}
% The \hilo\ package simply wraps the \cs{includegraphics}
% command of the \textsf{graphicx} package, which is loaded by the \hilo\
% package if necessary.
%
% \subsection{Include a picture}
%
% \DescribeMacro{\hilofig}
% The main command of this package is
% \cs{hilofig}\oarg{key val list}\marg{file}, where \textit{key val list}
% is the same as for \cs{includegraphics} (e.g. |width=...|, |height=...|,
% |scale=...|, etc), and \textit{file} is the basename of the pairs of
% files. If we write:
%\begin{verbatim}
%  \hilofig[width=.8\textwidth]{bird}
%\end{verbatim}
% and have specified |low| as the optional argument to the package, then
% the file that will be included at a width equal to 80\% of the
% value of \cs{textwidth} is |bird_low.eps|.
%
% When and if we later wish to switch to the hi-res pictures, we simply
% remove the |[low]| from |\usepackage[low]{hilowres}| in the preamble.
% The file that will be included in our example is then |bird.eps|.
%
% \subsection{Configuration}
%
% \DescribeMacro{\highext} \DescribeMacro{\lowext}
% If our files have different |highext|- and |lowext|-extensions than the
% default ones, i.e. an empty string and |_low| respectively, then we can
% change the default strings in the preamble with the commands
% \cs{highext}\marg{extension} and \cs{lowext}\marg{extension}. If we for
% instance have filenames such as |birdcolor.eps| and |birdgrey.eps|, in
% the preamble we can then change the defaults with:
%\begin{verbatim}
%  \highext{color}
%  \lowext{grey}
%\end{verbatim}
%
% If \LaTeX\ can't find a file in the current directory, then we probably
% need to put |\DeclareGraphicsExtensions{eps}|\footnote{From the
% \textsf{graphicx} package} in the preamble. Naturally, not only
% \textit{eps} is permitted, but other file formats that we normally use
% with \cs{includegraphics} are also ok here. If the pictures live in
% different directories, then in the preamble we must put
% \cs{graphicspath}\marg{dir-list}\footnotemark[\value{footnote}].
%
% \section{Sources}
%
% The source code doesn't contain any fancy stuff at all. It's very short
% and quite trivial\dots
%
% Begin with package identification and loading of the \textsf{graphicx}
% package.
%
% \iffalse
%<*package>
% \fi
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{hilowres}
    [1999/01/07 v1.0 Include optional low resolution images]
\RequirePackage{graphicx}
%    \end{macrocode}
% Define a ``high resolution flag'', which defaults to \textit{true} but
% is set to \textit{false} if the package option |low| is specified.
%
%    \begin{macrocode}
\newif\if@high\@hightrue
\DeclareOption{low}{\@highfalse}
\ProcessOptions
%    \end{macrocode}
% Output a message during compile for user information.
%
%    \begin{macrocode}
\if@high\typeout{^^J NOTE: Resolution is HIGH ^^J}
\else\typeout{^^J NOTE: Resolution is LOW ^^J}
\fi
%    \end{macrocode}
% The package source file uses internal commands for the |highext|-
% and |lowext|-extensions, and they defaults to a zero length string and
% to |_low| respectively.
%
%    \begin{macrocode}
\newcommand{\@highext}{}
\newcommand{\@lowext}{_low}
%    \end{macrocode}
%
% \begin{macro}{\hilofig}
% The primary user command is \cs{hilofig}\oarg{key val list}\marg{file}.
%
%    \begin{macrocode}
\newcommand{\hilofig}[2][]{%
\includegraphics[#1]{#2\if@high\@highext\else\@lowext\fi}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\highext}
% \begin{macro}{\lowext}
% The user can change the default |highext|- and |lowext|-extensions with
% the commands \cs{highext}\marg{extension} and
% \cs{lowext}\marg{extension} respectively.
%
%    \begin{macrocode}
\newcommand{\highext}[1]{\renewcommand{\@highext}{#1}}
\newcommand{\lowext} [1]{\renewcommand{\@lowext} {#1}}
%    \end{macrocode}
%
% \end{macro}
% \end{macro}
% And thats's all, folks\dots
%
%    \begin{macrocode}
\endinput
%    \end{macrocode}
% \iffalse
%</package>
% \fi
%
% \section{License}
%
% You may use the \hilo\ package freely, but at your own risk.  The
% author of |hilowres.dtx| and |hilowres.ins| (the complete \hilo\ package
% distribution) can not be held responsible for any consequence of your
% using any of these files, or files created from these, including
% hardware, software, and data damage.  You may not make any changes to
% the files |hilowres.dtx| or |hilowres.ins|. You may incorporate the code
% from these files in other files under different names, provided the
% original author is given full credit for his work and that you yourself
% take the complaints from the user(s) of your file(s).  You may freely
% distribute the files |hilowres.dtx| and |hilowres.ins|, provided: 1. You
% do not take money for the distribution or use of these files except for
% a nominal charge for diskettes and postage; and 2. You always distribute
% |hilowres.dtx| and |hilowres.ins| together at the same time.
%
% \Finale