summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/doclicense/doclicense.dtx
blob: 3d262e9942f34edc9cdfee599849a64b6162b904 (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
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
% \iffalse meta-comment
%
% Copyright (C) 2015-2019 by Robin Schneider <ypid@riseup.net>
%
% 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 Robin Schneider.
%
% This work consists of the files doclicense.dtx and doclicense.ins
% and the derived files doclicense.sty and doclicense.pdf.
%
% \fi
%
% \iffalse
%<*driver>
\ProvidesFile{doclicense.dtx}
%</driver>
%<package>%% See file 'doclicense.dtx' for copyright and license.
%<package>\NeedsTeXFormat{LaTeX2e}[1998/12/01]
%<package>\ProvidesPackage{doclicense}
%<*package>
    [2020/04/12 v1.10.1 Support for putting documents under a license]
%</package>
%
%<*driver>
\documentclass[english]{ltxdoc}
\setlength{\parindent}{0pt}
\newcommand{\PackageURL}{https://github.com/ypid/latex-packages/tree/master/doclicense}
\newcommand{\PackageCTANURL}{https://www.ctan.org/pkg/doclicense}
\newcommand{\PackageAuthor}{Robin Schneider}
\newcommand{\PackageAuthorEmail}{ypid@riseup.net}
\newcommand{\PackageName}{\PrintPackage{doclicense}}
\newcommand{\PrintPackage}[1]{\textsf{#1}}
\newcommand{\PrintOptionF}[1]{\emph{#1}} %% ^^A This macro is used for
%% ^^A explaining any parameter when they first come up in the documentation.
\newcommand{\DescribePara}[1]{\marginpar{\raggedleft\strut\MacroFont\string#1}}
\usepackage[
  hyphens,
  obeyspaces,
  spaces,
]{url}
\usepackage{
  babel,
  csquotes,
  xcolor,
  hyperxmp,
  hypdoc,
  nameref,
  xspace,
  eqlist,
}
%% ^^A https://tex.stackexchange.com/a/95893/32320
\setlength\IndexMin{100pt}
\usepackage[
  hyphenation={RaggedRight},
]{doclicense}
\GetFileInfo{doclicense.dtx}
\hypersetup{
  pdftitle={A manual for \PackageName},
  pdfauthor={\PackageAuthor{} <\PackageAuthorEmail>},
  pdfsubject={\fileinfo},
  baseurl={\PackageURL},
  pdfkeywords={This document corresponds to \PackageName\nobreakspace\fileversion,
    dated \filedate},
}

\title{The \PackageName{} package\thanks{This document
corresponds to \PackageName\nobreakspace\fileversion, dated \filedate.}}
\author{\PackageAuthor\\
  \texttt{\href{mailto:\PackageAuthorEmail?subject=LaTeX package doclicense%
    \&body=Dear Robin Schneider,}%
    {\PackageAuthorEmail}%
  }%
}

\EnableCrossrefs%
\CodelineIndex%
\RecordChanges%
\begin{document}
  \DocInput{doclicense.dtx}
  \PrintChanges%
  \PrintIndex%
\end{document}
%</driver>
% \fi
%
% ^^A \CheckSum{0}
% ^^A I use version control and so on which has much better checksums :)
%
% \CharacterTable
%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%   Digits        \0\1\2\3\4\5\6\7\8\9
%   Exclamation   \!     Double quote  \"     Hash (number) \#
%   Dollar        \$     Percent       \%     Ampersand     \&
%   Acute accent  \'     Left paren    \(     Right paren   \)
%   Asterisk      \*     Plus          \+     Comma         \,
%   Minus         \-     Point         \.     Solidus       \/
%   Colon         \:     Semicolon     \;     Less than     \<
%   Equals        \=     Greater than  \>     Question mark \?
%   Commercial at \@     Left bracket  \[     Backslash     \\
%   Right bracket \]     Circumflex    \^     Underscore    \_
%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%   Right brace   \}     Tilde         \~}
%
% \changes{0.07}{2015/02/05}{Initial version}
% \changes{0.08}{2015/02/06}{Added support for CC-zero and CC-pd and small improvements}
% \changes{0.09}{2015/02/07}{Added list of supported licenses to docu and added option imagemodifier.
%   Also renamed macro \cmd{\doclicenseLicense} to \cmd{\doclicenseThis}}
% \changes{0.10}{2015/02/13}{Added support for hyperxmp}
% \changes{1.0}{2015/03/30}{Removed space before quotes (Example: \enquote{CC } $\rightarrow$ \enquote{CC})}
% \changes{1.1}{2015/04/06}{Added support for Creative Commons 4.0 and added \cmd{\doclicenseImageFileName}}
% \changes{1.2}{2015/04/06}{Allow \cmd{\doclicenseModifier} to be used with hyperref. Fixed \cmd{\doclicenseIcon} macro, added missing image and wrote test framework. Added notes about how to add translations. Added Spanish translation.}
% \changes{1.4.0}{2015/12/13}{Added \cmd{\doclicensePlainFullText} and \cmd{\doclicenseFullText} macros Thanks to \href{https://github.com/siefkenj}{siefkenj} for the help.}
% \changes{1.4.1}{2016/04/10}{Translation fixes for: fr, en-gb. Included missing CC-by-nc-nd icon (US dollar).}
% \changes{1.5.0}{2016/04/24}{Allow to change the way text is typeset by \cmd{\doclicenseThis}.}
% \changes{1.6.0}{2017/10/07}{Added Russian and Italian translation. Added `imageposition` and `imagedistance` parameters.}
% \changes{1.7.0}{2018/02/17}{Update Russian and Spanish translation. Fix issue with unescaped newline causing two spaces between license name and 'license' word.}
% \changes{1.7.1}{2018/04/24}{Include .eps versions of the images to allow using `latex` with dvi output. Thanks to robertpetry for reporting.}
% \changes{1.8.0}{2018/06/10}{Added Polish translation.}
% \changes{1.9.0}{2019/04/07}{Added Catalan, Galician, Chinese and Portuguese translation. Detect and give hint when enquote macro is already defined. Fix LaTeX Error: Too deeply nested.}
% \changes{1.10.0}{2019/06/05}{Added Brazilian translation. Update Chinese and Portuguese translation. Do not use enumitem for list label customization (beamer compatibility).}
% \changes{1.10.1}{2020/04/12}{Fix image for CC-BY-NC EU. Fix URL for CC-PDDC. Improve wording for catalan language.}
%
%% ^^A nag warned about the center environment and it really messes up spacing.
%
% \DoNotIndex{\RequirePackage, \DeclareOption, \ProcessOptions}
% \DoNotIndex{\PackageWarning, \MessageBreak}
% \DoNotIndex{\DeclareRobustCommand, \newcommand, \renewcommand, \def, \edef}
% \DoNotIndex{\DeclareStringOption, \ProcessLocalKeyvalOptions}
% \DoNotIndex{\ProcessKeyvalOptions, \SetupKeyvalOptions, \DeclareBoolOption}
% \DoNotIndex{\newenvironment}
% \DoNotIndex{\if, \else, \fi, \ifcase, \or, \ifthenelse, \AND, \OR, \value, \relax}
% \DoNotIndex{\loop, \repeat, \the, \ifnum}
% \DoNotIndex{\equal, \boolean, \@currname, \newcounter, \setcounter}
% \DoNotIndex{\stepcounter, \addtocounter}
% \DoNotIndex{\endinput, \begin, \end}
% \DoNotIndex{\not}
%
% \maketitle
%
% \phantomsection
% \addcontentsline{toc}{section}{\abstractname}
% \begin{abstract}
% Support for putting documents under a license. \\
% Information site on CTAN: \url{\PackageCTANURL} \\
% Example on Stackexchange: \url{https://tex.stackexchange.com/a/226788/32320} \\
% Fork me on GitHub: \url{\PackageURL} \end{abstract}
%
% \tableofcontents
%
% \section{Introduction}
% The \PrintPackage{doclicense} package allows you to put your document under a
% license and include a link to read about the license or include an icon or
% image of the license.  Currently, only \doclicenseLongType is supported but this
% package is designed to handle all kinds of licenses. See \nameref{sec:contributing}.
%
% \section{Usage}
% Just load the package(s) placing
% \begin{quote}
%   |\usepackage{| \\
%   |%  babel,| \\
%   |%  hyperref,| \\
%   |%  hyperxmp,| \\
%   |  doclicense,| \\
%   |}|
% \end{quote}
% in the preamble of your \LaTeXe{} source file. This will select the default
% license which is \doclicenseNameRef, currently. Please always set your
% license explicitly as package options like so:
%
% \begin{quote}
%   |\usepackage{| \\
%   |%  babel,| \\
%   |%  hyperref,| \\
%   |%  hyperxmp,| \\
%   |}| \\
%   |\usepackage[| \\
%   |  type={CC},| \\
%   |  modifier={by-sa},| \\
%   |  version={3.0},| \\
%   |]{doclicense}|
% \end{quote}
%
% This will explicitly set the license to \doclicenseNameRef.
%
% If the \PrintPackage{hyperxmp} package is loaded, then the options
% \PrintOptionF{pdflicenseurl} and \PrintOptionF{pdfcopyright} will be set
% by \PrintPackage{doclicense} to the corresponding values
% (\enquote{\url{\doclicenseURL}} and \enquote{\doclicenseLongText{}}).
%
% \section{Package options}
%
% Sets the license type. \DescribePara{type}
% Like in the previous example, the type can be
% \enquote{CC} to cover all the \doclicenseLongType licenses.
% Please make sure that the type is all uppercase. See the \nameref{sec:supported-licenses} section for a complete list.
%
% Allows to
% select different subclasses of a license. In the
% example it is \enquote{by-sa}.
% Please make sure that the type is all lowercase. See the \nameref{sec:supported-licenses} section for a complete list.
%
% As \DescribePara{version} there can be more than one version of a license, the version can also be set.
%
% This package can output some texts like the long license name.
% \DescribePara{lang}
% Because of this, there needs to be a way to specify the language to use.
% If this parameter is omitted, then this package will default to
% \cmd{\languagename} which is normally set by packages like
% \PrintPackage{babel} or \PrintPackage{polyglossia}.
%
% Supported languages:
% ^^A Sorted alphabetically.
% \begin{eqlist}
%   \item[Brazilian]  Added by \href{https://github.com/iagows}{Iago}.
%   \item[Catalan]    Added by \href{https://github.com/elancha98}{Ernesto Lanchares}.
%   \item[Chinese]    Added by \href{https://github.com/sd44}{sd44}.
%   \item[English]    Added by \href{https://github.com/ypid}{Robin Schneider}.
%   \item[French]     Added by \href{https://github.com/ericguirbal}{\'Eric Guirbal}.
%   \item[Galician]   Submitted by Email.
%   \item[German]     Added by \href{https://github.com/ypid}{Robin Schneider}.
%   \item[Italian]    Added by \href{https://github.com/rig8f}{Filippo Rigotto}.
%   \item[Polish]     Added by \href{https://github.com/jsbien}{jsbien}.
%   \item[Portuguese] Added by \href{https://github.com/alexandre1985}{Daniel Alexandre Cerqueira Santos}.
%   \item[Russian]    Added by \href{https://github.com/bergentroll}{Anton Karmanov}.
%   \item[Spanish]    Added by \href{https://github.com/elsudano}{Carlos}. Updated by \href{https://github.com/IgnacioFDM}{IgnacioFDM}.
%
%
%
%
% \end{eqlist}
%
% Image position for \cmd{\doclicenseThis}: right (default) or left.
% \DescribePara{imageposition}
%
% Default image width for the license image.
% \DescribePara{imagewidth}
%
% Distance between text and image in \cmd{\doclicenseThis}.
% \DescribePara{imagedistance}

% Select different variations of license images.
% \DescribePara{imagemodifier}
% For example, Creative Commons provides sometimes more than one image for one version.
% See the \href{https://creativecommons.org/about/downloads}{download page}.
% You will note that there are by-nc.eu and by-nc which only differ in the money unit.
% By default the by-nc image would be used but you can change this with:
% \begin{quote}
%   |\usepackage[| \\
%   |  imagemodifier={-eu},| \\
%   |]{doclicense}|
% \end{quote}
%
% Note that if French or German is set as language then \enquote{-eu} will be used as
% default for this option.
%
% Currently supported are \enquote{-eu} and \enquote{-us}.
%
% This option allows you to specify
% \DescribePara{hyphenation}
% a macro name which is going to be expanded
% in the minipage environment of \cmd{\doclicenseThis}.
% That allows you to change the behaviour how \cmd{\doclicenseLongText} is
% typeset. By default, this option is not enabled.
%
% One possible use case is to set the option to \enquote{RaggedRight}.
% This will use the \cmd{\RaggedRight} macro provided by the
% \PrintPackage{ragged2e} package\footnote{The \PrintPackage{ragged2e} package will be loaded when it is required.}) with the intention of limiting the number of
% hyphenations while still allowing a hyphenation by typesetting
% \cmd{\doclicenseLongText} as ragged text.
%
% The idea of using ragged text is that the \cmd{\doclicenseLongText} is
% usually one or two full line and one half full line so avoiding hyphenations
% might look better compared to justified text.
%
% \enquote{RaggedRight} is also the setting used for this documentation.
% \cmd{\doclicenseThis} did not produce a hyphenation in case of this
% documentation but \TeX{} did fill up the first text line to it’s full width
% by adding additional space between words. This has been be avoided by setting
% the following option for this document:
%
% \begin{quote}
%   |\usepackage[| \\
%   |  hyphenation={RaggedRight},| \\
%   |]{doclicense}|
% \end{quote}
%
% Another option which can make sense is the \cmd{\raggedright} macro which
% more drastically limits the number of hyphenations. This can be set as shown
% below:
%
% \begin{quote}
%   |\usepackage[| \\
%   |  hyphenation={raggedright},| \\
%   |]{doclicense}|
% \end{quote}
%
% \section{Macros}
% \DescribeMacro{\doclicenseType}
% Expands to the type as set in the package options. Example: \enquote{\doclicenseType{}}
%
% \DescribeMacro{\doclicenseLongType}
% Same as \cmd{\doclicenseType} except that it expands to the long license
% type. Example: \enquote{\doclicenseLongType{}}
%
% \DescribeMacro{\doclicenseModifier}
% Expands to the modifier as set in the package options. Example: \enquote{\doclicenseModifier{}}
%
% \DescribeMacro{\doclicenseVersion}
% Expands to the version as set in the package options. Example: \enquote{\doclicenseVersion{}}
%
% \DescribeMacro{\doclicenseURL}
% Expands to the official URL about the license. Note that it expands to the
% raw URL string without the use of \cmd{\href} or similar. If you want the
% link to be clickable then you can use \cmd{\href} or \cmd{\url} from the
% \PrintPackage{hyperref} package or just read on because the following macros
% can also do this for your. Example:
% \enquote{\doclicenseURL{}}
%
% \DescribeMacro{\doclicenseName}
% Expands to the short name of the license. Example: \enquote{\doclicenseName{}}
%
% \DescribeMacro{\doclicenseLongName}
% Expands to the long name of the license. Example: \enquote{\doclicenseLongName{}}
%
% \DescribeMacro{\doclicenseNameRef}
% Same as \cmd{\doclicenseName} except that it links to the URL of the license.
% Example: \enquote{\doclicenseNameRef{}}
%
% \DescribeMacro{\doclicenseLongNameRef}
% Same as \cmd{\doclicenseLongName} except that it links to the URL of the
% license. Example:
% \enquote{\doclicenseLongNameRef{}}
%
% \DescribeMacro{\doclicenseText}
% Expands to a localized text which states that this document is licensed under
% the license. Example:
% \enquote{\doclicenseText{}}
%
% \DescribeMacro{\doclicenseLongText}
% Same as \cmd{\doclicenseText} except that it uses the long name of the license.
% Example: \enquote{\doclicenseLongText{}}
%
% \DescribeMacro{\doclicensePlainFullText}
% Verbatim prints the full license text.
%
% ^^A Don’t ask why I inserted that line break … (LaTeX made the \doclicensePlainFullText red)
%
% An example can be found in the \nameref{sec:plain_license_text} section.
%
% \DescribeMacro{\doclicensePlainFullTextFileName}
% \hspace{2.5em}Expands to the file name which the \cmd{\doclicensePlainFullTextFileName} macro uses to \cmd{\input} the license text file.
%
% \DescribeMacro{\doclicenseFullText}
% Nicely prints the full license text.
%
% ^^A Don’t ask why I inserted that line break … (LaTeX made the \doclicenseFullText red)
%
% An example can be found in the \nameref{sec:pretty_license_text} section.
%
% \DescribeMacro{\doclicenseFullTextFileName}
% Expands to the file name which the \cmd{\doclicenseFullText} macro uses to \cmd{\input} the license text file.
%
%
% \DescribeMacro{\doclicenseIcon}
% Expands to a icon of the license. Example:
% \enquote{\doclicenseIcon{}}. This macro is based on the
% \PrintPackage{ccicons} package.
%
% \DescribeMacro{\doclicenseTypeIcon}
% Expands to a icon of the license type. Example:
% \enquote{\doclicenseTypeIcon{}}. This macro is based on the
% \PrintPackage{ccicons} package.
%
% \DescribeMacro{\doclicenseImage}
% This is kind of similar to \cmd{\doclicenseIcon} but it will typeset an
% bigger pictogram of the license. Example:
% \enquote{\doclicenseImage}
%
% Note that you can change the image size with the \oarg{imagewidth} parameter
% like this:
% \enquote{\doclicenseImage[imagewidth=2em]}
%
% \begin{quote}
%   |\doclicenseImage[imagewidth=2em]|
% \end{quote}
%
% The images are bundled with the \PackageName{} package as vector graphics.
%
% \DescribeMacro{\doclicenseImageFileName}
% This macro expands to the file name of the image which the
% \cmd{\doclicenseImage} typesets.  You can use this file name with
% \cmd{\includegraphics} if you need more flexibility over how the image is
% typeset.
%
% The current file name is: \enquote{\doclicenseImageFileName}
%
% You do not have to worry about the file path. Normally your \LaTeX{} environment
% will find the image for you.
%
% \DescribeMacro{\doclicenseThis}
% And last but not least there is the \cmd{\doclicenseThis} macro which will
% typeset the \cmd{\doclicenseText} next to the \cmd{\doclicenseImage} in a
% \enquote{minipage} environment. This will look like the following:
%
% \doclicenseThis
%
% \section{Supported licenses}
% \label{sec:supported-licenses}
%
% Currently only Creative Commons is supported.
% The license type, modifier and version should be based on
% \href{https://spdx.org/licenses/}{SPDX license identifiers}. Direct support
% for SPDX license identifiers should be considered when supporting new
% licenses.
%
% \subsection{CC (Creative Commons)}
%
% \makeatletter
% \begin{eqlist}
%   \item[zero@1.0] \@nameuse{doclicense@lang@lic@CC@zero@1.0}
%   \item[pd@1.0] \@nameuse{doclicense@lang@lic@CC@pd@null}
%   \item[by@3.0] \@nameuse{doclicense@lang@lic@CC@by@3.0}
%   \item[by-sa@3.0] \@nameuse{doclicense@lang@lic@CC@by-sa@3.0}
%   \item[by-nd@3.0] \@nameuse{doclicense@lang@lic@CC@by-nd@3.0}
%   \item[by-nc@3.0] \@nameuse{doclicense@lang@lic@CC@by-nc@3.0}
%   \item[by-nc-sa@3.0] \@nameuse{doclicense@lang@lic@CC@by-nc-sa@3.0}
%   \item[by-nc-nd@3.0] \@nameuse{doclicense@lang@lic@CC@by-nc-nd@3.0}
%   \item[by@4.0] \@nameuse{doclicense@lang@lic@CC@by@4.0}
%   \item[by-sa@4.0] \@nameuse{doclicense@lang@lic@CC@by-sa@4.0}
%   \item[by-nd@4.0] \@nameuse{doclicense@lang@lic@CC@by-nd@4.0}
%   \item[by-nc@4.0] \@nameuse{doclicense@lang@lic@CC@by-nc@4.0}
%   \item[by-nc-sa@4.0] \@nameuse{doclicense@lang@lic@CC@by-nc-sa@4.0}
%   \item[by-nc-nd@4.0] \@nameuse{doclicense@lang@lic@CC@by-nc-nd@4.0}
% \end{eqlist}
% \makeatother
%
% \section{Contributing}
% \label{sec:contributing}
% This package is being developed on GitHub: \url{\PackageURL}. When you want
% to modify the .sty file, make sure that you make your changes in the .dtx
% file instead, as the .sty file is automatically generated.
%
% In case you want to add a translation for your language then just copy the
% file \path{doclicense-english.ldf} and replace the \enquote{english} in
% the filename with your language code (same as the language code used by
% \PrintPackage{babel}) and translate the file.
% If there are multiple language
% codes which should map to the same translation then have a look at the file
% \path{doclicense-american.ldf}.
%
% When you are done and have tested your translation (modify and run the
% \path{run_tests} script) then please send me the translated file(s) either
% via Email or preferably by opening a pull request on GitHub so that I can
% include them in the next release.
%
% \section{Plaintext license text}
% \label{sec:plain_license_text}
%
% The following is an example output of the \cmd{\doclicensePlainFullText} macro.
%
% \doclicensePlainFullText
%
% \section{Pretty license text}
% \label{sec:pretty_license_text}
%
% The following is an example output of the \cmd{\doclicenseFullText} macro.
%
% \doclicenseFullText
%
% \StopEventually{}
%
% \newpage
% \section{Implementation}
% \iffalse
%<*package>
% \fi
% \subsection{Declaring the options}
%    \begin{macrocode}
%% Parameters (((
\RequirePackage{kvoptions}
\DeclareStringOption[CC]{type}
\DeclareStringOption[by-sa]{modifier}
\DeclareStringOption{version}
\DeclareStringOption{lang}
\DeclareStringOption{imagemodifier}
\DeclareStringOption[right]{imageposition}
\DeclareStringOption[10em]{imagewidth}
\DeclareStringOption[2em]{imagedistance}
\DeclareStringOption{hyphenation}
%% )))

%    \end{macrocode}
% To test if all parameters are valid the macro |\ProcessLocalKeyvalOptions*|
% is expanded to ensure this before leaving the preamble. This is the only
% purpose for the |\ProcessLocalKeyvalOptions*| macro in this case.
%    \begin{macrocode}
\ProcessLocalKeyvalOptions*

%    \end{macrocode}
% \subsection{Dependencies}
%    \begin{macrocode}
%% Dependencies (((
\RequirePackage{xifthen}
\RequirePackage{etoolbox} %% \ifcsdef
\RequirePackage{xspace}
\RequirePackage{verbatim}
%% )))

%% Custom enumerate list with adjusted labels
%% that match the license text convetions
\newenvironment{doclicense@enumerate}{%
  \begin{enumerate}
    \renewcommand{\labelenumi}{(\alph{enumi})}%
    \renewcommand{\labelenumii}{(\arabic{enumii})}%
    \renewcommand{\labelenumiii}{(\Alph{enumiii})}%
    \renewcommand{\labelenumiv}{(\roman{enumiv})}%
}{\end{enumerate}}

\ifthenelse{
  \equal{\doclicense@hyphenation}{}
}{}{%
  \RequirePackage{ragged2e}

  \ifthenelse{\isnamedefined{\doclicense@hyphenation}}{}{%
    \PackageError{doclicense}{Hyphenation macro not defined}
      {The macro name given via the hyphenation option is not defined.}%
  }
}
\AtEndPreamble{%
  \@ifpackageloaded{csquotes}{
    %% csquotes has already been loaded so we are fine.
  }{
    \ifcsdef{enquote}{
      %% \enquote is defined but not by csquotes.
      \@ifpackageloaded{biblatex}{
        \PackageError{doclicense}{The enquote macro is defined by biblatex}
          {This package assumes that the enquote macro is defined by the
            csquotes package. Please load csquotes before you load biblatex so
            that biblatex does not define enquote instead.}%
      }{
        \PackageError{doclicense}{The enquote macro is defined by unknown package}
          {This package assumes that the enquote macro is defined by the
            csquotes package. Please check why enquote is defined without
            csquotes being loaded. Maybe try loading csquotes early so that it
            can define the enquote macro instead.}%
      }
    }{
      \RequirePackage{csquotes}
    }
  }
  \@ifpackageloaded{ccicons}{}{\RequirePackage{ccicons}}
    %% For \doclicenseIcon
  \@ifpackageloaded{graphicx}{}{\RequirePackage{graphicx}}
    %% For \doclicenseImage
  \@ifpackageloaded{hyperref}{}{\RequirePackage{hyperref}}
  \@ifpackageloaded{hyperxmp}{%
    %% The following options are only defined when the hyperxmp package was loaded.
    \hypersetup{
      pdfcopyright  = {\doclicenseLongText},
      pdflicenseurl = {\doclicenseURL},
    }
  }{}
}
%% )))

%    \end{macrocode}
% \subsection{Declare variables and macros}
%    \begin{macrocode}
%% Declare variables (((
\newcommand{\doclicense@baseUrlCC}{https://creativecommons.org}
\newcommand{\doclicense@versionFallback}{}
\newcommand{\doclicense@versionUsed}{}
\newboolean{doclicense@licenseKnown}
\newlength{\doclicense@hsize}
\newcommand{\doclicense@longName}{%
  \@nameuse{doclicense@lang@lic@\doclicense@type @\doclicense@modifier%
    @\doclicense@versionUsed}%
}
\newcommand{\doclicense@icon}{%
  \PackageError{doclicense}{Icon not defined}
    {Please check the documentation of doclicense to see what you can do about it.}%
}
\newcommand{\doclicense@modifier@uppercase}{\texorpdfstring{%
    \MakeUppercase{\doclicense@modifier}%
  }{%
    \doclicense@modifier}%
}
%% )))

%    \end{macrocode}
% \subsection{User macros}
%    \begin{macrocode}
%% User macros (((
\newcommand{\doclicenseType}{\doclicense@type\xspace}
\newcommand{\doclicenseLongType}{}
\newcommand{\doclicenseModifier}{\doclicense@modifier@uppercase\xspace}
\newcommand{\doclicenseVersion}{\doclicense@versionUsed\xspace}
\newcommand{\doclicenseName}{%
  \doclicense@type\nobreakspace\doclicense@modifier@uppercase\nobreakspace%
  \doclicense@versionUsed\xspace%
}
\newcommand{\doclicenseNameRef}{\href{\doclicenseURL}{\doclicenseName}\xspace}
\newcommand{\doclicenseLongName}{\doclicenseLongType\space%
  \doclicense@longName\xspace}
\newcommand{\doclicenseLongNameRef}{\href{\doclicenseURL}{\doclicenseLongName}}
\newcommand{\doclicenseText}{%
  \doclicense@lang@thisDoc\space
  \href{\doclicenseURL}{\enquote{\doclicenseName{}}}%
  \doclicense@lang@word@license.\xspace%
}
\newcommand{\doclicenseLongText}{%
  \doclicense@lang@thisDoc\space
  \href{\doclicenseURL}{\doclicenseLongType\space\enquote{\doclicense@longName}}%
  \doclicense@lang@word@license.\xspace%
}
\newcommand{\doclicenseIcon}{\doclicense@icon\xspace}
\newcommand{\doclicenseTypeIcon}{\doclicenseType}
% \newcommand{\doclicenseModifierIcon}{} %% Not directly provided by ccicons.
\newcommand{\doclicenseImageFileName}{%
  doclicense-\doclicense@type-\doclicense@modifier\doclicense@imagemodifier}
\newcommand{\doclicenseImage}[1][]{%
  \setkeys{doclicense}{#1}
  \href{\doclicenseURL}{%
    \includegraphics[
      width=\doclicense@imagewidth%
    ]{\doclicenseImageFileName}%
  }
}
\newcommand{\doclicensePlainFullTextFileName}{%
  doclicense-\doclicense@type-\doclicense@modifier%
  -\doclicense@versionUsed-plaintext
}
\newcommand{\doclicensePlainFullText}{%
  \verbatiminput{\doclicensePlainFullTextFileName}
}
\newcommand{\doclicenseFullTextFileName}{%
  doclicense-\doclicense@type-\doclicense@modifier-\doclicense@versionUsed-latex}
\newcommand{\doclicenseFullText}{\input{\doclicenseFullTextFileName}}

\newcommand{\doclicenseLicense}{\doclicenseThis} %% legacy support
\newcommand{\doclicenseThis}{%
  \setlength{\doclicense@hsize}{\textwidth-\doclicense@imagewidth-\doclicense@imagedistance}%
  \ifthenelse{\equal{\doclicense@imageposition}{left}}{%
    \begin{center}
      \begin{minipage}{\doclicense@imagewidth}
        \doclicenseImage%
      \end{minipage}
      \hfill
      \begin{minipage}{\doclicense@hsize}
        \ifthenelse{\isempty{\doclicense@hyphenation}}{}{%
          \@nameuse{\doclicense@hyphenation}%
        }%
        \doclicenseLongText%
      \end{minipage}
    \end{center}
  }{%
  % \ifthenelse{\isnamedefined{iflandscape}}{%
  %   \iflandscape{%
  %     \setlength{\doclicense@hsize}{\doclicense@hsize-10em}%
  %   }{}%
  % }{}%
  % {%
    \begin{center}
      \begin{minipage}{\doclicense@hsize}
        \ifthenelse{\isempty{\doclicense@hyphenation}}{}{%
          \@nameuse{\doclicense@hyphenation}%
        }%
        \doclicenseLongText%
      \end{minipage}
      \hfill
      \begin{minipage}{\doclicense@imagewidth}
        \doclicenseImage%
      \end{minipage}
    \end{center}
  % }
  }
}
%% )))

%    \end{macrocode}
% \subsection{Language selection}
% The following lines include the ldf file. All language dependent things
% should be stored and changed there. Note that one could also redefine
% macros like \cmd{\doclicenseLongText} if necessary.
%    \begin{macrocode}
%% Language support (((
\ifthenelse{\equal{\doclicense@lang}{}}{%
  \renewcommand{\doclicense@lang}{\languagename}}{}
\IfFileExists{doclicense-\doclicense@lang.ldf}{%
  \input{doclicense-\doclicense@lang.ldf}
}{%
  \PackageWarning{doclicense}{%
    No language definition for \doclicense@lang found.
    Please add one and submit a patch. Using English as fallback.}
  \renewcommand{\doclicense@lang}{english}
  \input{doclicense-\doclicense@lang.ldf}
}
\ifthenelse{\equal{\doclicense@imagemodifier}{-us}}{%
  \@namedef{doclicense@imagemodifier}{}
}{}

%% )))

%    \end{macrocode}
% \subsection{Internals}
%    \begin{macrocode}
%% Set license (((
\newcommand{\doclicense@setVersion}[1][]{%
  \ifthenelse{\equal{#1}{}}{}{%
    \renewcommand{\doclicense@versionFallback}{#1}
  }
  \ifthenelse{\equal{\doclicense@version}{}}{%
    \renewcommand{\doclicense@versionUsed}{\doclicense@versionFallback}
  }{%
    \renewcommand{\doclicense@versionUsed}{\doclicense@version}
  }
}
\newcommand{\doclicense@set}{%
  %% CC (((
  \ifthenelse{\equal{\doclicense@type}{CC}}{%
    \renewcommand{\doclicenseLongType}{Creative Commons\xspace}
    \renewcommand{\doclicenseTypeIcon}{\ccLogo\xspace}

    \doclicense@setVersion[3.0]

    %% Allow to predefine the following macros in ldf files.
    \ifcsdef{doclicense@UrlLangPart}{}{%
      \ifthenelse{\equal{\doclicense@lang@lic@CC@code}{}}{%
        \edef\doclicense@UrlLangPart{}
      }{%
        \edef\doclicense@UrlLangPart{/deed.\doclicense@lang@lic@CC@code}
      }
    }
    \ifcsdef{doclicenseURL}{}{%
      \edef\doclicenseURL{%
        \doclicense@baseUrlCC/%
        licenses/%
        \doclicense@modifier/%
        \doclicense@versionUsed\doclicense@UrlLangPart%
      }
    }
    \ifthenelse{\equal{\doclicense@modifier}{by}}{%
      \renewcommand{\doclicense@icon}{\ccby}
      \renewcommand{\doclicense@imagemodifier}{}
    }{}
    \ifthenelse{\equal{\doclicense@modifier}{by-sa}}{%
      \renewcommand{\doclicense@icon}{\ccbysa}
      \renewcommand{\doclicense@imagemodifier}{}
    }{}
    \ifthenelse{\equal{\doclicense@modifier}{by-nd}}{%
      \renewcommand{\doclicense@icon}{\ccbynd}
      \renewcommand{\doclicense@imagemodifier}{}
    }{}
    \ifthenelse{\equal{\doclicense@modifier}{by-nc}}{%
      \renewcommand{\doclicense@icon}{\ccbync}
      \ifthenelse{\equal{\doclicense@imagemodifier}{-eu}}{%
        \renewcommand{\doclicense@icon}{\ccbynceu}
      }{}
      \ifthenelse{\equal{\doclicense@imagemodifier}{-jp}}{%
        \renewcommand{\doclicense@icon}{\ccbyncjp}
      }{}
    }{}
    \ifthenelse{\equal{\doclicense@modifier}{by-nc-sa}}{
      \renewcommand{\doclicense@icon}{\ccbyncsa}
      \ifthenelse{\equal{\doclicense@imagemodifier}{-eu}}{%
        \renewcommand{\doclicense@icon}{\ccbyncsaeu}
      }{}
      \ifthenelse{\equal{\doclicense@imagemodifier}{-jp}}{%
        \renewcommand{\doclicense@icon}{\ccbyncsajp}
      }{}
    }{}
    \ifthenelse{\equal{\doclicense@modifier}{by-nc-nd}}{
      \renewcommand{\doclicense@icon}{\ccbyncnd}
      \ifthenelse{\equal{\doclicense@imagemodifier}{-eu}}{%
        \renewcommand{\doclicense@icon}{\ccbyncndeu}
      }{}
      \ifthenelse{\equal{\doclicense@imagemodifier}{-jp}}{%
        \renewcommand{\doclicense@icon}{\ccbyncndjp}
      }{}
    }{}
    \ifthenelse{\equal{\doclicense@modifier}{zero}}{%
      \renewcommand{\doclicense@icon}{\cczero}
      \renewcommand{\doclicense@imagemodifier}{}
      \doclicense@setVersion[1.0]
      \edef\doclicenseURL{%
        \doclicense@baseUrlCC/%
        publicdomain/%
        \doclicense@modifier/%
        \doclicense@versionUsed\doclicense@UrlLangPart}
    }{}
    \ifthenelse{\equal{\doclicense@modifier}{pd}}{
      \renewcommand{\doclicense@icon}{\ccpd}
      \renewcommand{\doclicense@imagemodifier}{}
      \doclicense@setVersion[null]
      \edef\doclicenseURL{%
        \doclicense@baseUrlCC/%
        licenses/publicdomain%
        \doclicense@UrlLangPart}
    }{}

    \ifcsdef{doclicense@lang@lic@\doclicense@type%
      @\doclicense@modifier @\doclicense@versionUsed}{}{%

      \PackageError{doclicense}{License long name not defined}%
        {%
          Please check the documentation of doclicense
          to see what you can do about it.%
        }%
    }

    \setboolean{doclicense@licenseKnown}{true}
  }{}%% )))
  \ifthenelse{\not\boolean{doclicense@licenseKnown}}{%
    \PackageError{doclicense}{License unknown}%
      {%
        Please check the documentation of doclicense
        to see what you can do about it.%
      }%
  }{}%
}
%% )))

\doclicense@set%
%    \end{macrocode}
% That's it.
%    \begin{macrocode}
\endinput
%    \end{macrocode}
%
% \iffalse
%</package>
% \fi
%
% \Finale
\endinput