summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/gradientframe/gradientframe.dtx
blob: f11c27511730f6ddf0154b8162dceedc58592871 (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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
% \iffalse The license starting three lines down applies to this file.
%<*batchfile>
{\obeylines\obeyspaces \gdef\thepreamble{

LaTeX package gradientframe for simple gradient frames around objects.

Copyright (C) Christian Raue, 2011
Send feedback to christian°raue@gmail°com (after being exposed to gravity).

This file may be distributed and/or modified under the
conditions of the LaTeX Project Public License, either
version 1.3c of this license or (at your option) any later
version.  The latest version of this license is in:

	http://www.latex-project.org/lppl.txt

and version 1.3c or later is part of all distributions of
LaTeX version 2005/12/01 or later.

This work has the LPPL maintenance status 'maintained'.

The Current Maintainer of this work is Christian Raue.

This work consists of gradientframe.dtx and the derived file
gradientframe.sty.

}}

\begingroup
\input{docstrip}
\keepsilent
\usedir{tex/latex/\jobname}
\expandafter\preamble\thepreamble\endpreamble
\askforoverwritefalse
\generate{\file{\jobname.sty}{\from{\jobname.dtx}{package}}}
\endgroup

\documentclass{ltxdoc}
\usepackage[american]{babel}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{charter}
\usepackage[margin=1.5in]{geometry}
\usepackage{color}
\usepackage{graphicx}
\usepackage[%
	pdftitle={the \jobname{} package},%
	pdfauthor={Christian Raue},%
	pdfsubject={LaTeX package documentation},%
	pdfkeywords={\jobname{} LaTeX gradient frame border around object table figure},%
 	pdfproducer={LaTeX},%
 	pdfcreator={LaTeX},%
	pdfborder={0 0 0},%
	pdfpagemode={UseOutlines},%
	pdfstartview={FitH},%
	pdfview={FitH},%
	pdfdisplaydoctitle=true,%
	]{hyperref}
\usepackage{tabularx}
\usepackage{listings}
\definecolor{lightgray}{gray}{.95}
\lstset{
	frame=trbl,%
	framerule=0pt,%
	basicstyle=\footnotesize\ttfamily,%
	breaklines=true,%
	tabsize=4,%
	numbers=left,%
	numberstyle=\tiny,%
	backgroundcolor=\color{lightgray},%
}
\usepackage{emp}
\ifx\pdftexversion\undefined
	\usepackage[dvips]{graphicx}
\else
	\usepackage{graphicx}
	\DeclareGraphicsRule{*}{mps}{*}{}
\fi
\usepackage{\jobname}

\DoNotIndex{\def}

%\CodelineIndex
%\EnableCrossrefs
\RecordChanges
\OnlyDescription
\setcounter{IndexColumns}{2}
\GetFileInfo{\jobname.sty}

\newcommand{\supdot}{%
	\scalebox{1.2}{$\dot{~}$}%
}
\newcommand{\package}[1]{%
	\texttt{#1}%
}
\newcommand{\resultarrow}{%
	\begin{center}
		\scalebox{2}{%
			\begin{picture}(9,10)
				\put(5,10){\vector(0,-4){10}}
			\end{picture}%
		}
	\end{center}%
}
\newcommand{\face}{%
	\fboxsep=5px
	\scalebox{2}{\fbox{%
		\Huge
		$\ddot\smile$%
	}}%
}

\title{the \package{\jobname} package\thanks{This document corresponds to \package{\jobname}~\fileversion, dated \filedate.}\\[1em]}
\author{Christian Raue\\[1em]\texttt{christian\supdot{}raue@gmail\supdot{}com}\\(after being exposed to gravity)\\[2em]}
\date{\filedate}

\begin{document}
\maketitle


\phantomsection
\addcontentsline{toc}{section}{\abstractname}
\begin{abstract}
\noindent
The \package{\jobname} package provides a command, |\gradientframe|, for simple discreet grayscale gradient frames
around objects, such as images or tables, to set them apart from the surrounding text.
\end{abstract}


\phantomsection
\addcontentsline{toc}{section}{\contentsname}
\tableofcontents
\clearpage


\section{Introduction}
The \package{gradientframe} package is loaded in the usual way, i.e. by putting the line
\begin{quote}
	|\usepackage{gradientframe}|
\end{quote}
in the document's preamble. The \package{gradientframe} package depends on the \package{color} package which is loaded
by the \package{gradientframe} package if not already done so far in the document's preamble.


\section{Usage}
\DescribeMacro\gradientframe
To frame an object, such as figure, table, etc., use |\gradientframe{|\meta{object}|}|.
By using |\gradientframe[|\meta{width}|]{|\meta{object}|}|, a space between the frame and the object (in all four
directions) can be added.


\section{Examples}
\subsection{Frame surrounding a figure}
\begin{lstlisting}
	\begin{center}
		\gradientframe{\includegraphics{image.jpg}}
	\end{center}
\end{lstlisting}
\resultarrow
\begin{center}
	\gradientframe{\face}
\end{center}


\subsection{Frame surrounding a figure with additional space}
\begin{lstlisting}
	\begin{center}
		\gradientframe[5mm]{\includegraphics{image.jpg}}
	\end{center}
\end{lstlisting}
\resultarrow
\begin{center}
	\gradientframe[5mm]{\face}
\end{center}


\subsection{Frame surrounding a table}
\begin{lstlisting}
	\begin{center}
		\gradientframe{%
			\begin{tabular}{r|l}
				\textbf{column A}	& \textbf{column B}	\\\hline
				cell 1A				& cell 1B			\\\hline
				cell 2A				& cell 2B			\\\hline
				cell 3A				& cell 3B			\\
			\end{tabular}%
		}
	\end{center}
\end{lstlisting}
\resultarrow
\begin{center}
	\gradientframe{%
		\begin{tabular}{r|l}
			\textbf{column A}	& \textbf{column B}	\\\hline
			cell 1A				& cell 1B			\\\hline
			cell 2A				& cell 2B			\\\hline
			cell 3A				& cell 3B			\\
		\end{tabular}%
	}
\end{center}
Be careful not to produce unintentional space when breaking lines. Add comments at line endings if needed to prevent
this, as shown in lines 2 and 8. Otherwise the result will look like this:
\begin{center}
	\gradientframe{
		\begin{tabular}{r|l}
			\textbf{column A}	& \textbf{column B}	\\\hline
			cell 1A				& cell 1B			\\\hline
			cell 2A				& cell 2B			\\\hline
			cell 3A				& cell 3B			\\
		\end{tabular}
	}
\end{center}


\clearpage
\subsection{Frame surrounding a MetaPost figure}
If you want to draw a frame around a MetaPost (or in the case of this example, MetaUML) generated figure, use the
|\empuse| command.
\begin{lstlisting}
	\begin{center}
		\begin{empfile}
			\begin{empcmds}
				input metauml;
			\end{empcmds}
			\begin{empdef}[unique_name](0,0)
				save start, end;
				Begin.start;
				End.end;
				leftToRight(15)(start, end);
				drawObjects(start, end);
				clink(transition)(start, end);
			\end{empdef}
			\gradientframe[5mm]{\empuse{unique_name}}
		\end{empfile}
	\end{center}
\end{lstlisting}
\resultarrow
\begin{center}
	\begin{empfile}
		\begin{empcmds}
			input metauml;
		\end{empcmds}
		\begin{empdef}[unique_name](0,0)
			save start, end;
			Begin.start;
			End.end;
			leftToRight(15)(start, end);
			drawObjects(start, end);
			clink(transition)(start, end);
		\end{empdef}
		\gradientframe[5mm]{\empuse{unique_name}}
	\end{empfile}
\end{center}
Alternatively, you could outsource both, the |empdef| environment and the |\empuse| command to a separate file, and use
|\input{|\meta{filename}|}| as argument to the |\gradientframe| command.


\StopEventually{
	\typeout{****************************************************}
	\typeout{* To finish the installation, you have to move the}
	\typeout{* following file into a directory searched by TeX:}
	\typeout{*}
	\typeout{* \space\space \jobname.sty}
	\typeout{*}
	\typeout{* Documentation is in \jobname.\ifpdf pdf\else dvi\fi.}
	\typeout{*}
	\typeout{* Happy TeXing!}
	\typeout{****************************************************}
	\end{document}
}


\clearpage
\DocInput{\jobname.dtx}


\clearpage
\phantomsection
\addcontentsline{toc}{section}{Change History}
\PrintChanges


%\phantomsection
%\addcontentsline{toc}{section}{Index}
%\PrintIndex


\Finale
%</batchfile>
% \fi
%
% \section{Implementation}
%
% \changes{v0.1}{2011/02/10}{Initial version.}
% \changes{v0.1a}{2011/02/10}{Fixed charset encoding issues on CTAN.}
%
%	\begin{macrocode}
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{gradientframe}[2011/02/10 v0.1a simple gradient frames around objects]
\RequirePackage{color}
%    \end{macrocode}%^^A must be exactly 4 spaces
%
% \begin{macro}{\gradientframe}
% This command defines the grayscale gradient frame around objects, with variable space between object and frame.
%	\begin{macrocode}
\newcommand{\gradientframe}[2][0mm]{%
	% Grayscale colors.
	\definecolor{gray98}{gray}{.98}%
	\definecolor{gray96}{gray}{.96}%
	\definecolor{gray94}{gray}{.94}%
	\definecolor{gray92}{gray}{.92}%
	\definecolor{gray90}{gray}{.90}%
	\definecolor{gray88}{gray}{.88}%
	\definecolor{gray86}{gray}{.86}%
	\definecolor{gray84}{gray}{.84}%
	\definecolor{gray82}{gray}{.82}%
	\definecolor{gray80}{gray}{.80}%
	\definecolor{gray78}{gray}{.78}%
	\definecolor{gray76}{gray}{.76}%
	\definecolor{gray74}{gray}{.74}%
	\definecolor{gray72}{gray}{.72}%
	\definecolor{gray70}{gray}{.70}%
%
	% Each color's line width.
	\newdimen\lineWidth%
	\lineWidth=0.3px%
%
	% Space between object and innermost frame line.
	\newdimen\borderSpacing%
	\borderSpacing=#1%
%
	\fboxrule=\lineWidth%
	\fboxsep=\lineWidth%
	\fcolorbox{gray98}{gray96}{%
		\fcolorbox{gray94}{gray92}{%
			\fcolorbox{gray90}{gray88}{%
				\fcolorbox{gray86}{gray84}{%
					\fcolorbox{gray82}{gray80}{%
						\fcolorbox{gray78}{gray76}{%
							\fcolorbox{gray74}{gray72}{%
								\fboxrule=\lineWidth%
								\fboxsep=\borderSpacing%
								\fcolorbox{gray70}{white}{%
									#2%
								}%
							}%
						}%
					}%
				}%
			}%
		}%
	}%
}%
%    \end{macrocode}%^^A must be exactly 4 spaces
% \end{macro}
%
\endinput
% \endinput