summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/lualatex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/lualatex')
-rw-r--r--Master/texmf-dist/tex/lualatex/cloze/cloze.sty118
1 files changed, 116 insertions, 2 deletions
diff --git a/Master/texmf-dist/tex/lualatex/cloze/cloze.sty b/Master/texmf-dist/tex/lualatex/cloze/cloze.sty
index bdb2eafeaaa..e092711f518 100644
--- a/Master/texmf-dist/tex/lualatex/cloze/cloze.sty
+++ b/Master/texmf-dist/tex/lualatex/cloze/cloze.sty
@@ -22,11 +22,21 @@
%%
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{cloze}
- [2016/06/23 v1.2 Package to typeset cloze worksheets or cloze tests]
-\RequirePackage{fontspec,luatexbase-mcb,kvoptions,xcolor}
+ [2020/05/20 v1.4 Package to typeset cloze worksheets or cloze tests]
+\RequirePackage{fontspec}
+\RequirePackage{luatexbase-mcb}
+\RequirePackage{kvoptions}
+\RequirePackage{setspace}
+\RequirePackage{xcolor}
+\RequirePackage{xparse}
+\RequirePackage{stackengine}
+\RequirePackage{ulem}
+\normalem
+\RequirePackage{transparent}
\directlua{
cloze = require('cloze')
}
+\newif\ifclozeshow\clozeshowtrue
\def\cloze@set@to@global{%
\directlua{cloze.set_is_global(true)}%
}
@@ -67,25 +77,35 @@
}
\DeclareStringOption{align}
\define@key{CLZ}{align}[]{\cloze@set@option[align]{#1}}
+\DeclareStringOption{boxheight}
+\define@key{CLZ}{boxheight}[]{\cloze@set@option[boxheight]{#1}}
+\DeclareStringOption{boxwidth}
+\define@key{CLZ}{boxwidth}[]{\cloze@set@option[boxwidth]{#1}}
\DeclareStringOption{distance}
\define@key{CLZ}{distance}[]{\cloze@set@option[distance]{#1}}
\DeclareVoidOption{hide}{%
+ \clozeshowfalse%
\cloze@set@option[hide]{true}%
\cloze@set@option[show]{false}%
}
\DeclareStringOption{linecolor}
\define@key{CLZ}{linecolor}[]{%
\cloze@set@option[linecolor]{\cloze@color{#1}}%
+ \cloze@set@option[linecolor_name]{#1}%
}
\DeclareStringOption{margin}
\define@key{CLZ}{margin}[]{\cloze@set@option[margin]{#1}}
\DeclareVoidOption{show}{%
+ \clozeshowtrue%
\cloze@set@option[show]{true}%
\cloze@set@option[hide]{false}%
}
+\DeclareStringOption{spacing}
+\define@key{CLZ}{spacing}[]{\cloze@set@option[spacing]{#1}}
\DeclareStringOption{textcolor}
\define@key{CLZ}{textcolor}[]{%
\cloze@set@option[textcolor]{\cloze@color{#1}}%
+ \cloze@set@option[textcolor_name]{#1}%
}
\DeclareStringOption{thickness}
\define@key{CLZ}{thickness}[]{\cloze@set@option[thickness]{#1}}
@@ -129,6 +149,18 @@
}%
\cloze@stop@marker{fix}%
}
+\newcommand{\clozenol}[2][]{%
+ {%
+ \cloze@set@local@options{#1}%
+ \clozefont\relax%
+ \ifclozeshow%
+ \color{\directlua{tex.print(cloze.get_value('textcolor_name'))}}%
+ \else%
+ \color{white}%
+ \fi%
+ #2%
+ }%
+}
\newenvironment{clozepar}[1][]%
{%
\par%
@@ -141,9 +173,53 @@
\par%
\directlua{cloze.unregister('par')}%
}
+\newcommand{\cloze@get@value}[1]{%
+ \directlua{
+ tex.print(cloze.get_value('#1'))
+ }%
+}
+\newsavebox{\cloze@box}
+\NewDocumentEnvironment{clozebox}{ s O{} +b}{%
+ \cloze@set@local@options{#2}%
+ \noindent%
+ \begin{lrbox}{\cloze@box}%
+ \directlua{
+ local boxheight = cloze.get_value('boxheight')
+ local boxwidth = cloze.get_value('boxwidth')
+ if boxheight then
+ tex.print('\\begin{minipage}[t][' .. boxheight .. '][t]{' .. boxwidth .. '}')
+ else
+ tex.print('\\begin{minipage}[t]{' .. boxwidth .. '}')
+ end
+ }
+ \clozefont\relax%
+ \ifclozeshow%
+ \color{\directlua{tex.print(cloze.get_value('textcolor_name'))}}#3%
+ \else%
+ \color{white}#3%
+ \fi%
+ \end{minipage}%
+ \end{lrbox}%
+ \IfBooleanTF{#1}%
+ {\usebox{\cloze@box}}%
+ {\fbox{\usebox{\cloze@box}}}%
+}{}
+\newenvironment{clozespace}[1][]%
+{%
+ \cloze@set@local@options{#1}%
+ \begin{spacing}{\directlua{tex.print(cloze.get_value('spacing'))}}%
+}{\end{spacing}}
\newcommand{\clozefil}[2][]{%
\cloze[#1]{#2}\clozelinefil[#1]%
}
+\newcommand{\clozeextend}[1][1]{%
+ \directlua{
+ local loop = #1
+ for variable = 1, loop do
+ tex.print(' \string\\hspace{1em} \string\\strut')
+ end
+ }
+}
\newcommand{\clozeline}[1][]{%
\cloze@set@local@options{#1}%
\directlua{cloze.line()}%
@@ -154,6 +230,44 @@
\directlua{cloze.linefil()}%
\strut%
}
+\newcommand{\cloze@text@color}[1]{%
+ \textcolor%
+ {\directlua{tex.print(cloze.get_value('textcolor_name'))}}%
+ {#1}%
+}
+\newcommand\cloze@strike@line{%
+ \bgroup%
+ \markoverwith{%
+ \cloze@text@color{%
+ \rule[0.5ex]{2pt}{1pt}%
+ }%
+ }%
+ \ULon%
+}
+\newcommand{\clozestrike}[3][]{%
+ \cloze@set@local@options{#1}%
+ \ifclozeshow%
+ \stackengine%
+ {\Sstackgap}% \Sstackgap or \Lstackgap or \stackgap or stacklength
+ {\cloze@strike@line{#2}}% anchor
+ {\cloze@text@color{\clozefont{}#3}}% item
+ {O}% O or U
+ {c}% \stackalignment or l or c or r
+ {\quietstack}% \quietstack or T or F
+ {T}% \useanchorwidth or T or F
+ {\stacktype}% \stacktype or S or L
+ \else%
+ \stackengine%
+ {\Sstackgap}% \Sstackgap or \Lstackgap or \stackgap or stacklength
+ {#2}% anchor
+ {\texttransparent{0}{\clozefont{}#3}}% item
+ {O}% O or U
+ {c}% \stackalignment or l or c or r
+ {\quietstack}% \quietstack or T or F
+ {T}% \useanchorwidth or T or F
+ {\stacktype}% \stacktype or S or L
+ \fi%
+}
\endinput
%%
%% End of file `cloze.sty'.