-
Notifications
You must be signed in to change notification settings - Fork 0
/
smiley.dtx
271 lines (239 loc) · 7.08 KB
/
smiley.dtx
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
% \iffalse
%% File: smiley.dtx by Dennis Heidsiek, mail: HeidsiekB at aol dot com
%%
%% You can get the latest version at http://github.com/zephyr/latex-smiley
%%
%<*driver>
\def\nameofplainTeX{plain}
\ifx\fmtname\nameofplainTeX\else
\expandafter\begingroup
\fi
\input docstrip.tex
\askforoverwritefalse
\preamble
THIS IS A AUTOMATICALLY GENERATED FILE CONTAINING EXPERIMENTAL CODE.
Do not distribute this file without also distributing the source files specified above.
Do not distribute a modified version of this file under the same name.
\endpreamble
\postamble
\endpostamble
\keepsilent
\generate{\file{smiley.sty}{\from{smiley.dtx}{package}}}
\generate{\file{smiley-demo.tex}{\from{smiley.dtx}{sample}}}
\ifx\fmtname\nameofplainTeX
\expandafter\endbatchfile
\else
\expandafter\endgroup
\fi
\documentclass{gmdocc}
\def\marginpartt{\scriptsize\ttfamily} % needed fix for XeTeX because of problems with the lmodern font.
\GetFileInfo{smiley.sty}
\usepackage{
xltxtra,
polyglossia,
smiley,
hyperref
}
\hypersetup{
pdfborder= 0 0 0,
colorlinks=true,
linkcolor=blue
}
\setmainlanguage{english}
%\setmainfont{Comic Jens} % This is a sportive package, so let’s have some fun ;)
\newcommand{\email}[1]{\href{mailto:#1}{#1}} % Why is this not in hyperref?
\newcommand{\githubuser}[4]{#1 \textsc{#2}\footnote{Follow or fork #1 at GitHub: \url{http://github.com/#3}}\\\email{#4}}
\title{The |smiley| package\footnote{\filenote}~\smiley{wink}}
\author{%
\githubuser{Dennis}{Heidsiek}{zephir}{[email protected]}\and
\githubuser{Arno}{Trautmann}{alt}{[email protected]}}
\begin{document}
\maketitle
\begin{abstract}
This is the documentation of the \LaTeXe\ package |smiley|. It provides a single command to typeset emoticons\footnote{\url{http://en.wikipedia.org/wiki/Emoticon}}: |\smiley{:-)}| how |\smiley{happy}| will output \smiley{:)}. The style can be changed at any times using a |key=value| interface, that means after |\smileysetup{usebold, usecolor, color=violet, angle=-45}|, the command |\smiley{irony}| yields \smileysetup{usebold, usecolor, color=violet, angle=-45}\smiley{irony}. If you find any incompatiblities with any package, please send me a e-mail and maybe I can take care of it.
\end{abstract}
\tableofcontents
\section{Commands for the user}
…
\section{Implementation}
\DocInput{smiley.dtx}
\end{document}
%</driver>
%
%<*package>
% \fi
% Let us dive into the implementation:
% \begin{macrocode}
%\subsection{Requirements}
\NeedsTeXFormat{LaTeX2e}
% For parsing |key=value| input:
\RequirePackage{pgfkeys}
\RequirePackage{pgfopts}
% For colors:
\RequirePackage{xcolor}
% For rotations:
\RequirePackage{graphicx}
%\subsection{Version}
\ProvidesPackage{smiley}
[2010/03/16 v0.1 provides smileys, initial experimental version.]
%\subsection{Data structures}
% Define boolean macros for the state:
\newif\ifsmiley@useitalic
\newif\ifsmiley@usebold
\newif\ifsmiley@useangle
\newif\ifsmiley@usecolour
% Explain how the |key=value| input should be processed and stored into the tree:
\pgfkeys{
/smiley/.cd,
useitalic/.is if = smiley@useitalic,
usebold/.is if = smiley@usebold,
useangle/.is if = smiley@useangle,
usecolor/.is if = smiley@usecolour,
usecolour/.is if = smiley@usecolour,
angle/.store in = \smiley@angle,
colour/.store in = \smiley@colour,
color/.style = {colour=#1},
inactive/.code = {%
\let\smiley\emph
\PackageInfo{smiley}
{Package inactive}%
}
}
\AtBeginDocument{
\pgfkeys{
/smiley/inactive/.code = {%
\PackageInfo{smiley}{%
The Option ‘inactive’ is only available in preamble!
}%
}
}
}
%\subsection{Package defaults}
\pgfkeys{
/smiley/.cd,
useitalic = false,
usebold = false,
useangle = true,
usecolour = false,
color = red,
angle = -85
}
%\subsection{User interface for changing values}
% Parsing |key=value| input:
\newcommand*{\smileysetup}{%
\pgfqkeys{/smiley}%
}
% Even if given as package option:
\ProcessPgfOptions{/smiley}
% Provides the ability to declare shortcuts for new smileys:
\newcommand*\definesmiley[2]{%
\expandafter\def\csname smiley@name@#1\endcsname{#2}
}
%\subsection{Commands to format something}
\newcommand*{\smiley@emph@apply}{%
\ifsmiley@useitalic
\expandafter\emph
\else
\expandafter\@firstofone
\fi
}
\newcommand*{\smiley@bold@apply}{%
\ifsmiley@usebold
\expandafter\textbf
\else
\expandafter\@firstofone
\fi
}
\newcommand*{\smiley@angle@apply}[1]{%
\ifsmiley@useangle
\rotatebox[origin=c]{\smiley@angle}{#1}
\else
#1
\fi
}
\newcommand*{\smiley@colour@apply}{%
\ifsmiley@usecolour
\expandafter\textcolor
\else
\expandafter\@secondoftwo
\fi
{\smiley@colour}%
}
% Applies all formatting to a given text:
\newcommand*{\smiley@apply}[1]{%
\smiley@angle@apply{\smiley@emph@apply{\smiley@bold@apply{\smiley@colour@apply{%
#1%
}}}}%
}
%\subsection{The main command}
%Decides which text should be formatted:
\newcommand*{\smiley}[1]{%
\expandafter\smiley@apply
\ifcsname smiley@name@#1\endcsname
{\csname smiley@name@#1\endcsname}
\else
{#1}
\fi
}
%\subsection{List of predefined smileys}
% In alphabetical order (some special charactes like |\}| have to be masked):
\definesmiley{alternative}{:)}
\definesmiley{angel}{O:)}
\definesmiley{angry}{>:(}
\definesmiley{cap}{d:-)}
\definesmiley{cheeky}{:-P}
\definesmiley{crying}{:'(}
\definesmiley{cylon}{!-|}
\definesmiley{evil}{\}:->}
\definesmiley{frown}{:<}
\definesmiley{grin}{=D}
\definesmiley{happy}{:-)}
\definesmiley{irony}{;-)}
\definesmiley{kiss}{:-*}
\definesmiley{klingon}{>:-l}
\definesmiley{laugh}{:-D}
\definesmiley{love}{<333}
\definesmiley{mad}{>:O}
\definesmiley{money}{:$}
\definesmiley{mustache}{:3}
\definesmiley{normal}{:-)}
\definesmiley{rose}{@\}-;-'---}
\definesmiley{sad}{:-(}
\definesmiley{santa}{*<:-)}
\definesmiley{sealed}{:-X}
\definesmiley{shock}{:O}
\definesmiley{skeptical}{:/}
\definesmiley{straight}{:|}
\definesmiley{smile}{:-)}
\definesmiley{wink}{;-)}
% \end{macrocode}
% \iffalse
%</package>
% \fi
% \iffalse
%<*sample>
\documentclass{article}
\usepackage{xltxtra}
\setmainfont{Comic Jens}
\usepackage{pgffor}
\usepackage{smiley} % [usecolor, color=green, inactive]
\begin{document}
\title{A short sample document for the \texttt{smiley} package}
\author{Dennis Heidsiek}
\maketitle
Some common emoticons: \smiley{happy} and \smiley{:(} and \smiley{>:-|>} and \smiley{rose} and \smiley{santa} and \smiley{yet unknown!} end of line \smiley{wink}.
Kerning problem: Geh\smiley{:o)}ft Geh\fbox{\smiley{:o)}}ft \smiley{sad} Geh\smiley{:o)}\kern-0.75emft!
\smileysetup{usebold=true, useitalic, usecolor, angle=-45}
\smiley{evil} Qua'pla! \smiley{klingon} bath'let
\smileysetup{color=blue, angle=-80}
\smiley{cylon} Bye your command! \smiley{cylon} \smiley{wink}
Unicode glyphs gives us much more fun: ſ-ſmiley \smiley{:-ſ} and em-dash-smiley: \smiley{:—)} vs.\ \smiley{:-)}
Custom shortcuts: \newcommand{\sniffy}{\smiley{irony}} \sniffy
Redefining of Smileys: \smiley{irony} \definesmiley{irony}{;)} \smiley{irony}
Sniffy²: \sniffy
\foreach \angle in {0, 2.5, 5, ..., 360} {\smileysetup{angle=\angle}\smiley{happy}}
\end{document}
%</sample>
% \fi
% \Finale
% \endinput