diff options
author | Karl Berry <karl@freefriends.org> | 2018-06-24 21:57:27 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2018-06-24 21:57:27 +0000 |
commit | c4bb697eced0fab994df2daf28104ba68e977bcc (patch) | |
tree | 2325a1699a36aa9597b42fd85b0c51de0f44adb1 /Master/texmf-dist/tex | |
parent | dd42876a9fee2d151acc9477f3f9faf2e1475ce2 (diff) |
dashundergaps (24jun18)
git-svn-id: svn://tug.org/texlive/trunk@48081 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r-- | Master/texmf-dist/tex/latex/dashundergaps/dashundergaps.sty | 289 |
1 files changed, 218 insertions, 71 deletions
diff --git a/Master/texmf-dist/tex/latex/dashundergaps/dashundergaps.sty b/Master/texmf-dist/tex/latex/dashundergaps/dashundergaps.sty index fb6e197aea2..17db0222797 100644 --- a/Master/texmf-dist/tex/latex/dashundergaps/dashundergaps.sty +++ b/Master/texmf-dist/tex/latex/dashundergaps/dashundergaps.sty @@ -1,78 +1,225 @@ -%% This is file `dashundergaps.sty' v1.2 by Merciadri Luca. - -\NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{dashundergaps}[2010/01/20 Dashing and underlining (phantom) text] -\PackageInfo{dashundergaps}{This is DashUnderGaps by Merciadri Luca.} - -\RequirePackage{ifthen}[1994/06/01] -\PassOptionsToPackage{normalem}{ulem} -\RequirePackage{ulem} -\newboolean{dot} % false at start -\newboolean{dash} % false at start - - -\DeclareOption{dash}{% -\typeout{Dashing mode activated!} -\setboolean{dash}{true} -\providecommand{\dashuline}{\bgroup -\ifdim\ULdepth=\maxdimen -\settodepth\ULdepth{(j}\advance\ULdepth.4pt\fi -\markoverwith{\kern.15em -\vtop{\kern\ULdepth \hrule width .3em}% -\kern.15em}\ULon} -} - - -\DeclareOption{dot}{% -\typeout{Dotting mode activated!} -\setboolean{dot}{true} -\providecommand{\dotuline}{\bgroup -\ifdim\ULdepth=\maxdimen -\settodepth\ULdepth{(j}\advance\ULdepth.4pt\fi -\markoverwith{\begingroup -\advance\ULdepth0.08ex -\lower\ULdepth\hbox{\kern.15em .\kern.1em}% -\endgroup}\ULon} -} - - -\DeclareOption{phantomtext}{% -\typeout{Phantom mode activated! All the gaps will be filled.} -\newboolean{teachernotes} % false at start -\newcounter{nb-gaps} -\setcounter{nb-gaps}{1} -\newcounter{nth-gaps} -\setcounter{nth-gaps}{1} +%% +%% 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 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 +%% `Tools Bundle'. You may however distribute the LaTeX `Tools 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 Frank Mittelbach +\RequirePackage[normalem]{ulem} +\def\dotuline{\bgroup + \UL@setULdepth + \markoverwith{\begingroup + \advance\ULdepth0.08ex + \lower\ULdepth\hbox{\normalfont \kern.1em .\kern.04em}% + \endgroup}% + \ULon} + +\def\@ublank{\bgroup\let\UL@leadtype\@empty\ULon} \def\phantom@putbox{\ifx\UL@start\@empty \else % not inner \vrule\@width\z@ \LA@penalty\@M {\UL@skip\wd\UL@box \UL@leaders \kern-\UL@skip}% - \hbox to\wd\UL@box{}\fi}% - -\providecommand{\gap}[1]{% -\bgroup -\let\UL@putbox=\phantom@putbox -\ifthenelse{\boolean{teachernotes}} -{\textbf{#1} (\arabic{nth-gaps})} -{\ifthenelse{\boolean{dash} \AND \boolean{dot}}{\uline{#1}(\arabic{nth-gaps})}{\ifthenelse{\boolean{dash}}{\dashuline{#1} (\arabic{nth-gaps})}{\ifthenelse{\boolean{dot}}{\dotuline{#1} (\arabic{nth-gaps})}{\uline{#1} (\arabic{nth-gaps})}}} + \hb@xt@\wd\UL@box{}% +\fi} + +\RequirePackage{xparse,l3keys2e} +\ProvidesExplPackage + {dashundergaps} + {2018/06/24} + {v2.0a} + {Dashing and underlining (phantom) text} + +\DeclareDocumentCommand \gap { som } { \__fmdug_gap:nnn {#1}{#2}{#3} } +\NewDocumentCommand \dashundergapssetup { m } + { \keys_set:nn {fmdug} {#1} \ignorespaces } +\DeclareDocumentCommand \TeacherModeOn {} + { \bool_set_true:N \l__fmdug_teacher_bool } +\DeclareDocumentCommand \TeacherModeOff {} + { \bool_set_true: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 +\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~ tested! } + { Nesting~ doesn't~ make~ much~ sense~ as~ the~ inner~ one~ wouldn't~ be~ + visible.~ ~ To~ allow~ continuation~ it~ is~ handled~ as~ if~ it~ wasn't~ + been~ asked~ for. } +\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 { \uline } + ,gap-format / dash + .code:n = \tl_set:Nn \l__fmdug_gap_format_tl { \dashuline } + ,gap-format / dot + .code:n = \tl_set:Nn \l__fmdug_gap_format_tl { \dotuline } + ,gap-format / wave + .code:n = \tl_set:Nn \l__fmdug_gap_format_tl { \uwave } + ,gap-format / blank + .code:n = \tl_set:Nn \l__fmdug_gap_format_tl { \@ublank } + ,gap-format / unknown + .code:n = \tl_set:Nn \l__fmdug_gap_format_tl { #1 } + ,gap-format + .initial:n = underline + % ==================================== + ,teacher-gap-format + .choice: + ,teacher-gap-format / underline + .code:n = \tl_set:Nn \l__fmdug_teacher_gap_format_tl { \uline } + ,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 { \@ublank } + ,teacher-gap-format / unknown + .code:n = \tl_set:Nn \l__fmdug_teacher_gap_format_tl { #1 } + ,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 = 10pt + % ------------------ + ,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_eq:NN \UL@putbox \phantom@putbox + \str_case:nnF {#2} + { + {u} { \uline } + {w} { \uwave } + {b} { \@ublank } + {.} { \dotuline } + {-} { \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: } -\addtocounter{nb-gaps}{1} -\addtocounter{nth-gaps}{1} -\egroup -}} - - -\DeclareOption{teachernotes}{% -\typeout{Phantom mode deactivated! All the gaps will be filled with their content.} -\setboolean{teachernotes}{true} +\cs_new:Npn \__fmdug_display_total_gaps: { + \vfill \centering + \bfseries Total~ Gaps:~ \thetotalgapnumber } - - -\DeclareOption{displaynbgaps}{% -\typeout{Gaps counting mode activated!} -\addtocounter{nb-gaps}{-1} -\AtEndDocument{\vfill \centering \bfseries GAPS: \arabic{nb-gaps}.} +\AtEndDocument{ + \bool_if:NT \g__fmdug_display_total_gaps_bool + \__fmdug_display_total_gaps: } - -\ProcessOptions\relax - +\ProcessKeysPackageOptions{fmdug} +\endinput +%% +%% End of file `dashundergaps.sty'. |