Debian Codegraph @

texmf-dist/source/latex/dirtytalk/dirtytalk.dtx

raw
1 % \iffalse % This section (iffalse to fi) won't appear in the source code
2 % documentation. It is irrelevant for the package and only includes the "driver"
3 % for the documentation. it will be stripped off by docstrip when producing the
4 % .sty file.
5 %<*driver>
6 \documentclass{article}
7 \usepackage[T1]{fontenc} % character encoding
8 \usepackage[ngerman, english]{babel} % to demonstrate \glqq etc.
9 \usepackage{doc} % to create the documentation file
10 \usepackage{dirtytalk} % the package we're talking about
11 \usepackage{booktabs} % nicer tables
12 \usepackage[colorlinks]{hyperref} % click able links in PDF and PDF meta data
13 \usepackage{lmodern} % font used
14 \EnableCrossrefs
15 \CodelineIndex
16 \newcommand{\mdash}{\,---\,}
17
18 % the following weired code is to obfuscate my e-mail address and so hide it
19 % from spam bots:
20 \newcommand{\partone}{mori$\mathrm{t}$z.kla}
21 \newcommand{\parttwo}{mmler$\,\!$$\partial$stud}
22 \newcommand{\partthree}{ent.$\mathrm{kit.}$edu}
23 \newcommand{\myemail}{\partone\parttwo\partthree}
24 \newcommand{\humanproof}{(If you felt sad when Littlefoot's mother died in the%
25 original \textit{Land Before Time} you'll know what the $\partial$ means\dots)}
26
27 \parskip.5em
28 \title{The \textsf{dirtytalk} Package}
29 \author{M. Klammler\footnote{\myemail\newline\humanproof}}
30 \date{\today}
31
32 \hypersetup{%
33 pdftitle={The dirtytalk Package},%
34 pdfauthor={M. Klammler},%
35 pdfsubject={LaTeX},%
36 pdfkeywords={LaTeX, package, dirtytalk, quotes, quoting, quotations}%
37 }%
38
39 \begin{document}
40 \DocInput{dirtytalk.dtx}
41 \end{document}
42 %</driver>
43 % \fi
44
45 % \maketitle
46 % \begin{abstract}
47 % This document explains the usage of the \textsf{dirtytalk} package for
48 % \LaTeXe. It can be used to typeset \say{quotations} more comfortable. The source
49 % code is also explained.
50 % \end{abstract}
51 % \tableofcontents
52 % \clearpage{}
53 % \paragraph{Who should use this package?} Everybody who feels typesetting
54 % quotes in \LaTeX{} could be more comfortable.
55 % \paragraph{Who should \textit{really} use this package?} Everybody who
56 % typesets German texts using \verb+\glqq{}Hallo Welt\grqq{}+ for a simple
57 % \glqq{}Hallo Welt\grqq{} or\mdash even worse\mdash those who already started
58 % writing a text using the same glyphs for nested quotations and soon after find
59 % themselves in the embarrassing position of replacing them while being no
60 % \textsf{regexp} whiz.
61 % \section{Usage}
62 % \subsection{Loading}
63 % Put \verb+\usepackage{dirtytalk}+ in the preamble of your document.
64 % \subsection{Macros}\DescribeMacro{\say}
65 % Loaded the package you can typeset quotations by \verb+\say{hello world}+ to
66 % get \say{hello world}. Nested quotations are recognized as in:
67 %
68 % \begin{tabular}{p{50.mm}p{50.mm}}
69 % \verb+Alice said: \say{Why did+\linebreak%
70 % \verb+you do that, Bob?}+%
71 % &Alice said: \say{Why did you do that, Bob?}\\[\parskip]
72 % \verb+And Bob answered: \say{+\linebreak%
73 % \verb+What do you mean with+\linebreak%
74 % \verb+\say{that}, dear Alice?}+%
75 % &And Bob answered: \say{What do you mean with \say{that}, dear Alice?}\\
76 % \end{tabular}
77 % \subsection{Options}
78 % The package can be loaded with a couple of options to alter the glyphs being
79 % used. These are given in the \texttt{key=value} style.
80 % \begin{table}[ht]
81 % \begin{center}
82 % \begin{tabular}{lll}
83 % \toprule
84 % key &default value &glyph\\
85 % \midrule
86 % \texttt{left} &\verb+``+ &``\\
87 % \texttt{right} &\verb+''+ &''\\
88 % \texttt{leftsub} &\verb+`+ &`\\
89 % \texttt{rightsub} &\verb+'+ &'\\
90 % \bottomrule
91 % \end{tabular}
92 % \caption{Options for the \textsf{dirtytalk} package.}
93 % \end{center}
94 % \end{table}
95 %
96 % So my fellow German citizens might load the package with
97 % \begin{verbatim}
98 % \usepackage[%
99 % left = \glqq,%
100 % right = \grqq,%
101 % leftsub = \glq,%
102 % rightsub = \grq%
103 % ]{dirtytalk}
104 % \end{verbatim}
105 %
106 % to get German glyphs. Pleas note that the package does \textit{not} check your
107 % document language to alter the symbols used. It depends on you as the author to
108 % specify those you want.
109 %
110 % Happy \LaTeX ing!
111 %
112 % \section{Source Code Documentation}
113 % This section shows and explains the entire code of the package. (It is
114 % intended for \LaTeX{} programmers only.)
115 % \subsection{Identification}
116 % \begin{macrocode}
117 \NeedsTeXFormat{LaTeX2e}
118 \ProvidesPackage{dirtytalk}[2010/11/21 A package making "quoting" easier]
119 % \end{macrocode}
120 % \subsection{Preliminary Declarations}
121 % We use options from the \texttt{key=value} type so we need to load a package
122 % supporting this:
123 % \begin{macrocode}
124 \RequirePackage{kvoptions}
125 % \end{macrocode}
126 % Define the glyphs that will enclose the phrases. We initially define them for
127 % English which will probably be the most requested standard. If the package is
128 % loaded with options, the following macros will be redefined.
129 %
130 % \begin{macro}{\dirtytalk@lqq}
131 % Outer opening (left) quotation mark glyph.
132 % \begin{macrocode}
133 \newcommand{\dirtytalk@lqq}{``}
134 % \end{macrocode}
135 % \end{macro}
136 % \begin{macro}{\dirtytalk@rqq}
137 % Outer closing (right) quotation mark glyph.
138 % \begin{macrocode}
139 \newcommand{\dirtytalk@rqq}{''}
140 % \end{macrocode}
141 % \end{macro}
142 % \begin{macro}{\dirtytalk@lq}
143 % Inner opening (left) quotation mark glyph.
144 % \begin{macrocode}
145 \newcommand{\dirtytalk@lq}{`}
146 % \end{macrocode}
147 % \end{macro}
148 % \begin{macro}{\dirtytalk@rq}
149 % Inner closing (right) quotation mark glyph.
150 % \begin{macrocode}
151 \newcommand{\dirtytalk@rq}{'}
152 % \end{macrocode}
153 % \end{macro}
154 % \subsection{Options}
155 % We allow the author to specify own quotation mark glyphs instead of those
156 % defined above by passing them as options.
157 % \begin{macrocode}
158 \DeclareStringOption{left}
159 \DeclareStringOption{right}
160 \DeclareStringOption{leftsub}
161 \DeclareStringOption{rightsub}
162 % \end{macrocode}
163 % \begin{macrocode}
164 \ProcessKeyvalOptions*
165 % \end{macrocode}
166 % \subsection{More Declarations}
167 % After processing the options (in case of the \textsf{kvoptions}' string
168 % options that means a macro has been defined holding the key value) we check if
169 % they are empty and, if not so, redefine the default glyphs. For this task we
170 % need the \textsf{ifthen} package.
171 % \begin{macrocode}
172 \RequirePackage{ifthen}
173 % \end{macrocode}
174 % \begin{macrocode}
175 \ifthenelse%
176 {\equal{\dirtytalk@left}{}}%
177 {}%
178 {\renewcommand{\dirtytalk@lqq}{\dirtytalk@left}}
179 % \end{macrocode}
180 % \begin{macrocode}
181 \ifthenelse%
182 {\equal{\dirtytalk@right}{}}%
183 {}%
184 {\renewcommand{\dirtytalk@rqq}{\dirtytalk@right}}
185 % \end{macrocode}
186 % \begin{macrocode}
187 \ifthenelse%
188 {\equal{\dirtytalk@leftsub}{}}%
189 {}%
190 {\renewcommand{\dirtytalk@lq}{\dirtytalk@leftsub}}
191 % \end{macrocode}
192 % \begin{macrocode}
193 \ifthenelse%
194 {\equal{\dirtytalk@rightsub}{}}%
195 {}%
196 {\renewcommand{\dirtytalk@rq}{\dirtytalk@rightsub}}
197 % \end{macrocode}
198 % And we define a counter that represents the depth to which a quotation is
199 % nested. However, we will only distinguish between \say{not nested} and
200 % \say{nested} (\texttt{dirtytalk@qdepth} $>$ 1). Since there is no convention for
201 % sub-sub-quotes. (At least, I don't know any.)
202 % \begin{macrocode}
203 \newcounter{dirtytalk@qdepth}
204 % \end{macrocode}
205 % Using this counter, we can now determine which glyph we have to use.
206 % \begin{macro}{\dirtytalk@lsymb}
207 % We define one macro for opening quotes:
208 % \begin{macrocode}
209 \newcommand%
210 {\dirtytalk@lsymb}%
211 {\ifthenelse%
212 {\value{dirtytalk@qdepth}>1}%
213 {\dirtytalk@lq}%
214 {\dirtytalk@lqq}%
215 }%
216 % \end{macrocode}
217 % \end{macro}
218 % \begin{macro}{\dirtytalk@rsymb}
219 % And one for closing quotes:
220 % \begin{macrocode}
221 \newcommand{\dirtytalk@rsymb}%
222 {\ifthenelse%
223 {\value{dirtytalk@qdepth}>1}%
224 {\dirtytalk@rq}%
225 {\dirtytalk@rqq}%
226 }
227 % \end{macrocode}
228 % \end{macro}
229 % \begin{macro}{\say}
230 % And so finally we can declare the only macro this package provides to the
231 % author. On opening quotes we increment the \texttt{dirtytalk@qdepth} counter and
232 % decrement it on closing ones. The appropriate glyph is obtained form
233 % \verb+\dirtytalk@lsymb+ or \verb+\dirtytalk@rsymb+ respectively.
234 % \begin{macrocode}
235 \providecommand{\say}[1]%
236 {%
237 \addtocounter{dirtytalk@qdepth}{1}%
238 \dirtytalk@lsymb%
239 #1%
240 \dirtytalk@rsymb%
241 \addtocounter{dirtytalk@qdepth}{-1}%
242 }
243 % \end{macrocode}
244 % \end{macro}
245 % \section{Copyright Statement}
246 % I, the copyright holder of this work, release the source code of the
247 % \textsf{dirtytalk} package as well as this documentation into the \textbf{public
248 % domain}. This applies worldwide.
249 %
250 % In some countries this may not be legally possible; if so: I grant anyone the
251 % right to use this work for any purpose, without any conditions, unless such
252 % conditions are required by law.