File: coqnotations.sty

package info (click to toggle)
coq-doc 8.16.1-1
  • links: PTS, VCS
  • area: non-free
  • in suites: bookworm
  • size: 42,788 kB
  • sloc: ml: 219,673; sh: 4,035; python: 3,372; ansic: 2,529; makefile: 728; lisp: 279; javascript: 87; xml: 24; sed: 2
file content (93 lines) | stat: -rw-r--r-- 3,368 bytes parent folder | download | duplicates (2)
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
% The LaTeX generator wraps all custom spans in \DUrole{class}{contents}.  That
% command then checks for another command called \DUroleclass.

% Most of our CSS class names have dashes, so we need ‘\csname … \endcsname’

% <magic>
% \def\newcssclass#1#2{\expandafter\def\csname DUrole#1\endcsname ##1{#2}}
% </magic>

\RequirePackage{adjustbox}
\RequirePackage{xcolor}
\RequirePackage{amsmath}

\definecolor{nbordercolor}{HTML}{AAAAAA}
\definecolor{nbgcolor}{HTML}{EAEAEA}
\definecolor{nholecolor}{HTML}{4E9A06}

\newlength{\nscriptsize}
\setlength{\nscriptsize}{0.8em}

\newlength{\nboxsep}
\setlength{\nboxsep}{2pt}

\newcommand*{\scriptsmallsquarebox}[1]{%
  % Force width
  \makebox[\nscriptsize]{%
    % Force height and center vertically
    \raisebox{\dimexpr .5\nscriptsize - .5\height \relax}[\nscriptsize][0pt]{%
      % Cancel depth
      \raisebox{\depth}{#1}}}}
\newcommand*{\nscriptdecoratedbox}[2][]{\adjustbox{cfbox=nbordercolor 0.5pt 0pt,bgcolor=nbgcolor}{#2}}
\newcommand*{\nscriptbox}[1]{\nscriptdecoratedbox{\scriptsmallsquarebox{\textbf{#1}}}}
\newcommand*{\nscript}[2]{\text{\hspace{-.5\nscriptsize}\raisebox{-#1\nscriptsize}{\nscriptbox{\small#2}}}}
\newcommand*{\nsup}[1]{^{\nscript{0.15}{#1}}}
\newcommand*{\nsub}[1]{_{\nscript{0.35}{#1}}}
\newcommand*{\nnotation}[1]{#1}
\newcommand*{\nbox}[1]{\adjustbox{cfbox=nbordercolor 0.5pt \nboxsep,bgcolor=nbgcolor}{#1}}
\newcommand*{\nrepeat}[1]{\text{\nbox{#1\hspace{.5\nscriptsize}}}}
\newcommand*{\nwrapper}[1]{\ensuremath{\displaystyle#1}} % https://tex.stackexchange.com/questions/310877/
\newcommand*{\nhole}[1]{\textit{\color{nholecolor}#1}}

% <magic>
% Make it easier to define new commands matching CSS classes
\newcommand{\newcssclass}[2]{%
  \expandafter\def\csname DUrole#1\endcsname##1{#2}
}
% </magic>

% https://tex.stackexchange.com/questions/490262/
\def\naltsep{}
\newsavebox{\nsavedalt}
\newlength{\naltvruleht}
\newlength{\naltvruledp}
\def\naltvrule{\smash{\vrule height\naltvruleht depth\naltvruledp}}
\newcommand{\nalternative}[2]{%
  % First measure the contents of the box without the bar
  \bgroup%
  \def\naltsep{}%
  \savebox{\nsavedalt}{#1}%
  \setlength{\naltvruleht}{\ht\nsavedalt}%
  \setlength{\naltvruledp}{\dp\nsavedalt}%
  \addtolength{\naltvruleht}{#2}%
  \addtolength{\naltvruledp}{#2}%
  % Then redraw it with the bar
  \def\naltsep{\naltvrule}%
  #1\egroup}

\newcssclass{notation-sup}{\nsup{#1}}
\newcssclass{notation-sub}{\nsub{#1}}
\newcssclass{notation}{\nnotation{\textbf{#1}}}
\newcssclass{repeat}{\nrepeat{#1}}
\newcssclass{repeat-wrapper}{\nwrapper{#1}}
\newcssclass{repeat-wrapper-with-sub}{\nwrapper{#1}}
\newcssclass{hole}{\nhole{#1}}
\newcssclass{alternative}{\nalternative{\nbox{#1}}{0pt}}
\newcssclass{alternative-block}{#1}
\newcssclass{repeated-alternative}{\nalternative{#1}{\nboxsep}}
\newcssclass{alternative-separator}{\quad\naltsep{}\quad}
\newcssclass{prodn-table}{%
  \begin{savenotes}
  \sphinxattablestart
  \begin{tabulary}{\linewidth}[t]{lLLL}
  #1
  \end{tabulary}
  \par
  \sphinxattableend
  \end{savenotes}}
% latex puts targets 1 line below where they should be; prodn-target corrects for this
\newcssclass{prodn-target}{\raisebox{\dimexpr \nscriptsize \relax}{#1}}
\newcssclass{prodn-cell-nonterminal}{#1 &}
\newcssclass{prodn-cell-op}{#1 &}
\newcssclass{prodn-cell-production}{#1 &}
\newcssclass{prodn-cell-tag}{#1\\}