| 1 |
% \iffalse meta-comment |
| 2 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3 |
% fillwith.dtx |
| 4 |
% Additions and changes Copyright (C) 2024 Clea F. Rees. |
| 5 |
% Code from skeleton.dtx Copyright (C) 2015-2024 Scott Pakin (see below). |
| 6 |
% |
| 7 |
% This work may be distributed and/or modified under the |
| 8 |
% conditions of the LaTeX Project Public License, either version 1.3c |
| 9 |
% of this license or (at your option) any later version. |
| 10 |
% The latest version of this license is in |
| 11 |
% https://www.latex-project.org/lppl.txt |
| 12 |
% and version 1.3c or later is part of all distributions of LaTeX |
| 13 |
% version 2008-05-04 or later. |
| 14 |
% |
| 15 |
% This work has the LPPL maintenance status \muaintained'. |
| 16 |
% |
| 17 |
% The Current Maintainer of this work is Clea F. Rees. |
| 18 |
% |
| 19 |
% This work consists of all files listed in manifest.txt. |
| 20 |
% |
| 21 |
% The file fillwith.dtx is a derived work under the terms of the |
| 22 |
% LPPL. It is based on version 2.4 of skeleton.dtx which is part of |
| 23 |
% dtxtut by Scott Pakin. A copy of dtxtut, including the |
| 24 |
% unmodified version of skeleton.dtx is available from |
| 25 |
% https://www.ctan.org/pkg/dtxtut and released under the LPPL. |
| 26 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 27 |
% \fi |
| 28 |
% |
| 29 |
% \iffalse |
| 30 |
%<*driver> |
| 31 |
\RequirePackage{svn-prov} |
| 32 |
\ProvidesFileSVN{$Id: fillwith.dtx 10202 2024-08-08 15:33:47Z cfrees $}[v0.3 \revinfo][\filename: \filebase] |
| 33 |
\DefineFileInfoSVN[fillwith] |
| 34 |
\GetFileInfoSVN* |
| 35 |
% ref. ateb Max Chernoff: https://tex.stackexchange.com/a/723294/ |
| 36 |
\def\MakePrivateLetters{\makeatletter\ExplSyntaxOn\endlinechar13} |
| 37 |
\documentclass[british,a4paper]{ltxdoc} |
| 38 |
\usepackage{babel} |
| 39 |
\usepackage[tt={monowidth,lining,tabular},sf={lining,proportional},rm={lining,proportional}]{cfr-lm} |
| 40 |
\usepackage{fillwith} |
| 41 |
\usepackage{parskip} |
| 42 |
\usepackage{verbatim} |
| 43 |
\usepackage{graphicx} |
| 44 |
\usepackage{xurl} |
| 45 |
% sicrhau hyperindex=false: llwytho CYN bookmark |
| 46 |
\usepackage{hypdoc}% ateb Ulrike Fischer: https://tex.stackexchange.com/a/695555/ |
| 47 |
\usepackage{bookmark} |
| 48 |
\usepackage{cleveref} |
| 49 |
\EnableCrossrefs |
| 50 |
\CodelineIndex |
| 51 |
\RecordChanges |
| 52 |
%^^A \OnlyDescription |
| 53 |
%^^A \ExplSyntaxOn |
| 54 |
%^^A \makeatletter |
| 55 |
\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} |
| 56 |
%^^A \makeatother |
| 57 |
%^^A \ExplSyntaxOff |
| 58 |
\definecolor{strawberry}{rgb}{1.000,0.000,0.502} |
| 59 |
\definecolor{blueberry}{rgb}{0.000,0.000,1.000} |
| 60 |
\definecolor{moss}{rgb}{0.000,0.502,0.251} |
| 61 |
\hypersetup{% |
| 62 |
colorlinks=true, |
| 63 |
citecolor={moss}, |
| 64 |
extension=pdf, |
| 65 |
linkcolor={strawberry}, |
| 66 |
linktocpage=true, |
| 67 |
pdfcreator={TeX}, |
| 68 |
pdfproducer={pdfeTeX}, |
| 69 |
urlcolor={blueberry}% |
| 70 |
} |
| 71 |
\NewDocElement[% |
| 72 |
idxtype=opt., |
| 73 |
idxgroup=options, |
| 74 |
printtype=\textit{opt.}, |
| 75 |
]{Opt}{option} |
| 76 |
\NewDocumentCommand \val { m } |
| 77 |
{% |
| 78 |
{\ttfamily =\,\meta{#1}}% |
| 79 |
} |
| 80 |
\ExplSyntaxOn |
| 81 |
\NewDocumentCommand \vals { m } |
| 82 |
{ |
| 83 |
{ |
| 84 |
\ttfamily = \, |
| 85 |
\clist_use:nn { #1 } { \textbar } |
| 86 |
} |
| 87 |
} |
| 88 |
\ExplSyntaxOff |
| 89 |
\setcounter{IndexColumns}{2} |
| 90 |
\makeatletter |
| 91 |
\def\@xobeysp{\leavevmode\penalty100\ } |
| 92 |
\makeatother |
| 93 |
\begin{document} |
| 94 |
\DocInput{\filename} |
| 95 |
\end{document} |
| 96 |
%</driver> |
| 97 |
% \fi |
| 98 |
% \title{\filebase{} \filerev} |
| 99 |
% \author{Clea F. Rees} |
| 100 |
% \date{\filedate} |
| 101 |
% \maketitle |
| 102 |
% \begin{abstract} |
| 103 |
% 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{% |
| 104 |
% See \href{https://tex.stackexchange.com/a/241139/}{tex.stackexchange.com/a/241139/}.% |
| 105 |
% }. |
| 106 |
% 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. |
| 107 |
% 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. |
| 108 |
% 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. |
| 109 |
% Currently, the package supports solid rules or dotted lines. |
| 110 |
% The remainder of the current line may optionally be filled in the same way and the โfillerโ may be coloured if desired. |
| 111 |
% |
| 112 |
% Lines may optionally be numbered, though the numbered versions should not be used to fill long stretches as they are extremely inefficient. |
| 113 |
% \textbf{Numbered fills are highly experimental and not recommended for use in โrealโ documents.} |
| 114 |
% That is, it seems to work, but I recommend using an alternative package or solution if you need a reliable numbering mechanism. |
| 115 |
% \end{abstract} |
| 116 |
% |
| 117 |
% \section{Load}\label{sec:pkg} |
| 118 |
% To use the package simply load it in your preamble in the usual way. |
| 119 |
% |
| 120 |
% \iffalse |
| 121 |
%<*verb> |
| 122 |
% \fi |
| 123 |
\begin{verbatim} |
| 124 |
\usepackage[<options>]{fillwith} |
| 125 |
\end{verbatim} |
| 126 |
% \iffalse |
| 127 |
%</verb> |
| 128 |
% \fi |
| 129 |
% |
| 130 |
% A small number of options may be specified when loading the package. |
| 131 |
% See \cref{sec:config}. |
| 132 |
% |
| 133 |
% We start with an example in \cref{sec:ee}. |
| 134 |
% \Cref{sec:use} describes the basic commands illustrated in this example. |
| 135 |
% \Cref{sec:config} explains the options used by these commands, together with other customisation features of \pkg{fillwith}. |
| 136 |
% |
| 137 |
% \section{Example}\label{sec:ee} |
| 138 |
% |
| 139 |
% The code below illustrates most package features. |
| 140 |
% |
| 141 |
% \Cref{fig:ee1} demonstrates filling with rules. |
| 142 |
% Note the effect of altering \texttt{fillwith ht} on line-spacing. |
| 143 |
% \begin{figure} |
| 144 |
% \centering |
| 145 |
% \fbox{\includegraphics{fillwith-example.pdf}} |
| 146 |
% \caption{Filling with rules.}\label{fig:ee1} |
| 147 |
% \end{figure} |
| 148 |
% |
| 149 |
% \Cref{fig:ee2} shows dotted fillings. |
| 150 |
% Note the use of \cmd{\fillwithset} to alter the colour. |
| 151 |
% \begin{figure} |
| 152 |
% \centering |
| 153 |
% \fbox{\includegraphics[page=2]{fillwith-example.pdf}} |
| 154 |
% \caption{Filling with dotted lines.}\label{fig:ee2} |
| 155 |
% \end{figure} |
| 156 |
% |
| 157 |
% \Cref{fig:ee3} shows numbered fillings. |
| 158 |
% Note the use of \texttt{goal ht} to divide the available vertical space more-or-less equally. |
| 159 |
% \begin{figure} |
| 160 |
% \centering |
| 161 |
% \fbox{\includegraphics[page=3]{fillwith-example.pdf}} |
| 162 |
% \caption{Filling with numbered lines.}\label{fig:ee3} |
| 163 |
% \end{figure} |
| 164 |
% |
| 165 |
% \verbatiminput{fillwith-example.tex} |
| 166 |
% |
| 167 |
% \section{Usage}\label{sec:use} |
| 168 |
% |
| 169 |
% \DescribeMacro{\fillwith}\oarg{options} |
| 170 |
% \DescribeMacro{\fillwith*} |
| 171 |
% |
| 172 |
% Fill vertically with current settings, optionally modified by \meta{options}. |
| 173 |
% See \cref{sec:config} for \meta{options}. |
| 174 |
% 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. |
| 175 |
% |
| 176 |
% \DescribeMacro{\fillwithrules}\oarg{line-spacing} |
| 177 |
% \DescribeMacro{\fillwithrules*} |
| 178 |
% |
| 179 |
% Convenience wrappers which just set \texttt{style = rules} and set the line-spacing to \meta{line-spacing}. |
| 180 |
% These macros do nothing which cannot be done using \cmd{\fillwith} and \cmd{\fillwith*}. |
| 181 |
% |
| 182 |
% \DescribeMacro{\fillwithdottedlines}\oarg{line-spacing} |
| 183 |
% \DescribeMacro{\fillwithdottedlines*} |
| 184 |
% |
| 185 |
% Convenience wrappers which just set \texttt{style = dots} and set the line-spacing to \meta{line-spacing}. |
| 186 |
% These macros do nothing which cannot be done using \cmd{\fillwith} and \cmd{\fillwith*}. |
| 187 |
% |
| 188 |
% \DescribeMacro{\fillwithnolines}\oarg{options} |
| 189 |
% \DescribeMacro{\fillwithnolines*} |
| 190 |
% |
| 191 |
% Fill vertically with current settings, numbering each complete line, after optionally setting \meta{options}. |
| 192 |
% Numbering \textbf{requires} use of these commands, as opposed to the generic \cmd{\fillwith}/\cmd{\fillwith*}. |
| 193 |
% |
| 194 |
% \section{Customisation}\label{sec:config} |
| 195 |
% |
| 196 |
% Options can be set per use, locally or globally. |
| 197 |
% A small number of options are implemented as package options (\cref{sec:pkg}). |
| 198 |
% |
| 199 |
% \DescribeMacro{\fillwithset}\marg{options} |
| 200 |
% Set local or global defaults. |
| 201 |
% |
| 202 |
% \DescribeOpt{colour}\val{colour name} |
| 203 |
% \DescribeOpt{color} |
| 204 |
% \DescribeOpt{lliw} |
| 205 |
% |
| 206 |
% Colour to be used for (solid) rules. |
| 207 |
% |
| 208 |
% Initially \texttt{gray}. |
| 209 |
% Available as a package option. |
| 210 |
% |
| 211 |
% \DescribeOpt{dotted color}\val{colour name} |
| 212 |
% \DescribeOpt{dotted colour} |
| 213 |
% |
| 214 |
% Colour to be used for dotted lines. |
| 215 |
% |
| 216 |
% Initially \texttt{black}. |
| 217 |
% Available as a package option. |
| 218 |
% |
| 219 |
% \DescribeOpt{cont}\vals{true,false} |
| 220 |
% |
| 221 |
% Whether to fill the remainder of any current line. |
| 222 |
% 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. |
| 223 |
% |
| 224 |
% Initially \texttt{false}. |
| 225 |
% Default is \texttt{true}. |
| 226 |
% |
| 227 |
% \DescribeOpt{fillwith~ht}\val{real positive number expressed as decimal} |
| 228 |
% |
| 229 |
% Multiplication factor for line-spacing. |
| 230 |
% Typically, hand-written content requires greater spacing than typewritten content. |
| 231 |
% This option scales the standard line-spacing. |
| 232 |
% |
| 233 |
% Initially \texttt{2}, which is also the default value. |
| 234 |
% Decimal values such as \texttt{1.5} are permitted. |
| 235 |
% |
| 236 |
% \DescribeOpt{goal ~ ht}\val{dimension} |
| 237 |
% |
| 238 |
% Used only by \cmd{\fillwithnolines} and \cmd{\fillwithnolines*}. |
| 239 |
% Sets the target dimension to fill with numbered lines. |
| 240 |
% If unspecified, the code tries to fill the remaining vertical space on the current page. |
| 241 |
% 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. |
| 242 |
% In contrast, multiple unnumbered fills can coexist on the same page without issue --- the available space will simply be divided equally between them. |
| 243 |
% |
| 244 |
% Initially unset. |
| 245 |
% No default. |
| 246 |
% |
| 247 |
% \DescribeOpt{no ~ font}\val{font switches} |
| 248 |
% |
| 249 |
% Font switches to apply when typesetting numbers for numbered fills. |
| 250 |
% |
| 251 |
% Initially \cmd{\normalfont}\cmd{\normalsize}, which is also the default value. |
| 252 |
% 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. |
| 253 |
% |
| 254 |
% \DescribeOpt{style}\vals{rule,dots,line,lines,rules} |
| 255 |
% |
| 256 |
% Style of fill. |
| 257 |
% \texttt{rule}, \texttt{line}, \texttt{rules} and \texttt{lines} are synonyms which all denote solid rules or lines. |
| 258 |
% \texttt{dots} uses dotted lines rather than solid rules. |
| 259 |
% 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. |
| 260 |
% |
| 261 |
% Initially \texttt{dots}, which is also the default value. |
| 262 |
% |
| 263 |
% If an unknown value is used, the code will attempt to use two macros derived from that value. |
| 264 |
% The first is constructed simply by preceding \meta{value} with a backslash and the second by also appending \texttt{part}. |
| 265 |
% 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. |
| 266 |
% In theory, this supports filling with somewhat arbitrary content, but the implementation is untested and \textbf{should not be used in real documents}. |
| 267 |
% |
| 268 |
% |
| 269 |
% \changes{v0.0}{???}{First public release.} |
| 270 |
% \changes{\fileversion}{\filedate}{} |
| 271 |
% |
| 272 |
% |
| 273 |
% \MaybeStop{% |
| 274 |
% \PrintChanges |
| 275 |
% \PrintIndex |
| 276 |
% } |
| 277 |
% |
| 278 |
% \section{Implementation} |
| 279 |
% |
| 280 |
% You do not need to read the remainder of this document in order to install or use the package. |
| 281 |
% |
| 282 |
% \iffalse |
| 283 |
%<@@=fillwith> |
| 284 |
%<*sty> |
| 285 |
% \fi |
| 286 |
% \begin{macrocode} |
| 287 |
\NeedsTeXFormat{LaTeX2e}[2021-11-15] |
| 288 |
\RequirePackage{svn-prov} |
| 289 |
\ProvidesPackageSVN[\filebase.sty]{$Id: fillwith.dtx 10202 2024-08-08 15:33:47Z cfrees $}[v0.0 \revinfo][\filebase: fill vertically with non-space] |
| 290 |
% this is needed only because l3doc overwrites \fileversion and \filedate |
| 291 |
% neither ltxdoc nor doc does this |
| 292 |
\DefineFileInfoSVN |
| 293 |
% \end{macrocode} |
| 294 |
% \iffalse |
| 295 |
% ^^A Paid รข defnyddio \GetFileInfoSVN*/\GetFileInfoSVN{} yn y fan hon!! |
| 296 |
% \fi |
| 297 |
% \begin{macrocode} |
| 298 |
\RequirePackage{xcolor} |
| 299 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 300 |
% copied verbatim, excepting format from Joseph Wright's' siunitx.sty under LPPL |
| 301 |
\@ifundefined{ExplLoaderFileDate}{% |
| 302 |
\RequirePackage{expl3}% |
| 303 |
}{} |
| 304 |
% almost verbatim from siunitx.sty |
| 305 |
\@ifl@t@r\ExplLoaderFileDate{2022-02-24}{% |
| 306 |
}{% |
| 307 |
\PackageError{fillwith}{Support package expl3 too old} |
| 308 |
{% |
| 309 |
You need to update your installation of the bundles 'l3kernel' and |
| 310 |
'l3packages'.\MessageBreak |
| 311 |
Loading~fillwith~will~abort!% |
| 312 |
}% |
| 313 |
\endinput |
| 314 |
} |
| 315 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 316 |
\ExplSyntaxOn |
| 317 |
\prop_gput:Nnn \g_msg_module_name_prop { fillwith } { fillwith } |
| 318 |
|
| 319 |
% BEGIN Expl pkg option setup |
| 320 |
|
| 321 |
\keys_define:nn { fillwith } |
| 322 |
{ |
| 323 |
color .meta:n = { |
| 324 |
colour = #1, |
| 325 |
}, |
| 326 |
colour .code:n = { |
| 327 |
\colorlet{fillwithcolour}{#1} |
| 328 |
}, |
| 329 |
dotted ~ color .meta:n = { |
| 330 |
dotted colour = #1, |
| 331 |
}, |
| 332 |
dotted color .meta:n = { |
| 333 |
dotted colour = #1, |
| 334 |
}, |
| 335 |
dotted ~ colour .meta:n = { |
| 336 |
dotted colour = #1, |
| 337 |
}, |
| 338 |
dotted colour .code:n = { |
| 339 |
\colorlet{fillwithdottedcolour}{#1} |
| 340 |
}, |
| 341 |
lliw .meta:n = { |
| 342 |
colour = #1, |
| 343 |
}, |
| 344 |
colour .initial:n = gray, |
| 345 |
dotted colour .initial:n = black, |
| 346 |
} |
| 347 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 348 |
% Joseph Wright: from siunitx.sty ; https://chat.stackexchange.com/transcript/message/64327823#64327823 |
| 349 |
\providecommand \IfFormatAtLeastTF { \@ifl@t@r \fmtversion } |
| 350 |
\IfFormatAtLeastTF { 2022-06-01 } |
| 351 |
{ |
| 352 |
\ProcessKeyOptions [ fillwith ] |
| 353 |
}{ |
| 354 |
\RequirePackage { l3keys2e } |
| 355 |
\ProcessKeysOptions { fillwith } |
| 356 |
} |
| 357 |
\IfFormatAtLeastTF { 2020-10-01 }{ |
| 358 |
}{ |
| 359 |
\RequirePackage { xparse } |
| 360 |
\providecommand \ExpandArgs [1] |
| 361 |
{ \cs_if_exist_use:c { exp_args:N #1 } } |
| 362 |
} |
| 363 |
% END Expl pkg option setup |
| 364 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 365 |
% BEGIN vars |
| 366 |
\box_new:N \l__fillwith_adj_rule_box |
| 367 |
\box_new:N \l__fillwith_part_rule_box |
| 368 |
\box_new:N \l__fillwith_tmpa_box |
| 369 |
\box_new:N \l__fillwith_tmpb_box |
| 370 |
% BEGIN coffins |
| 371 |
\coffin_new:N \l__fillwith_line_coffin |
| 372 |
\coffin_new:N \l__fillwith_lines_coffin |
| 373 |
\coffin_new:N \l__fillwith_part_coffin |
| 374 |
\coffin_new:N \l__fillwith_tmpa_coffin |
| 375 |
% END coffins |
| 376 |
% BEGIN dims |
| 377 |
\dim_new:N \l__fillwith_ht_dim |
| 378 |
\dim_new:N \l__fillwith_dp_dim |
| 379 |
\dim_new:N \l__fillwith_rem_dim |
| 380 |
\dim_new:N \l__fillwith_line_ht_dim |
| 381 |
\dim_new:N \l__fillwith_line_adj_hsize_dim |
| 382 |
\dim_set:Nn \l__fillwith_line_ht_dim { 0.4pt } |
| 383 |
\dim_new:N \l__fillwith_line_madj_dim |
| 384 |
\dim_new:N \l__fillwith_line_vadj_dim |
| 385 |
\dim_set_eq:NN \l__fillwith_line_vadj_dim \c_zero_dim |
| 386 |
\dim_new:N \l__fillwith_goal_dim |
| 387 |
\dim_new:N \l__fillwith_tmpa_dim |
| 388 |
% END dims |
| 389 |
\int_new:N \g__fillwith_cnt_int |
| 390 |
% END vars |
| 391 |
% BEGIN fns |
| 392 |
\cs_new_protected_nopar:Nn \__fillwith_style: {} |
| 393 |
\cs_new_protected_nopar:Nn \__fillwith_coffin_tht:N |
| 394 |
{ |
| 395 |
\dim_eval:n { \coffin_ht:N #1 + \coffin_dp:N #1 } |
| 396 |
} |
| 397 |
% BEGIN \__fillwith_hrulefill: |
| 398 |
\cs_new_protected_nopar:Npn \__fillwith_hrulefill_part: |
| 399 |
{ |
| 400 |
\vrule height \c_zero_dim depth \l__fillwith_line_ht_dim width 0.1pt |
| 401 |
} |
| 402 |
\cs_new_protected_nopar:Npn \__fillwith_hrulefill: |
| 403 |
{ |
| 404 |
\vrule height \c_zero_dim depth \l__fillwith_line_ht_dim width \l__fillwith_line_adj_hsize_dim |
| 405 |
} |
| 406 |
% END \__fillwith_hrulefill: |
| 407 |
% BEGIN \__fillwith_dottedfill: |
| 408 |
\cs_new_protected_nopar:Npn \__fillwith_dottedfill_part: |
| 409 |
{ |
| 410 |
\hbox to 0.33em {\hss .\hss} |
| 411 |
} |
| 412 |
\cs_new_protected_nopar:Npn \__fillwith_dottedfill: |
| 413 |
{ |
| 414 |
\leaders \hbox to 0.33em {\hss .\hss} \hfill \kern \c_zero_dim |
| 415 |
} |
| 416 |
% END \__fillwith_dottedfill: |
| 417 |
% END fns |
| 418 |
% \end{macrocode} |
| 419 |
% \begin{macro}{\fillwithset} |
| 420 |
% Wrapper command for configuration. |
| 421 |
% Most global or local customisation will use this as most keys are not valid package options. |
| 422 |
% \begin{macrocode} |
| 423 |
\NewDocumentCommand\fillwithset { +m }{ |
| 424 |
\keys_set:nn { fillwith } { #1 } |
| 425 |
} |
| 426 |
% \end{macrocode} |
| 427 |
% \end{macro} |
| 428 |
% \begin{macrocode} |
| 429 |
% BEGIN keys (+) |
| 430 |
\keys_define:nn { fillwith } |
| 431 |
{ |
| 432 |
cont .bool_set:N = \l__fillwith_cont_bool, |
| 433 |
cont .default:n = true, |
| 434 |
cont .initial:n = false, |
| 435 |
fillwith~ht .tl_set:N = \l__fillwith_ht_tl, |
| 436 |
fillwith~ht .initial:n = 2, |
| 437 |
fillwith~ht .default:n = 2, |
| 438 |
goal ~ ht .dim_set:N = \l__fillwith_goal_dim, |
| 439 |
line nos .bool_set:N = \l__fillwith_nos_bool, |
| 440 |
line ~ nos .bool_set:N = \l__fillwith_nos_bool, |
| 441 |
line ~ nos .default:n = true, |
| 442 |
line ~ nos .initial:n = false, |
| 443 |
no ~ font .tl_set:N = \l__fillwith_no_font_tl, |
| 444 |
no ~ font .initial:n = { \normalfont\normalsize }, |
| 445 |
no ~ font .default:n = { \normalfont\normalsize }, |
| 446 |
style .choices:nn = |
| 447 |
{ |
| 448 |
rule, dots , line , lines , rules , unknown |
| 449 |
}{ |
| 450 |
\if_case:w \l_keys_choice_int |
| 451 |
\or: \cs_set_eq:NN \__fillwith_style: \__fillwith_hrulefill: |
| 452 |
\or: \cs_set_eq:NN \__fillwith_style: \__fillwith_dottedfill: |
| 453 |
\or: \cs_set_eq:NN \__fillwith_style: \__fillwith_hrulefill: |
| 454 |
\or: \cs_set_eq:NN \__fillwith_style: \__fillwith_hrulefill: |
| 455 |
\or: \cs_set_eq:NN \__fillwith_style: \__fillwith_hrulefill: |
| 456 |
\else: \cs_set_protected_nopar:Nn \__fillwith_style: { \use:c { \l_keys_choice_tl } } |
| 457 |
\fi: |
| 458 |
\if_case:w \l_keys_choice_int |
| 459 |
\or: \cs_set_eq:NN \__fillwith_style_part: \__fillwith_hrulefill_part: |
| 460 |
\or: \cs_set_eq:NN \__fillwith_style_part: \__fillwith_dottedfill_part: |
| 461 |
\or: \cs_set_eq:NN \__fillwith_style_part: \__fillwith_hrulefill_part: |
| 462 |
\or: \cs_set_eq:NN \__fillwith_style_part: \__fillwith_hrulefill_part: |
| 463 |
\or: \cs_set_eq:NN \__fillwith_style_part: \__fillwith_hrulefill_part: |
| 464 |
\else: \cs_set_protected_nopar:Nn \__fillwith_style_part: { \use:c { \l_keys_choice_tl part } } |
| 465 |
\fi: |
| 466 |
}, |
| 467 |
style .default:n = dots, |
| 468 |
style .initial:n = dots, |
| 469 |
} |
| 470 |
% END keys (+) |
| 471 |
% |
| 472 |
% BEGIN \__fillwith_fill: |
| 473 |
% ref: https://tex.stackexchange.com/a/241139/ Harish Kumar |
| 474 |
\cs_new_protected_nopar:Nn \__fillwith_fill: |
| 475 |
{ |
| 476 |
\__fillwith_measures: |
| 477 |
\dim_set:Nn \l__fillwith_line_adj_hsize_dim { \hsize - \@totalleftmargin } |
| 478 |
\vbox_set:Nn \l__fillwith_adj_rule_box |
| 479 |
{ |
| 480 |
\parindent=0pt |
| 481 |
\vrule height \l__fillwith_ht_dim depth \l__fillwith_dp_dim width \c_zero_dim |
| 482 |
\skip_horizontal:n { \@totalleftmargin } |
| 483 |
\__fillwith_style: |
| 484 |
} |
| 485 |
\if_mode_horizontal: |
| 486 |
\bool_if:NT \l__fillwith_cont_bool |
| 487 |
{ |
| 488 |
\leaders \box_use:N \l__fillwith_part_rule_box \hfill \kern \c_zero_dim |
| 489 |
}{ |
| 490 |
\vrule height \l__fillwith_ht_dim depth \l__fillwith_dp_dim width \c_zero_dim |
| 491 |
} |
| 492 |
%^^A gweithio ond erbyn y rheolau |
| 493 |
%^^A byddai'n achosi draferth, siwr o fod |
| 494 |
% \tex_par:D |
| 495 |
%^^A yn lle hynny, ceisio hyn - oes perygl hefyd? |
| 496 |
\para_raw_end: |
| 497 |
\else: |
| 498 |
\unskip |
| 499 |
\skip_vertical:n { \l__fillwith_dp_dim } |
| 500 |
\fi: |
| 501 |
\xleaders \box_use:N \l__fillwith_adj_rule_box \vfill |
| 502 |
\para_end: |
| 503 |
\normalcolor |
| 504 |
} |
| 505 |
% END \__fillwith_fill: |
| 506 |
% BEGIN \__fillwith_measures: |
| 507 |
\cs_new_protected_nopar:Nn \__fillwith_measures: |
| 508 |
{ |
| 509 |
\color{fillwithcolour} |
| 510 |
\offinterlineskip |
| 511 |
\hbox_set:Nn \l__fillwith_part_rule_box |
| 512 |
{ |
| 513 |
\strut |
| 514 |
\__fillwith_style_part: |
| 515 |
\kern \c_zero_dim |
| 516 |
} |
| 517 |
\dim_set:Nn \l__fillwith_tmpa_dim { \box_ht:N \l__fillwith_part_rule_box } |
| 518 |
\dim_set:Nn \l__fillwith_ht_dim { \l__fillwith_ht_tl \l__fillwith_tmpa_dim } |
| 519 |
\box_set_ht:Nn \l__fillwith_part_rule_box { \l__fillwith_ht_dim } |
| 520 |
\dim_set:Nn \l__fillwith_tmpa_dim { \box_dp:N \l__fillwith_part_rule_box } |
| 521 |
% neu \fp_to_dim:n { \l__fillwith_ht_tl * \l__fillwith_tmpa_dim } ?? |
| 522 |
\dim_set:Nn \l__fillwith_dp_dim { \l__fillwith_ht_tl \l__fillwith_tmpa_dim } |
| 523 |
\box_set_dp:Nn \l__fillwith_part_rule_box { \l__fillwith_dp_dim } |
| 524 |
} |
| 525 |
% END \__fillwith_measures: |
| 526 |
% BEGIN fillwith |
| 527 |
% \end{macrocode} |
| 528 |
% \begin{macro}{\fillwith} |
| 529 |
% The package is basically this macro. |
| 530 |
% \begin{macrocode} |
| 531 |
\NewDocumentCommand \fillwith { s o } |
| 532 |
{ |
| 533 |
\group_begin: |
| 534 |
\IfValueT { #2 } |
| 535 |
{ |
| 536 |
\keys_set:nn { fillwith } { #2 } |
| 537 |
} |
| 538 |
\IfBooleanTF { #1 } |
| 539 |
{ |
| 540 |
\bool_set_true:N \l__fillwith_cont_bool |
| 541 |
}{ |
| 542 |
\bool_set_false:N \l__fillwith_cont_bool |
| 543 |
} |
| 544 |
\__fillwith_fill: |
| 545 |
\group_end: |
| 546 |
} |
| 547 |
% \end{macrocode} |
| 548 |
% \end{macro} |
| 549 |
% \begin{macrocode} |
| 550 |
% END fillwith |
| 551 |
% BEGIN fillwithrules |
| 552 |
% \end{macrocode} |
| 553 |
% \begin{macro}{\fillwithrules} |
| 554 |
% Simple convenience wrapper with simplified syntax for (solid) rules. |
| 555 |
% \begin{macrocode} |
| 556 |
\NewDocumentCommand \fillwithrules { s O { 2 } } |
| 557 |
{ |
| 558 |
\group_begin: |
| 559 |
\IfBooleanTF { #1 } |
| 560 |
{ |
| 561 |
\bool_set_true:N \l__fillwith_cont_bool |
| 562 |
}{ |
| 563 |
\bool_set_false:N \l__fillwith_cont_bool |
| 564 |
} |
| 565 |
\keys_set:nn { fillwith } { style = rules, fillwith~ht=#2 } |
| 566 |
\__fillwith_fill: |
| 567 |
\group_end: |
| 568 |
} |
| 569 |
% \end{macrocode} |
| 570 |
% \end{macro} |
| 571 |
% \begin{macrocode} |
| 572 |
% END fillwithrules |
| 573 |
% BEGIN fillwithdottedlines |
| 574 |
% \end{macrocode} |
| 575 |
% \begin{macro}{\fillwithdottedlines} |
| 576 |
% Simple convenience wrapper with simplified syntax for dotted lines. |
| 577 |
% \begin{macrocode} |
| 578 |
\NewDocumentCommand \fillwithdottedlines { s O { 2 } } |
| 579 |
{ |
| 580 |
\group_begin: |
| 581 |
\IfBooleanTF { #1 } |
| 582 |
{ |
| 583 |
\bool_set_true:N \l__fillwith_cont_bool |
| 584 |
}{ |
| 585 |
\bool_set_false:N \l__fillwith_cont_bool |
| 586 |
} |
| 587 |
\colorlet{fillwithcolour}{fillwithdottedcolour} |
| 588 |
\keys_set:nn { fillwith } { style = dots, fillwith~ht=#2 } |
| 589 |
\__fillwith_fill: |
| 590 |
\group_end: |
| 591 |
} |
| 592 |
% \end{macrocode} |
| 593 |
% \end{macro} |
| 594 |
% \begin{macrocode} |
| 595 |
% END fillwithdottedlines |
| 596 |
% BEGIN fillwithnolines |
| 597 |
\cs_new_protected:Nn \__fillwith_nos: % rhybudd: ARAF ! SLOW! |
| 598 |
{ |
| 599 |
\parindent=0pt |
| 600 |
\__fillwith_measures: |
| 601 |
\dim_set_eq:NN \l__fillwith_line_adj_hsize_dim \linewidth |
| 602 |
\vcoffin_set:Nnn \l__fillwith_line_coffin { \l__fillwith_line_adj_hsize_dim } |
| 603 |
{ |
| 604 |
\parindent=0pt |
| 605 |
\vrule height \l__fillwith_ht_dim depth \l__fillwith_dp_dim width \c_zero_dim |
| 606 |
\skip_horizontal:n \c_zero_skip |
| 607 |
\__fillwith_style: |
| 608 |
} |
| 609 |
\coffin_set_eq:NN \l__fillwith_lines_coffin \l__fillwith_line_coffin |
| 610 |
\if_mode_horizontal: |
| 611 |
\bool_if:NTF \l__fillwith_cont_bool |
| 612 |
{ |
| 613 |
\leaders \box_use:N \l__fillwith_part_rule_box \hfill \kern \c_zero_dim |
| 614 |
\int_gincr:N \g__fillwith_cnt_int |
| 615 |
% \vcoffin_set:Nnn \l__fillwith_tmpa_coffin { 1.5em} |
| 616 |
% { |
| 617 |
% \l__fillwith_no_font_tl \int_to_arabic:n { \g__fillwith_cnt_int } |
| 618 |
% } |
| 619 |
% \coffin_mark_handle:Nnnn \l__fillwith_tmpa_coffin {B} {l} { red } |
| 620 |
% \coffin_mark_handle:Nnnn \l__fillwith_tmpa_coffin {b} {l} { green } |
| 621 |
% \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 } |
| 622 |
% \coffin_mark_handle:Nnnn \l__fillwith_lines_coffin {T} {r} { blue } |
| 623 |
% \coffin_mark_handle:Nnnn \l__fillwith_lines_coffin {t} {r} { magenta } |
| 624 |
\dim_set:Nn \l__fillwith_line_vadj_dim { \l__fillwith_dp_dim } |
| 625 |
}{ |
| 626 |
\vrule height \l__fillwith_ht_dim depth \l__fillwith_dp_dim width \c_zero_dim |
| 627 |
} |
| 628 |
\dim_set:Nn \l__fillwith_line_madj_dim { \@totalleftmargin } |
| 629 |
\para_raw_end: |
| 630 |
\else: |
| 631 |
\dim_set_eq:NN \l__fillwith_line_madj_dim \c_zero_dim |
| 632 |
\unskip |
| 633 |
\skip_vertical:n { \l__fillwith_dp_dim } |
| 634 |
\fi: |
| 635 |
\int_gincr:N \g__fillwith_cnt_int |
| 636 |
\vcoffin_set:Nnn \l__fillwith_tmpa_coffin { 1.5em} |
| 637 |
{ |
| 638 |
\l__fillwith_no_font_tl \int_to_arabic:n { \g__fillwith_cnt_int } |
| 639 |
} |
| 640 |
\coffin_attach:NnnNnnnn \l__fillwith_lines_coffin {B} {r} \l__fillwith_tmpa_coffin {B} {l} {2.5pt} {\c_zero_dim} |
| 641 |
\dim_set:Nn \l__fillwith_rem_dim |
| 642 |
{ |
| 643 |
\l__fillwith_goal_dim -\footskip - \pagetotal |
| 644 |
} |
| 645 |
\dim_until_do:nNnn { \__fillwith_coffin_tht:N \l__fillwith_lines_coffin } > { \l__fillwith_rem_dim - \l__fillwith_ht_dim - \l__fillwith_dp_dim } |
| 646 |
{ |
| 647 |
\coffin_join:NnnNnnnn \l__fillwith_lines_coffin { b } { l } \l__fillwith_line_coffin { t } { l } { \c_zero_dim } { \c_zero_dim } |
| 648 |
\int_gincr:N \g__fillwith_cnt_int |
| 649 |
\vcoffin_set:Nnn \l__fillwith_tmpa_coffin {1.5em} |
| 650 |
{ |
| 651 |
\l__fillwith_no_font_tl \int_to_arabic:n { \g__fillwith_cnt_int } |
| 652 |
} |
| 653 |
\coffin_attach:NnnNnnnn \l__fillwith_lines_coffin {B} {r} \l__fillwith_tmpa_coffin {B} {l} {2.5pt} {\c_zero_dim} |
| 654 |
} |
| 655 |
\coffin_typeset:Nnnnn \l__fillwith_lines_coffin { B } { l } { \l__fillwith_line_madj_dim } { \l__fillwith_line_vadj_dim } |
| 656 |
\para_end: |
| 657 |
\normalcolor |
| 658 |
} |
| 659 |
% \end{macrocode} |
| 660 |
% \begin{macro}{\fillwithnolines} |
| 661 |
% Provisional experimental macro for numbered fill. |
| 662 |
% \begin{macrocode} |
| 663 |
\NewDocumentCommand \fillwithnolines { s O { } } |
| 664 |
{ |
| 665 |
\group_begin: |
| 666 |
\IfBooleanTF { #1 } |
| 667 |
{ |
| 668 |
\bool_set_true:N \l__fillwith_cont_bool |
| 669 |
}{ |
| 670 |
\bool_set_false:N \l__fillwith_cont_bool |
| 671 |
} |
| 672 |
\keys_set:nn { fillwith } { goal ~ ht = \pagegoal, #2 } |
| 673 |
\__fillwith_nos: |
| 674 |
\group_end: |
| 675 |
} |
| 676 |
% \end{macrocode} |
| 677 |
% \end{macro} |
| 678 |
% \begin{macrocode} |
| 679 |
% END fillwithnolines |
| 680 |
\ExplSyntaxOff |
| 681 |
% \end{macrocode} |
| 682 |
% \iffalse |
| 683 |
%</sty> |
| 684 |
% \fi |
| 685 |
% |
| 686 |
% \subsection{Demonstration} |
| 687 |
% |
| 688 |
% Simple example to demonstrate usage. |
| 689 |
% |
| 690 |
% \iffalse |
| 691 |
%<*ee> |
| 692 |
% \fi |
| 693 |
% \begin{macrocode} |
| 694 |
\listfiles |
| 695 |
\documentclass[british,a6paper]{article} |
| 696 |
\usepackage{babel} |
| 697 |
\usepackage[scale=.85,marginparwidth=0pt,marginparsep=0pt]{geometry} |
| 698 |
\usepackage{fillwith} |
| 699 |
\usepackage{cfr-lm} |
| 700 |
\begin{document} |
| 701 |
\author{A. N. Author} |
| 702 |
\title{\texttt{fillwith} Demo} |
| 703 |
\maketitle |
| 704 |
\begin{enumerate} |
| 705 |
\item What is the answer to the question? |
| 706 |
\fillwithrules |
| 707 |
\item How did you answer the previous question? |
| 708 |
\fillwith*[style=line] |
| 709 |
\item Why answer? |
| 710 |
|
| 711 |
\fillwith*[style=rule,fillwith ht=1.25,colour=blue!40!cyan] |
| 712 |
\clearpage |
| 713 |
\item Evaluate your responses so far. |
| 714 |
\fillwithdottedlines |
| 715 |
\item Evaluate your responses so far. |
| 716 |
|
| 717 |
{% |
| 718 |
\fillwithset{dotted colour=magenta}% |
| 719 |
\fillwithdottedlines[1.5] |
| 720 |
} |
| 721 |
\item Criticise your evaluation. |
| 722 |
\fillwithdottedlines* |
| 723 |
\clearpage |
| 724 |
\item Assess your answers. |
| 725 |
\fillwithnolines[goal ht = .33\textheight] |
| 726 |
\item Assess your answers. |
| 727 |
|
| 728 |
\fillwithnolines[style=rules,no font=\bfseries\tiny,colour=green!50!gray,goal ht = .67\textheight] |
| 729 |
\item Summarise your analysis. |
| 730 |
\fillwithnolines* |
| 731 |
\end{enumerate} |
| 732 |
|
| 733 |
\end{document} |
| 734 |
% \end{macrocode} |
| 735 |
% \iffalse |
| 736 |
%</ee> |
| 737 |
% \fi |
| 738 |
% \subsection{Other} |
| 739 |
% \iffalse |
| 740 |
%<*other> |
| 741 |
% \fi |
| 742 |
% \begin{macrocode} |
| 743 |
% \end{macrocode} |
| 744 |
% \iffalse |
| 745 |
%</other> |
| 746 |
% \fi |
| 747 |
%\Finale |