Debian Codegraph @

texmf-dist/doc/generic/memoize/memoize-doc-common.sty

raw
1 %% memoize-doc-common.sty
2 %%
3 %% This file is a part of Memoize, a TeX package for externalization of
4 %% graphics and memoization of compilation results in general, available at
5 %% https://ctan.org/pkg/memoize and https://github.com/sasozivanovic/memoize.
6 %%
7 %% Copyright (c) 2020- Saso Zivanovic <[email protected]>
8 %% (Sa\v{s}o \v{Z}ivanovi\'{c})
9 %%
10 %% This work may be distributed and/or modified under the conditions of the
11 %% LaTeX Project Public License, either version 1.3c of this license or (at
12 %% your option) any later version. The latest version of this license is in
13 %% https://www.latex-project.org/lppl.txt and version 1.3c or later is part of
14 %% all distributions of LaTeX version 2008 or later.
15 %%
16 %% This work has the LPPL maintenance status `maintained'.
17 %% The Current Maintainer of this work is Saso Zivanovic.
18 %%
19 %% The files belonging to this work and covered by LPPL are listed in
20 %% (<texmf>/doc/generic/memoize/)FILES.
21
22 \ProvidesPackage{memoize-doc-common}
23
24 \usepackage[inline,shortlabels]{enumitem}
25 \usepackage{tcolorbox}
26 \tcbuselibrary{listings,hooks,raster,skins}
27 \usepackage{tikz}
28 \usepackage{xstring}
29 \usepackage{microtype}
30
31 \usepackage{listings}
32 \lstset{
33 language=[LaTeX]TeX,
34 columns=fullflexible,
35 basicstyle=\ttfamily\small,
36 commentstyle=\color{purple},
37 moredelim={[is][\pstyle]{~}{~}}
38 }
39 \lstMakeShortInline[moredelim={[is][\pstyle]{~}{~}}]{ˇ}%
40 \tcbset{
41 linerange/.style={listing options app={linerange=#1}},
42 }
43
44
45 %%%%%%%%%%%%%%
46 % title page %
47
48 \usepackage{pdftexcmds}
49 \let\pdfsystem\pdf@system
50
51 \def\ParseProvidesPackage\ProvidesPackage#1[#2/#3/#4 v#5 #6]{%
52 \def\packagename{#1}%
53 \year=#2\relax\month=#3\relax\day=#4\relax
54 \def\packagever{#5}\def\packagedesc{#6}%
55 \ignorespaces
56 }
57
58 \newcommand\packageversion{\def\@packageversion}
59 \renewcommand\maketitle{%
60 \begingroup
61 \mmzset{disable, auto={tcolorbox}{clear options}}% \mmznext does not work here -- todo: maybe it does now
62 \begin{tcolorbox}[
63 colback=emphcolor,
64 fonttitle=\LARGE\bf,
65 halign title=center,
66 halign upper=center,
67 halign lower=center,
68 tikznode lower,
69 adjusted title=\@title,
70 ]
71 \@packageversion
72 \tcblower
73 \Large\@author
74 \end{tcolorbox}
75 \endgroup
76 }
77 \colorlet{emphcolor}{yellow!90!black}
78 \usepackage{marvosym}
79 \let\emailsymbol\Letter
80 \let\homepagesymbol\ComputerMouse
81 \usepackage{fontawesome} % for \faGithub
82
83
84 %%%%%%%%%%%%%%%%%%%%%%%%
85 % \verb@eol@error hack %
86
87 % The problem: doc.sty (re)defines \verb "to check for newlines in its argument
88 % since a missing delimiter is difficult to detect in doc source." In
89 % principle, that's great, but I really hate it that I can't use Emacs's
90 % "fill-paragraph" without fear of getting the "Text for \noexpand\verb command
91 % ended by end of line" error.
92 %
93 % Solution: the original \verb@eol@error defines a newline (which is active at
94 % that point) to throw an error. We redefine \verb@eol@error to define a
95 % newline to gobble an immediately following percent character (assuming that
96 % we are processing .dtx documentation) and spaces.
97
98 \begingroup
99 \obeylines%
100 \gdef\verb@eol@error{\obeylines%
101 \def^^M{\futurelet\verb@eol@nextchar\verb@eol@peek}%
102 }%
103 \endgroup
104 \gdef\verb@eol@peek{%
105 \if\@percentchar\verb@eol@nextchar
106 \expandafter\verb@eol@ignorepercentchar
107 \else
108 \space % we need one space, though!
109 \expandafter\verb@eol@ignorespaces
110 \fi
111 }
112 \def\verb@eol@ignorepercentchar#1{% #1 = "%"
113 \@xobeysp\verb@eol@ignorespaces}
114 \begingroup\catcode`\ =13 \gdef\verb@eol@otherspace{ }\endgroup
115 % |\ignorespaces| wouldn't work here, as our spaces are of category 13
116 \def\verb@eol@ignorespaces{%
117 \futurelet\verb@eol@nextchar\verb@eol@ignorespaces@peek}
118 \def\verb@eol@ignorespaces@peek{%
119 \expandafter\ifx\verb@eol@otherspace\verb@eol@nextchar
120 \expandafter\verb@eol@ignorespaces@space
121 \fi
122 }
123 \def\verb@eol@ignorespaces@space#1{\verb@eol@ignorespaces}
124
125 % The same hack, but for \lstinline of package listings.
126 % https://tex.stackexchange.com/a/473459/16819
127
128 \def\lst@InlineM#1{\gdef\lst@inlinechars{%
129 \lst@Def{`#1}{\lst@DeInit\egroup\global\let\lst@inlinechars\@empty}%
130 \lst@Def{13}{\lst@ProcessSpace}}% <---
131 \lst@inlinechars}
132
133
134 %%%%%%%%%%%
135 % various %
136
137 \usepackage{hologo}
138 \newcommand\PGFmanual[1]{%
139 \href
140 {http://mirrors.ctan.org/graphics/pgf/base/doc/pgfmanual.pdf}
141 {\S#1 of the Ti\emph{k}Z \& \textsc{PGF} manual}%
142 }
143 \newcommand\ManualBeamer[1][]{%
144 \href
145 {http://mirrors.ctan.org/macros/latex/contrib/beamer/doc/beameruserguide.pdf}
146 {#1\ifstrempty{#1}{}{ }the Beamer manual}%
147 }
148 \newcommand\TeXbyTopic[1][]{%
149 \href
150 {http://mirrors.ctan.org/info/texbytopic/TeXbyTopic.pdf}
151 {TeX by Topic\ifstrempty{#1}{}{, #1}}%
152 }
153 \newcommand\TeXbook[1][]{%
154 \hologo{TeX}book\ifstrempty{#1}{}{, #1}%
155 }
156 \newcommand\Alt{\,$\vert$\,}
157 \newcommand\hyp{\discretionary{}{}{}}
158 \newcommand\fncomma{\ensuremath{{^,}}}
159
160
161 % load hyperref before this
162
163 \protected\def\hypercolor#1#2{% #1 = url/link/.., #2 = color
164 \expanded{%
165 \noexpand\HyColor@HyperrefColor{#2}\expandonce{\csname @#1color\endcsname}%
166 }%
167 }
168
169 \RenewDocumentCommand\url{ o D(){} m }{%
170 {\IfValueT{#1}{\hypercolor{url}{#1}}\href{#2#3}{\texttt{#3}}}}
171
172 \def\pkgcolor{black}
173 \NewDocumentCommand\pkg{O{\pkgcolor}m}{{%
174 \hypercolor{url}{#1}%
175 \href{https://ctan.org/pkg/#2}{\texttt{#2}}}}
176
177 \NewDocumentCommand\Href{O{Hyperlink}mm}{{\hypercolor{url}{#1}\href{#2}{#3}}}