summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/hilowres/hilowres.dtx
blob: d86bb7169cf8255cf7a7337f2ba2139bfa2ed1e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
% \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