From c9114c95eeccd2cb2dc4363eb22e60dd1b1fcb48 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Wed, 30 Dec 2020 21:52:14 +0000 Subject: skeldoc (30dec20) git-svn-id: svn://tug.org/texlive/trunk@57264 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/latex/skeldoc/LICENSE | 21 + Master/texmf-dist/doc/latex/skeldoc/README.md | 11 + Master/texmf-dist/doc/latex/skeldoc/skeldoc.pdf | Bin 0 -> 216738 bytes Master/texmf-dist/doc/latex/skeldoc/skeldoc.tex | 220 +++++++ Master/texmf-dist/tex/latex/skeldoc/skeldoc.sty | 778 ++++++++++++++++++++++++ 5 files changed, 1030 insertions(+) create mode 100644 Master/texmf-dist/doc/latex/skeldoc/LICENSE create mode 100644 Master/texmf-dist/doc/latex/skeldoc/README.md create mode 100644 Master/texmf-dist/doc/latex/skeldoc/skeldoc.pdf create mode 100644 Master/texmf-dist/doc/latex/skeldoc/skeldoc.tex create mode 100644 Master/texmf-dist/tex/latex/skeldoc/skeldoc.sty (limited to 'Master/texmf-dist') diff --git a/Master/texmf-dist/doc/latex/skeldoc/LICENSE b/Master/texmf-dist/doc/latex/skeldoc/LICENSE new file mode 100644 index 00000000000..eb75fde0e7d --- /dev/null +++ b/Master/texmf-dist/doc/latex/skeldoc/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 Magnus Lie Hetland + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Master/texmf-dist/doc/latex/skeldoc/README.md b/Master/texmf-dist/doc/latex/skeldoc/README.md new file mode 100644 index 00000000000..c1f6deaa92c --- /dev/null +++ b/Master/texmf-dist/doc/latex/skeldoc/README.md @@ -0,0 +1,11 @@ +# skeldoc.sty + +The **skeldoc** package lets you produce placeholder elements for documents +under development, similar to the skeleton screens used while loading contents +in many applications and websites. It also has a mechanism for attaching +explanatory endnotes to these placeholder, or to anything else in your +document. For an example of use, along with some explanations, see the file +[skeldoc.pdf](skeldoc.pdf), or [its source](skeldoc.tex). + +The package is written by [Magnus Lie Hetland](mailto:mlh@ntnu.no) and is +released under the [MIT license](LICENSE). diff --git a/Master/texmf-dist/doc/latex/skeldoc/skeldoc.pdf b/Master/texmf-dist/doc/latex/skeldoc/skeldoc.pdf new file mode 100644 index 00000000000..541a42cad5d Binary files /dev/null and b/Master/texmf-dist/doc/latex/skeldoc/skeldoc.pdf differ diff --git a/Master/texmf-dist/doc/latex/skeldoc/skeldoc.tex b/Master/texmf-dist/doc/latex/skeldoc/skeldoc.tex new file mode 100644 index 00000000000..ec9ad5c435d --- /dev/null +++ b/Master/texmf-dist/doc/latex/skeldoc/skeldoc.tex @@ -0,0 +1,220 @@ +% Copyright (c) 2020 Magnus Lie Hetland +% +% Permission is hereby granted, free of charge, to any person obtaining a copy +% of this software and associated documentation files (the "Software"), to deal +% in the Software without restriction, including without limitation the rights +% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +% copies of the Software, and to permit persons to whom the Software is +% furnished to do so, subject to the following conditions: +% +% The above copyright notice and this permission notice shall be included in all +% copies or substantial portions of the Software. +% +% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +% SOFTWARE. + +\documentclass[twocolumn, a4paper]{article} + +\usepackage{lmodern} +\def\sfdefault{cmbr} +\def\ttdefault{cmtl} + +\usepackage{skeldoc} + +\usepackage{amsthm} +\newtheorem{thm}{Theorem} + +% For discussing commmands: + +\makeatletter +\ExplSyntaxOn + +% Copied from http://ctan.uib.no/macros/latex/base/doc.dtx +% Protect when used in moving arguments. +{\catcode`\|=\z@ \catcode`\\=12 |gdef|bslash{\}} + +\NewDocumentCommand \cs { m } {% + \texttt{\bslash #1}% +} + +\NewDocumentCommand \braces { +m } {% + \string{#1\string}% +} + +\NewDocumentCommand \pkg { o m } { + \IfNoValueTF { #1 } { + \textsf { #2 } + } { + \href{ #1 }{ \textsf { #2 } } + } +} + +\NewDocumentCommand \var { m } { + $\langle$ + \textnormal{\textit{#1}} + $\rangle$ +} + +\ExplSyntaxOff +\makeatother + +% To illustrate the \skelpseudo command: + +\usepackage{pseudo} + +\title{\skelline{The \pkg{skeldoc} package is intended for incremental +document development, with commands that insert simplified placeholder +elements for missing parts, similar to \emph{skeleton screens}, optionally +with associated notes explaining the placeholders.}} + +\author{\skelline[5cm]{The \pkg{skeldoc} package is written by Magnus Lie +Hetland.}} + +\begin{document} +\maketitle + +\begin{abstract} + \skelpar[4] +\end{abstract} + +\section{Introduction} + +\skelpar[7]{All the skeleton commands are followed by an optional argument in +brackets, and one (also optional) in braces, like +\cs{skelfoo}\texttt{[\var{conf}]\braces{\var{note}}}. The first argument is +for limited local +configuration, setting keys relevant to the specific command. Each command +also lets you supply one such config value \emph{without} a key, leaving the +key implicit. For example, for \cs{skelline} (a single skeleton line), this is +\texttt{width} and for \cs{skelpar} (a single skeleton paragraph), it's +\texttt{lines}. So \cs{skelline[5cm]} is the same as +\cs{skelline[width\,=\,5cm]}. The \cs{skelpar} command also has the keys +\texttt{first-width}, \texttt{width} and \texttt{last-width}, to adjust the +various line widths. + +The argument in braces is a \emph{note} associated with the skeleton element, +typeset using the \cs{skelnote} command, which places a number in the margin +and an note at the end of the document (or wherever the \cs{printskelnotes} +command is placed), with hyperlinks in both directions. + +Beyond the keys available locally, there are several \emph{global} config +keys, which may be set using the \cs{skelset} command (which respects \TeX{} +groups, so such config may also be local, e.g., by wrapping the relevant part +of the document in braces). For example, one might use +\cs{skelset\braces{main-color\allowbreak\,=\,black}} to produce a look along +the lines of the \pkg[https://ctan.org/pkg/censor]{censor} package. Shared +defaults for the local keys may also be set in this way, generally using the +local key name with the type of element as a prefix; for example, +\texttt{par-lines} is used to set the default for the \texttt{lines} key of +the \cs{skelpar} command. There are also some other general keys, like +\texttt{main-color} and \texttt{full-width}. For an overview of the +configuration keys, please consult the source file, \texttt{skeldoc.sty}.} +\skelenum[3] +\noindent +\skelpar[3] + +\section{\skelline} + +\skelpar + +\skelnote{It is possible to add notes in arbitrary parts of a document with +the \cs{skelnote} command. This could also be used as a simple to-do or +annotation mechanism.} +Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy +eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam +voluptua. +\skelpar[2] +At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd +gubergren, no sea takimata sanctus est. + +\skelpar +\skelitems{The \cs{skelenum} and \cs{skelitems} commands produce skeleton +\emph{lists} (using \texttt{enumeration} and \texttt{itemize}). Their implicit +key is \texttt{items}, which controls the number of items, while +\texttt{item-lines} controls the number of lines per item.} +\noindent +\skelpar[4] + +\begin{figure} +\skelfig[5cm]{Skeleton figures (\cs{skelfig}) have \texttt{height} as their +implicit key. The width may be modified using the \texttt{width} key.} +\skelcaption{Skeleton captions are best typeset using the special-purpose +\cs{skelcaption} command, rather than simply placing a \cs{skelpar} in a +normal \cs{caption}, at least if you intend to attach a note. This is because +captions are generally typeset more than once, in order to determine whether +to center them; \cs{skelcaption} prevents any attached note from being added +to the note list twice. + +The implicit argument of \cs{skelcaption} is \texttt{lines}, and the other +keys are as for \cs{skelpar}, relying on the same defaults and global +configuration.} +\end{figure}% + +\skelpar +\begin{equation} + \skelline +\end{equation} +\skelpars[3]{Multiple skeleton paragraphs may be produced using the +\cs{skelpars} command, whose implicit key is \texttt{pars}, controlling +the number of paragraphs.} + +\begin{table} +\skelcaption[1]{The \cs{skelcaption} command may be used for figures and +tables alike.} +\skeltabular[7]{The \cs{skeltabular} command produces a skeleton table +(specifically, a \texttt{tabularx}). The implicit key is \texttt{rows}, +controlling the number of rows in the table. The \cs{tabcolsep} and +\cs{arraystretch} used can be set with the \texttt{colsep} and +\texttt{stretch} keys.} +\end{table} + +\skelpar + +\begin{thm} + \skelpar[3] +\end{thm} +\begin{proof} +\skelpar +\end{proof} + +\skelpar + +\section{\skelline} + +\skelpar +\skelpseudo[ + head={\pr{Lorem-Ipsum}(\id{dolor}, \id{sit}, \id{amet})}, +]{The \cs{skelpseudo} command only works if the +\pkg[https://ctan.org/pkg/pseudo]{pseudo} package has been imported. (It is +not imported by the \pkg{skeldoc} package.) The implicit key is +\texttt{lines}, the number of lines to produce (in addition to the headline, +if any). By default, no headline is included, but one may be set using the +\texttt{head} key (e.g., using the \cs{pr} command from the +\pkg[https://ctan.org/pkg/pseudo]{pseudo} package, rather than \cs{hd}, +because the \texttt{head} key handles the \cs{multicolumn} stuff itself; for +example, use +\texttt{head\,=\,\braces{\cs{pr}\braces{\var{name}}(\var{args})}}). The indent +pattern is set using the \texttt{newlines} key, which should be a +comma-separated list of newline commands as used by the +\pkg[https://ctan.org/pkg/pseudo]{pseudo} package (such as \cs{\bslash+} or +\cs{\bslash--}). This list is used round-robin as the lines progress. E.g., if +you want pseudocode without any indentation, simply use +\texttt{newlines\,=\,\cs{\bslash}}.} +\skelpar + +\section{Discussion} + +\skelpars[2] + +\skelbib{The \cs{skelbib} command produces a skeleton bibliography, with the +number of items controlled by the implicit key \texttt{items}. The number of +lines per item is controlled by \texttt{item-lines}.} + +\printskelnotes + +\end{document} diff --git a/Master/texmf-dist/tex/latex/skeldoc/skeldoc.sty b/Master/texmf-dist/tex/latex/skeldoc/skeldoc.sty new file mode 100644 index 00000000000..5afb1c9c5f7 --- /dev/null +++ b/Master/texmf-dist/tex/latex/skeldoc/skeldoc.sty @@ -0,0 +1,778 @@ +% Copyright (c) 2020 Magnus Lie Hetland +% +% Permission is hereby granted, free of charge, to any person obtaining a copy +% of this software and associated documentation files (the "Software"), to deal +% in the Software without restriction, including without limitation the rights +% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +% copies of the Software, and to permit persons to whom the Software is +% furnished to do so, subject to the following conditions: +% +% The above copyright notice and this permission notice shall be included in all +% copies or substantial portions of the Software. +% +% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +% SOFTWARE. + +\def \skelversion {0.1} +\def \skeldate {2020-12-30} + +\RequirePackage{expl3} + +\ProvidesExplPackage + {skeldoc} + {\skeldate} + {\skelversion} + {Placeholders for unfinished documents} + +\RequirePackage{xcolor} +\RequirePackage{xparse} + +\RequirePackage{tabularx} +\RequirePackage{booktabs} + +\RequirePackage{hyperref} + +\RequirePackage{enotez} +\setenotez{backref, mark-cs={}} + +\RequirePackage{marginnote} + +\RequirePackage{enumitem} + +\cs_new:Npn \skel_tl_from_key:N #1 { + \tl_set_rescan:Nno #1 { } { \l_keys_key_str } +} + +% #1: command name +% #2: variable associated with unknown keys +% #3: key-val list for local \keys_define:nn +% +% Note: Local keyword arguments referring to global defaults should be token +% lists (..._tl, rather than, say, ..._int) to avoid expansion of the default +% when it is set initially. +\cs_new:Npn \skel_defaults:nnn #1 #2 #3 { + + \keys_define:nn { skeldoc / #1 } { + + #3 + + unknown .code:n = { + \tl_set_rescan:Nno #2 { } { \l_keys_key_str } + }, + unknown .value_forbidden:n = true + + } + +} + +% #1: command name +% #2: key-val list for local \keys_set:nn +\cs_new:Npn \skel_args:nn #1 #2 { + + \keys_set:nn { skeldoc / #1 } { #2 } + +} + +%% Configuration %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% Blue from Solarized (https://ethanschoonover.com/solarized/) +% (See also https://ctan.org/pkg/xcolor-solarized.) +\definecolor{skel-blue}{HTML}{268BD2} + +\keys_define:nn { skeldoc } { + + %% General config + + main-color .code:n = \colorlet{skel-main-color}{#1} , + main-color .initial:n = black!7 , + + full-width .tl_set:N = \l_skel_full_width_tl , + full-width .initial:n = \linewidth , + + short-width .tl_set:N = \l_skel_short_width_tl , + short-width .initial:n = .72\l_skel_full_width_tl , + + fill-width .tl_set:N = \l_skel_fill_width_tl , + fill-width .initial:n = 0pt~plus~1fill , + + hypersetup .tl_set:N = \l_skel_hypersetup_tl , + hypersetup .initial:n = hidelinks , + + % With basic LaTeX classes, twocolumn seems to shrink \marginparwidth to + % 4.0pt. marginnote.sty uses this width, so we must make sure there's room + % for our endnote marks. (To avoid having \marginpardiwth interfered with, + % just set min-mpwidth=0pt in the preamble.) + min-mpwidth .dim_set:N = \l_skel_min_mpwidth_dim , + min-mpwidth .initial:n = 3em , + + line-raise .tl_set:N = \l_skel_line_raise_tl , + line-raise .initial:n = -.3ex , + + line-height .tl_set:N = \l_skel_line_height_tl , + line-height .initial:n = 2.1ex , + + %% \skelnote is only configured through \skelset -- no local config + + note-font .tl_set:N = \l_skel_note_font_tl , + note-font .initial:n = \normalsize\normalfont , + + note-color .code:n = \colorlet{skel-note-color}{#1} , + note-color .initial:n = skel-blue!70 , + + %% Defaults for \skelline + + line-width .tl_set:N = \l_skel_line_width_default_tl , + line-width .initial:n = \l_skel_short_width_tl , + + %% Defaults for \skelpar + + par-lines .int_set:N = \l_skel_par_lines_default_int , + par-lines .initial:n = 10 , + + par-first-width .tl_set:N = \l_skel_par_first_width_default_tl , + par-first-width .initial:n = \l_skel_fill_width_tl , + + par-width .tl_set:N = \l_skel_par_width_default_tl , + par-width .initial:n = \l_skel_full_width_tl , + + par-last-width .tl_set:N = \l_skel_par_last_width_default_tl , + par-last-width .initial:n = \l_skel_short_width_tl , + + %% Defaults for \skelfig + + fig-width .tl_set:N = \l_skel_fig_width_default_tl , + fig-width .initial:n = \l_skel_full_width_tl , + + fig-height .tl_set:N = \l_skel_fig_height_default_tl , + fig-height .initial:n = 5cm , + + %% Defaults for \skelcaption + + caption-lines .int_set:N = \l_skel_caption_lines_default_int , + caption-lines .initial:n = 3 , + + %% Defaults for \skelpars + + pars-pars .int_set:N = \l_skel_pars_default_int , + pars-pars .initial:n = 5 , + + %% Defaults for lists (\skelitems and \skelenum) + + list-items .int_set:N = \l_skel_list_items_default_int , + list-items .initial:n = 4 , + + list-item-lines .int_set:N = \l_skel_list_item_lines_default_int , + list-item-lines .initial:n = 2 , + + %% Defaults for \skeltabular + + tabular-rows .int_set:N = \l_skel_tabular_rows_default_int , + tabular-rows .initial:n = 10 , + + tabular-colsep .tl_set:N = \l_skel_tabular_colsep_default_tl , + tabular-colsep .initial:n = 2pt , + + tabular-stretch .tl_set:N = \l_skel_tabular_stretch_default_tl , + tabular-stretch .initial:n = 1.2 , + + %% Defaults for \skelbib + + bib-items .int_set:N = \l_skel_bib_items_default_int , + bib-items .initial:n = 12 , + + bib-item-lines .int_set:N = \l_skel_bib_item_lines_default_int , + bib-item-lines .initial:n = 2 , + + %% Defaults for \skelpseudo + + pseudo-lines .int_set:N = \l_skel_pseudo_lines_default_int , + pseudo-lines .initial:n = 8 , + + pseudo-head .tl_set:N = \l_skel_pseudo_head_default_tl , + pseudo-head .initial:n = , + + pseudo-newlines .tl_set:N = \l_skel_pseudo_newlines_default_tl , + pseudo-newlines .initial:n = { + \\+, \\-, \\+, \\+, \\--, \\+, \\, \\- + }, + +} + +\NewDocumentCommand \skelset { +m } { + \keys_set:nn { skeldoc } { #1 } +} + +%% Rules %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% #1: raise +% #2: width +% #3: thickness +\cs_new_protected:Npn \skel_rule:nnn #1 #2 #3 { + \textcolor {skel-main-color} { + \rule [#1] {#2} {#3} + } +} + +% #1: width +\cs_new_protected:Npn \skel_line:n #1 { + \skel_rule:nnn + { \l_skel_line_raise_tl } { #1 } { \l_skel_line_height_tl } +} +\cs_new:Npn \skel_line: { + \skel_line:n { \l_skel_line_width_tl } +} + +% #1: raise +% #2: width/fill +% #3: thickness +\cs_new_protected:Npn \skel_fill:nnn #1 #2 #3 { + \leavevmode + \textcolor{skel-main-color}{ + \leaders\hrule + height \dim_eval:n { #3 + #1 } + depth \dim_eval:n { -#1 } + \skip_horizontal:n { #2 } + } + \kern0pt +} + +% #1: fill +\cs_new:Npn \skel_fill:n #1 { + \skel_fill:nnn + { \l_skel_line_raise_tl } + { #1 } + { \l_skel_line_height_tl } +} + +\cs_new:Npn \skel_fill: { + \skel_fill:n { \l_skel_fill_width_tl } +} + +%% skelline %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\skel_defaults:nnn { skelline } { \l_skel_line_width_tl } { + + width .tl_set:N = \l_skel_line_width_tl , + width .initial:n = \l_skel_line_width_default_tl , + +} +\NewDocumentCommand \skelline { +O{} +g } { + + \group_begin: + + \skel_args:nn { skelline } { #1 } + + \IfValueT { #2 } { \skelnote { #2 } } + + \skel_line: + + \group_end: + +} + +%% skelpar %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\int_new:N \l_skel_par_lines_int + +\skel_defaults:nnn { skelpar } { \l_skel_par_lines_tl } { + + lines .tl_set:N = \l_skel_par_lines_tl , + lines .initial:n = \l_skel_par_lines_default_int , + + first-width .tl_set:N = \l_skel_par_first_width_tl , + first-width .initial:n = \l_skel_par_first_width_default_tl , + + width .tl_set:N = \l_skel_par_width_tl , + width .initial:n = \l_skel_par_width_default_tl , + + last-width .tl_set:N = \l_skel_par_last_width_tl , + last-width .initial:n = \l_skel_par_last_width_default_tl , + +} +\NewDocumentCommand \skelpar { +O{} +g } { + + \group_begin: + + \skel_args:nn { skelpar } { #1 } + \int_set:Nn \l_skel_par_lines_int \l_skel_par_lines_tl + + \IfValueT { #2 } { \skelnote { #2 } } + + \skel_par: + + \group_end: + +} + +% \skelpar implementation -- also used in \skelcaption + +\cs_new_protected:Npn \skel_par: { + + \group_begin: + + \int_compare:nNnTF { \l_skel_par_lines_int } = { 1 } { + \skel_line:n { \l_skel_par_last_width_tl } + } { + \skel_fill:n { \l_skel_par_first_width_tl } \\ + } + + \int_decr:N \l_skel_par_lines_int + + \int_step_inline:nn { \l_skel_par_lines_int } { + + \int_compare:nNnTF { ##1 } = { \l_skel_par_lines_int } { + \skel_line:n { \l_skel_par_last_width_tl } + } { + \skel_line:n { \l_skel_par_width_tl } + } + + \allowbreak + + } + + \group_end: + +} + +%% \skelfig %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\skel_defaults:nnn { skelfig } { \l_skel_fig_height_tl } { + + width .tl_set:N = \l_skel_fig_width_tl , + width .initial:n = \l_skel_fig_width_default_tl , + + height .tl_set:N = \l_skel_fig_height_tl , + height .initial:n = \l_skel_fig_height_default_tl , + +} +\NewDocumentCommand \skelfig { +O{} +g } { + + \group_begin: + + \skel_args:nn { skelfig } { #1 } + + \IfValueT { #2 } { \skelnote { #2 } } + + \skel_rule:nnn + { 0pt } + { \l_skel_fig_width_tl } + { \l_skel_fig_height_tl } + + \group_end: + +} + +%% \skelcaption %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\skel_defaults:nnn { skelcaption } { \l_skel_caption_lines_tl } { + + lines .tl_set:N = \l_skel_caption_lines_tl , + lines .initial:n = \l_skel_caption_lines_default_int , + + first-width .tl_set:N = \l_skel_par_first_width_tl , + first-width .initial:n = \l_skel_par_first_width_default_tl , + + width .tl_set:N = \l_skel_par_width_tl , + width .initial:n = \l_skel_par_width_default_tl , + + last-width .tl_set:N = \l_skel_par_last_width_tl , + last-width .initial:n = \l_skel_par_last_width_default_tl , + +} +\NewDocumentCommand \skelcaption { +O{} +g } { + + \group_begin: + + \skel_args:nn { skelcaption } { #1 } + \int_set:Nn \l_skel_par_lines_int \l_skel_caption_lines_tl + + \skel_maybe_skip_note:n \l_skel_par_lines_int + + % In case we have paragraphs in the note -- we don't want those on the + % loose inside \caption (and we might as well avoid putting the + % conditional in there, while we're at it): + \tl_clear:N \l_tmpa_tl + \IfValueT { #2 } { + \tl_set:Nn \l_tmpa_tl { \skelnote { #2 } } + } + + \caption{ + \l_tmpa_tl + \skel_par: + } + + \group_end: + +} + +%% \skelpars %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\int_new:N \l_skel_pars_int + +\skel_defaults:nnn { skelpars } { \l_skel_pars_tl } { + + pars .int_set:N = \l_skel_pars_tl , + pars .initial:n = \l_skel_pars_default_int , + +} +\NewDocumentCommand \skelpars { +O{} +g } { + + \group_begin: + + \skel_args:nn { skelpars } { #1 } + \int_set:Nn \l_skel_pars_int \l_skel_pars_tl + \int_set:Nn \l_skel_par_lines_int \l_skel_par_lines_tl + + \IfValueT { #2 } { \skelnote { #2 } } + + \int_step_inline:nn { \l_skel_pars_int } { + \skel_par: + \int_compare:nNnF { ##1 } = { \l_skel_pars_int } { + \par + } + } + + \group_end: + +} + +%% Lists: \skelitems and \skelenum %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\skel_defaults:nnn { lists } { \l_skel_items_tl } { + + items .tl_set:N = \l_skel_list_items_tl , + items .initial:n = \l_skel_list_items_default_int , + + item-lines .tl_set:N = \l_skel_list_item_lines_tl , + item-lines .initial:n = \l_skel_list_item_lines_default_int , + +} + +\NewDocumentCommand \skelitems { +O{} +g } { + + \skel_list:nnn { #1 } { #2 } { itemize } + +} + +\NewDocumentCommand \skelenum { +O{} +g } { + + \skel_list:nnn { #1 } { #2 } { enumerate } + +} + +\cs_new:Npn \skel_list:nnn #1 #2 #3 { + + \group_begin: + + \skel_args:nn { lists } { #1 } + \int_set:Nn \l_skel_par_lines_int \l_skel_list_item_lines_tl + + \begin{#3} + \int_step_inline:nn { \l_skel_list_items_tl } { + \item \mbox{} + \int_compare:nNnT { ##1 } = { 1 } { + \IfValueT { #2 } { \skelnote { #2 } } + } + \skel_par: + } + \end{#3} + + \group_end: +} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% Initial definitions here may be overridden for some additional +% customization, beyond the configuration keys. + +% Could also use l columns here, and \skel_rule:n with a given width in the +% header row, but if colortbl is imported (e.g., indirectly via pseudo), using +% \skel_fill: in later rows won't work. +\cs_new:Npn \skel_tabular_env:n #1 { + \begin{tabularx}{\l_skel_full_width_tl}[t]{@{}p{.22\linewidth}p{1.5cm}X@{}} + #1 + \end{tabularx} +} + +\tl_const:Nn \c_skel_tabular_row_tl { + \skel_fill: & \skel_fill: & \skel_fill: \\ +} + +\tl_const:Nn \c_skel_tabular_note_raise_tl { -1.8ex } + +\skel_defaults:nnn { skeltabular } { \l_skel_tabular_rows_tl } { + + rows .tl_set:N = \l_skel_tabular_rows_tl , + rows .initial:n = \l_skel_tabular_rows_default_int , + + colsep .tl_set:N = \l_skel_tabular_colsep_tl , + colsep .initial:n = \l_skel_tabular_colsep_default_tl , + + stretch .tl_set:N = \arraystretch , + stretch .initial:n = \l_skel_tabular_stretch_default_tl , + +} +\NewDocumentCommand \skeltabular { +O{} +g } { + + \group_begin: + + \skel_args:nn { skeltabular } { #1 } + + \dim_set:Nn \tabcolsep \l_skel_tabular_colsep_tl + + \IfValueT { #2 } { + % Adjusted for top-alignment to match that of \skelline/\skelpar + \raisebox{ \c_skel_tabular_note_raise_tl }{ + \skelnote { #2 } + } + } + + \tl_clear:N \l_tmpa_tl + \int_step_inline:nn { \l_skel_tabular_rows_tl } { + \tl_put_right:Nn \l_tmpa_tl { + \c_skel_tabular_row_tl + } + } + + \skel_tabular_env:n { + \toprule + \c_skel_tabular_row_tl + \midrule + \l_tmpa_tl + \bottomrule + } + + \group_end: + +} + +%% \skelbib %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\skel_defaults:nnn { skelbib } { \l_skel_bib_items_tl } { + + items .tl_set:N = \l_skel_bib_items_tl , + items .initial:n = \l_skel_bib_items_default_int , + + item-lines .tl_set:N = \l_skel_bib_item_lines_tl , + item-lines .initial:n = \l_skel_bib_item_lines_default_int , + +} +\NewDocumentCommand \skelbib { +O{} +g } { + + \group_begin: + + \skel_args:nn { skelbib } { #1 } + + \IfValueT { #2 } { + % Hack: Inject note into the section name, for positioning. + \tl_set_eq:NN \l_tmpa_tl \refname + \tl_set:Nn \refname { \skelnote{#2} \l_tmpa_tl } + } + \int_set:Nn \l_tmpa_int \l_skel_bib_items_tl + \begin{thebibliography} { \int_use:N \l_tmpa_int } + \int_step_inline:nn { \l_skel_bib_items_tl } { + \bibitem{bibitem##1} + \skelpar[lines=\l_skel_bib_item_lines_tl] + } + \end{thebibliography} + + \group_end: + +} + +%% \skelpseudo %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\int_new:N \l_skel_pseudo_lines_int + +\skel_defaults:nnn { skelpseudo } { \l_skel_pseudo_lines_tl } { + + lines .tl_set:N = \l_skel_pseudo_lines_tl , + lines .initial:n = \l_skel_pseudo_lines_default_int , + + % If no head is given, the headline will be suppressed + head .tl_set:N = \l_skel_pseudo_head_tl , + head .initial:n = \l_skel_pseudo_head_default_tl , + + newlines .tl_set:N = \l_skel_pseudo_newlines_tl , + % Can't use this, because we wouldn't know the number of levels to expand: + % newlines .initial:n = \l_skel_pseudo_newlines_default_tl , + newlines .initial:n = , + +} +\NewDocumentCommand \skelpseudo { +O{} +g } { + + \group_begin: + + \skel_args:nn { skelpseudo } { #1 } + \int_set:Nn \l_skel_pseudo_lines_int \l_skel_pseudo_lines_tl + + % Body, constructed incrementally + \tl_clear:N \l_tmpa_tl + + % Line number, so we know when we're done + \int_zero:N \l_tmpa_int + + % Because we can't use .initial:n for newlines: + \tl_if_empty:NT \l_skel_pseudo_newlines_tl { + \tl_set_eq:NN + \l_skel_pseudo_newlines_tl + \l_skel_pseudo_newlines_default_tl + } + + \seq_set_from_clist:NN \l_tmpa_seq \l_skel_pseudo_newlines_tl + + \int_while_do:nNnn { \l_tmpa_int } < { \l_skel_pseudo_lines_int + 1 } { + + \seq_map_inline:Nn \l_tmpa_seq { + + \int_incr:N \l_tmpa_int + + \int_compare:nNnT { \l_tmpa_int } > { \l_skel_pseudo_lines_int } { + \seq_map_break: + } + + \tl_put_right:Nn \l_tmpa_tl { \skelline ##1 } + + } + + } + + % Expanding the head, to see if it's actually empty + \tl_set:Nx \l_tmpb_tl \l_skel_pseudo_head_tl + \tl_if_empty:NTF \l_tmpb_tl { + \begin{pseudo} + \IfValueT { #2 } { \skelnote { #2 } } + \l_tmpa_tl + \end{pseudo} + } { + \begin{pseudo}* + \multicolumn{2} + {>{\pseudohpad} l <{\pseudohpad}} + { \IfValueT { #2 } { \skelnote { #2 } } + \l_tmpb_tl } + \\ + \l_tmpa_tl + \end{pseudo} + } + + \group_end: + + % The indentation behavior gets messed up by the group around the pseudo + % environment. This restores the behavior: No indent unless you have a + % new paragraph. + \noindent\ignorespaces + +} + +%% Notes %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\cs_new:Npn \skel_note:n #1 { + \leavevmode + % Smash to avoid messing with vertical alignment of of surrounding text + \smash{\marginnote{ + \l_skel_note_font_tl + \textcolor{skel-note-color}{ + \endnotemark + } + }} + \endnotetext{\ignorespaces #1 \unskip} + \ignorespaces +} + +\NewDocumentCommand \skelnote { +m } { + \skel_note:n { #1 } +} + +\cs_set_eq:NN \skel_note_orig:n \skel_note:n + +\cs_new:Npn \skel_skip_note: { + \cs_gset_eq:NN \skel_note:n \skel_note_skipped:n +} + +\cs_new:Npn \skel_note_skipped:n #1 { + \cs_gset_eq:NN \skel_note:n \skel_note_orig:n +} + +\AtBeginDocument { + + % Make sure this is run after caption is loaded, even if it's loaded + % before skeldoc: + \@ifpackageloaded { caption } { + % The caption package typesets the caption twice even if it's only a + % single line -- but only if the singlelinecheck is on, so we'll turn + % that on locally, for predictability. + \cs_new:Npn \skel_maybe_skip_note:n #1 { + \captionsetup{singlelinecheck=true} + \skel_skip_note: + } + } { + % Without caption.sty, assuming default LaTeX behavior, which is that the + % caption is typeset twice only if there are two or more lines (as + % indicated by #1). + \cs_new:Npn \skel_maybe_skip_note:n #1 { + \int_compare:nNnT { #1 } > { 1 } { + \skel_skip_note: + } + } + } + + % If the \marginparwidth is too low when the document begins, we change + % it to make room: + \dim_compare:nNnT { \marginparwidth } < { \l_skel_min_mpwidth_dim } { + \dim_set:Nn \marginparwidth { \l_skel_min_mpwidth_dim } + } + + % Supply hyperref.sty with the hidelinks option, unless that's been turned + % off (or changed) with \skelset: + \hypersetup { \l_skel_hypersetup_tl } + +} + +% Rewritten (from enotez.sty), to avoid having the \box_move_up:nn shift my +% margin notes. Adding a \smash to the hypertarget, but not the link (which +% would then be essentially unclickable). +\cs_set_protected:Npn \enotez_write_mark:nn #1#2 { + \bool_if:NTF \l__enotez_hyperfootnotes_bool { + \enotezwritemark { \hyperlink {enz.#1} { \enmarkstyle #2 } } + \bool_if:NT \l__enotez_hyperbackref_bool { + \smash { % Added + \box_move_up:nn {1em} + { \hbox:n { \hypertarget {enz.#1.backref} { } } } + } + } + } + { \enotezwritemark { \enmarkstyle #2 } } +} + +% The default enumitem paragraph-style list has the label protrude into the +% margin, which can be problematic in twocolumn layout, with a narrow column +% gap. To automatically compute the width of the widest label, we keep the +% widest label from enotez in \g_skel_widest_note_label_tl. +\newlist { skel-note-list-type } { enumerate } { 10 } +\tl_new:N \g_skel_widest_note_label_tl +\setlist [ skel-note-list-type ] { + widest = \g_skel_widest_note_label_tl, + label = \arabic*., + leftmargin = *, + listparindent=\parindent, + parsep = 0pt, + itemsep = 4.0pt plus 2.0pt minus 1.0pt, + +} + +\DeclareInstance { enotez-list } { skel-note-list } { list } { + number = \textcolor{skel-note-color}{#1.}, + list-type = skel-note-list-type, +} + +\NewDocumentCommand \printskelnotes { } { + \tl_set:Ne \g_skel_widest_note_label_tl \theendnote + \printendnotes[skel-note-list] +} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -- cgit v1.2.3