diff options
author | Norbert Preining <norbert@preining.info> | 2022-07-28 03:00:49 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2022-07-28 03:00:49 +0000 |
commit | 5937dac9360bdf40d1b0baf9d7384b109fb5b7a7 (patch) | |
tree | 461be8ac399baf669aa36b7c4c1faa01171101ef /macros/latex/contrib | |
parent | ba846abb1dbfe9c19277bb894d88c7cce953b4be (diff) |
CTAN sync 202207280300
Diffstat (limited to 'macros/latex/contrib')
-rw-r--r-- | macros/latex/contrib/fixdif/fixdif-zh-cn.pdf | bin | 0 -> 139880 bytes | |||
-rw-r--r-- | macros/latex/contrib/fixdif/fixdif-zh-cn.tex | 334 | ||||
-rw-r--r-- | macros/latex/contrib/fixdif/fixdif.dtx | 27 | ||||
-rw-r--r-- | macros/latex/contrib/fixdif/fixdif.ins | 2 | ||||
-rw-r--r-- | macros/latex/contrib/fixdif/fixdif.pdf | bin | 331118 -> 98246 bytes | |||
-rw-r--r-- | macros/latex/contrib/scripture/README.md | 75 | ||||
-rw-r--r-- | macros/latex/contrib/scripture/scripture.dtx | 2541 | ||||
-rw-r--r-- | macros/latex/contrib/scripture/scripture.ins | 47 | ||||
-rw-r--r-- | macros/latex/contrib/scripture/scripture.pdf | bin | 0 -> 755299 bytes |
9 files changed, 3017 insertions, 9 deletions
diff --git a/macros/latex/contrib/fixdif/fixdif-zh-cn.pdf b/macros/latex/contrib/fixdif/fixdif-zh-cn.pdf Binary files differnew file mode 100644 index 0000000000..52bd0f8cd2 --- /dev/null +++ b/macros/latex/contrib/fixdif/fixdif-zh-cn.pdf diff --git a/macros/latex/contrib/fixdif/fixdif-zh-cn.tex b/macros/latex/contrib/fixdif/fixdif-zh-cn.tex new file mode 100644 index 0000000000..df9fb1a7b5 --- /dev/null +++ b/macros/latex/contrib/fixdif/fixdif-zh-cn.tex @@ -0,0 +1,334 @@ +\documentclass[letterpaper,11pt]{article} +\usepackage{indentfirst} + +\usepackage{manfnt,marginnote} +\newcounter{fixdifattention} +\newcommand\attention[1][1]{\setcounter{fixdifattention}{1}% + \ifnum#1=1 \def\attentiontext{\dbend}\else + \def\attentiontext{\loop\dbend\,% + \addtocounter{fixdifattention}{1}% + \ifnum \value{fixdifattention}<#1 \repeat\dbend}\fi% + \marginnote{\makebox[0pt][r]{\attentiontext}}} + +\usepackage{xcolor} +\definecolor{titlecolor}{RGB}{0,128,8} + +\usepackage{fontspec} +\setmainfont{STIX Two Text} +\setsansfont{Inter}[Scale=MatchLowercase] +\setmonofont{Noto Sans Mono}[Scale=MatchLowercase] +\usepackage{xeCJK,xeCJKfntef} +\setCJKmainfont{Source Han Serif SC} +\setCJKsansfont{Source Han Sans SC} +\setCJKmonofont{Source Han Sans SC} +\renewcommand\abstractname{摘\hskip.8em 要} +\renewcommand\contentsname{目\hskip.8em 录} +\DeclareRobustCommand\zhemph{\CJKunderdot} +\usepackage{unicode-math} +\setmathfont{STIX Two Math} + +\usepackage{doc} +\DeclareRobustCommand\marg[1]{\texttt{\{}\meta{#1}\texttt{\}}} + +\usepackage{fancyvrb} +\fvset{xleftmargin=2em,fontsize=\small} +\MakeShortVerb| + +\usepackage{hologo} +\DeclareRobustCommand\XeTeX{\hologo{XeTeX}} +\DeclareRobustCommand\LuaTeX{\hologo{LuaTeX}} + +\DeclareRobustCommand\pkg{\textsf} +\DeclareRobustCommand\opt{\texttt} + +\usepackage{hyperref} +\hypersetup{pdffitwindow, + pdftitle = {fixdif 宏包(中文文档)}, + pdfauthor = {AlphaZTX}, + pdfcreator = {pdfLaTeX/XeLaTeX/LuaLaTeX}, + linkcolor = black, + urlcolor = titlecolor!75!black, +} + +\makeatletter +\renewcommand\section{\@startsection{section}{1}{\z@}% + {-2.5ex plus -1ex minus -.2ex}% + {1ex plus .2ex}% + {\normalfont\Large\bfseries\color{titlecolor}}} +\renewcommand\subsection{\@startsection{subsection}{2}{\z@}% + {-2ex plus -1ex minus -.2ex}% + {.5ex plus .2ex}% + {\normalfont\normalsize\bfseries\color{titlecolor}}} +\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}% + {.8ex plus .4ex minus .2ex}% + {-1em}% + {\indent\normalfont\normalsize\bfseries\color{titlecolor}}} +\def\ps@plain{\let\@mkboth\@gobbletwo + \def\@oddhead{\hbox{}\llap{\raisebox{-24.44cm}[0pt][0pt]{% + \sffamily\bfseries\color{titlecolor!10}\fontsize{238pt}{0pt}\selectfont% + \char"66\char"69\char"78\char"64\char"69\char"66}% + \hspace*{-14.72cm}}\hfil\hbox{}\rlap{\raisebox{.2cm}[0pt][0pt]{% + \hspace*{1.4cm}\sffamily\bfseries\color{titlecolor!35}% + \fontsize{128pt}{0pt}\selectfont\thepage}}}% + \def\@oddfoot{\reset@font}\let\@evenhead\@oddhead\let\@evenfoot\@oddfoot} +\makeatother +\pagestyle{plain} + +\usepackage{fixdif} + +\linespread{1.2} +\parskip8pt plus 4pt minus 2pt +\parindent2em + +\title{\bfseries\pkg{fixdif} 宏包} +\author{AlphaZTX} +\date{2022/7/27\quad Version 1.3b% + \thanks{源代码见~\hyperref{https://github.com/AlphaZTX/fixdif}{}{}{GitHub} + 或~\hyperref{https://www.ctan.org/pkg/fixdif}{}{}{CTAN},或~\texttt{texdoc + fixdif}。} +} + +\begin{document} +\maketitle +\thispagestyle{plain} + +\begin{abstract} +\pkg{fixdif} 宏包重定义了 \LaTeX{} 中的 \cs{d} 命令,使之在数学模式下可以得到 +微分算符 $\d{}$,在正文中仍然是原来的重音符号(例如 |\d{o}| 得到 \d o)。 + +本宏包支持不同的编译方式,在 pdf\TeX、\XeTeX{} 和 \LuaTeX{} 均可使用。本宏包在 +\XeTeX{} 和 \LuaTeX{} 下兼容 \pkg{unicode-math} 宏包。 +\end{abstract} + +{\parskip0pt +\tableofcontents +} + +\section{背景} +我们一般更推荐在微分算符与前面的内容之间留出一个比较小的间距\footnote{% +见 \hyperref{https://tex.stackexchange.com/questions/14821/whats-the-% +proper-way-to-typeset-a-differential-operator}{}{}{\TeX.SX}。},比如在下面展示的 +两种情况中,右边的比左边的更好: +\[f(x)\mathrm{d}x\qquad\text{\&}\qquad f(x)\d x.\] +微分算符 $\d{}$ 与其前面的表达式之间的间距可认为是乘积的一种表示。 + +有些用户习惯使用下面的方法定义一个宏: +\begin{Verbatim} +\renewcommand\d{\mathop{\mathrm{d}}\!} +\end{Verbatim} +这个命令在很多情况下不会产生什么大问题,但是在下面给出的 3 个使用场景下就会出现 +不容忽略的问题: +\begin{enumerate} +\item 当 $\d{}$ 出现在用斜杠表示的分式的分母中时,$\d{}$ 前面会留出多余的间距。 +例如 |$\d y/\d x$| 得到 $\mathrm{d}y/\,\mathrm{d}x$; + +\item 上面定义的 \cs{d} 会覆盖原来的 \cs{d} 命令。在 \LaTeX{} 的原始定义下,\cs{d} +是一个重音符号命令,用来产生字母下方的点。如果使用了上面的定义,则在正文中 |\d{o}| +将不会得到“\d{o}”而是得到一条报错。 + +\item 前面说到,$\d{}$ 前面的间距可以认为是乘积的一种表示,因此这个间距可被视为 +一个二元运算符。在上下标中时,二元运算符在两侧的间距应当消失,例如 $a+b$ 放到上标 +中就会变成 $^{a+b}$。但是通过上面的方法定义的 \cs{d} 在上下标中,其前面的间距不会 +消失,例如 |$a^{f(x)\d x}$| 会得到 $a^{f(x)\,\mathrm{d}x}$ 而不是 $a^{f(x)\d x}$。 +\end{enumerate} +面对以上问题,解决方案是使用本宏包。 + +\section{宏包简介} +在导言区添加 +\begin{Verbatim} +\usepackage{fixdif} +\end{Verbatim} +以使用本宏包。使用了本宏包后,在正文中输入 +\begin{Verbatim} +\[ f(x)\d x, \quad \frac{\d y}{\d x}, + \quad\d y/\d x, \quad a^{y\d x}. \] +\end{Verbatim} +会得到 +\[f(x)\d x,\quad \frac{\d y}{\d x},\quad \d y/\d x,\quad a^{y\d x}.\] + +\subsection{对 \pkg{unicode-math} 宏包的兼容} +如果你在文档中使用了 \pkg{unicode-math} 宏包(编译方式为 \XeTeX{} 或 \LuaTeX{}), +需注意以下几点: +\begin{itemize} +\item 如需使用 \pkg{amsmath} 宏包,请在 \pkg{unicode-math} \zhemph{之前}% +载入 \pkg{amsmath}。 + +\item 在载入 \pkg{unicode-math} 后通过 \cs{setmathfont} 指定数学字体。 +若使用默认的数学字体,建议显式指明 |\setmathfont{Latin Modern Math}|, +这样可以避免在用斜杠表示的分式中产生不好的间距; + +\item \pkg{fixdif} 宏包需要在 \pkg{unicode-math} 宏包\zhemph{后}载入。 +\end{itemize} +从而,引入宏包的正确顺序是: +\begin{Verbatim} +\usepackage{amsmath} +\usepackage{unicode-math} +\setmathfont{...}[...] +\usepackage{fixdif} +\end{Verbatim} + +\subsection{对 \pkg{hyperref} 宏包的兼容} +如果你使用了 \pkg{hyperref} 宏包,需注意 \pkg{fixdif} 宏包需要在 \pkg{hyperref} +之后载入,否则会引起冲突。 + +\subsection{基本命令及宏包选项} +\DescribeMacro{\d} +\pkg{fixdif} 宏包提供了 \cs{d} 命令用于在数学模式中得到微分算符“$\d{}$”。 +在正文中,\cs{d} 会保留其原有的重音符号的功能。例如: +\begin{Verbatim} +$\d x$ 和 \d x +\end{Verbatim} +以上代码会得到“$\d x$ 和 \d x”。 + +\paragraph{设置 \cs{d} 的字体} +本宏包提供了两个选项来控制 \cs{d} 的字体,分别为 \opt{rm} 和 \opt{normal}。 +其中,\opt{rm} 为默认值,表示 \cs{d} 的字体为罗马体(\cs{mathrm}); +\opt{normal} 表示 \cs{d} 的字体为数学模式下的常规体(\cs{mathnormal}), +效果类似于意大利体。例如在载入宏包时开启 \opt{normal} 选项: +\begin{Verbatim} +\usepackage[normal]{fixdif} % 导言区 +\end{Verbatim} +正文中的 |$f(x)\d x$| 会得到 $f(x)\,dx$。 + +\DescribeMacro{\resetdfont} +除了上面的两种字体,\pkg{fixdif} 也支持通过在导言区使用 \cs{resetdfont} 命令 +自定义 \cs{d} 的字体。例如: +\begin{Verbatim} +\resetdfont{\mathsf} % 导言区 +\end{Verbatim} +在此设置下,正文中的 |\d x| 会得到 $\mathsf{d}x$。 + +\paragraph{\cs{partial} 的行为} +\DescribeMacro{\partial} +\pkg{fixdif} 宏包将 \cs{partial} 归为微分算符,正文中的 \cs{partial} 前面也会有 +自动的间距。例如 |$\partial x\partial y$| 会得到 $\partial x\partial y$。 +若不需要将 \cs{partial} 视为微分算符,可以开启 \opt{nopartial} 选项: +\begin{Verbatim} +\usepackage[nopartial]{fixdif} +\end{Verbatim} + +\section{通过 \pkg{fixdif} 定义微分算符命令} +{\attention[6]}注意!本节中的命令只能在\zhemph{导言区}中使用! + + +\subsection{通过命令名称定义微分算符命令} +\noindent\textcolor{titlecolor}{\cs{letdif}\marg{cmd}\marg{csname}}% +\DescribeMacro{\letdif}\hfill(仅限在导言区使用) + +\cs{letdif} 命令有两个参数:第一个参数 \meta{cmd} 是新定义的微分算符命令, +以反斜杠开头;第二个参数 \meta{csname} 是需要设置为微分算符的数学符号的命令名称, +也就是一个完整的命令去掉最前面的反斜杠。举个例子: +\begin{Verbatim} +\letdif{\vr}{delta} +\end{Verbatim} +这样定义的 |\vr| 在数学模式中就相当于一个 |\delta|,但是它的前面会加上自动的间距。 + +通过 \cs{letdif} 命令,我们可以原封不动地把一个数学符号变成微分算符。例如: +\begin{Verbatim} +\letdif{\delta}{delta} +\end{Verbatim} +这样 |\delta| 本身就会具备微分算符的属性。 + +\cs{letdif} 的第二个参数 \meta{csname} 可以重复使用,也就是说,你可以把同一个符号 +定义为两个不同的微分算符命令。例如: +\begin{Verbatim} +\letdif{\nabla}{nabla} +\letdif{\grad}{nabla} +\end{Verbatim} +这样 |\nabla| 和 |\grad| 都会得到微分算符 $\nabla$。 + +\noindent\textcolor{titlecolor}{\cs{letdif*}\marg{cmd}\marg{csname}}% +\DescribeMacro{\letdif*}\hfill(仅限在导言区使用) + +\cs{letdif*} 与 \cs{letdif} 基本相同,唯一的区别在于 \cs{letdif*} 会在微分算符 +后面添加额外的矫正。建议在使用了 \pkg{unicode-math} 的文档中使用 \cs{letdif*}。 +例如: +\begin{Verbatim} +\usepackage{unicode-math} +\setmathfont{TeX Gyre Termes Math} +\usepackage{fixdif} +\letdif{\vr}{updelta} +\end{Verbatim} +这样定义的 |\vr| 后面就会有负的间距,如果不希望得到这一负间距,可以把上面的最后一行 +改为: +\begin{Verbatim} +\letdif*{\vr}{updelta} +\end{Verbatim} + +\subsection{定义包含多个命令或字符的微分算符命令} + +\noindent\textcolor{titlecolor}{\cs{newdif}\marg{cmd}\marg{multi-cmd}}% +\DescribeMacro{\newdif}\hfill(仅限在导言区使用,后无矫正)\\ +\noindent\textcolor{titlecolor}{\cs{newdif*}\marg{cmd}\marg{multi-cmd}}% +\DescribeMacro{\newdif*}\hfill(仅限在导言区使用,后有矫正) + +上面两个命令的第一个参数 \meta{cmd} 是新定义的微分算符命令,第二个参数 +\meta{multi-cmd} 是超过一个字(token)的命令组合或字符串。举个例子,在 +\pkg{xcolor} 宏包下可以这样使用: +\begin{Verbatim} +\newdif{\redsfd}{\textsf{\color{red}d}} +\end{Verbatim} +这样就定义了一个 |\redsfd| 命令。再举一个例子: +\begin{Verbatim} +\newdif{\D}{\mathrm{D}} +\end{Verbatim} +这样,在正文中输入 |$y\D x$| 就会得到 $y\,\mathrm{D}x$。 + +{\attention[2]}如果 \cs{newdif}(\texttt{*}) 后面的第二个参数 \meta{multi-cmd} +仅包含一个字(token),也就是一个命令或字符,请使用 \cs{letdif}(\texttt{*}) 命令 +而不是 \cs{newdif}(\texttt{*})。 + +\cs{newdif}(\texttt{*}) 会检查第一个参数 \meta{cmd} 是否已经被定义,若 \meta{cmd} +已被定义,则会报错。 + +\noindent\textcolor{titlecolor}{\cs{renewdif}\marg{cmd}\marg{multi-cmd}}\DescribeMacro{\renewdif} +\hfill(仅限在导言区使用,后无矫正)\\ +\noindent\textcolor{titlecolor}{\cs{renewdif*}\marg{cmd}\marg{multi-cmd}}\DescribeMacro{\renewdif*} +\hfill(仅限在导言区使用,后有矫正) + +这两个命令用于将 \meta{cmd} 重定义为微分算符命令。 +若 \meta{cmd} 还未被定义,则会报错。 + +\section{正文中临时的微分算符命令} +\noindent\textcolor{titlecolor}{\cs{mathdif}\marg{symbol}}% +\DescribeMacro{\mathdif}\hfill(仅限在数学模式使用,后无矫正)\\ +\noindent\textcolor{titlecolor}{\cs{mathdif*}\marg{symbol}}% +\DescribeMacro{\mathdif*}\hfill(仅限在数学模式使用,后有矫正) + +如需在正文中少量使用某一数学符号作为微分算符,可以使用上面的两个命令。 +例如,\verb|$x\mathdif{\Delta}\psi$| 会得到 $x\mathdif{\Delta}\psi$。 + +\section{举例} + +本节将告诉你如何在文档中正确使用 \pkg{fixdif} 宏包。 + +看以下两行代码: +\begin{Verbatim} +\letdif{\Delta}{Delta} +\letdif{\nabla}{nabla} +\end{Verbatim} +哪一行更合理一些?答案是第二行。 + +有时,大写的“$\Delta$”会被用作拉普拉斯算符(与 $\nabla^2$ 意义相同); +另一些时候,大写的“$\Delta$”会被当作变量或函数。所以对 $\Delta$ 作为 +拉普拉斯算符和变量或函数的情况分别进行定义是更好的做法。我们建议将 |$\Delta$| +作为 $\Delta$ 的原始定义进行保留,对表示拉普拉斯算符的 $\Delta$ 另加定义。 +从而我们这样修改上面的第一行: +\begin{Verbatim} +\letdif{\laplacian}{Delta} +\end{Verbatim} +如果你比较擅长使用 \pkg{xparse} 宏包的接口,你也可以采用下面的方法: +\begin{Verbatim} +\letdif{\nabla}{nabla} +\DeclareDocumentCommand{ \laplacian }{ s }{ + \IfBooleanTF { #1 } { \mathdif{\Delta} } { \nabla^2 } +} +\end{Verbatim} +这样,|\laplacian| 会得到 $\nabla^2$,|\laplacian*| 会得到 $\Delta$。 + +\paragraph{处理正负号与微分算符之间的间距} +输入 |$-\d x$| 会得到 $-\d x$。如果你不希望在正负号与微分算符之间保留 +一定的间距,可以输入 |$-{\d x}$|,这样就会得到 $-{\d x}$。 +不过话说回来,$-\d x$ 的效果也并非不可接受。 + +\end{document}
\ No newline at end of file diff --git a/macros/latex/contrib/fixdif/fixdif.dtx b/macros/latex/contrib/fixdif/fixdif.dtx index 34d709b9ab..5cc0a60a12 100644 --- a/macros/latex/contrib/fixdif/fixdif.dtx +++ b/macros/latex/contrib/fixdif/fixdif.dtx @@ -116,6 +116,8 @@ Copyright (C) 2022 by Zhang Tingxuan <alphaztx@163.com>. \Msg{* *} \Msg{* To produce the documentation run the file *} \Msg{* fixdif.dtx through pdfLaTeX/XeLaTeX/LuaLaTeX. *} +\Msg{* XeLaTeX and LuaLaTeX are recommended if you *} +\Msg{* hope the PDF file to be smaller. *} \Msg{* *} \Msg{* Happy TeXing! *} \Msg{* *} @@ -129,7 +131,7 @@ Copyright (C) 2022 by Zhang Tingxuan <alphaztx@163.com>. %</internal> % %<*driver> -\ProvidesFile{fixdif.dtx}[2022/7/19 (c) Copyright 2022 by Zhang Tingxuan] +\ProvidesFile{fixdif.dtx}[2022/7/27 (c) Copyright 2022 by Zhang Tingxuan] \documentclass{ltxdoc} \usepackage{xcolor} @@ -148,7 +150,7 @@ Copyright (C) 2022 by Zhang Tingxuan <alphaztx@163.com>. \title{The \pkg{fixdif} Package} \author{Zhang Tingxuan} -\date{2022/7/19\quad Version 1.3a\thanks{\url{https://github.com/AlphaZTX/fixdif}}} +\date{2022/7/27\quad Version 1.3b\thanks{\url{https://github.com/AlphaZTX/fixdif}}} \usepackage{hyperref} \hypersetup{ @@ -173,13 +175,19 @@ Copyright (C) 2022 by Zhang Tingxuan <alphaztx@163.com>. {.8ex plus .4ex minus .2ex}% {-1em}% {\normalfont\normalsize\bfseries\color{titlecolor}}} +\def\ps@fixdif{\let\@mkboth\@gobbletwo + \def\@oddhead{\hbox{}\hfil\hbox{}% + \rlap{\raisebox{-.1cm}[0pt][0pt]{% + \hspace*{.6cm}\sffamily\bfseries\color{titlecolor!35}% + \fontsize{128pt}{0pt}\selectfont\thepage}}}% + \def\@oddfoot{\reset@font}\let\@evenhead\@oddhead\let\@evenfoot\@oddfoot} \def\UrlAlphabet{% - \do\a\do\b\do\c\do\d\do\e\do\f\do\g\do\h\do\i\do\j% - \do\k\do\l\do\m\do\n\do\o\do\p\do\q\do\r\do\s\do\t% - \do\u\do\v\do\w\do\x\do\y\do\z\do\A\do\B\do\C\do\D% - \do\E\do\F\do\G\do\H\do\I\do\J\do\K\do\L\do\M\do\N% - \do\O\do\P\do\Q\do\R\do\S\do\T\do\U\do\V\do\W\do\X% - \do\Y\do\Z} + \do\a\do\b\do\c\do\d\do\e\do\f\do\g\do\h\do\i\do\j% + \do\k\do\l\do\m\do\n\do\o\do\p\do\q\do\r\do\s\do\t% + \do\u\do\v\do\w\do\x\do\y\do\z\do\A\do\B\do\C\do\D% + \do\E\do\F\do\G\do\H\do\I\do\J\do\K\do\L\do\M\do\N% + \do\O\do\P\do\Q\do\R\do\S\do\T\do\U\do\V\do\W\do\X% + \do\Y\do\Z} \def\UrlDigits{\do\1\do\2\do\3\do\4\do\5\do\6\do\7\do\8\do\9\do\0} \g@addto@macro{\UrlBreaks}{\UrlOrds} \g@addto@macro{\UrlBreaks}{\UrlAlphabet} @@ -189,6 +197,7 @@ Copyright (C) 2022 by Zhang Tingxuan <alphaztx@163.com>. \setmathfont{Latin Modern Math} \fi \makeatother +\pagestyle{fixdif} \usepackage{fixdif} @@ -465,7 +474,7 @@ Copyright (C) 2022 by Zhang Tingxuan <alphaztx@163.com>. % Check the \TeX{} format and provides the package name. % \begin{macrocode} \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{fixdif}[2022/7/19 Interface for defining differential operators.] +\ProvidesPackage{fixdif}[2022/7/27 Interface for defining differential operators.] % \end{macrocode} % % \subsection{Control the skip between slashes and differential operator} diff --git a/macros/latex/contrib/fixdif/fixdif.ins b/macros/latex/contrib/fixdif/fixdif.ins index f0dd92e342..1bea3ed204 100644 --- a/macros/latex/contrib/fixdif/fixdif.ins +++ b/macros/latex/contrib/fixdif/fixdif.ins @@ -78,6 +78,8 @@ \Msg{* *} \Msg{* To produce the documentation run the file *} \Msg{* fixdif.dtx through pdfLaTeX/XeLaTeX/LuaLaTeX. *} +\Msg{* XeLaTeX and LuaLaTeX are recommended if you *} +\Msg{* hope the PDF file to be smaller. *} \Msg{* *} \Msg{* Happy TeXing! *} \Msg{* *} diff --git a/macros/latex/contrib/fixdif/fixdif.pdf b/macros/latex/contrib/fixdif/fixdif.pdf Binary files differindex 1f40b218ba..2295c49d3d 100644 --- a/macros/latex/contrib/fixdif/fixdif.pdf +++ b/macros/latex/contrib/fixdif/fixdif.pdf diff --git a/macros/latex/contrib/scripture/README.md b/macros/latex/contrib/scripture/README.md new file mode 100644 index 0000000000..9aab2b86ec --- /dev/null +++ b/macros/latex/contrib/scripture/README.md @@ -0,0 +1,75 @@ +# scripture — A LaTeX style for typesetting Bible quotations + +The `scripture` package provides a set of macros for typesetting quotations +from the Bible. It provides many features commonly seen in Bibles such as +dropped text for chapter numbers, superscripts for verse numbers, indented +lines for poetry sections, narrow sections and hanging paragraphs. A reference +for the quotation can optionally be added. + +## Installation from TeXLive or MiKTeX + +The `scripture` package is in TeXLive and MiKTeX and can be installed in the +usual way through your distribution. E.g., in TeXLive by running: + +``` +tlmgr install scripture +``` + +## Installation from CTAN + +Download and unpack `scripture.zip` from CTAN at +https://ctan.org/pkg/scripture + +Change to the `scripture` directory, then run: + +``` +tex scripture.ins +``` + +to generate `scripture.sty`. + +Copy `scripture.sty` to `$TEXMFHOME/tex/latex/scripture/` and `scripture.pdf` +to `$TEXMFHOME/doc/latex/scripture/`. + +You can find `$TEXMFHOME` by running: + +``` +kpsewhich -var-value=TEXMFHOME +``` + +## Installation from Git Source + +`scripture` uses the `l3build` system. + +Clone the git repository using: + +``` +git clone https://github.com/dcpurton/scripture.git +``` + +Change to the `scripture` directory, and then the style file (`scripture.sty`) +and documentation (`scripture.pdf`) can be installed by running: + +``` +l3build install --full +``` + +## Licence + +``` +Copyright (c) 2018-2022 David Purton <dcpurton@marshwiggle.net> + +This work may be distributed and/or modified under the conditions of +the LaTeX Project2 Public License, either version 1.3c of this license +or (at your option) any later version. The latest version of this +license is in + http://www.latex-project.org/lppl.txt +and version 1.3c or later is part of all distributions of LaTeX +version 2005/12/01 or later. + +This work is "maintained" (as per the LPPL maintenance status) +by David Purton. + +This work consists of the files scripture.ins, scripture.dtx, README.md, +and the derived files scripture.sty and scripture.pdf +``` diff --git a/macros/latex/contrib/scripture/scripture.dtx b/macros/latex/contrib/scripture/scripture.dtx new file mode 100644 index 0000000000..e9d51175fb --- /dev/null +++ b/macros/latex/contrib/scripture/scripture.dtx @@ -0,0 +1,2541 @@ +% \iffalse meta-comment +% +% Copyright (c) 2022 David Purton <dcpurton@marshwiggle.net> +% +% 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 +% http://www.latex-project.org/lppl.txt +% and version 1.3c or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +%<*driver> +\documentclass[a4paper]{l3doc} +\usepackage[parindent=1em]{scripture} +\usepackage[skins]{tcolorbox} +\newtcolorbox{scriptureexample}[1][]{% + bicolor, colframe=cyan, colback=cyan!10, colbacklower=white, left=2mm, + right=2mm, fontupper=\footnotesize, fontlower=\footnotesize, sidebyside, + sidebyside gap=6mm, sidebyside align=top, lefthand ratio=0.6, before + skip=\bigskipamount, after skip=\bigskipamount, #1 +} +\ExplSyntaxOn +\makeatletter +\cs_new_protected:Npn \__dcp_codedoc_environment_index:n #1 + { + \@bsphack + \begingroup + \__codedoc_target: + \index + { + #1\actualchar{\protect\ttfamily#1}~(environment) + \encapchar hdclindex{\the\c@HD@hypercount}{usage} + } + \index + { + environments:\levelchar#1\actualchar{\protect\ttfamily#1} + \encapchar hdclindex{\the\c@HD@hypercount}{usage} + } + \endgroup + \@esphack + } +\cs_new_protected:Npn \__dcp_codedoc_envmacro_index:nN #1#2 + { + \DoNotIndex {#1} + \bool_if:NT #2 + { + \__codedoc_if_macro_internal:nF {#1} + { \seq_gput_right:Nn \g_doc_macros_seq {#1} } + \hbox_set:Nw \l__codedoc_macro_index_box + \hbox_unpack_drop:N \l__codedoc_macro_index_box + \int_gincr:N \c@CodelineNo + \@bsphack + \begingroup + \__codedoc_target: + \index + { + #1\actualchar{\protect\ttfamily#1}~(environment) + \encapchar hdclindex{\the\c@HD@hypercount}{main} + } + \index + { + environments:\levelchar#1\actualchar{\protect\ttfamily#1} + \encapchar hdclindex{\the\c@HD@hypercount}{main} + } + \endgroup + \@esphack + \int_gdecr:N \c@CodelineNo + \exp_args:NNNo \hbox_set_end: + \tl_set:Nn \saved@indexname { \l__codedoc_index_key_tl } + } + } +\DeclareDocumentEnvironment { environment } { O{} +v } + { + \cs_set_eq:NN \__codedoc_function_index:n \__dcp_codedoc_environment_index:n + \__codedoc_function:nnw {#1} {#2} + } + { \__codedoc_function_end: } +\DeclareDocumentEnvironment { option } { O{} +v } + { + \cs_set_eq:NN \__codedoc_function_index:n \SpecialOptionIndex + \__codedoc_function:nnw {#1} {#2} + } + { \__codedoc_function_end: } +\DeclareDocumentEnvironment { envmacro } { O{} +v } + { + \cs_set_eq:NN \__codedoc_macro_index:nN \__dcp_codedoc_envmacro_index:nN + \__codedoc_macro:nnw {#1} {#2} + } + { \__codedoc_macro_end: } +\DeclareDocumentCommand \opt { m } + { + \SpecialOptionIndex{#1} + \texttt{#1} + } +\DeclareRobustCommand \val {\texttt} +\makeatother +\ExplSyntaxOff +\begin{document} +\DocInput{\jobname.dtx} +\end{document} +%</driver> +% \fi +% +% \changes{v1.0}{2022/07/27}{First public release} +% +% \title{The \pkg{scripture} package} +% \author{David Purton\thanks{Email: \url{dcpurton@marshwiggle.net}}} +% \date{2022/07/27 v1.0} +% +% \maketitle +% +% \begin{abstract} +% The \pkg{scripture} package provides a set of macros for typesetting +% quotations from the Bible. It provides many features commonly seen in +% Bibles such as dropped text for chapter numbers, superscripts for verse +% numbers, indented lines for poetry sections, narrow sections and hanging +% paragraphs. A reference for the quotation can optionally be added. +% \end{abstract} +% +% \tableofcontents +% +% \begin{documentation} +% +% \section{Introduction} +% +% Bibles tend to use a number of standard features when laying out chapters +% and verses. The main goal for the \pkg{scripture} package is to be able to +% quickly and easily input text and have it output nicely with minimal manual +% adjustment. +% +% The package supports dropped text for chapter numbers, superscripts for +% verse numbers, appropriately indented lines for the first and second halves +% of poetry, flush right sections, centred sections, narrow sections and +% hanging sections. +% +% The package could be used for typesetting an entire Bible, but it is mainly +% envisioned that it will be used for producing Scripture quotations. The +% passage reference can be included on the last line if there is space or +% failing that on the following line. +% +% \subsection{Bug reports and feature requests} +% +% Bug reports and feature requests can be made at the \pkg{scripture} package +% GitHub repository. See \url{https://github.com/dcpurton/scripture}. +% +% \subsection{Limitations} +% +% The \pkg{scripture} package makes extensive use of \LaTeX{} \env{list} +% environments and the \cs{parshape} command. This means there are some +% limitations. In particular, you should not: +% \begin{itemize} +% \item Nest the \env{scripture} environment or any of its internal +% environments. +% \item Modify the \cs{parshape} within a \env{scripture} environment. +% \item Include any other \env{list} based environment within a +% \env{scripture} environment. +% \end{itemize} +% +% \section{Documentation} +% +% \subsection{Basic usage} +% +% Scripture quotations must be set within a \env{scripture} environment. A +% simple quotation might be produced as follows: +% +% \begin{scriptureexample} +% \begin{verbatim} +% \begin{scripture}[Isaiah 56:1--2][version=NIVUK] +% \ch{56}This is what the \textsc{Lord} says: +% +% \begin{poetry} +% `Maintain justice +% and do what is right, +% +% for my salvation is close at hand +% and my righteousness will soon be revealed. +% +% \vs{2}Blessed is the one who does this--- +% the person who holds it fast, +% +% who keeps the Sabbath without desecrating it, +% and keeps their hands from doing any evil.' +% \end{poetry} +% \end{scripture} +% \end{verbatim} +% +% \tcblower +% +% \begin{scripture}[Isaiah 56:1--2][version=NIVUK] +% \ch{56}This is what the \textsc{Lord} says: +% +% \begin{poetry} +% `Maintain justice +% and do what is right, +% +% for my salvation is close at hand +% and my righteousness will soon be revealed. +% +% \vs{2}Blessed is the one who does this--- +% the person who holds it fast, +% +% who keeps the Sabbath without desecrating it, +% and keeps their hands from doing any evil.' +% \end{poetry} +% \end{scripture} +% \end{scriptureexample} +% +% \subsection{Macros for typesetting scripture quotations} +% +% \subsubsection{Functions} +% +% \begin{function}{\ch, \ch*} +% \begin{syntax} +% |\ch|\marg{chapter number} +% |\ch*|\marg{chapter number} +% \end{syntax} +% Format a chapter number. By default these are formatted using drop text +% taking up two lines and the text is separated from the chapter number by a +% horizontal space of 0.5\,em. +% +% If the \opt{dropchap} option is \val{true} (default), then this function +% attempts to add sufficient space for the dropped chapter when its +% paragraph contains only one line. The starred version suppresses this +% behaviour. +% \end{function} +% +% \begin{function}{\extraskip} +% \begin{syntax} +% |\extraskip| +% \end{syntax} +% Add a small vertical space of \opt{extraskip} between a paragraph. This +% function attempts to add additional space to avoid a clash with a drop +% chapter if required. +% \end{function} +% +% \begin{function}{\nohang} +% \begin{syntax} +% |\nohang| +% \end{syntax} +% In a \env{hanging} environment, this function indents the first line of +% the paragraph a length of \opt{hanging/hang} $+$ \opt{parindent}. +% Remaining lines continue to be indented by a length of \opt{hanging/hang}. +% \end{function} +% +% \begin{function}{\scripturesetup} +% \begin{syntax} +% |\scripturesetup|\marg{options} +% \end{syntax} +% Set default format for quotations. See section \ref{options} for +% supported formatting \meta{|options|}. +% \end{function} +% +% \begin{function}{\vs} +% \begin{syntax} +% |\vs|\marg{verse number} +% \end{syntax} +% Format a verse number. By default these are formatted using a superscript. +% \end{function} +% +% \subsubsection{Environments} +% +% All scripture quotations must be set within a \env{scripture} environment. +% The rest of the environments documented below are only defined with the +% \env{scripture} environment. In most cases there is a default small +% \meta{\opt{aboveskip}} and \meta{\opt{belowskip}} inserted above and below +% these internal environments, but these are ignored if the environment is at +% the start or end of a \env{scripture} environment. +% +% \begin{environment}{center} +% \begin{syntax} +% |\begin{center}|\oarg{options} +% \quad\meta{centred text} +% |\end{center}| +% \end{syntax} +% \end{environment} +% +% \noindent Environment for typesetting centred sections of scripture +% quotations. +% +% See section \ref{centeroptions} for supported formatting \meta{|options|}. +% +% \begin{scriptureexample} +% \begin{verbatim} +% \begin{scripture}[Daniel 5:25] +% \vs{25}‘This is the inscription that was +% written: +% +% \begin{center} +% \textsc{mene, mene, tekel, parsin} +% \end{center} +% \end{scripture} +% \end{verbatim} +% +% \tcblower +% +% \begin{scripture}[Daniel 5:25] +% \vs{25}‘This is the inscription that was +% written: +% +% \begin{center} +% \textsc{mene, mene, tekel, parsin} +% \end{center} +% \end{scripture} +% \end{scriptureexample} +% +% \begin{environment}{flushright} +% \begin{syntax} +% |\begin{flushright}|\oarg{options} +% \quad\meta{right aligned text} +% |\end{flushright}| +% \end{syntax} +% \end{environment} +% +% \noindent Environment for typesetting right aligned sections of scripture +% quotations. +% +% See section \ref{flushrightoptions} for supported formatting +% \meta{|options|}. +% +% \begin{scriptureexample} +% \begin{verbatim} +% \begin{scripture}[Jeremiah 2:29] +% \begin{poetry}[belowskip=0pt] +% \vs{5}‘Why do you bring charges against me? +% You have all rebelled against me,’ +% \end{poetry} +% +% \begin{flushright}[aboveskip=0pt] +% declares the \textsc{Lord}. +% \end{flushright} +% \end{scripture} +% \end{verbatim} +% +% \tcblower +% +% \begin{scripture}[Jeremiah 2:29] +% \begin{poetry}[belowskip=0pt] +% \vs{5}‘Why do you bring charges against me? +% You have all rebelled against me,’ +% \end{poetry} +% +% \begin{flushright}[aboveskip=0pt] +% declares the \textsc{Lord}. +% \end{flushright} +% \end{scripture} +% \end{scriptureexample} +% +% \begin{environment}{hanging} +% \begin{syntax} +% |\begin{hanging}|\oarg{options} +% \quad\meta{hanging text} +% |\end{hanging}| +% \end{syntax} +% \end{environment} +% +% \noindent Environment for typesetting hanging sections of scripture +% quotations. +% +% See section \ref{hangingoptions} for supported formatting \meta{|options|}. +% +% \begin{scriptureexample} +% \begin{verbatim} +% \begin{scripture}[Genesis 1:3--5] +% \begin{hanging} +% \vs{3}And God said, ‘Let there be light,’ and +% there was light. \vs{4}God saw that the light +% was good, and he separated the light from the +% darkness. \vs{5}God called the light ‘day’, +% and the darkness he called ‘night’. And there +% was evening, and there was morn\-ing---the +% first day. +% \end{hanging} +% \end{scripture} +% \end{verbatim} +% +% \tcblower +% +% \begin{scripture}[Genesis 1:3--5] +% \begin{hanging} +% \vs{3}And God said, ‘Let there be light,’ and +% there was light. \vs{4}God saw that the light +% was good, and he separated the light from the +% darkness. \vs{5}God called the light ‘day’, +% and the darkness he called ‘night’. And there +% was evening, and there was morn\-ing---the +% first day. +% \end{hanging} +% \end{scripture} +% \end{scriptureexample} +% +% \begin{environment}{midparachap} +% \begin{syntax} +% |\begin{midparachap}| +% \quad\meta{text containing a chapter break} +% |\end{midparachap}| +% \end{syntax} +% \end{environment} +% +% \noindent Environment for typesetting paragraph with a chapter break within +% it. +% +% \begin{scriptureexample} +% \begin{verbatim} +% \begin{scripture}[1 Corinthians 10:31--11:1] +% \begin{midparachap} +% \vs{31}So whether you eat or drink or +% whatever you do, do it all for the glory of +% God. \vs{32}Do not cause anyone to stumble, +% whether Jews, Greeks or the church of +% God---\vs{33}even as I try to please everyone +% in every way. For I am not seeking my own +% good but the good of many, so that they may +% be saved. \ch{11}Follow my example, as I +% follow the example of Christ. +% \end{midparachap} +% \end{scripture} +% \end{verbatim} +% +% \tcblower +% +% \begin{scripture}[1 Corinthians 10:31--11:1] +% \begin{midparachap} +% \vs{31}So whether you eat or drink or +% whatever you do, do it all for the glory of +% God. \vs{32}Do not cause anyone to stumble, +% whether Jews, Greeks or the church of +% God---\vs{33}even as I try to please everyone +% in every way. For I am not seeking my own +% good but the good of many, so that they may +% be saved. \ch{11}Follow my example, as I +% follow the example of Christ. +% \end{midparachap} +% \end{scripture} +% \end{scriptureexample} +% +% \begin{environment}{narrow} +% \begin{syntax} +% |\begin{narrow}|\oarg{options} +% \quad\meta{quotation} +% |\end{narrow}| +% \end{syntax} +% \end{environment} +% +% \noindent Environment for typesetting narrow sections of scripture +% quotations. +% +% See section \ref{narrowoptions} for supported formatting \meta{|options|}. +% +% \begin{scriptureexample} +% \begin{verbatim} +% \begin{scripture}[2 Kings 18:18--19] +% \vs{18}They called for the king; and Eliakim +% son of Hilkiah the palace administrator, Shebna +% the secretary, and Joah son of Asaph the +% recorder went out to them. +% +% \vs{19}The field commander said to them, ‘Tell +% Hezekiah: +% +% \begin{narrow} +% ‘“This is what the great king, the king of +% Assyria, says: on what are you basing this +% confidence of yours? +% \end{narrow} +% \end{scripture} +% \end{verbatim} +% +% \tcblower +% +% \begin{scripture}[2 Kings 18:18--19] +% \vs{18}They called for the king; and Eliakim +% son of Hilkiah the palace administrator, Shebna +% the secretary, and Joah son of Asaph the +% recorder went out to them. +% +% \vs{19}The field commander said to them, ‘Tell +% Hezekiah: +% +% \begin{narrow} +% ‘“This is what the great king, the king of +% Assyria, says: on what are you basing this +% confidence of yours? +% \end{narrow} +% \end{scripture} +% \end{scriptureexample} +% +% \begin{environment}{poetry} +% \begin{syntax} +% |\begin{poetry}|\oarg{options} +% \quad\meta{first half of verse} +% \quad\meta{second half of verse} +% \quad +% \quad\meta{first half of verse} +% \quad\meta{second half of verse} +% |\end{poetry}| +% \end{syntax} +% \end{environment} +% +% \noindent Environment for typesetting poetry sections of scripture +% quotations. +% +% Poetry sections of the Bible often have a first have and a parallel second +% half which is indented a little. These should be set on separate consecutive +% lines. Leaving a blank line indicates that the next line should return to +% the first half indent. +% +% See section \ref{poetryoptions} for supported formatting \meta{|options|}. +% +% \begin{scriptureexample} +% \begin{verbatim} +% \begin{scripture}[Isaiah 1:2] +% \begin{poetry} +% \vs{2}Hear me, you heavens! Listen, earth! +% For the \textsc{Lord} has spoken: +% +% ‘I reared children and brought them up, +% but they have rebelled against me. +% \end{poetry} +% \end{scripture} +% \end{verbatim} +% +% \tcblower +% +% \begin{scripture}[Isaiah 1:2] +% \begin{poetry} +% \vs{2}Hear me, you heavens! Listen, earth! +% For the \textsc{Lord} has spoken: +% +% ‘I reared children and brought them up, +% but they have rebelled against me. +% \end{poetry} +% \end{scripture} +% \end{scriptureexample} +% +% \begin{environment}{scripture} +% \begin{syntax} +% |\begin{scripture}|\oarg{reference}\oarg{options} +% \quad\meta{quotation} +% |\end{scripture}| +% \end{syntax} +% \end{environment} +% +% \noindent Main environment for typesetting scripture quotations. +% +% The optional \meta{|reference|} is printed at the end of the quotation. See +% section \ref{options} for supported formatting \meta{|options|}. +% +% \begin{scriptureexample} +% \begin{verbatim} +% \begin{scripture}[John 3:16][version=NIV] +% \vs{16}For God so loved the world that he gave +% his one and only Son, that whoever believes in +% him shall not perish but have eternal life. +% \end{scripture} +% \end{verbatim} +% +% \tcblower +% +% \begin{scripture}[John 3:16][version=NIV] +% \vs{16}For God so loved the world that he gave +% his one and only Son, that whoever believes in +% him shall not perish but have eternal life. +% \end{scripture} +% \end{scriptureexample} +% +% \subsection{Options} +% \label{options} +% +% Default formatting \meta{|options|} can be set using +% \cs{usepackage}|[|\meta{|options|}|]{scripture}| or +% \cs{scripturesetup}|{|\meta{|options|}|}|. Local formatting \meta{|options|} +% can be set by passing them to the various environments described above. +% +% \begin{option}{aboveskip} +% \begin{syntax} +% |aboveskip =| \meta{skip} \hfill Default: 0pt +% \end{syntax} +% \meta{|skip|} inserted above the \env{scripture} environment. +% \end{option} +% +% \begin{option}{belowskip} +% \begin{syntax} +% |belowskip =| \meta{skip} \hfill Default: 0pt +% \end{syntax} +% \meta{|skip|} inserted below the \env{scripture} environment. +% \end{option} +% +% \begin{option}{leftmargin} +% \begin{syntax} +% |leftmargin =| \meta{dimen} \hfill Default: 0pt +% \end{syntax} +% \meta{|dimen|} used for the left margin of the \env{scripture} +% environment. +% \end{option} +% +% \begin{option}{rightmargin} +% \begin{syntax} +% |rightmargin =| \meta{dimen} \hfill Default: 0pt +% \end{syntax} +% \meta{|dimen|} used for the right margin of the \env{scripture} +% environment. +% \end{option} +% +% \begin{option}{chapter/font} +% \begin{syntax} +% |chapter/font =| \meta{font} \hfill Default: \cs{bfseries} +% \end{syntax} +% \meta{|font|} used for the \cs{ch} function. +% \end{option} +% +% \begin{option}{chapter/drop} +% \begin{syntax} +% |chapter/drop =| \meta{boolean} \hfill Default: true +% \end{syntax} +% Whether the chapter should be set as a drop letter taking up two +% lines or as a normal letter taking up one line. The value of +% \meta{|boolean|} is optional and assumed to be \val{true} if not present. +% This option is the opposite of \opt{chapter/nodrop}. +% \end{option} +% +% \begin{option}{chapter/nodrop} +% \begin{syntax} +% |chapter/nodrop =| \meta{boolean} \hfill Default: false +% \end{syntax} +% Whether the chapter should be set as a drop letter taking up two lines or +% as a normal letter taking up one line. The value of \meta{|boolean|} is +% optional and assumed to be \val{true} if not present. This option is the +% opposite of \opt{chapter/drop}. +% \end{option} +% +% \begin{option}{chapter/sep} +% \begin{syntax} +% |chapter/sep =| \meta{dimen} \hfill Default: 0.5em +% \end{syntax} +% \meta{|dimen|} used to separate a \cs{ch} from the following text. +% \end{option} +% +% \begin{option}{extraskip} +% \begin{syntax} +% |extraskip =| \meta{skip} \hfill Default: \cs{medskip} +% \end{syntax} +% \meta{|skip|} used for the \cs{extraskip} function. +% \end{option} +% +% \begin{option}{font} +% \begin{syntax} +% |font =| \meta{font} \hfill Default: \emph{Empty} +% \end{syntax} +% \meta{|font|} used for the \env{scripture} environment. +% \end{option} +% +% \begin{option}{indent} +% \begin{syntax} +% |indent =| \meta{boolean} \hfill Default: true +% \end{syntax} +% Whether to indent the first line of a \env{scripture} environment or not +% by \cs{parindent}. The value of \meta{|boolean|} is optional and assumed to +% be \val{true} if not present. This option is the opposite of +% \opt{noindent}. +% \end{option} +% +% \begin{option}{noindent} +% \begin{syntax} +% |noindent =| \meta{boolean} \hfill Default: false +% \end{syntax} +% Whether to indent the first line of a \env{scripture} environment or not +% by \cs{parindent}. The value of \meta{|boolean|} is optional and assumed to +% be \val{true} if not present. This option is the opposite of +% \opt{indent}. +% \end{option} +% +% \begin{option}{parindent} +% \begin{syntax} +% |parindent =| \meta{dimen} \hfill Default: \cs{parindent} +% \end{syntax} +% \meta{|dimen|} to use when indenting the first line of a paragraph in the +% \env{scripture} environment. +% \end{option} +% +% \begin{option}{parskip} +% \begin{syntax} +% |parskip =| \meta{skip} \hfill Default: \cs{parskip} +% \end{syntax} +% \meta{|skip|} to use between paragraphs in the \env{scripture} environment. +% \end{option} +% +% \begin{option}{reference/delim} +% \begin{syntax} +% |reference/delim =| \meta{delim} \hfill Default: \cs{hfill} +% \end{syntax} +% \meta{|delim|} to use between the \env{scripture} quotation and its +% \val{reference}. +% \end{option} +% +% \begin{option}{reference/font} +% \begin{syntax} +% |reference/font =| \meta{font} \hfill Default: bfseries +% \end{syntax} +% \meta{|font|} used when printing the \val{reference} for a \env{scripture} +% quotation. +% \end{option} +% +% \begin{option}{reference/format} +% \begin{syntax} +% |reference/format =| \meta{macro} \hfill Default: \#1 +% \end{syntax} +% \meta{|macro|} used to format the \val{reference} for a \env{scripture} +% quotation. |#1| contains the text of the \val{reference}. +% \end{option} +% +% \begin{option}{reference/sep} +% \begin{syntax} +% |reference/sep =| \meta{dimen} \hfill Default: 2em +% \end{syntax} +% The minimum \meta{|dimen|} allowed between the end of a \env{scripture} +% quotation and its \val{reference} before the \val{reference} is pushed to +% the following line. +% \end{option} +% +% \begin{option}{verse/font} +% \begin{syntax} +% |verse/font =| \meta{font} \hfill Default: \emph{Empty} +% \end{syntax} +% \meta{|font|} used for the \cs{vs} function. +% \end{option} +% +% \begin{option}{verse/format} +% \begin{syntax} +% |verse/format =| \meta{macro} \hfill Default: \cs{textsuperscript}\{\#1\} +% \end{syntax} +% \meta{|macro|} used to format the \cs{vs} function. |#1| contains the +% argument of \cs{vs}. +% \end{option} +% +% \begin{option}{version} +% \begin{syntax} +% |version =| \meta{version} \hfill Default: \emph{Empty} +% \end{syntax} +% \meta{|version|} added to the \val{reference} for a \env{scripture} +% quotation. +% \end{option} +% +% \begin{option}{version/delim} +% \begin{syntax} +% |version/delim =| \meta{delim} \hfill Default: \{\ \} +% \end{syntax} +% \meta{|delim|} to use between the \val{reference} and the \val{version} of a +% \env{scripture} quotation. +% \end{option} +% +% \begin{option}{version/format} +% \begin{syntax} +% |version/format =| \meta{macro} \hfill Default: (\#1) +% \end{syntax} +% \meta{|macro|} used to format the \val{version} for a \env{scripture} +% quotation. |#1| contains the text of the \val{version}. +% \end{option} +% +% \subsubsection{Options for the \env{center} environment} +% \label{centeroptions} +% +% If these options are passed directly to the \env{center} environment rather +% than to the package, \cs{scripturesetup} or the \env{scripture} environment, +% then the |center/| prefix should be dropped. +% +% \begin{option}{center/aboveskip} +% \begin{syntax} +% |center/aboveskip =| \meta{skip} \hfill Default: \cs{medskip} +% \end{syntax} +% \meta{|skip|} inserted above the \env{center} environment. +% \end{option} +% +% \begin{option}{center/belowskip} +% \begin{syntax} +% |center/belowskip =| \meta{skip} \hfill Default: \cs{medskip} +% \end{syntax} +% \meta{|skip|} inserted below the \env{center} environment. +% \end{option} +% +% \begin{option}{center/leftmargin} +% \begin{syntax} +% |center/leftmargin =| \meta{dimen} \hfill Default: 0pt +% \end{syntax} +% \meta{|dimen|} used for the left margin of the \env{center} environment. +% \end{option} +% +% \begin{option}{center/rightmargin} +% \begin{syntax} +% |center/rightmargin =| \meta{dimen} \hfill Default: 0pt +% \end{syntax} +% \meta{|dimen|} used for the right margin of the \env{center} environment. +% \end{option} +% +% \subsubsection{Options for the \env{flushright} environment} +% \label{flushrightoptions} +% +% If these options are passed directly to the \env{flushright} environment rather +% than to the package, \cs{scripturesetup} or the \env{scripture} environment, +% then the |flushright/| prefix should be dropped. +% +% \begin{option}{flushright/aboveskip} +% \begin{syntax} +% |flushright/aboveskip =| \meta{skip} \hfill Default: \cs{medskip} +% \end{syntax} +% \meta{|skip|} inserted above the \env{flushright} environment. +% \end{option} +% +% \begin{option}{flushright/belowskip} +% \begin{syntax} +% |flushright/belowskip =| \meta{skip} \hfill Default: \cs{medskip} +% \end{syntax} +% \meta{|skip|} inserted below the \env{flushright} environment. +% \end{option} +% +% \begin{option}{flushright/leftmargin} +% \begin{syntax} +% |flushright/leftmargin =| \meta{dimen} \hfill Default: 0pt +% \end{syntax} +% \meta{|dimen|} used for the left margin of the \env{flushright} environment. +% \end{option} +% +% \begin{option}{flushright/rightmargin} +% \begin{syntax} +% |flushright/rightmargin =| \meta{dimen} \hfill Default: 0pt +% \end{syntax} +% \meta{|dimen|} used for the right margin of the \env{flushright} environment. +% \end{option} +% +% \subsubsection{Options for the \env{hanging} environment} +% \label{hangingoptions} +% +% If these options are passed directly to the \env{hanging} environment rather +% than to the package, \cs{scripturesetup} or the \env{scripture} environment, +% then the |hanging/| prefix should be dropped. +% +% \begin{option}{hanging/aboveskip} +% \begin{syntax} +% |hanging/aboveskip =| \meta{skip} \hfill Default: \cs{medskip} +% \end{syntax} +% \meta{|skip|} inserted above the \env{hanging} environment. +% \end{option} +% +% \begin{option}{hanging/belowskip} +% \begin{syntax} +% |hanging/belowskip =| \meta{skip} \hfill Default: \cs{medskip} +% \end{syntax} +% \meta{|skip|} inserted below the \env{hanging} environment. +% \end{option} +% +% \begin{option}{hanging/hang} +% \begin{syntax} +% |hanging/hang =| \meta{dimen} \hfill Default: 2em +% \end{syntax} +% \meta{|dimen|} used for the indent of subsequent lines of the +% \env{hanging} environment. +% \end{option} +% +% \begin{option}{hanging/leftmargin} +% \begin{syntax} +% |hanging/leftmargin =| \meta{dimen} \hfill Default: 1em +% \end{syntax} +% \meta{|dimen|} used for the left margin of the \env{hanging} environment. +% \end{option} +% +% \begin{option}{hanging/rightmargin} +% \begin{syntax} +% |hanging/rightmargin =| \meta{dimen} \hfill Default: 1em +% \end{syntax} +% \meta{|dimen|} used for the right margin of the \env{hanging} environment. +% \end{option} +% +% \subsubsection{Options for the \env{narrow} environment} +% \label{narrowoptions} +% +% If these options are passed directly to the \env{narrow} environment rather +% than to the package, \cs{scripturesetup} or the \env{scripture} environment, +% then the |narrow/| prefix should be dropped. +% +% \begin{option}{narrow/aboveskip} +% \begin{syntax} +% |narrow/aboveskip =| \meta{skip} \hfill Default: \cs{medskip} +% \end{syntax} +% \meta{|skip|} inserted above the \env{narrow} environment. +% \end{option} +% +% \begin{option}{narrow/belowskip} +% \begin{syntax} +% |narrow/belowskip =| \meta{skip} \hfill Default: \cs{medskip} +% \end{syntax} +% \meta{|skip|} inserted below the \env{narrow} environment. +% \end{option} +% +% \begin{option}{narrow/leftmargin} +% \begin{syntax} +% |narrow/leftmargin =| \meta{dimen} \hfill Default: 1em +% \end{syntax} +% \meta{|dimen|} used for the left margin of the \env{narrow} environment. +% \end{option} +% +% \begin{option}{narrow/rightmargin} +% \begin{syntax} +% |narrow/rightmargin =| \meta{dimen} \hfill Default: 1em +% \end{syntax} +% \meta{|dimen|} used for the right margin of the \env{narrow} environment. +% \end{option} +% +% \subsubsection{Options for the \env{poetry} environment} +% \label{poetryoptions} +% +% If these options are passed directly to the \env{poetry} environment rather +% than to the package, \cs{scripturesetup} or the \env{scripture} environment, +% then the |poetry/| prefix should be dropped. +% +% \begin{option}{poetry/aboveskip} +% \begin{syntax} +% |poetry/aboveskip =| \meta{skip} \hfill Default: \cs{medskip} +% \end{syntax} +% \meta{|skip|} inserted above the \env{poetry} environment. +% \end{option} +% +% \begin{option}{poetry/belowskip} +% \begin{syntax} +% |poetry/belowskip =| \meta{skip} \hfill Default: \cs{medskip} +% \end{syntax} +% \meta{|skip|} inserted below the \env{poetry} environment. +% \end{option} +% +% \begin{option}{poetry/bigindent} +% \begin{syntax} +% |poetry/bigindent =| \meta{dimen} \hfill Default: 4em +% \end{syntax} +% \meta{|dimen|} used for the indent subsequent lines of a line of poetry in +% a \env{poetry} environment if it needs to flow on to the following line. +% \end{option} +% +% \begin{option}{poetry/indent} +% \begin{syntax} +% |poetry/indent =| \meta{dimen} \hfill Default: 1em +% \end{syntax} +% \meta{|dimen|} used for the second half of a line of poetry in a +% \env{poetry} environment. +% \end{option} +% +% \begin{option}{poetry/leftmargin} +% \begin{syntax} +% |poetry/leftmargin =| \meta{dimen} \hfill Default: 1em +% \end{syntax} +% \meta{|dimen|} used for the left margin of the \env{poetry} environment. +% \end{option} +% +% \begin{option}{poetry/rightmargin} +% \begin{syntax} +% |poetry/rightmargin =| \meta{dimen} \hfill Default: 0pt +% \end{syntax} +% \meta{|dimen|} used for the right margin of the \env{poetry} environment. +% \end{option} +% +% \end{documentation} +% +% \begin{implementation} +% +% \section{Implementation} +% +% \begin{macrocode} +%<*package> +%<@@=scripture> +% \end{macrocode} +% +% \begin{macrocode} +\NeedsTeXFormat{LaTeX2e}[2021-11-15] +\ProvidesExplPackage{scripture}{2022/07/27}{1.0} + {Format Scripture Quotations (DCP)} +\RequirePackage{l3keys2e} +% \end{macrocode} +% +% \subsection{Messages} +% +% \env{scripture} environments along with all internal environments can not be +% nested. +% +% \begin{macrocode} +\msg_new:nnnn { scripture } { nested-environment } + { Nesting~of~scripture~environments~not~supported. } + { You~have~tried~to~nest~a~scripture~environment~or \\ + one~of~its~internal~environments,~which~is~not~supported. } +% \end{macrocode} +% +% \subsection{Options} +% +% Key-value settings for the \env{scripture} environment and its inner +% environments. +% \begin{macrocode} +\keys_define:nn { scripture } + { + , aboveskip .tl_set:N = \l_@@_aboveskip_tl + , aboveskip .value_required:n = true + , aboveskip .initial:n = \c_zero_skip + , belowskip .tl_set:N = \l_@@_belowskip_tl + , belowskip .value_required:n = true + , belowskip .initial:n = \c_zero_skip + , leftmargin .tl_set:N = \l_@@_leftmargin_tl + , leftmargin .value_required:n = true + , leftmargin .initial:n = \c_zero_dim + , rightmargin .tl_set:N = \l_@@_rightmargin_tl + , rightmargin .value_required:n = true + , rightmargin .initial:n = \c_zero_dim + , chapter / font .tl_set:N = \l_@@_chap_font_tl + , chapter / font .value_required:n = true + , chapter / font .initial:n = \bfseries + , chapter / drop .bool_set:N = \l_@@_chap_drop_bool + , chapter / drop .default:n = true + , chapter / drop .initial:n = true + , chapter / nodrop .bool_set_inverse:N = \l_@@_chap_drop_bool + , chapter / nodrop .default:n = true + , chapter / sep .tl_set:N = \l_@@_chap_sep_tl + , chapter / sep .value_required:n = true + , chapter / sep .initial:n = 0.5 em + , extraskip .tl_set:N = \l_@@_extraskip_tl + , extraskip .value_required:n = true + , extraskip .initial:n = \medskipamount + , font .tl_set:N = \l_@@_font_tl + , font .value_required:n = true + , font .initial:n = + , indent .bool_set:N = \l_@@_indent_bool + , indent .default:n = true + , indent .initial:n = true + , noindent .bool_set_inverse:N = \l_@@_indent_bool + , noindent .default:n = true + , parindent .tl_set:N = \l_@@_parindent_tl + , parindent .value_required:n = true + , parindent .initial:n = \parindent + , parskip .tl_set:N = \l_@@_parskip_tl + , parskip .value_required:n = true + , parskip .initial:n = \parskip + , reference / delim .tl_set:N = \l_@@_ref_delim_tl + , reference / delim .value_required:n = true + , reference / delim .initial:n = \hfill + , reference / font .tl_set:N = \l_@@_ref_font_tl + , reference / font .value_required:n = true + , reference / font .initial:n = \bfseries + , reference / format .cs_set:Np = \@@_ref_format:n #1 + , reference / format .value_required:n = true + , reference / format .initial:n = #1 + , reference / sep .tl_set:N = \l_@@_ref_sep_tl + , reference / sep .value_required:n = true + , reference / sep .initial:n = 2 em + , verse / font .tl_set:N = \l_@@_verse_font_tl + , verse / font .value_required:n = true + , verse / font .initial:n = + , verse / format .cs_set:Np = \@@_verse_format:n #1 + , verse / format .value_required:n = true + , verse / format .initial:n = \textsuperscript{#1} + , version .tl_set:N = \l_@@_version_tl + , version .value_required:n = true + , version .initial:n = + , version / delim .tl_set:N = \l_@@_version_delim_tl + , version / delim .value_required:n = true + , version / delim .initial:n = \c_space_tl + , version / format .cs_set:Np = \@@_version_format:n #1 + , version / format .value_required:n = true + , version / format .initial:n = (#1) +% \end{macrocode} +% Options for the \env{center} environment. +% \begin{macrocode} + , center / aboveskip .tl_set:N = \l_@@_center_aboveskip_tl + , center / aboveskip .value_required:n = true + , center / aboveskip .initial:n = \medskipamount + , center / belowskip .tl_set:N = \l_@@_center_belowskip_tl + , center / belowskip .value_required:n = true + , center / belowskip .initial:n = \medskipamount + , center / leftmargin .tl_set:N = \l_@@_center_leftmargin_tl + , center / leftmargin .value_required:n = true + , center / leftmargin .initial:n = \c_zero_dim + , center / rightmargin .tl_set:N = \l_@@_center_rightmargin_tl + , center / rightmargin .value_required:n = true + , center / rightmargin .initial:n = \c_zero_dim +% \end{macrocode} +% Options for the \env{flushright} environment. +% \begin{macrocode} + , flushright / aboveskip .tl_set:N = \l_@@_flushright_aboveskip_tl + , flushright / aboveskip .value_required:n = true + , flushright / aboveskip .initial:n = \medskipamount + , flushright / belowskip .tl_set:N = \l_@@_flushright_belowskip_tl + , flushright / belowskip .value_required:n = true + , flushright / belowskip .initial:n = \medskipamount + , flushright / leftmargin .tl_set:N = \l_@@_flushright_leftmargin_tl + , flushright / leftmargin .value_required:n = true + , flushright / leftmargin .initial:n = \c_zero_dim + , flushright / rightmargin .tl_set:N = \l_@@_flushright_rightmargin_tl + , flushright / rightmargin .value_required:n = true + , flushright / rightmargin .initial:n = \c_zero_dim +% \end{macrocode} +% Options for the \env{hanging} environment. +% \begin{macrocode} + , hanging / aboveskip .tl_set:N = \l_@@_hanging_aboveskip_tl + , hanging / aboveskip .value_required:n = true + , hanging / aboveskip .initial:n = \medskipamount + , hanging / belowskip .tl_set:N = \l_@@_hanging_belowskip_tl + , hanging / belowskip .value_required:n = true + , hanging / belowskip .initial:n = \medskipamount + , hanging / hang .tl_set:N = \l_@@_hanging_hang_tl + , hanging / hang .value_required:n = true + , hanging / hang .initial:n = 2 em + , hanging / leftmargin .tl_set:N = \l_@@_hanging_leftmargin_tl + , hanging / leftmargin .value_required:n = true + , hanging / leftmargin .initial:n = 1 em + , hanging / rightmargin .tl_set:N = \l_@@_hanging_rightmargin_tl + , hanging / rightmargin .value_required:n = true + , hanging / rightmargin .initial:n = \c_zero_dim +% \end{macrocode} +% Options for the \env{narrow} environment. +% \begin{macrocode} + , narrow / aboveskip .tl_set:N = \l_@@_narrow_aboveskip_tl + , narrow / aboveskip .value_required:n = true + , narrow / aboveskip .initial:n = \medskipamount + , narrow / belowskip .tl_set:N = \l_@@_narrow_belowskip_tl + , narrow / belowskip .value_required:n = true + , narrow / belowskip .initial:n = \medskipamount + , narrow / leftmargin .tl_set:N = \l_@@_narrow_leftmargin_tl + , narrow / leftmargin .value_required:n = true + , narrow / leftmargin .initial:n = 1 em + , narrow / rightmargin .tl_set:N = \l_@@_narrow_rightmargin_tl + , narrow / rightmargin .value_required:n = true + , narrow / rightmargin .initial:n = 1 em +% \end{macrocode} +% Options for the \env{poetry} environment. +% \begin{macrocode} + , poetry / aboveskip .tl_set:N = \l_@@_poetry_aboveskip_tl + , poetry / aboveskip .value_required:n = true + , poetry / aboveskip .initial:n = \medskipamount + , poetry / belowskip .tl_set:N = \l_@@_poetry_belowskip_tl + , poetry / belowskip .value_required:n = true + , poetry / belowskip .initial:n = \medskipamount + , poetry / bigindent .tl_set:N = \l_@@_poetry_big_indent_tl + , poetry / bigindent .value_required:n = true + , poetry / bigindent .initial:n = 4 em + , poetry / indent .tl_set:N = \l_@@_poetry_indent_tl + , poetry / indent .value_required:n = true + , poetry / indent .initial:n = 1 em + , poetry / leftmargin .tl_set:N = \l_@@_poetry_leftmargin_tl + , poetry / leftmargin .value_required:n = true + , poetry / leftmargin .initial:n = 1 em + , poetry / rightmargin .tl_set:N = \l_@@_poetry_rightmargin_tl + , poetry / rightmargin .value_required:n = true + , poetry / rightmargin .initial:n = \c_zero_dim + } +% \end{macrocode} +% Process package options using \pkg{l3keys2e} package. +% \begin{macrocode} +\ProcessKeysOptions { scripture } +% \end{macrocode} +% +% \subsection{The main \env{scripture} environment} +% +% \begin{macro}{\l_@@_active_bool, \l_@@_active_inner_bool} +% Flags to ensure that environments are not nested. +% \begin{macrocode} +\bool_new:N \l_@@_active_bool +\bool_new:N \l_@@_active_inner_bool +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_extra_skip:} +% Insert a little extra vertical space between two paragraphs. This function +% tests if the previous paragraph is only one line in length and began +% with a \cs{ch} function. If this condition is met, more space is added +% if necessary to avoid the following paragraph clashing with the drop +% chapter. +% \begin{macrocode} +\cs_new_protected:Nn \@@_extra_skip: + { + \int_compare:nNnT + \l_@@_chap_par_prevgraf_int = 1 + { + \dim_compare:nNnT + { \parskip + \l_@@_extraskip_tl } < \baselineskip + { + \addvspace { \baselineskip } + } + \int_zero:N \l_@@_chap_par_prevgraf_int + } + \addvspace { \l_@@_extraskip_tl } + } +% \end{macrocode} +% \end{macro} +% +% \subsubsection{Formatting and printing quotation references} +% +% \begin{macro}{\@@_format_full_ref:n} +% Format a scripture quotation with its reference. +% \begin{macrocode} +\cs_new_protected:Nn \@@_format_full_ref:n + { + \group_begin: + \l_@@_ref_font_tl + \@@_ref_format:n { #1 } +% \end{macrocode} +% Append a Bible version if it has been specified. +% \begin{macrocode} + \tl_if_empty:NF \l_@@_version_tl + { + \l_@@_version_delim_tl + \@@_version_format:n { \l_@@_version_tl } + } + \group_end: + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_reference:n} +% Output the reference for the Scripture quotation. +% \begin{macrocode} +\cs_new_protected:Nn \@@_reference:n + { + \hbox_set:Nn \l_tmpa_box + { + \skip_horizontal:N \l_@@_ref_sep_tl + \@@_format_full_ref:n { #1 } + } +% \end{macrocode} +% Since the \env{poetry} environment uses \cs{@@_obeylines:} there is always +% an extra \cs{parskip} when a \env{scripture} quotation ends with a +% \env{poetry} +% environment. +% \begin{macrocode} + \bool_if:NT \g_@@_poetry_end_bool + { \skip_vertical:n { -\parskip } } + \dim_compare:nNnT + { \box_wd:N \l_tmpa_box + \g_@@_final_line_dim } + > + { \linewidth - \@totalleftmargin } + { \skip_vertical:N \baselineskip } +% \end{macrocode} +% If a \env{scripture} quotation ends with an inner environment, there will +% be an extra space of \cs{baselineskip}. +% \begin{macrocode} + \int_compare:nNnT \prevgraf = \c_zero_int + { \skip_vertical:n { -\baselineskip } } + \l_@@_ref_delim_tl + \box_use:N \l_tmpa_box + } +% \end{macrocode} +% \end{macro} +% +% \subsubsection{Formatting and printing chapter numbers} +% +% \begin{macro}{\l_@@_chap_fontsize_dim} +% Calculated font size of a drop chapter number. +% \begin{macrocode} +\dim_new:N \l_@@_chap_fontsize_dim +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\l_@@_chap_height_dim} +% Calculated height of a drop chapter number. +% \begin{macrocode} +\dim_new:N \l_@@_chap_height_dim +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\l_@@_chap_width_dim} +% Calculated width of drop chapter number. +% \begin{macrocode} +\dim_new:N \l_@@_chap_width_dim +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\l_@@_chap_par_prevgraf_int} +% Store the number of lines a chapter paragraph takes up. +% \begin{macrocode} +\int_new:N \l_@@_chap_par_prevgraf_int +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\l_@@_chap_X_height_dim} +% Calculated height of X at current font size. This is used as the height +% for a drop chapter. +% \begin{macrocode} +\dim_new:N \l_@@_chap_X_height_dim +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_drop_chap_set_up:n} +% Set up chapter drop cap and calculate its various dimensions. +% \begin{macrocode} +\cs_new_protected:Nn \@@_drop_chap_set_up:n + { + \hbox_set:Nn \l_tmpa_box { X } + \dim_set:Nn \l_@@_chap_X_height_dim + { \box_ht:N \l_tmpa_box } + \dim_set:Nn \l_@@_chap_height_dim + { \baselineskip + \l_@@_chap_X_height_dim } + \dim_set:Nn \l_@@_chap_fontsize_dim + { + \f@size pt * + \dim_ratio:nn + { \l_@@_chap_height_dim } + { \l_@@_chap_X_height_dim } + } + \hbox_set:Nn \l_tmpa_box + { + \l_@@_chap_font_tl + \fontsize + { \l_@@_chap_fontsize_dim } + { \l_@@_chap_fontsize_dim } + \selectfont + #1 + } + \dim_set:Nn \l_@@_chap_width_dim + { \box_wd:N \l_tmpa_box } + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_drop_chap_output:} +% Output a drop chapter. +% \begin{macrocode} +\cs_new_protected:Nn \@@_drop_chap_output: + { + \noindent + \parshape 3 ~ + \dim_eval:n + { \@totalleftmargin + \l_@@_chap_width_dim + \l_@@_chap_sep_tl } ~ + \dim_eval:n + { \linewidth - \l_@@_chap_width_dim - \l_@@_chap_sep_tl } ~ + \dim_eval:n + { \@totalleftmargin + \l_@@_chap_width_dim + \l_@@_chap_sep_tl } ~ + \dim_eval:n + { \linewidth - \l_@@_chap_width_dim - \l_@@_chap_sep_tl } ~ + \@totalleftmargin ~ + \linewidth + \box_use:N \l_tmpb_box + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_nodrop_chap:n} +% Format a non-drop chapter. +% \begin{macrocode} +\cs_new_protected:Nn \@@_nodrop_chap:n + { + \group_begin: + \l_@@_chap_font_tl + #1 + \group_end: + \skip_horizontal:N \l_@@_chap_sep_tl + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_chap:n} +% Position a drop chapter. +% \begin{macrocode} +\cs_new_protected:Nn \@@_chap:n + { + \@@_drop_chap_set_up:n { #1 } + \hbox_set:Nn \l_tmpb_box + { + \box_move_down:nn + { \baselineskip } + { + \hbox_overlap_left:n + { + \box_use:N \l_tmpa_box + \skip_horizontal:N \l_@@_chap_sep_tl + } + } + } + \box_set_ht:Nn \l_tmpb_box { \c_zero_dim } + \box_set_dp:Nn \l_tmpb_box { \c_zero_dim } + \bool_if:NTF \l_@@_mid_para_chap_bool + { \@@_mid_para_drop_chap_output: } + { + \par + \@@_drop_chap_output: + } + \hook_gput_next_code:nn { para / after } + { \int_set_eq:NN \l_@@_chap_par_prevgraf_int \prevgraf } + \hook_gput_next_code:nn { para / before } + { + \int_zero:N \l_@@_chap_par_prevgraf_int + \int_compare:nNnT + \@listdepth > \c_zero_int + { \parshape 1 ~ \@totalleftmargin ~ \linewidth } + } + } +% \end{macrocode} +% \end{macro} +% +% \subsubsection{Formatting and printing verse numbers} +% +% \begin{macro}{\@@_verse_output:n} +% Output a formatted verse. +% \begin{macrocode} +\cs_new_protected:Nn \@@_verse_output:n + { + \mode_if_vertical:T + { \mode_leave_vertical: } + \group_begin: + \l_@@_verse_font_tl + \@@_verse_format:n { #1 } + \group_end: + } +% \end{macrocode} +% \end{macro} +% +% \subsubsection{Calculating the length of the final line in a paragraph} +% +% \begin{macro}{\g_@@_final_line_dim} +% Store the length of the final line in a paragraph. +% \begin{macrocode} +\dim_new:N \g_@@_final_line_dim +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_calc_final_line_length:} +% Calculate the length of the final line in a paragraph. +% \begin{macrocode} +\cs_new_protected:Nn \@@_calc_final_line_length: + { + \skip_set:Nn \abovedisplayshortskip { -\baselineskip } + \skip_set_eq:NN \abovedisplayskip \abovedisplayshortskip + \skip_zero:N \belowdisplayshortskip + \skip_zero:N \belowdisplayskip + $$ + \dim_compare:nNnT \predisplaysize > \c_zero_dim + { + \dim_gset:Nn \g_@@_final_line_dim + { \predisplaysize - 2 em } + } + \cs_gset_nopar:Nx \@@_reset_spacing: + { + \dim_set:Nn \predisplaysize { \dim_use:N \predisplaysize } + \int_set:Nn \prevgraf { \int_use:N \prevgraf } + } + $$ + \@@_reset_spacing: + \dim_compare:nNnT \g_@@_final_line_dim > \linewidth + { + \dim_gset_eq:NN \g_@@_final_line_dim \linewidth + } + \dim_compare:nNnT \g_@@_final_line_dim > { \c_zero_dim - 1 sp } + { + \skip_vertical:n { -\baselineskip - \parskip } + } + } +% \end{macrocode} +% \end{macro} +% +% \subsubsection{The \env{scripture} environment} +% +% \begin{macro}{\g_@@_start_bool} +% Flag indicating whether we are currently setting the first paragraph in a +% \env{scripture} environment. If this is \val{true}, any \opt{aboveskip} +% for an inner environment will be ignored. +% \begin{macrocode} +\bool_new:N \g_@@_start_bool +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_begin:n} +% Begin a scripture quotation. +% \begin{macrocode} +\cs_new_protected:Nn \@@_begin:n + { + \bool_if:NT \l_@@_active_bool + { + \msg_error:nn { scripture } { nested-environment } + } + \bool_set_true:N \l_@@_active_bool + \tl_if_novalue:nF { #1 } + { + \keys_set:nn { scripture } { #1 } + } +% \end{macrocode} +% If the \env{scripture} environment begins immediately after an \cs{item}, +% then insert a new paragraph and apply a negative skip. Life is much easier +% if all paragraphs in a \env{scripture} are the same rather than the first +% one being in the first paragraph of an \cs{item}. +% \begin{macrocode} + \legacy_if:nT { @newlist } + { + \strut + \par + \vspace* { \dim_eval:n { -\baselineskip - \parskip } } + } + \mode_if_vertical:T + { + \addvspace { \l_@@_aboveskip_tl } + } + \DeclareDocumentCommand { \ch } { sm } + { + \bool_if:NTF \l_@@_chap_drop_bool + { + \@@_chap:n { ##2 } + \bool_if:nT { ##1 } + { + \hook_gput_next_code:nn { para / after } + { \int_zero:N \l_@@_chap_par_prevgraf_int } + } + } + { \@@_nodrop_chap:n { ##2 } } + } + \bool_gset_true:N \g_@@_start_bool + \bool_gset_false:N \g_@@_poetry_end_bool + \dim_set_eq:NN \parindent \l_@@_parindent_tl + \cs_set_eq:NN \extraskip \@@_extra_skip: + \cs_set_eq:NN \vs \@@_verse_output:n + \hook_gclear_next_code:n { para / before } + \hook_gput_next_code:nn { para / end } + { \skip_set_eq:NN \parskip \l_@@_parskip_tl } + \hook_gput_next_code:nn { para / after } + { \bool_gset_false:N \g_@@_start_bool } + \l_@@_font_tl +% \end{macrocode} +% For left and right margins, use \cs{parshape} is already in a list, +% otherwise use \cs{leftskip} and \cs{rightskip} +% \begin{macrocode} + \bool_lazy_or:nnT + { \dim_compare_p:n { \l_@@_leftmargin_tl > 0pt } } + { \dim_compare_p:n { \l_@@_rightmargin_tl > 0pt } } + { + \dim_sub:Nn \linewidth + { \l_@@_leftmargin_tl + \l_@@_rightmargin_tl } + \int_compare:nNnTF + \@listdepth > \c_zero_int + { + \dim_add:Nn \@totalleftmargin \l_@@_leftmargin_tl + \parshape 1 ~ \@totalleftmargin ~ \linewidth + } + { + \dim_add:Nn \leftskip \l_@@_leftmargin_tl + \dim_add:Nn \rightskip \l_@@_rightmargin_tl + } + } + \bool_if:NF \l_@@_indent_bool + { \noindent } + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_end:n} +% End a scripture quotation with a reference. +% \begin{macrocode} +\cs_new_protected:Nn \@@_end:n + { +% \end{macrocode} +% Normally \cs{unskip} does not work in vertical mode, but there are some +% situations where it does work. The following condition is true if the +% \env{scripture} environment has ended with one of its internal +% environments. This removes any unwanted \opt{belowskip} if present and +% leaves the previously calculated line length of the final paragraph intact. +% \begin{macrocode} + \mode_if_vertical:TF + { + \unskip + \unskip + } + { \@@_calc_final_line_length: } +% \end{macrocode} +% Restore left margin by resetting the \cs{parshape} if in a list +% based environment, otherwise the space required for the reference is +% incorrectly calculated. +% \begin{macrocode} + \bool_lazy_or:nnT + { \dim_compare_p:n { \l_@@_leftmargin_tl > 0pt } } + { \dim_compare_p:n { \l_@@_rightmargin_tl > 0pt } } + { + \dim_add:Nn \linewidth \l_@@_leftmargin_tl + \int_compare:nNnT + \@listdepth > \c_zero_int + { + \dim_sub:Nn \@totalleftmargin \l_@@_leftmargin_tl + \parshape 1 ~ \@totalleftmargin ~ \linewidth + } + } + \tl_if_novalue:nF { #1 } + { + \@@_reference:n { #1 } + } + \par +% \end{macrocode} +% Restore right margin by resetting the \cs{parshape} if in a \LaTeX{} list +% based environment, since only the left margin was restored above. +% \begin{macrocode} + \bool_lazy_or:nnT + { \dim_compare_p:n { \l_@@_leftmargin_tl > 0pt } } + { \dim_compare_p:n { \l_@@_rightmargin_tl > 0pt } } + { + \int_compare:nNnT + \@listdepth > \c_zero_int + { + \dim_add:Nn \linewidth \l_@@_rightmargin_tl + \parshape 1 ~ \@totalleftmargin ~ \linewidth + } + } + \dim_compare:nNnTF + \l_@@_belowskip_tl > \parskip + { + \addvspace + { + \skip_eval:n { \l_@@_belowskip_tl - \parskip } + } + } + { + \addvspace { \l_@@_belowskip_tl } + } + } +% \end{macrocode} +% \end{macro} +% +% \subsection{Scripture internal environments} +% +% \begin{macro}{\l_@@_delta_below_skip} +% Correction to \tn{@topsepadd} for internal environments. This enables a +% different \opt{aboveskip} and \opt{belowskip} which are normally the +% same for \LaTeX{} lists. +% \begin{macrocode} +\skip_new:N \l_@@_delta_below_skip +% \end{macrocode} +% \end{macro} +% +% \subsubsection{The \env{center} environment} +% +% \begin{macro}{\@@_center_begin:n} +% Begin a centred section in a scripture quotation. +% \begin{macrocode} +\cs_new_protected:Nn \@@_center_begin:n + { + \bool_if:NT \l_@@_active_inner_bool + { + \msg_error:nn { scripture } { nested-environment } + } + \bool_set_true:N \l_@@_active_inner_bool + \tl_if_novalue:nF { #1 } + { + \keys_set:nn + { scripture / center } + { #1 } + } + \par + \list { } + { + \skip_set_eq:NN \l_@@_delta_below_skip \l_@@_center_belowskip_tl +% \end{macrocode} +% Ignore \opt{aboveskip} if at the beginning of a \env{scripture} environment. +% \begin{macrocode} + \bool_if:NTF \g_@@_start_bool + { \skip_zero:N \topsep } + { + \dim_compare:nTF + { \parskip >= \l_@@_center_aboveskip_tl > \c_zero_skip } + { + \skip_zero:N \topsep + \skip_zero:N \l_@@_delta_below_skip + } + { + \skip_set_eq:NN \topsep \l_@@_center_aboveskip_tl + \skip_sub:Nn \l_@@_delta_below_skip \l_@@_center_aboveskip_tl + } + } + \skip_set_eq:NN \parsep \parskip + \skip_zero:N \partopsep + \dim_zero:N \leftmargin + \dim_zero:N \labelsep + } + \centering + \item + \relax + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_center_end:} +% End a centred section in a scripture quotation. +% \begin{macrocode} +\cs_new_protected:Nn \@@_center_end: + { + \@@_calc_final_line_length: + \skip_add:Nn \@topsepadd \l_@@_delta_below_skip + \endlist + } +% \end{macrocode} +% \end{macro} +% +% \subsubsection{The \env{flushright} environment} +% +% \begin{macro}{\@@_flushright_begin:n} +% Begin a flushright section in a scripture quotation. +% \begin{macrocode} +\cs_new_protected:Nn \@@_flushright_begin:n + { + \bool_if:NT \l_@@_active_inner_bool + { + \msg_error:nn { scripture } { nested-environment } + } + \bool_set_true:N \l_@@_active_inner_bool + \tl_if_novalue:nF { #1 } + { + \keys_set:nn + { scripture / flushright } + { #1 } + } + \par + \list { } + { + \skip_set_eq:NN \l_@@_delta_below_skip \l_@@_flushright_belowskip_tl +% \end{macrocode} +% Ignore \opt{aboveskip} if at the beginning of a \env{scripture} environment. +% \begin{macrocode} + \bool_if:NTF \g_@@_start_bool + { \skip_zero:N \topsep } + { + \dim_compare:nTF + { \parskip >= \l_@@_flushright_aboveskip_tl > \c_zero_skip } + { + \skip_zero:N \topsep + \skip_zero:N \l_@@_delta_below_skip + } + { + \skip_set_eq:NN \topsep \l_@@_flushright_aboveskip_tl + \skip_sub:Nn \l_@@_delta_below_skip \l_@@_flushright_aboveskip_tl + } + } + \dim_set_eq:NN \leftmargin \l_@@_flushright_leftmargin_tl + \dim_set_eq:NN \rightmargin \l_@@_flushright_rightmargin_tl + \skip_set_eq:NN \parsep \parskip + \skip_zero:N \partopsep + \dim_zero:N \leftmargin + \dim_zero:N \labelsep + } + \raggedleft + \item + \relax + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_flushright_end:} +% End a flushright section in a scripture quotation. +% \begin{macrocode} +\cs_new_protected:Nn \@@_flushright_end: + { + \@@_calc_final_line_length: + \skip_add:Nn \@topsepadd \l_@@_delta_below_skip + \endlist + } +% \end{macrocode} +% \end{macro} +% +% \subsubsection{The \env{hanging} environment} +% +% \begin{macro}{\l_@@_hanging_parindent_saved_dim} +% Save the \cs{parindent} for later use in \env{hanging} environment. +% \begin{macrocode} +\dim_new:N \l_@@_hanging_parindent_saved_dim +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_hanging_chap:n} +% Position a drop chapter in a \env{hanging} environment. +% \begin{macrocode} +\cs_new_protected:Nn \@@_hanging_chap:n + { + \@@_drop_chap_set_up:n { #1 } + \dim_compare:nNnTF + \l_@@_chap_width_dim < \leftmargin + { + \tl_set:Nx \l_@@_chap_sep_tl + { + \dim_eval:n { \leftmargin - \l_@@_chap_width_dim } + } + } + { + \parshape 3 ~ + \dim_eval:n + { + \@totalleftmargin - \leftmargin + \l_@@_chap_width_dim + + \l_@@_chap_sep_tl + } ~ + \dim_eval:n + { + \linewidth + \leftmargin - \l_@@_chap_width_dim - + \l_@@_chap_sep_tl + } ~ + \dim_eval:n + { + \@totalleftmargin - \leftmargin + \l_@@_chap_width_dim + + \l_@@_chap_sep_tl + } ~ + \dim_eval:n + { + \linewidth + \leftmargin - \l_@@_chap_width_dim - + \l_@@_chap_sep_tl + } ~ + \@totalleftmargin ~ \linewidth + } + \mode_if_vertical:T + { + \tl_set:Nx \l_@@_chap_sep_tl + { + \dim_eval:n + { + \l_@@_chap_sep_tl + \l_@@_hanging_parindent_saved_dim + } + } + \@@_nohang: + } + \hbox_set:Nn \l_tmpb_box + { + \box_move_down:nn + { \baselineskip } + { + \hbox_overlap_left:n + { + \box_use:N \l_tmpa_box + \skip_horizontal:N \l_@@_chap_sep_tl + } + } + } + \box_set_ht:Nn \l_tmpb_box { \c_zero_dim } + \box_set_dp:Nn \l_tmpb_box { \c_zero_dim } + \box_use:N \l_tmpb_box + \hook_gput_next_code:nn { para / begin } + { \parshape 1 ~ \@totalleftmargin ~ \linewidth } + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_hanging_verse:n} +% Position a \cs{vs} in a \env{hanging} environment. The verse is set to +% overlap to the left if at the beginning of a hanging paragraph. +% \begin{macrocode} +\cs_new_protected:Nn \@@_hanging_verse:n + { + \mode_if_vertical:TF + { + \strut + \hbox_overlap_left:n + { + \@@_verse_output:n { #1 } + } + } + { \@@_verse_output:n { #1 } } + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_nohang:} +% Don't hang a paragraph in a \env{hanging} environment. Instead the +% paragraph is indented by \cs{parindent} from its normal hanging position. +% \begin{macrocode} +\cs_new_protected_nopar:Nn \@@_nohang: + { + \para_raw_noindent: + \hbox_to_wd:nn { \l_@@_hanging_parindent_saved_dim } { } + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_hanging_begin:n} +% Begin a hanging section in a scripture quotation. +% \begin{macrocode} +\cs_new_protected:Nn \@@_hanging_begin:n + { + \bool_if:NT \l_@@_active_inner_bool + { + \msg_error:nn { scripture } { nested-environment } + } + \bool_set_true:N \l_@@_active_inner_bool + \tl_if_novalue:nF { #1 } + { + \keys_set:nn + { scripture / hanging } + { #1 } + } + \par + \list { } + { + \skip_set_eq:NN \l_@@_delta_below_skip \l_@@_hanging_belowskip_tl +% \end{macrocode} +% Ignore \opt{aboveskip} if at the beginning of a \env{scripture} environment. +% \begin{macrocode} + \bool_if:NTF \g_@@_start_bool + { \dim_zero:N \topsep } + { + \dim_compare:nTF + { \parskip >= \l_@@_hanging_aboveskip_tl > \c_zero_skip } + { + \skip_zero:N \topsep + \skip_zero:N \l_@@_delta_below_skip + } + { + \skip_set_eq:NN \topsep \l_@@_hanging_aboveskip_tl + \skip_sub:Nn \l_@@_delta_below_skip \l_@@_hanging_aboveskip_tl + } + \int_compare:nNnT \l_@@_chap_par_prevgraf_int = 1 + { \addvspace { \baselineskip } } + \int_zero:N \l_@@_chap_par_prevgraf_int + } + \dim_set:Nn \leftmargin + { \l_@@_hanging_leftmargin_tl + \l_@@_hanging_hang_tl } + \dim_set_eq:NN \rightmargin \l_@@_hanging_rightmargin_tl + \dim_set:Nn \itemindent { -\l_@@_hanging_hang_tl } + \dim_set:Nn \listparindent { -\l_@@_hanging_hang_tl } + \skip_set_eq:NN \parsep \parskip + \skip_zero:N \partopsep + \dim_zero:N \labelsep + \dim_set_eq:NN \l_@@_hanging_parindent_saved_dim \parindent + } + \bool_if:NTF \l_@@_chap_drop_bool + { \cs_set_eq:NN \ch \@@_hanging_chap:n } + { \cs_set_eq:NN \ch \@@_nodrop_chap:n } + \cs_set_eq:NN \vs \@@_hanging_verse:n + \cs_set_eq:NN \nohang \@@_nohang: + \item + \relax + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_hanging_end:} +% End a hanging section in a scripture quotation. +% \begin{macrocode} +\cs_new_protected:Nn \@@_hanging_end: + { + \@@_calc_final_line_length: + \skip_add:Nn \@topsepadd \l_@@_delta_below_skip + \endlist + } +% \end{macrocode} +% \end{macro} +% +% \subsubsection{The \env{midparachap} environment} +% +% \begin{macro}{\@@_vbox_set_top:Nw} +% Define missing \cs{vbox_set_top:Nw} function. +% \begin{macrocode} +\cs_new_protected:Npn \@@_vbox_set_top:Nw #1 + { + \tex_setbox:D #1 \tex_vtop:D + \c_group_begin_token + \color_group_begin: + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\l_@@_mid_para_chap_bool} +% Flag if setting a paragraph containing a mid-paragraph chapter. +% \begin{macrocode} +\bool_new:N \l_@@_mid_para_chap_bool +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\l_@@_mid_para_chap_line_box} +% Store last line before a mid-paragraph chapter. +% \begin{macrocode} +\box_new:N \l_@@_mid_para_chap_line_box +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\g_@@_mid_para_chap_prevgraf_int} +% Store the number of lines a paragraph containing a mid-paragraph chapter +% takes up. +% \begin{macrocode} +\int_new:N \g_@@_mid_para_chap_prevgraf_int +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\l_@@_mid_para_chap_snap_box} +% Store unpacked last line before a mid-paragraph chapter. +% \begin{macrocode} +\box_new:N \l_@@_mid_para_chap_snap_box +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\l_@@_mid_para_chap_spacefactor_int} +% Store space factor before a mid-paragraph chapter. +% \begin{macrocode} +\int_new:N \l_@@_mid_para_chap_spacefactor_int +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\l_@@_mid_para_chap_box} +% Box containing a paragraph with a chapter break. +% \begin{macrocode} +\box_new:N \l_@@_mid_para_chap_box +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_mid_para_drop_chap_output:} +% Output a mid-paragraph drop chapter. +% \begin{macrocode} +\cs_new_protected:Nn \@@_mid_para_drop_chap_output: + { + \unskip + \int_set_eq:NN \l_@@_mid_para_chap_spacefactor_int \spacefactor + \strut + \par + \int_gset_eq:NN \g_@@_mid_para_chap_prevgraf_int \prevgraf + \box_set_to_last:N \l_@@_mid_para_chap_line_box + \hbox_set:Nn \l_@@_mid_para_chap_snap_box + { + \hbox_unpack_drop:N \l_@@_mid_para_chap_line_box + \unskip + \unskip + \unpenalty + } + \nointerlineskip + \dim_compare:nNnTF + { + \box_wd:N \l_@@_mid_para_chap_snap_box + + \l_@@_chap_width_dim + + \l_@@_chap_sep_tl + } + < + { \linewidth - \leftskip - \rightskip - 3 em } + { + \@@_drop_chap_output: + \hbox_unpack_drop:N \l_@@_mid_para_chap_snap_box + \int_set_eq:NN \spacefactor \l_@@_mid_para_chap_spacefactor_int + \c_space_tl + \@@_verse_output:n { 1 } + } + { + \group_begin: + \noindent + \skip_horizontal:n { -\leftskip } + \hbox_unpack_drop:N \l_@@_mid_para_chap_snap_box + \skip_zero:N \parfillskip + \par + \int_gadd:Nn \g_@@_mid_para_chap_prevgraf_int \prevgraf + \group_end: + \@@_drop_chap_output: + } + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_mid_para_chap_begin:} +% Begin a paragraph containing a mid-paragraph chapter. +% \begin{macrocode} +\cs_new_protected:Nn \@@_mid_para_chap_begin: + { + \par + \bool_set_true:N \l_@@_mid_para_chap_bool + \skip_zero:N \parskip + \@@_vbox_set_top:Nw \l_@@_mid_para_chap_box + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_mid_para_chap_end:} +% End a paragraph containing a mid-paragraph chapter. +% \begin{macrocode} +\cs_new_protected:Nn \@@_mid_para_chap_end: + { + \@@_calc_final_line_length: + \int_gadd:Nn \g_@@_mid_para_chap_prevgraf_int { \prevgraf - 1 } + \vbox_set_end: +% \end{macrocode} +% Attempt to allow the mid-paragraph chapter box to break across pages. +% \begin{macrocode} + \dim_compare:nNnTF + { \box_ht_plus_dp:N \l_@@_mid_para_chap_box } + > + { \pagegoal - \pagetotal - \baselineskip } + { + \int_set:Nn \vbadness { 10000 } + \vbox_set_split_to_ht:NNn + \l_tmpa_box \l_@@_mid_para_chap_box + { \pagegoal - \pagetotal - \baselineskip } + \box_use_drop:N \l_tmpa_box + \goodbreak + \box_use_drop:N \l_@@_mid_para_chap_box + } + { + \box_use_drop:N \l_@@_mid_para_chap_box + \skip_vertical:n { \baselineskip - \lineskip } + } + \par + \noindent + \skip_horizontal:N \g_@@_final_line_dim + \@@_reset_spacing: + } +% \end{macrocode} +% \end{macro} +% +% \subsubsection{The \env{narrow} environment} +% +% \begin{macro}{\@@_narrow_begin:n} +% Begin a narrow section in a scripture quotation. +% \begin{macrocode} +\cs_new_protected:Nn \@@_narrow_begin:n + { + \bool_if:NT \l_@@_active_inner_bool + { + \msg_error:nn { scripture } { nested-environment } + } + \bool_set_true:N \l_@@_active_inner_bool + \tl_if_novalue:nF { #1 } + { + \keys_set:nn + { scripture / narrow } + { #1 } + } + \par + \list { } + { + \skip_set_eq:NN \l_@@_delta_below_skip \l_@@_narrow_belowskip_tl +% \end{macrocode} +% Ignore \opt{aboveskip} if at the beginning of a \env{scripture} environment. +% \begin{macrocode} + \bool_if:NTF \g_@@_start_bool + { \skip_zero:N \topsep } + { + \dim_compare:nTF + { \parskip >= \l_@@_narrow_aboveskip_tl > \c_zero_skip } + { + \skip_zero:N \topsep + \skip_zero:N \l_@@_delta_below_skip + } + { + \skip_set_eq:NN \topsep \l_@@_narrow_aboveskip_tl + \skip_sub:Nn \l_@@_delta_below_skip \l_@@_narrow_aboveskip_tl + } + } + \dim_set_eq:NN \leftmargin \l_@@_narrow_leftmargin_tl + \dim_set_eq:NN \rightmargin \l_@@_narrow_rightmargin_tl + \dim_set_eq:NN \listparindent \parindent + \dim_set_eq:NN \itemindent \parindent + \skip_set_eq:NN \parsep \parskip + \skip_zero:N \partopsep + \dim_zero:N \labelsep + } + \item + \relax + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_narrow_end:} +% End a narrow section in a scripture quotation. +% \begin{macrocode} +\cs_new_protected:Nn \@@_narrow_end: + { + \@@_calc_final_line_length: + \skip_add:Nn \@topsepadd \l_@@_delta_below_skip + \endlist + } +% \end{macrocode} +% \end{macro} +% +% \subsubsection{The \env{poetry} environment} +% +% \begin{macro}{\g_@@_poetry_end_bool} +% Flag indicating that a \env{poetry} environment just ended. +% \begin{macrocode} +\bool_new:N \g_@@_poetry_end_bool +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\l_@@_poetry_prevgraf_int} +% Store the number of lines a line of poetry takes up. +% \begin{macrocode} +\int_new:N \l_@@_poetry_prevgraf_int +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_poetry_chap:n} +% Position a chapter in a \env{poetry} environment. +% \begin{macrocode} +\cs_new_protected:Nn \@@_poetry_chap:n + { + \@@_drop_chap_set_up:n { #1 } + \dim_compare:nNnT \l_@@_chap_width_dim < \l_@@_poetry_leftmargin_tl + { + \tl_set:Nx \l_@@_chap_sep_tl + { + \dim_eval:n + { + \l_@@_poetry_leftmargin_tl - \l_@@_chap_width_dim + } + } + } + \hbox_set:Nn \l_tmpb_box + { + \box_move_down:nn + { \baselineskip } + { + \hbox_overlap_left:n + { + \box_use:N \l_tmpa_box + \skip_horizontal:N \l_@@_chap_sep_tl + } + } + } + \box_set_ht:Nn \l_tmpb_box { \c_zero_dim } + \box_set_dp:Nn \l_tmpb_box { \c_zero_dim } + \parshape 2 ~ + \dim_eval:n + { + \@totalleftmargin - \l_@@_poetry_leftmargin_tl + + \l_@@_chap_width_dim + \l_@@_chap_sep_tl + } ~ + \dim_eval:n + { + \linewidth - \@totalleftmargin + \l_@@_poetry_leftmargin_tl - + \l_@@_chap_width_dim - \l_@@_chap_sep_tl + } ~ + \dim_eval:n + { \@totalleftmargin + \l_@@_poetry_big_indent_tl } ~ + \dim_eval:n + { \linewidth - \l_@@_poetry_big_indent_tl } + \dim_compare:nNnT + { \l_@@_chap_width_dim + \l_@@_chap_sep_tl } + > + { \l_@@_poetry_leftmargin_tl + \listparindent } + { + \hook_gput_next_code:nn { para / begin } + { + \int_compare:nNnT \l_@@_poetry_prevgraf_int = 1 + { + \parshape 2 ~ + \dim_eval:n + { + \@totalleftmargin - \l_@@_poetry_leftmargin_tl + + \l_@@_chap_width_dim + \l_@@_chap_sep_tl - + \listparindent + } ~ + \dim_eval:n + { + \linewidth - \@totalleftmargin + \l_@@_poetry_leftmargin_tl - + \l_@@_chap_width_dim - \l_@@_chap_sep_tl + + \listparindent + } ~ + \dim_eval:n + { \@totalleftmargin + \l_@@_poetry_big_indent_tl } ~ + \dim_eval:n + { \linewidth - \l_@@_poetry_big_indent_tl } + } + } + } + \box_use:N \l_tmpb_box + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_poetry_nodrop_chap:n} +% Format a non-drop chapter for \env{poetry} environment in a +% \env{scripture} quotation. +% \begin{macrocode} +\cs_new_protected:Nn \@@_poetry_nodrop_chap:n + { + \hbox_overlap_left:n + { + \group_begin: + \l_@@_chap_font_tl + #1 + \group_end: + \skip_horizontal:N \l_@@_chap_sep_tl + } + } +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\@@_poetry_mode_vertical_verse:n} +% Format a verse for poetry scripture quotations in vertical and horizontal +% mode. +% \begin{macrocode} +\cs_new_protected:Nn \@@_poetry_mode_vertical_verse:n + { + \strut + \hbox_overlap_left:n + { + \@@_verse_output:n { #1 } + } + } +\cs_new_protected:Nn \@@_poetry_mode_horizontal_verse:n + { + \skip_horizontal:n { -\listparindent } + \@@_poetry_mode_vertical_verse:n { #1 } + \skip_horizontal:N \listparindent + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_poetry_par:} +% par macro for poetry sections +% \begin{macrocode} +\cs_new_protected:Nn \@@_poetry_par: + { + \mode_if_vertical:TF + { + \cs_set_eq:NN \vs \@@_poetry_mode_vertical_verse:n + \noindent + } + { + \cs_set_eq:NN \vs \@@_poetry_mode_horizontal_verse:n + \@@_tmp_para_end: + } + \parshape 2 ~ + \@totalleftmargin ~ + \linewidth ~ + \dim_eval:n + { \@totalleftmargin + \l_@@_poetry_big_indent_tl } ~ + \dim_eval:n + { \linewidth - \l_@@_poetry_big_indent_tl } + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_obeylines:} +% Special version of obeylines which doesn't insert par at end of +% environment. +% \begin{macrocode} +\group_begin: + \char_set_catcode_active:N \^^M + \cs_gset_protected_nopar:Nn \@@_obeylines: % + {% + \char_set_catcode_active:N \^^M% + \cs_set_eq:NN ^^M \@@_obeylines_end:% + }% +\group_end: +\cs_new_protected:Nn \@@_obeylines_end: + { + \peek_meaning:NF \end + { + \par + \int_set:Nn \l_@@_poetry_prevgraf_int { \int_use:N \prevgraf } + } + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_poetry_begin:} +% Begin a poetry section in a scripture quotation. +% \begin{macrocode} +\cs_new_protected:Nn \@@_poetry_begin: + { + \bool_if:NT \l_@@_active_inner_bool + { + \msg_error:nn { scripture } { nested-environment } + } + \bool_set_true:N \l_@@_active_inner_bool + \par + \list { } + { + \skip_set_eq:NN \l_@@_delta_below_skip \l_@@_poetry_belowskip_tl + \bool_if:NTF \g_@@_start_bool + { + \skip_zero:N \topsep + } + { + \dim_compare:nTF + { \parskip >= \l_@@_poetry_aboveskip_tl > \c_zero_skip } + { + \skip_zero:N \topsep + \skip_zero:N \l_@@_delta_below_skip + } + { + \skip_set_eq:NN \topsep \l_@@_poetry_aboveskip_tl + \skip_sub:Nn \l_@@_delta_below_skip \l_@@_poetry_aboveskip_tl + } + \int_compare:nNnT \l_@@_chap_par_prevgraf_int = 1 + { \addvspace { \baselineskip } } + \int_zero:N \l_@@_chap_par_prevgraf_int + } + \dim_set_eq:NN \leftmargin \l_@@_poetry_leftmargin_tl + \dim_set_eq:NN \rightmargin \l_@@_poetry_rightmargin_tl + \dim_set_eq:NN \itemindent \l_@@_poetry_indent_tl + \dim_set_eq:NN \listparindent \l_@@_poetry_indent_tl + \skip_zero:N \parsep + \skip_zero:N \partopsep + \dim_zero:N \labelsep + } + \raggedright + \dim_set_eq:NN \listparindent \l_@@_poetry_indent_tl + \dim_set_eq:NN \parindent \l_@@_poetry_indent_tl + \bool_if:NTF \l_@@_chap_drop_bool + { \cs_set_eq:NN \ch \@@_poetry_chap:n } + { \cs_set_eq:NN \ch \@@_poetry_nodrop_chap:n } + \cs_set_eq:NN \vs \@@_poetry_mode_vertical_verse:n + \item + \relax + \cs_set_eq:NN \@@_tmp_para_end: \par + \cs_set_eq:NN \par \@@_poetry_par: + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_poetry_end:} +% End a poetry section in a scripture quotation. +% \begin{macrocode} +\cs_new_protected:Nn \@@_poetry_end: + { + \@@_calc_final_line_length: + \skip_add:Nn \@topsepadd \l_@@_delta_below_skip + \endlist + \bool_gset_true:N \g_@@_poetry_end_bool + \hook_gput_next_code:nn { para / begin } + { \bool_gset_false:N \g_@@_poetry_end_bool } + } +% \end{macrocode} +% \end{macro} +% +% +% \subsection{Public \LaTeX{} Interface} +% +% \begin{macro}{\scripturesetup} +% \begin{arguments} +% \item \meta{|options|} to set. +% \end{arguments} +% Set key-value settings. +% \begin{macrocode} +\NewDocumentCommand { \scripturesetup } { m } + { + \keys_set:nn { scripture } { #1 } + } +% \end{macrocode} +% \end{macro} +% +% \begin{envmacro}{scripture} +% \begin{arguments} +% \item \meta{|reference|} of quotation. +% \item \meta{|options|} to set. +% \end{arguments} +% Format a scripture quotation with optional reference. +% \begin{macrocode} +\NewDocumentEnvironment { scripture } { oo } + { + \@@_begin:n { #2 } +% \end{macrocode} +% \begin{envmacro}{center} +% \begin{arguments} +% \item \meta{|options|} to set. +% \end{arguments} +% \begin{macrocode} + \DeclareDocumentEnvironment { center } { o } + { + \@@_center_begin:n { ##1 } + \ignorespaces + } + { \@@_center_end: } +% \end{macrocode} +% \end{envmacro} +% \begin{envmacro}{flushright} +% \begin{arguments} +% \item \meta{|options|} to set. +% \end{arguments} +% \begin{macrocode} + \DeclareDocumentEnvironment { flushright } { o } + { + \@@_flushright_begin:n { ##1 } + \ignorespaces + } + { \@@_flushright_end: } +% \end{macrocode} +% \end{envmacro} +% \begin{envmacro}{hanging} +% \begin{arguments} +% \item \meta{|options|} to set. +% \end{arguments} +% \begin{macrocode} + \DeclareDocumentEnvironment { hanging } { o } + { + \@@_hanging_begin:n { ##1 } + \ignorespaces + } + { \@@_hanging_end: } +% \end{macrocode} +% \end{envmacro} +% \vspace{-2\baselineskip} +% \begin{envmacro}{midparachap} +% \begin{macrocode} + \DeclareDocumentEnvironment { midparachap } { } + { + \@@_mid_para_chap_begin: + \ignorespaces + } + { \@@_mid_para_chap_end: } +% \end{macrocode} +% \end{envmacro} +% \begin{envmacro}{narrow} +% \begin{arguments} +% \item \meta{|options|} to set. +% \end{arguments} +% \begin{macrocode} + \DeclareDocumentEnvironment { narrow } { o } + { + \@@_narrow_begin:n { ##1 } + \ignorespaces + } + { \@@_narrow_end: } +% \end{macrocode} +% \end{envmacro} +% \begin{envmacro}{poetry} +% \begin{arguments} +% \item \meta{|options|} to set. +% \end{arguments} +% The \env{poetryaux} environment is required because \cs{@@_obeylines:} +% breaks the reading of optional arguments. +% \begin{macrocode} + \DeclareDocumentEnvironment { poetryaux } { o } + { + \tl_if_novalue:nF { ##1 } + { + \keys_set:nn + { scripture / poetry } + { ##1 } + } + \@@_poetry_begin: + \ignorespaces + } + { \@@_poetry_end: } + \DeclareDocumentEnvironment { poetry } { } + { + \@@_obeylines: + \poetryaux + } + { \endpoetryaux } +% \end{macrocode} +% \end{envmacro} +% \begin{macrocode} + \ignorespaces + } + { + \@@_end:n { #1 } + } +% \end{macrocode} +% \end{envmacro} +% \begin{macrocode} +%</package> +% \end{macrocode} +% \end{implementation} +% +% \PrintChanges +% +% \PrintIndex diff --git a/macros/latex/contrib/scripture/scripture.ins b/macros/latex/contrib/scripture/scripture.ins new file mode 100644 index 0000000000..44698f3ffd --- /dev/null +++ b/macros/latex/contrib/scripture/scripture.ins @@ -0,0 +1,47 @@ +\iffalse meta-comment + +Copyright (c) 2022 David Purton <dcpurton@marshwiggle.net> + +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 + http://www.latex-project.org/lppl.txt +and version 1.3c or later is part of all distributions of LaTeX +version 2005/12/01 or later. + +\fi + +\input l3docstrip.tex +\askforoverwritefalse + +\preamble + +This is a generated file. + +Copyright (c) 2022 David Purton <dcpurton@marshwiggle.net> + +This work may be distributed and/or modified under the conditions of +the LaTeX Project2 Public License, either version 1.3c of this license +or (at your option) any later version. The latest version of this +license is in + http://www.latex-project.org/lppl.txt +and version 1.3c or later is part of all distributions of LaTeX +version 2005/12/01 or later. + +This work is "maintained" (as per the LPPL maintenance status) +by David Purton. + +This work consists of the files scripture.ins, scripture.dtx, README.md, +and the derived files scripture.sty and scripture.pdf + +\endpreamble + +\postamble +\endpostamble + +\keepsilent + +\generate{\file{scripture.sty}{\from{scripture.dtx}{package}}} + +\endbatchfile diff --git a/macros/latex/contrib/scripture/scripture.pdf b/macros/latex/contrib/scripture/scripture.pdf Binary files differnew file mode 100644 index 0000000000..6ebd1f263f --- /dev/null +++ b/macros/latex/contrib/scripture/scripture.pdf |