-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshadowtext.tex
335 lines (278 loc) · 9.03 KB
/
shadowtext.tex
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
%% This is file `shadowtext.tex',
%% Copyright 2012 Yori Zwols
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% 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.3 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 Y. Zwols.
%
%
\documentclass{article}
\usepackage{xcolor}
\usepackage{fullpage}
\usepackage{shadowtext}
\usepackage{multicol}
\shadowbboxmode{text}
\begin{document}
\title{\bf The
\shadowcolor{black!30!white}\shadowoffset{1.5pt}\shadowtext{shadowtext}
package \\ \bigskip \normalfont\small Version 0.4}
\author{Y. Zwols ([email protected])}
\maketitle
\shadowoffset{1pt}
\parindent=0pt
\parskip=8pt
\section{Usage}
The shadowtext package introduces a new command, namely the {\tt $\backslash$shadowtext} command. This is a box
that adds a shadow behind text. Its usage is simple. The following code and its output illustrates the usage.
\begin{minipage}{\textwidth}
\begin{multicols*}{2}
{\footnotesize
\begin{verbatim}
\shadowtext{This is a text with a shadow}
\end{verbatim}}
\shadowtext{This is a text with a shadow}
\end{multicols*}
\end{minipage}
\section{Changing the position of the shadow}
The position of the shadow consists of two components: a horizontal offset and a vertical offset.
The package offers two ways of changing the position of the shadow. The first and easiest way of
changing the position is by using the {\tt $\backslash$setshadowoffset} command. This commands
sets the horizontal and vertical offset simultaneously. For example:
\begin{minipage}{\textwidth}
\begin{multicols*}{2}
{\footnotesize
\begin{verbatim}
\shadowoffset{2pt}
\shadowtext{This is a text with a shadow}
\end{verbatim}}
\shadowoffset{2pt}
\shadowtext{This is a text with a shadow}
\end{multicols*}
\end{minipage}
Alternatively, one may use the commands {\tt shadowoffsetx} and {\tt shadowoffsety} to independently change
the horizontal and vertical offset. For example:
\begin{minipage}{\textwidth}
\begin{multicols*}{2}
{\footnotesize
\begin{verbatim}
\shadowoffsetx{1pt}
\shadowoffsety{2pt}
\shadowtext{This is a text with a shadow}
\end{verbatim}}
\shadowoffsetx{1pt}
\shadowoffsety{2pt}
\shadowtext{This is a text with a shadow}\\
\phantom{}
\end{multicols*}
\end{minipage}
Also, by setting the offset to a negative number, it is possible to
make shadows in other directions, as the following example shows:
\begin{minipage}{\textwidth}
\begin{multicols*}{2}
{\footnotesize
\begin{verbatim}
\shadowoffsetx{-2pt}
\shadowoffsety{2pt}
\shadowtext{This is a text with a shadow}
\end{verbatim}}
\shadowoffsetx{-2pt}
\shadowoffsety{2pt}
\shadowtext{This is a text with a shadow}\\
\phantom{}
\end{multicols*}
\end{minipage}
\section{Changing the color of the shadow}
The color of the shadow may be changed by using the {\tt shadowcolor} and {\tt shadowrgb} commands.\footnote{Internally, the
package uses the {\tt $\backslash$color} command from the color package to set its color}
The {\tt shadowcolor} command takes as an argument the name of a color, whereas {\tt shadowrgb} takes a comma-separated list of red, green, blue
values. For example, the following code adds a blueish shadow using {\tt $\backslash$shadowcolor}:
\begin{minipage}{\textwidth}
\begin{multicols*}{2}
{\footnotesize
\begin{verbatim}
\shadowoffset{1pt}
\shadowcolor{blue!40!white}
\shadowtext{This is a text with a shadow}
\end{verbatim}}
\shadowoffset{1pt}
\shadowcolor{blue!40!white}
\shadowtext{This is a text with a shadow}\\
\phantom{}
\end{multicols*}
\end{minipage}
The following code produces a red shadow using {\tt $\backslash$shadowrgb}:
\begin{minipage}{\textwidth}
\begin{multicols*}{2}
{\footnotesize
\begin{verbatim}
\shadowoffset{1pt}
\shadowrgb{1.0, 0.5, 0.5}
\shadowtext{This is a text with a shadow}
\end{verbatim}}
\shadowoffset{1pt}
\shadowrgb{1.0, 0.5, 0.5}
\shadowtext{This is a text with a shadow}\\
\phantom{}
\end{multicols*}
\end{minipage}
\section{Changing the bounding box}
There are two natural choices for the bounding box around the shadow text. The
first choice is the bounding box around the main text; the second
is the bounding box around the main text plus its shadow. These two choices are
referred to as the \textit{text} mode and the \textit{full} mode, respectively.
They can be activated by the commands {\tt $\backslash$shadowbboxmode\{text\}}
and {\tt $\backslash$shadowbboxmode\{full\}} commands, respectively.
For backwards compatibility reasons, the default bounding box mode is ``full''.
\fboxsep=0pt
\newcommand{\myfbox}[1]{{\color{blue!50!white}{\fbox{\normalcolor#1}}}}
\subsection{``Full'' bounding box mode}
This mode is activated by {\tt $\backslash$shadowbboxmode\{full\}}. The following output demonstrates (and tests) its effect. The boxes are shown in blue in the second column.
\shadowbboxmode{full}
\renewcommand\arraystretch{2}
\begin{tabular}{@{}l@{\qquad}l@{\qquad}l}
\textbf{Shadow position} & \textbf{Inside framebox} & \textbf{Without framebox} \\
Above left
& \shadowoffset{-6pt} This is a \myfbox{\shadowtext{great}} package!
& \shadowoffset{-6pt} This is a \shadowtext{great} package! \\
Below left
& \shadowoffsetx{-6pt}\shadowoffsety{6pt} This is a \myfbox{\shadowtext{great}} package!
& \shadowoffsetx{-6pt}\shadowoffsety{6pt} This is a \shadowtext{great} package! \\
Above right
& \shadowoffsetx{6pt}\shadowoffsety{-6pt} This is a \myfbox{\shadowtext{great}} package!
& \shadowoffsetx{6pt}\shadowoffsety{-6pt} This is a \shadowtext{great} package! \\
Below right
& \shadowoffset{6pt} This is a \myfbox{\shadowtext{great}} package!
& \shadowoffset{6pt} This is a \shadowtext{great} package! \\
\end{tabular}
\subsection{``Text'' bounding box mode}
This mode is activated by {\tt $\backslash$shadowbboxmode\{text\}}. The following output demonstrates (and tests) its effect. The boxes are shown in blue in the second column.
\shadowbboxmode{text}
\renewcommand\arraystretch{2}
\begin{tabular}{@{}l@{\qquad}l@{\qquad}l}
\textbf{Shadow position} & \textbf{Inside framebox} & \textbf{Without framebox} \\
Above left
& \shadowoffset{-6pt} This is a \myfbox{\shadowtext{great}} package!
& \shadowoffset{-6pt} This is a \shadowtext{great} package! \\
Below left
& \shadowoffsetx{-6pt}\shadowoffsety{6pt} This is a \myfbox{\shadowtext{great}} package!
& \shadowoffsetx{-6pt}\shadowoffsety{6pt} This is a \shadowtext{great} package! \\
Above right
& \shadowoffsetx{6pt}\shadowoffsety{-6pt} This is a \myfbox{\shadowtext{great}} package!
& \shadowoffsetx{6pt}\shadowoffsety{-6pt} This is a \shadowtext{great} package! \\
Below right
& \shadowoffset{6pt} This is a \myfbox{\shadowtext{great}} package!
& \shadowoffset{6pt} This is a \shadowtext{great} package! \\
\end{tabular}
\section{More examples}
The following code illustrates how to use shadowtext in more interesting settings:
\definecolor{navy}{rgb}{0,0,0.5}
\begin{minipage}{\textwidth}
\begin{multicols*}{2}
{\footnotesize
\begin{verbatim}
\definecolor{navy}{rgb}{0,0,0.5}
\shadowrgb{0.8, 0.8, 1}
\shadowoffset{1pt}
\shadowtext{
\color{navy}
\fontsize{16}{16}\selectfont
Large!}
\end{verbatim}}
\color{navy}
\shadowrgb{0.8, 0.8, 1}
\shadowoffset{2pt}
\shadowtext{\fontsize{16}{16}\selectfont \textbf{Large!}}\\
\phantom{}\\
\phantom{}\\
\phantom{}
\end{multicols*}
\end{minipage}
\color{black}
\begin{minipage}{\textwidth}
\begin{multicols*}{2}
{\footnotesize
\begin{verbatim}
\shadowoffset{1pt}
\color{black}
\shadowtext{%
\begin{tabular}{|l|l|}
\hline
1 & 2 \\
3 & 4 \\
\hline
\end{tabular}
}
\end{verbatim}}
\shadowoffset{1pt}
\shadowtext{
\begin{tabular}{|l|l|}
\hline
1 & 2 \\
3 & 4 \\
\hline
\end{tabular}
}
\phantom{}\\
\phantom{}\\
\phantom{}\\
\phantom{}\\
\phantom{}\\
\phantom{}
\end{multicols*}
\end{minipage}
\begin{minipage}{\textwidth}
\begin{multicols*}{2}
{\footnotesize
\begin{verbatim}
\shadowoffset{1pt}
\shadowtext{$\sqrt{2\pi}e^{-n}$}
\end{verbatim}}
\shadowoffset{1pt}
\shadowtext{$\sqrt{2\pi}e^{-n}$}\\
\phantom{}
\end{multicols*}
\end{minipage}
\color{black}
\begin{minipage}{\textwidth}
\begin{multicols*}{2}
{\footnotesize
\begin{verbatim}
\shadowoffset{2pt}
\shadowtext{
\color{navy}%
\fontencoding{T1}%
\fontfamily{pag}%
\fontseries{b}%
\fontsize{32}{32}%
\selectfont%
Section \color{red}\arabic{section}%
}
\end{verbatim}}
\shadowoffset{2pt}
\shadowtext{
\color{navy}%
\fontencoding{T1}%
\fontfamily{pag}%
\fontseries{b}%
\fontsize{32}{32}%
\selectfont%
Section \color{red}\arabic{section}
}
\phantom{}\\
\phantom{}\\
\phantom{}\\
\phantom{}\\
\phantom{}\\
\end{multicols*}
\end{minipage}
\section{Limitations}
\shadowcolor{black!20!white}\shadowtext{Currently, the {\tt $\backslash$shadowtext} command does not support line breaks. In that respect, it behave like e.g. {\tt $\backslash$mbox} and {\tt $\backslash$fbox}.} (The previous sentence purposely runs into the margin to illustrate this limitation.)
\end{document}