summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/dashundergaps/dashundergaps.sty
blob: 61587cc0d963251b1426fe88ca07fa31ceb8d5d7 (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
%%
%% This is file `dashundergaps.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% dashundergaps.dtx  (with options: `package')
%% 
%% This is a generated file.
%% 
%% Copyright 2018-2021 Frank Mittelbach
%% 
%% This file was generated from file(s) of the LaTeX `dashundergaps Bundle'.
%% --------------------------------------------------------------------------
%% 
%% It may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3c
%% 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.3c or later is part of all distributions of LaTeX
%% version 2005/12/01 or later.
%% 
%% This file may only be distributed together with a copy of the LaTeX
%% `dashundergaps Bundle'. You may however distribute the `dashundergaps Bundle'
%% without such generated files.
%% 
%% The newest sources can be found below
%% 
%%    https://github.com/FrankMittelbach/fmitex/
%% 
%% where one can also log issues in case there are any.
%% 
%% 
%% File: dashundergaps.dtx (C) Copyright 2018-2021 Frank Mittelbach

\def\dashundergapsdate   {2021-03-05}    % don't forget to also adjust build.lua!
\def\dashundergapsversion{v2.0h}

\RequirePackage[normalem]{ulem}
\protected\def\dotuline{\leavevmode\bgroup
  \UL@setULdepth
  \ifx\UL@on\UL@onin \advance\ULdepth2\p@\fi
  \markoverwith{\begingroup
     \lower\ULdepth\hbox{\normalfont \kern.1em .\kern.04em}%
     \endgroup}%
  \ULon}
\protected\def\uwave{\leavevmode\bgroup
  \UL@setULdepth
  \advance\ULdepth 0.6\p@
  \markoverwith{\lower\ULdepth\hbox{\sixly \char58}}\ULon}
\def\fmdug@ublank{\bgroup\let\UL@leadtype\@empty\ULon}
\def\UL@dischyp{\global\setbox\UL@hyphenbox\hbox
   {\ifnum \hyphenchar\font<\z@ \string-\else \char\hyphenchar\font \fi}%
   \kern\wd\UL@hyphenbox \LA@penalty\@M
   \UL@stop \kern-\wd\UL@hyphenbox
   \discretionary{\fmdug@box\UL@hyphenbox}{}{}\UL@start}
\def\UL@putbox{\ifx\UL@start\@empty \else % not inner
  \vrule\@width\z@ \LA@penalty\@M
  {\UL@skip\wd\UL@box \UL@leaders \kern-\UL@skip}%
  \fmdug@box\UL@box  \fi}
\let\fmdug@box\box

\RequirePackage{l3keys2e}
\@ifpackagelater{expl3}{2018-06-24}
  {}
  {%
    \PackageError{dashundergaps}{Support package l3kernel too old}
      {%
        Please install an up to date version of l3kernel\MessageBreak
        using your TeX package manager or from CTAN.\MessageBreak
        \MessageBreak
        Loading dashundergaps will abort!%
      }%
    \endinput
  }
\ProvidesExplPackage{dashundergaps}
                    {\dashundergapsdate}
                    {\dashundergapsversion}
                    {Dashing and underlining phantom text}

\DeclareDocumentCommand \gap { som }
   {
     \protected@edef\next{#3}
     \__fmdug_gap:nno {#1}{#2}{ \next } }
\NewDocumentCommand \dashundergapssetup { m }
  { \keys_set:nn {fmdug} {#1} \ignorespaces }
\DeclareDocumentCommand \TeacherModeOn  {}
                        { \bool_set_true:N \l__fmdug_teacher_bool }
\DeclareDocumentCommand \TeacherModeOff {}
                        { \bool_set_false:N \l__fmdug_teacher_bool }
\newcounter{gapnumber}
\newcounter{totalgapnumber}

\dim_new:N \l__fmdug_extend_dim
\tl_new:N \l__fmdug_extra_left_gap_tl
\tl_new:N \l__fmdug_extra_right_gap_tl
\tl_new:N \l__fmdug_gap_format_tl
\tl_new:N \l__fmdug_teacher_gap_format_tl
\msg_new:nnn {dashundergaps} {deprecated}
  { The~ #1~ `#2'~ you~ used~ \msg_line_context: \ is~ deprecated~ and~
    there~ is~ no~ replacement.~ Since~ I~ will~ not~ guarantee~ that~
    #1~ `#2'~ will~ be~ kept~ forever~ I~ strongly~ encourage~ you~
    to~ remove~ it~ from~ your~ document. }
\msg_new:nnnn {dashundergaps} {nested}
  { The~ \gap command~ can't~ be~ nested! }
  { Nesting~ doesn't~ make~ much~ sense~ as~ the~ inner~ one~
    wouldn't~ be~ visible.~ ~ To~ allow~ further~ processing~ it~ is~
    handled~ as~ if~ it~ hasn't~ been~ asked~ for. }
\msg_new:nnnn {dashundergaps} {gap-format-value}
  { Unknown~ value~ for~ key~ '#1 gap-format'! }
  { Supported~ values~ are~ 'underline',~ 'double-underline',\\
    'dash',~ 'dot',~ 'wave'~ or~ 'blank'. }
\keys_define:nn {fmdug}
     {
       % ====================================
      ,teacher-mode      .bool_set:N = \l__fmdug_teacher_bool
      ,teacher-mode      .default:n  = true
      ,teacher-mode      .initial:n  = false
       % ------------------
      ,gap-mode  .bool_set_inverse:N = \l__fmdug_teacher_bool
       % ====================================
      ,gap-format
         .choice:
      ,gap-format / underline
         .code:n = \tl_set:Nn \l__fmdug_gap_format_tl
                              { \__fmdug_gap_format_adjust:n{.4pt} \uline }
      ,gap-format / double-underline
         .code:n = \tl_set:Nn \l__fmdug_gap_format_tl
                              { \__fmdug_gap_format_adjust:n{2pt} \uuline }
      ,gap-format / dash
         .code:n = \tl_set:Nn \l__fmdug_gap_format_tl
                           { \__fmdug_gap_format_adjust:n{0pt} \dashuline }
      ,gap-format / dot
         .code:n = \tl_set:Nn \l__fmdug_gap_format_tl
                         { \__fmdug_gap_format_adjust:n{-.08ex} \dotuline }
      ,gap-format / wave
         .code:n = \tl_set:Nn \l__fmdug_gap_format_tl
                              { \__fmdug_gap_format_adjust:n{1pt} \uwave }
      ,gap-format / blank
         .code:n = \tl_set:Nn \l__fmdug_gap_format_tl { \fmdug@ublank  }
      ,gap-format / unknown
         .code:n = \msg_error:nnn{dashundergaps}{gap-format-value}{}
      ,gap-format
         .initial:n = underline
       % ====================================
       ,gap-format-adjust
         .choice:
       ,gap-format-adjust / true
         .code:n = \cs_set:Npn \__fmdug_gap_format_adjust:n ##1
                               { \setlength\ULdepth {##1} }
       ,gap-format-adjust / false
         .code:n = \cs_set_eq:NN \__fmdug_gap_format_adjust:n \use_none:n
      ,gap-format-adjust
         .default:n = true
      ,gap-format-adjust
         .initial:n = true
      ,adjust .meta:n = { gap-format-adjust }
       % ====================================
      ,teacher-gap-format
         .choice:
     ,teacher-gap-format / underline
         .code:n = \tl_set:Nn \l__fmdug_teacher_gap_format_tl { \uline }
      ,teacher-gap-format / double-underline
         .code:n = \tl_set:Nn \l__fmdug_teacher_gap_format_tl { \uuline }
      ,teacher-gap-format / dash
         .code:n = \tl_set:Nn \l__fmdug_teacher_gap_format_tl { \dashuline }
      ,teacher-gap-format / dot
         .code:n = \tl_set:Nn \l__fmdug_teacher_gap_format_tl { \dotuline }
      ,teacher-gap-format / wave
         .code:n = \tl_set:Nn \l__fmdug_teacher_gap_format_tl { \uwave }
      ,teacher-gap-format / blank
         .code:n = \tl_set:Nn \l__fmdug_teacher_gap_format_tl { \fmdug@ublank }
      ,teacher-gap-format / unknown
         .code:n = \msg_error:nnn{dashundergaps}{gap-format-value}{teacher-}
      ,teacher-gap-format
         .initial:n = blank
       % ====================================
      ,gap-widen         .bool_set:N = \l__fmdug_gap_widen_bool
      ,gap-widen         .default:n  = true
      ,gap-widen         .initial:n  = false
       % ------------------
      ,widen                 .meta:n = { gap-widen }
       % ------------------
      ,gap-extend-minimum .dim_set:N = \l__fmdug_gap_min_dim
      ,gap-extend-minimum .initial:n = 20pt
       % ------------------
      ,gap-extend-percent .tl_set:N  = \l__fmdug_gap_percent_tl
      ,gap-extend-percent .initial:n = 20
       % ====================================
      ,gap-numbers        .bool_set:N = \l__fmdug_number_bool
      ,gap-numbers        .default:n  = true
      ,gap-numbers        .initial:n  = true
       % ------------------
      ,numbers                .meta:n = { gap-numbers }
       % ------------------
      ,gap-number-format .tl_set:N    = \l__fmdug_gapnum_format_tl
      ,gap-number-format .initial:n   = \textnormal{\space (\thegapnumber)}
       % ====================================
      ,display-total-gaps .bool_gset:N = \g__fmdug_display_total_gaps_bool
      ,display-total-gaps   .default:n = true
      ,display-total-gaps   .initial:n = false
       % ====================================
      ,gap-font    .tl_set:N = \l__fmdug_font_tl
      ,gap-font   .default:n =
      ,gap-font   .initial:n = \bfseries
       % ====================================
      ,teachermode   .meta:n =  { teacher-mode }
      ,dash          .meta:n =  { gap-format = dash }
      ,dot           .meta:n =  { gap-format = dot }
      ,displaynbgaps .meta:n =  { display-total-gaps }
       % ------------------
      ,phantomtext
         .code:n = \msg_warning:nnnn{dashundergaps}{deprecated}
                                    {option}{phantomtext}
       % ====================================
     }
\cs_new:Npn\__fmdug_gap:nnn #1#2#3 {
  \group_begin:
    \l__fmdug_font_tl
    \cs_set:Npn \__fmdug_gap:nnn ##1##2##3
      {
        \msg_error:nn{dashundergaps}{nested}
        ##3
      }
    \stepcounter{totalgapnumber}
    \bool_xor:nnT { #1 } { \l__fmdug_number_bool }
      { \refstepcounter{gapnumber} }
    \bool_if:NTF \l__fmdug_gap_widen_bool
      {
        \settowidth \l__fmdug_extend_dim {#3}
        \dim_set:Nn \l__fmdug_extend_dim
                  { \l__fmdug_gap_percent_tl \l__fmdug_extend_dim / 200 }
       \dim_compare:nNnT \l__fmdug_extend_dim < { .5\l__fmdug_gap_min_dim }
          { \dim_set:Nn \l__fmdug_extend_dim { .5\l__fmdug_gap_min_dim } }
       \tl_set:Nn \l__fmdug_extra_left_gap_tl
          { \hbox_to_wd:nn\l__fmdug_extend_dim{} \allowbreak }
       \tl_set:Nn \l__fmdug_extra_right_gap_tl
          { \allowbreak \hbox_to_wd:nn\l__fmdug_extend_dim{} }
      }
      {
        \tl_clear:N \l__fmdug_extra_left_gap_tl
        \tl_clear:N \l__fmdug_extra_right_gap_tl
      }
    \bool_if:NTF \l__fmdug_teacher_bool
      { \l__fmdug_teacher_gap_format_tl }
      {
        \cs_set:Npn   \fmdug@box ##1 {\hbox_to_wd:nn{\box_wd:N ##1}{}}
        \str_case:nnF {#2}
            {
              {u} { \__fmdug_gap_format_adjust:n{.4pt}   \uline  }
              {d} { \__fmdug_gap_format_adjust:n{2pt}    \uuline }
              {w} { \__fmdug_gap_format_adjust:n{1pt}    \uwave  }
              {b} { \fmdug@ublank }
              {.} { \__fmdug_gap_format_adjust:n{-.08ex} \dotuline }
              {-} { \__fmdug_gap_format_adjust:n{0pt}   \dashuline }
            }
            { \l__fmdug_gap_format_tl }
      }
    {\l__fmdug_extra_left_gap_tl #3 \l__fmdug_extra_right_gap_tl }
    \bool_xor:nnT { #1 } { \l__fmdug_number_bool }
                  { \l__fmdug_gapnum_format_tl }
  \group_end:
}
\cs_generate_variant:Nn \__fmdug_gap:nnn {nno}
\cs_new:Npn \__fmdug_display_total_gaps: {
  \vfill \centering
  \bfseries Total~ Gaps:~ \thetotalgapnumber
}
\AtEndDocument{
  \bool_if:NT \g__fmdug_display_total_gaps_bool
              \__fmdug_display_total_gaps:
}
\ProcessKeysPackageOptions{fmdug}
\endinput
%%
%% End of file `dashundergaps.sty'.