-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfillwith.dtx
More file actions
746 lines (740 loc) · 25 KB
/
Copy pathfillwith.dtx
File metadata and controls
746 lines (740 loc) · 25 KB
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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
% \iffalse meta-comment
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% fillwith.dtx
% Additions and changes Copyright (C) 2024-2025 Clea F. Rees.
% Code from skeleton.dtx Copyright (C) 2015-2024 Scott Pakin (see below).
%
% This work 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
% https://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions of LaTeX
% version 2008-05-04 or later.
%
% This work has the LPPL maintenance status \muaintained'.
%
% The Current Maintainer of this work is Clea F. Rees.
%
% This work consists of all files listed in manifest.txt.
%
% The file fillwith.dtx is a derived work under the terms of the
% LPPL. It is based on version 2.4 of skeleton.dtx which is part of
% dtxtut by Scott Pakin. A copy of dtxtut, including the
% unmodified version of skeleton.dtx is available from
% https://www.ctan.org/pkg/dtxtut and released under the LPPL.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \fi
%
% \iffalse
%<*driver>
\RequirePackage{svn-prov}
\ProvidesFileSVN{$Id: fillwith.dtx 11374 2025-11-30 06:32:40Z cfrees $}[v0.3 \revinfo][\filename: \filebase]
\DefineFileInfoSVN[fillwith]
\GetFileInfoSVN*
% ref. ateb Max Chernoff: https://tex.stackexchange.com/a/723294/
\def\MakePrivateLetters{\makeatletter\ExplSyntaxOn\endlinechar13}
\documentclass[british,a4paper]{ltxdoc}
% ltnews42 / ateb David Carlisle: https://tex.stackexchange.com/a/754799/ (sylwad Ulrike Fischer rhywle ond alla i ddim canfod o hyd iddo fe)
\partokencontext=0
\usepackage{babel}
\usepackage[tt={monowidth,lining,tabular},sf={lining,proportional},rm={lining,proportional}]{cfr-lm}
\usepackage{fillwith}
\usepackage{parskip}
\usepackage{verbatim}
\usepackage{graphicx}
\usepackage{xurl}
% sicrhau hyperindex=false: llwytho CYN bookmark
\usepackage{hypdoc}% ateb Ulrike Fischer: https://tex.stackexchange.com/a/695555/
\usepackage{bookmark}
\usepackage{cleveref}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
%^^A \OnlyDescription
%^^A \ExplSyntaxOn
%^^A \makeatletter
\DoNotIndex{\verb,\ProvidesPackageSVN,\NeedsTeXFormat,\ProcessKeyOptions,\ExplSyntaxOn,\ExplSyntaxOff,\RequirePackage,\NeedsTeXFormat,\DefineFileInfoSVN,\GetInfoSVN,\@ifundefined,\@ifl@t@r\ExplLoaderFileDate,\endinput,\PackageError,\PackageWarning,\PackageInfo,\keys_define:nn,\keys_set:nn,\ProcessKeysOptionns,\author,\title,\maketitle,\date,\revinfo,\ProcessKeysOptions,\MessageBreak,\fmtversion,\documentclass,\ExplLoaderFileDate,\filebase,\fileversion,\fileinfo,\filebase:,\filedate,\documentclass,\@ifl@t@r,\begin,\end,\item,\IfFormatAtLeastTF}
%^^A \makeatother
%^^A \ExplSyntaxOff
\definecolor{strawberry}{rgb}{1.000,0.000,0.502}
\definecolor{blueberry}{rgb}{0.000,0.000,1.000}
\definecolor{moss}{rgb}{0.000,0.502,0.251}
\hypersetup{%
colorlinks=true,
citecolor={moss},
extension=pdf,
linkcolor={strawberry},
linktocpage=true,
pdfcreator={TeX},
pdfproducer={pdfeTeX},
urlcolor={blueberry}%
}
\NewDocElement[%
idxtype=opt.,
idxgroup=options,
printtype=\textit{opt.},
]{Opt}{option}
\NewDocumentCommand \val { m }
{%
{\ttfamily =\,\meta{#1}}%
}
\ExplSyntaxOn
\NewDocumentCommand \vals { m }
{
{
\ttfamily = \,
\clist_use:nn { #1 } { \textbar }
}
}
\ExplSyntaxOff
\setcounter{IndexColumns}{2}
\makeatletter
\def\@xobeysp{\leavevmode\penalty100\ }
\makeatother
\begin{document}
\DocInput{\filename}
\end{document}
%</driver>
% \fi
% \title{\filebase{} \filerev}
% \author{Clea F. Rees}
% \date{\filedate}
% \maketitle
% \begin{abstract}
% A small package originally based on \href{https://tex.stackexchange.com/a/241139/}{Harish Kumar's answer} to a question I asked on \TeX{} SE\footnote{%
% See \href{https://tex.stackexchange.com/a/241139/}{tex.stackexchange.com/a/241139/}.%
% }.
% The intended purpose was the creation of worksheets for students where I would like \LaTeX{} to use the available vertical space to provide lined areas for answers.
% Since then, the code has been (partially) rewritten in \pkg{expl3} and extended in response to both my own needs and others' questions on \TeX{} SE.
% The package aims to do one thing: to fill a vertical space in the same way as, say, \verb|\vfill|, but with some kind of ‘filler’ rather than empty space.
% Currently, the package supports solid rules or dotted lines.
% The remainder of the current line may optionally be filled in the same way and the ‘filler’ may be coloured if desired.
%
% Lines may optionally be numbered, though the numbered versions should not be used to fill long stretches as they are extremely inefficient.
% \textbf{Numbered fills are highly experimental and not recommended for use in ‘real’ documents.}
% That is, it seems to work, but I recommend using an alternative package or solution if you need a reliable numbering mechanism.
% \end{abstract}
%
% \section{Load}\label{sec:pkg}
% To use the package simply load it in your preamble in the usual way.
%
% \iffalse
%<*verb>
% \fi
\begin{verbatim}
\usepackage[<options>]{fillwith}
\end{verbatim}
% \iffalse
%</verb>
% \fi
%
% A small number of options may be specified when loading the package.
% See \cref{sec:config}.
%
% We start with an example in \cref{sec:ee}.
% \Cref{sec:use} describes the basic commands illustrated in this example.
% \Cref{sec:config} explains the options used by these commands, together with other customisation features of \pkg{fillwith}.
%
% \section{Example}\label{sec:ee}
%
% The code below illustrates most package features.
%
% \Cref{fig:ee1} demonstrates filling with rules.
% Note the effect of altering \texttt{fillwith ht} on line-spacing.
% \begin{figure}
% \centering
% \fbox{\includegraphics{fillwith-example.pdf}}
% \caption{Filling with rules.}\label{fig:ee1}
% \end{figure}
%
% \Cref{fig:ee2} shows dotted fillings.
% Note the use of \cmd{\fillwithset} to alter the colour.
% \begin{figure}
% \centering
% \fbox{\includegraphics[page=2]{fillwith-example.pdf}}
% \caption{Filling with dotted lines.}\label{fig:ee2}
% \end{figure}
%
% \Cref{fig:ee3} shows numbered fillings.
% Note the use of \texttt{goal ht} to divide the available vertical space more-or-less equally.
% \begin{figure}
% \centering
% \fbox{\includegraphics[page=3]{fillwith-example.pdf}}
% \caption{Filling with numbered lines.}\label{fig:ee3}
% \end{figure}
%
% \verbatiminput{fillwith-example.tex}
%
% \section{Usage}\label{sec:use}
%
% \DescribeMacro{\fillwith}\oarg{options}
% \DescribeMacro{\fillwith*}
%
% Fill vertically with current settings, optionally modified by \meta{options}.
% See \cref{sec:config} for \meta{options}.
% If used in the middle of a line, the starred form fills to the end of the line first, whereas the unstarred form does not.
%
% \DescribeMacro{\fillwithrules}\oarg{line-spacing}
% \DescribeMacro{\fillwithrules*}
%
% Convenience wrappers which just set \texttt{style = rules} and set the line-spacing to \meta{line-spacing}.
% These macros do nothing which cannot be done using \cmd{\fillwith} and \cmd{\fillwith*}.
%
% \DescribeMacro{\fillwithdottedlines}\oarg{line-spacing}
% \DescribeMacro{\fillwithdottedlines*}
%
% Convenience wrappers which just set \texttt{style = dots} and set the line-spacing to \meta{line-spacing}.
% These macros do nothing which cannot be done using \cmd{\fillwith} and \cmd{\fillwith*}.
%
% \DescribeMacro{\fillwithnolines}\oarg{options}
% \DescribeMacro{\fillwithnolines*}
%
% Fill vertically with current settings, numbering each complete line, after optionally setting \meta{options}.
% Numbering \textbf{requires} use of these commands, as opposed to the generic \cmd{\fillwith}/\cmd{\fillwith*}.
%
% \section{Customisation}\label{sec:config}
%
% Options can be set per use, locally or globally.
% A small number of options are implemented as package options (\cref{sec:pkg}).
%
% \DescribeMacro{\fillwithset}\marg{options}
% Set local or global defaults.
%
% \DescribeOpt{colour}\val{colour name}
% \DescribeOpt{color}
% \DescribeOpt{lliw}
%
% Colour to be used for (solid) rules.
%
% Initially \texttt{gray}.
% Available as a package option.
%
% \DescribeOpt{dotted color}\val{colour name}
% \DescribeOpt{dotted colour}
%
% Colour to be used for dotted lines.
%
% Initially \texttt{black}.
% Available as a package option.
%
% \DescribeOpt{cont}\vals{true,false}
%
% Whether to fill the remainder of any current line.
% Generally, users will probably prefer to use the starred command forms for local usage, but this option permits modification of the package default on a local or global basis.
%
% Initially \texttt{false}.
% Default is \texttt{true}.
%
% \DescribeOpt{fillwith~ht}\val{real positive number expressed as decimal}
%
% Multiplication factor for line-spacing.
% Typically, hand-written content requires greater spacing than typewritten content.
% This option scales the standard line-spacing.
%
% Initially \texttt{2}, which is also the default value.
% Decimal values such as \texttt{1.5} are permitted.
%
% \DescribeOpt{goal ~ ht}\val{dimension}
%
% Used only by \cmd{\fillwithnolines} and \cmd{\fillwithnolines*}.
% Sets the target dimension to fill with numbered lines.
% If unspecified, the code tries to fill the remaining vertical space on the current page.
% If more than one use of a \pkg{fillwith} macro is used on a single page, this option \textbf{must} be used for numbered fills to prevent a single instance taking (almost) all available space.
% In contrast, multiple unnumbered fills can coexist on the same page without issue --- the available space will simply be divided equally between them.
%
% Initially unset.
% No default.
%
% \DescribeOpt{no ~ font}\val{font switches}
%
% Font switches to apply when typesetting numbers for numbered fills.
%
% Initially \cmd{\normalfont}\cmd{\normalsize}, which is also the default value.
% Note the commands used here should be switches rather than text commands -- for example, use \cmd{\bfseries} rather than \cmd{\textbf} --- since the commands should not expect an argument.
%
% \DescribeOpt{style}\vals{rule,dots,line,lines,rules}
%
% Style of fill.
% \texttt{rule}, \texttt{line}, \texttt{rules} and \texttt{lines} are synonyms which all denote solid rules or lines.
% \texttt{dots} uses dotted lines rather than solid rules.
% The dots are slightly more densely packed than the standard used for dotted fills by the standard classes, as these seem a bit too widely spaced to provide ideal guidelines.
%
% Initially \texttt{dots}, which is also the default value.
%
% If an unknown value is used, the code will attempt to use two macros derived from that value.
% The first is constructed simply by preceding \meta{value} with a backslash and the second by also appending \texttt{part}.
% For example, if \texttt{style}\val{mystyle} is used, the code will try to use \cs{mystyle} and \cs{mystylepart} for complete and partial lines.
% In theory, this supports filling with somewhat arbitrary content, but the implementation is untested and \textbf{should not be used in real documents}.
%
%
% \changes{v0.0}{???}{First public release.}
% \changes{\fileversion}{\filedate}{}
%
%
% \MaybeStop{%
% \PrintChanges
% \PrintIndex
% }
%
% \section{Implementation}
%
% You do not need to read the remainder of this document in order to install or use the package.
%
% \iffalse
%<@@=fillwith>
%<*sty>
% \fi
% \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}[2021-11-15]
\RequirePackage{svn-prov}
\ProvidesPackageSVN[\filebase.sty]{$Id: fillwith.dtx 11374 2025-11-30 06:32:40Z cfrees $}[v0.0 \revinfo][\filebase: fill vertically with non-space]
% this is needed only because l3doc overwrites \fileversion and \filedate
% neither ltxdoc nor doc does this
\DefineFileInfoSVN
% \end{macrocode}
% \iffalse
% ^^A Paid â defnyddio \GetFileInfoSVN*/\GetFileInfoSVN{} yn y fan hon!!
% \fi
% \begin{macrocode}
\RequirePackage{xcolor}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% copied verbatim, excepting format from Joseph Wright's' siunitx.sty under LPPL
\@ifundefined{ExplLoaderFileDate}{%
\RequirePackage{expl3}%
}{}
% almost verbatim from siunitx.sty
\@ifl@t@r\ExplLoaderFileDate{2022-02-24}{%
}{%
\PackageError{fillwith}{Support package expl3 too old}
{%
You need to update your installation of the bundles 'l3kernel' and
'l3packages'.\MessageBreak
Loading~fillwith~will~abort!%
}%
\endinput
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\ExplSyntaxOn
\prop_gput:Nnn \g_msg_module_name_prop { fillwith } { fillwith }
% BEGIN Expl pkg option setup
\keys_define:nn { fillwith }
{
color .meta:n = {
colour = #1,
},
colour .code:n = {
\colorlet{fillwithcolour}{#1}
},
dotted ~ color .meta:n = {
dotted colour = #1,
},
dotted color .meta:n = {
dotted colour = #1,
},
dotted ~ colour .meta:n = {
dotted colour = #1,
},
dotted colour .code:n = {
\colorlet{fillwithdottedcolour}{#1}
},
lliw .meta:n = {
colour = #1,
},
colour .initial:n = gray,
dotted colour .initial:n = black,
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Joseph Wright: from siunitx.sty ; https://chat.stackexchange.com/transcript/message/64327823#64327823
\providecommand \IfFormatAtLeastTF { \@ifl@t@r \fmtversion }
\IfFormatAtLeastTF { 2022-06-01 }
{
\ProcessKeyOptions [ fillwith ]
}{
\RequirePackage { l3keys2e }
\ProcessKeysOptions { fillwith }
}
\IfFormatAtLeastTF { 2020-10-01 }{
}{
\RequirePackage { xparse }
\providecommand \ExpandArgs [1]
{ \cs_if_exist_use:c { exp_args:N #1 } }
}
% END Expl pkg option setup
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% BEGIN vars
\box_new:N \l__fillwith_adj_rule_box
\box_new:N \l__fillwith_part_rule_box
% BEGIN coffins
\coffin_new:N \l__fillwith_line_coffin
\coffin_new:N \l__fillwith_lines_coffin
\coffin_new:N \l__fillwith_tmpa_coffin
% END coffins
% BEGIN dims
\dim_new:N \l__fillwith_ht_dim
\dim_new:N \l__fillwith_dp_dim
\dim_new:N \l__fillwith_rem_dim
\dim_new:N \l__fillwith_line_ht_dim
\dim_new:N \l__fillwith_line_adj_hsize_dim
\dim_set:Nn \l__fillwith_line_ht_dim { 0.4pt }
\dim_new:N \l__fillwith_line_madj_dim
\dim_new:N \l__fillwith_line_vadj_dim
\dim_set_eq:NN \l__fillwith_line_vadj_dim \c_zero_dim
\dim_new:N \l__fillwith_goal_dim
\dim_new:N \l__fillwith_tmpa_dim
% END dims
\int_new:N \g__fillwith_cnt_int
% END vars
% BEGIN fns
\cs_new_protected_nopar:Nn \__fillwith_style: {}
\cs_new_protected_nopar:Nn \__fillwith_coffin_tht:N
{
\dim_eval:n { \coffin_ht:N #1 + \coffin_dp:N #1 }
}
% BEGIN \__fillwith_hrulefill:
\cs_new_protected_nopar:Npn \__fillwith_hrulefill_part:
{
\vrule height \c_zero_dim depth \l__fillwith_line_ht_dim width 0.1pt
}
\cs_new_protected_nopar:Npn \__fillwith_hrulefill:
{
\vrule height \c_zero_dim depth \l__fillwith_line_ht_dim width \l__fillwith_line_adj_hsize_dim
}
% END \__fillwith_hrulefill:
% BEGIN \__fillwith_dottedfill:
\cs_new_protected_nopar:Npn \__fillwith_dottedfill_part:
{
\hbox to 0.33em {\hss .\hss}
}
\cs_new_protected_nopar:Npn \__fillwith_dottedfill:
{
\leaders \hbox to 0.33em {\hss .\hss} \hfill \kern \c_zero_dim
}
% END \__fillwith_dottedfill:
% END fns
% \end{macrocode}
% \begin{macro}{\fillwithset}
% Wrapper command for configuration.
% Most global or local customisation will use this as most keys are not valid package options.
% \begin{macrocode}
\NewDocumentCommand\fillwithset { +m }{
\keys_set:nn { fillwith } { #1 }
}
% \end{macrocode}
% \end{macro}
% \begin{macrocode}
% BEGIN keys (+)
\keys_define:nn { fillwith }
{
cont .bool_set:N = \l__fillwith_cont_bool,
cont .default:n = true,
cont .initial:n = false,
fillwith~ht .tl_set:N = \l__fillwith_ht_tl,
fillwith~ht .initial:n = 2,
fillwith~ht .default:n = 2,
goal ~ ht .dim_set:N = \l__fillwith_goal_dim,
line nos .bool_set:N = \l__fillwith_nos_bool,
line ~ nos .bool_set:N = \l__fillwith_nos_bool,
line ~ nos .default:n = true,
line ~ nos .initial:n = false,
no ~ font .tl_set:N = \l__fillwith_no_font_tl,
no ~ font .initial:n = { \normalfont\normalsize },
no ~ font .default:n = { \normalfont\normalsize },
style .choices:nn =
{
rule, dots , line , lines , rules , unknown
}{
\if_case:w \l_keys_choice_int
\or: \cs_set_eq:NN \__fillwith_style: \__fillwith_hrulefill:
\or: \cs_set_eq:NN \__fillwith_style: \__fillwith_dottedfill:
\or: \cs_set_eq:NN \__fillwith_style: \__fillwith_hrulefill:
\or: \cs_set_eq:NN \__fillwith_style: \__fillwith_hrulefill:
\or: \cs_set_eq:NN \__fillwith_style: \__fillwith_hrulefill:
\else: \cs_set_protected_nopar:Nn \__fillwith_style: { \use:c { \l_keys_choice_tl } }
\fi:
\if_case:w \l_keys_choice_int
\or: \cs_set_eq:NN \__fillwith_style_part: \__fillwith_hrulefill_part:
\or: \cs_set_eq:NN \__fillwith_style_part: \__fillwith_dottedfill_part:
\or: \cs_set_eq:NN \__fillwith_style_part: \__fillwith_hrulefill_part:
\or: \cs_set_eq:NN \__fillwith_style_part: \__fillwith_hrulefill_part:
\or: \cs_set_eq:NN \__fillwith_style_part: \__fillwith_hrulefill_part:
\else: \cs_set_protected_nopar:Nn \__fillwith_style_part: { \use:c { \l_keys_choice_tl part } }
\fi:
},
style .default:n = dots,
style .initial:n = dots,
}
% END keys (+)
%
% BEGIN \__fillwith_fill:
% ref: https://tex.stackexchange.com/a/241139/ Harish Kumar
\cs_new_protected_nopar:Nn \__fillwith_fill:
{
\__fillwith_measures:
\dim_set:Nn \l__fillwith_line_adj_hsize_dim { \hsize - \@totalleftmargin }
\vbox_set:Nn \l__fillwith_adj_rule_box
{
\parindent=0pt
\vrule height \l__fillwith_ht_dim depth \l__fillwith_dp_dim width \c_zero_dim
\skip_horizontal:n { \@totalleftmargin }
\__fillwith_style:
}
\if_mode_horizontal:
\bool_if:NT \l__fillwith_cont_bool
{
\leaders \box_use:N \l__fillwith_part_rule_box \hfill \kern \c_zero_dim
}{
\vrule height \l__fillwith_ht_dim depth \l__fillwith_dp_dim width \c_zero_dim
}
%^^A gweithio ond erbyn y rheolau
%^^A byddai'n achosi draferth, siwr o fod
% \tex_par:D
%^^A yn lle hynny, ceisio hyn - oes perygl hefyd?
\para_raw_end:
\else:
\unskip
\skip_vertical:n { \l__fillwith_dp_dim }
\fi:
\xleaders \box_use:N \l__fillwith_adj_rule_box \vfill
\para_end:
\normalcolor
}
% END \__fillwith_fill:
% BEGIN \__fillwith_measures:
\cs_new_protected_nopar:Nn \__fillwith_measures:
{
\color{fillwithcolour}
\offinterlineskip
\hbox_set:Nn \l__fillwith_part_rule_box
{
\strut
\__fillwith_style_part:
\kern \c_zero_dim
}
\dim_set:Nn \l__fillwith_tmpa_dim { \box_ht:N \l__fillwith_part_rule_box }
\dim_set:Nn \l__fillwith_ht_dim { \l__fillwith_ht_tl \l__fillwith_tmpa_dim }
\box_set_ht:Nn \l__fillwith_part_rule_box { \l__fillwith_ht_dim }
\dim_set:Nn \l__fillwith_tmpa_dim { \box_dp:N \l__fillwith_part_rule_box }
% neu \fp_to_dim:n { \l__fillwith_ht_tl * \l__fillwith_tmpa_dim } ??
\dim_set:Nn \l__fillwith_dp_dim { \l__fillwith_ht_tl \l__fillwith_tmpa_dim }
\box_set_dp:Nn \l__fillwith_part_rule_box { \l__fillwith_dp_dim }
}
% END \__fillwith_measures:
% BEGIN fillwith
% \end{macrocode}
% \begin{macro}{\fillwith}
% The package is basically this macro.
% \begin{macrocode}
\NewDocumentCommand \fillwith { s o }
{
\group_begin:
\IfValueT { #2 }
{
\keys_set:nn { fillwith } { #2 }
}
\IfBooleanTF { #1 }
{
\bool_set_true:N \l__fillwith_cont_bool
}{
\bool_set_false:N \l__fillwith_cont_bool
}
\__fillwith_fill:
\group_end:
}
% \end{macrocode}
% \end{macro}
% \begin{macrocode}
% END fillwith
% BEGIN fillwithrules
% \end{macrocode}
% \begin{macro}{\fillwithrules}
% Simple convenience wrapper with simplified syntax for (solid) rules.
% \begin{macrocode}
\NewDocumentCommand \fillwithrules { s O { 2 } }
{
\group_begin:
\IfBooleanTF { #1 }
{
\bool_set_true:N \l__fillwith_cont_bool
}{
\bool_set_false:N \l__fillwith_cont_bool
}
\keys_set:nn { fillwith } { style = rules, fillwith~ht=#2 }
\__fillwith_fill:
\group_end:
}
% \end{macrocode}
% \end{macro}
% \begin{macrocode}
% END fillwithrules
% BEGIN fillwithdottedlines
% \end{macrocode}
% \begin{macro}{\fillwithdottedlines}
% Simple convenience wrapper with simplified syntax for dotted lines.
% \begin{macrocode}
\NewDocumentCommand \fillwithdottedlines { s O { 2 } }
{
\group_begin:
\IfBooleanTF { #1 }
{
\bool_set_true:N \l__fillwith_cont_bool
}{
\bool_set_false:N \l__fillwith_cont_bool
}
\colorlet{fillwithcolour}{fillwithdottedcolour}
\keys_set:nn { fillwith } { style = dots, fillwith~ht=#2 }
\__fillwith_fill:
\group_end:
}
% \end{macrocode}
% \end{macro}
% \begin{macrocode}
% END fillwithdottedlines
% BEGIN fillwithnolines
\cs_new_protected:Nn \__fillwith_nos: % rhybudd: ARAF ! SLOW!
{
\parindent=0pt
\__fillwith_measures:
\dim_set_eq:NN \l__fillwith_line_adj_hsize_dim \linewidth
\vcoffin_set:Nnn \l__fillwith_line_coffin { \l__fillwith_line_adj_hsize_dim }
{
\parindent=0pt
\vrule height \l__fillwith_ht_dim depth \l__fillwith_dp_dim width \c_zero_dim
\skip_horizontal:n \c_zero_skip
\__fillwith_style:
}
\coffin_set_eq:NN \l__fillwith_lines_coffin \l__fillwith_line_coffin
\if_mode_horizontal:
\bool_if:NTF \l__fillwith_cont_bool
{
\leaders \box_use:N \l__fillwith_part_rule_box \hfill \kern \c_zero_dim
\int_gincr:N \g__fillwith_cnt_int
% \vcoffin_set:Nnn \l__fillwith_tmpa_coffin { 1.5em}
% {
% \l__fillwith_no_font_tl \int_to_arabic:n { \g__fillwith_cnt_int }
% }
% \coffin_mark_handle:Nnnn \l__fillwith_tmpa_coffin {B} {l} { red }
% \coffin_mark_handle:Nnnn \l__fillwith_tmpa_coffin {b} {l} { green }
% \coffin_attach:NnnNnnnn \l__fillwith_lines_coffin {B} {r} \l__fillwith_tmpa_coffin {B} {l} {2.5pt} { \l__fillwith_ht_dim + \l__fillwith_dp_dim }
% \coffin_mark_handle:Nnnn \l__fillwith_lines_coffin {T} {r} { blue }
% \coffin_mark_handle:Nnnn \l__fillwith_lines_coffin {t} {r} { magenta }
\dim_set:Nn \l__fillwith_line_vadj_dim { \l__fillwith_dp_dim }
}{
\vrule height \l__fillwith_ht_dim depth \l__fillwith_dp_dim width \c_zero_dim
}
\dim_set:Nn \l__fillwith_line_madj_dim { \@totalleftmargin }
\para_raw_end:
\else:
\dim_set_eq:NN \l__fillwith_line_madj_dim \c_zero_dim
\unskip
\skip_vertical:n { \l__fillwith_dp_dim }
\fi:
\int_gincr:N \g__fillwith_cnt_int
\vcoffin_set:Nnn \l__fillwith_tmpa_coffin { 1.5em}
{
\l__fillwith_no_font_tl \int_to_arabic:n { \g__fillwith_cnt_int }
}
\coffin_attach:NnnNnnnn \l__fillwith_lines_coffin {B} {r} \l__fillwith_tmpa_coffin {B} {l} {2.5pt} {\c_zero_dim}
\dim_set:Nn \l__fillwith_rem_dim
{
\l__fillwith_goal_dim -\footskip - \pagetotal
}
\dim_until_do:nNnn { \__fillwith_coffin_tht:N \l__fillwith_lines_coffin } > { \l__fillwith_rem_dim - \l__fillwith_ht_dim - \l__fillwith_dp_dim }
{
\coffin_join:NnnNnnnn \l__fillwith_lines_coffin { b } { l } \l__fillwith_line_coffin { t } { l } { \c_zero_dim } { \c_zero_dim }
\int_gincr:N \g__fillwith_cnt_int
\vcoffin_set:Nnn \l__fillwith_tmpa_coffin {1.5em}
{
\l__fillwith_no_font_tl \int_to_arabic:n { \g__fillwith_cnt_int }
}
\coffin_attach:NnnNnnnn \l__fillwith_lines_coffin {B} {r} \l__fillwith_tmpa_coffin {B} {l} {2.5pt} {\c_zero_dim}
}
\coffin_typeset:Nnnnn \l__fillwith_lines_coffin { B } { l } { \l__fillwith_line_madj_dim } { \l__fillwith_line_vadj_dim }
\para_end:
\normalcolor
}
% \end{macrocode}
% \begin{macro}{\fillwithnolines}
% Provisional experimental macro for numbered fill.
% \begin{macrocode}
\NewDocumentCommand \fillwithnolines { s O { } }
{
\group_begin:
\IfBooleanTF { #1 }
{
\bool_set_true:N \l__fillwith_cont_bool
}{
\bool_set_false:N \l__fillwith_cont_bool
}
\keys_set:nn { fillwith } { goal ~ ht = \pagegoal, #2 }
\__fillwith_nos:
\group_end:
}
% \end{macrocode}
% \end{macro}
% \begin{macrocode}
% END fillwithnolines
\ExplSyntaxOff
% \end{macrocode}
% \iffalse
%</sty>
% \fi
%
% \subsection{Demonstration}
%
% Simple example to demonstrate usage.
%
% \iffalse
%<*ee>
% \fi
% \begin{macrocode}
\listfiles
\documentclass[british,a6paper]{article}
\usepackage{babel}
\usepackage[scale=.85,marginparwidth=0pt,marginparsep=0pt]{geometry}
\usepackage{fillwith}
\usepackage{cfr-lm}
\begin{document}
\author{A. N. Author}
\title{\texttt{fillwith} Demo}
\maketitle
\begin{enumerate}
\item What is the answer to the question?
\fillwithrules
\item How did you answer the previous question?
\fillwith*[style=line]
\item Why answer?
\fillwith*[style=rule,fillwith ht=1.25,colour=blue!40!cyan]
\clearpage
\item Evaluate your responses so far.
\fillwithdottedlines
\item Evaluate your responses so far.
{%
\fillwithset{dotted colour=magenta}%
\fillwithdottedlines[1.5]
}
\item Criticise your evaluation.
\fillwithdottedlines*
\clearpage
\item Assess your answers.
\fillwithnolines[goal ht = .33\textheight]
\item Assess your answers.
\fillwithnolines[style=rules,no font=\bfseries\tiny,colour=green!50!gray,goal ht = .67\textheight]
\item Summarise your analysis.
\fillwithnolines*
\end{enumerate}
\end{document}
% \end{macrocode}
% \iffalse
%</ee>
% \fi
% \subsection{Other}
% \iffalse
%<*other>
% \fi
% \begin{macrocode}
% \end{macrocode}
% \iffalse
%</other>
% \fi
%\Finale