diff options
Diffstat (limited to 'macros')
20 files changed, 2435 insertions, 246 deletions
diff --git a/macros/generic/witharrows/witharrows-french.pdf b/macros/generic/witharrows/witharrows-french.pdf Binary files differindex 8ea76ae1de..2d9b238271 100644 --- a/macros/generic/witharrows/witharrows-french.pdf +++ b/macros/generic/witharrows/witharrows-french.pdf diff --git a/macros/generic/witharrows/witharrows-french.tex b/macros/generic/witharrows/witharrows-french.tex index 86b7f660f9..8c19fc72f8 100644 --- a/macros/generic/witharrows/witharrows-french.tex +++ b/macros/generic/witharrows/witharrows-french.tex @@ -1228,11 +1228,11 @@ $\begin{WithArrows}[code-after = \Arrow[v]{1-2}{2-2}{division par $2$} ] \end{WithArrows}$ -\interitem +\interitem L'extension \pkg{witharrows} fournit une autre commande disponible dans le |code-after| : la commande -|\MultiArrow|. Cette commande dessine un «rateau». La liste des rangées concernées par ce rateau -est donnée dans le premier argument de la commande |\MultiArrow|. La syntaxe utilisée pour décrire cette liste -est celle de la commande |\foreach| de \pkg{pgffor}. +|\MultiArrow|. Cette commande dessine un «rateau». La liste des rangées concernées par ce rateau est donnée dans le +premier argument de la commande |\MultiArrow|. La syntaxe utilisée pour décrire cette liste est celle de la +commande |\foreach| de \pkg{pgffor}. \begin{Verbatim} $\begin{WithArrows}[tikz = rounded corners, diff --git a/macros/generic/witharrows/witharrows.dtx b/macros/generic/witharrows/witharrows.dtx index f14d21114a..2e6c4270ea 100644 --- a/macros/generic/witharrows/witharrows.dtx +++ b/macros/generic/witharrows/witharrows.dtx @@ -15,8 +15,8 @@ % % \fi % \iffalse -\def\myfileversion{2.6b} -\def\myfiledate{2021/01/31} +\def\myfileversion{2.6c} +\def\myfiledate{2021/03/04} % % %<*batchfile> @@ -2669,10 +2669,7 @@ version 2005/12/01 or later. % % % \medskip -% The version of 2020/02/08 of \pkg{expl3} has replaced |\l_keys_key_tl| by -% |\l_keys_key_str|. We have immediatly changed in this file. Now, you test the -% existence of |\l_keys_key_str| in order to detect if the version of LaTeX used -% by the final user is up to date. +% We use |\seq_set_map_x:NNn| which has been introduced the 2020/07/16. % \begin{macrocode} \msg_new:nnn { witharrows } { expl3~too~old } { @@ -2680,12 +2677,14 @@ version 2005/12/01 or later. You~can~go~on~but~you~will~probably~have~other~errors~ if~you~use~the~functionalities~of~witharrows. } -\cs_if_exist:NF \l_keys_key_str +\cs_if_exist:NF \seq_set_map_x:NNn { \msg_error:nn { witharrows } { expl3~too~old } } % \end{macrocode} % % \bigskip +% The package \pkg{xparse} is still loaded for use on Overleaf. % \begin{macrocode} +\RequirePackage { xparse } \RequirePackage { varwidth } %</LaTeX> % \end{macrocode} @@ -6824,6 +6823,33 @@ version 2005/12/01 or later. % \bigskip % \subsection{The error messages of the package} % +% +% \begin{macrocode} +\str_new:N \l_witharrows_body_str +% \end{macrocode} +% +% The following commands must \emph{not} be protected since they will be used in +% error messages. +% \begin{macrocode} +\cs_new:Npn \@@_potential_body_i: + { + \str_if_empty:NF \l_witharrows_body_str + { \\ If~you~want~to~see~the~body~of~the~environment,~type~H~<return>. } + } +% \end{macrocode} +% +% \begin{macrocode} +\cs_new:Npn \@@_potential_body_ii: + { + \str_if_empty:NTF \l_nicematrix_body_str + { No~further~help~available } + { + The~body~of~your~environment~was:\\ + \l_witharrows_body_str + } + } +% \end{macrocode} +% % \begin{macrocode} \str_const:Nn \c_@@_option_ignored_str { If~you~go~on,~this~option~will~be~ignored. } @@ -6880,40 +6906,48 @@ version 2005/12/01 or later. % % \begin{macrocode} %<*LaTeX> -\@@_msg_new:nn { newline~at~the~end~of~env } +\@@_msg_new:nnn { newline~at~the~end~of~env } { The~environments~of~witharrows~(\{WithArrows\}~and~ \{DispWithArrows\})~should~not~end~by~\token_to_str:N \\.\\ However,~you~can~go~on~for~this~time.~No~similar~error~will~be~ - raised~in~this~document. + raised~in~this~document. + \@@_potential_body_i: } + { \@@_potential_body_ii: } %</LaTeX> % \end{macrocode} % % \begin{macrocode} -\@@_msg_new:nn { Invalid~option~format } +\@@_msg_new:nnn { Invalid~option~format } { The~key~'format'~should~contain~only~letters~r,~c~and~l~and~ must~not~be~empty.\\ \c_@@_option_ignored_str + \@@_potential_body_i: } + { \@@_potential_body_ii: } % \end{macrocode} % % \begin{macrocode} -\@@_msg_new:nn { invalid~key~o } +\@@_msg_new:nnn { invalid~key~o } { The~key~'o'~for~individual~arrows~can~be~used~only~in~mode~ 'group'~or~in~mode~'groups'.\\ \c_@@_option_ignored_str + \@@_potential_body_i: } + { \@@_potential_body_ii: } % \end{macrocode} % % \begin{macrocode} -\@@_msg_new:nn { Value~for~a~key } +\@@_msg_new:nnn { Value~for~a~key } { The~key~'\l_keys_key_str'~should~be~used~without~value. \\ However,~you~can~go~on~for~this~time. + \@@_potential_body_i: } + { \@@_potential_body_ii: } % \end{macrocode} % % \begin{macrocode} @@ -6988,7 +7022,7 @@ version 2005/12/01 or later. % % % \begin{macrocode} -\@@_msg_new:nn { Too~much~columns~in~WithArrows } +\@@_msg_new:nnn { Too~much~columns~in~WithArrows } { Your~environment~\{\l_@@_type_env_str\}~has~\int_use:N \l_@@_nb_cols_int\ columns~and~you~try~to~use~one~more.~ @@ -6996,18 +7030,22 @@ version 2005/12/01 or later. If~you~really~want~to~use~more~columns~(after~the~arrows)~you~should~use~ the~option~'more-columns'~at~a~global~level~or~for~an~environment. \\ However,~you~can~go~one~for~this~time. + \@@_potential_body_i: } + { \@@_potential_body_ii: } % \end{macrocode} % % \begin{macrocode} -\@@_msg_new:nn { Too~much~columns~in~DispWithArrows } +\@@_msg_new:nnn { Too~much~columns~in~DispWithArrows } { Your~environment~\{\l_@@_type_env_str\}~has~\int_use:N \l_@@_nb_cols_int\ columns~and~you~try~to~use~one~more.~ Maybe~you~have~forgotten~a~\c_backslash_str\c_backslash_str\ at~the~end~of~row~\int_use:N \g_@@_line_int. \\ This~error~is~fatal. + \@@_potential_body_i: } + { \@@_potential_body_ii: } % \end{macrocode} % % \begin{macrocode} @@ -7035,7 +7073,7 @@ version 2005/12/01 or later. % % % \begin{macrocode} -\@@_msg_new:nn +\@@_msg_new:nnn { Too~few~lines~for~an~arrow } { Line~\l_@@_input_line_str\ @@ -7043,7 +7081,9 @@ version 2005/12/01 or later. of~your~environment~\{\l_@@_type_env_str\}~can't~be~drawn~ because~it~arrives~after~the~last~row~of~the~environment. \\ If~you~go~on,~this~arrow~will~be~ignored. + \@@_potential_body_i: } + { \@@_potential_body_ii: } % \end{macrocode} % % \begin{macrocode} @@ -7056,21 +7096,25 @@ version 2005/12/01 or later. % \end{macrocode} % % \begin{macrocode} -\@@_msg_new:nn { WithArrows~outside~math~mode } +\@@_msg_new:nnn { WithArrows~outside~math~mode } { The~environment~\{\l_@@_type_env_str\}~should~be~used~only~in~math~mode~ like~the~environment~\{aligned\}~of~amsmath. \\ Nevertheless,~you~can~go~on. + \@@_potential_body_i: } + { \@@_potential_body_ii: } % \end{macrocode} % % \begin{macrocode} -\@@_msg_new:nn { DispWithArrows~in~math~mode } +\@@_msg_new:nnn { DispWithArrows~in~math~mode } { The~environment~\{\l_@@_type_env_str\}~should~be~used~only~outside~math~ mode~like~the~environments~\{align\}~and~\{align*\}~of~amsmath. \\ This~error~is~fatal. + \@@_potential_body_i: } + { \@@_potential_body_ii: } % \end{macrocode} % % \begin{macrocode} @@ -7100,13 +7144,15 @@ version 2005/12/01 or later. % \end{macrocode} % % \begin{macrocode} -\@@_msg_new:nn { Arrow~not~in~last~column } +\@@_msg_new:nnn { Arrow~not~in~last~column } { You~should~use~the~command~\l_@@_string_Arrow_for_msg_str\ only~in~the~last~column~(column~\int_use:N\l_@@_nb_cols_int)~ of~your~environment~\{\l_@@_type_env_str\}.\\ However~you~can~go~on~for~this~time. + \@@_potential_body_i: } + { \@@_potential_body_ii: } % \end{macrocode} % % \begin{macrocode} diff --git a/macros/generic/witharrows/witharrows.pdf b/macros/generic/witharrows/witharrows.pdf Binary files differindex 7727d27d1c..03a0cb1161 100644 --- a/macros/generic/witharrows/witharrows.pdf +++ b/macros/generic/witharrows/witharrows.pdf diff --git a/macros/latex/contrib/apa7/apa7.dtx b/macros/latex/contrib/apa7/apa7.dtx index 9819cca02b..85bcdc5e88 100644 --- a/macros/latex/contrib/apa7/apa7.dtx +++ b/macros/latex/contrib/apa7/apa7.dtx @@ -4,11 +4,11 @@ % % % CHANGE THESE VALUES WITH EACH NEW RELEASE: % % % -%<class>\ProvidesClass{apa7}[2021/03/03 v2.09 APA formatting (7th edition)] +%<class>\ProvidesClass{apa7}[2021/03/04 v2.10 APA formatting (7th edition)] % % %<*internal> % -\def\apaSevenVersionDate{2021/03/03} -\def\apaSevenVersionNumber{2.09} +\def\apaSevenVersionDate{2021/03/04} +\def\apaSevenVersionNumber{2.10} % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -267,6 +267,8 @@ and the derived files apa7.ins, % % \changes{v2.09}{2021/03/03}{Updated APA7endfloat.cfg file to use more modern DeclareDelayedFloatFlavor. This fixes the bug where longtable can be shown on the same page as another table. } % +% \changes{v2.10}{2021/03/04}{Update BibLaTex instructions to remove DeclareLanguageMapping and remove commands that are no longer required. } +% % \begin{abstract} % The \textit{Publication Manual} of the American Psychological % Association is widely used in the social sciences. The most @@ -788,9 +790,8 @@ and the derived files apa7.ins, % \textit{\textbf{Note:} This is the recommended method for 7th edition citations and references.} \\ % Biblatex is the most APA-compliant bibiliography package. The % \DescribeMacro{biblatex}|biblatex| option directs \textsf{apa7} to -% load the \textsf{biblatex} package with the following options: -% style=apa,sortcites=true,sorting=nyt; however, the -% |\DeclareLanguageMapping| and |\addbibresource| commands will need +% load the \textsf{biblatex} package with the following option: +% style=apa; however, the |\addbibresource| command will need % to be specified by the user within the document preamble. In the % absence of bibliographic options, \textsf{apa7} will mask references % using \textsf{biblatex} commands if the |mask| option is specified. @@ -915,8 +916,7 @@ and the derived files apa7.ins, \usepackage[american]{babel} \usepackage{csquotes} - \usepackage[style=apa,sortcites=true,sorting=nyt,backend=biber]{biblatex} - \DeclareLanguageMapping{american}{american-apa} + \usepackage[style=apa,backend=biber]{biblatex} \addbibresource{bibliography.bib} \title{Sample APA-Style Document Using the \textsf{apa7} Package} @@ -1235,7 +1235,7 @@ and the derived files apa7.ins, \ClassInfo{apa7}{No bibliography package was specified; defaulting to (but not loading) Biblatex} }{% \def\def@biblatex{\@biblatexmode}% the selected bibliography package is Biblatex - \RequirePackage[style=apa,sortcites=true,sorting=nyt,backend=biber]{biblatex} + \RequirePackage[style=apa,backend=biber]{biblatex} \@ifundefined{def@man}{% \defbibheading{bibliography}[\refname]{\section*{\normalfont\textbf{#1}}}% }{% @@ -3411,8 +3411,7 @@ and the derived files apa7.ins, \usepackage[american]{babel} \usepackage{csquotes} -\usepackage[style=apa,sortcites=true,sorting=nyt,backend=biber]{biblatex} -\DeclareLanguageMapping{american}{american-apa} +\usepackage[style=apa,backend=biber]{biblatex} \addbibresource{bibliography.bib} \title{Sample APA-Style Document Using the \textsf{apa7} Package} @@ -3528,8 +3527,7 @@ skill in interpreting the results for the masses. \usepackage[american]{babel} \usepackage{csquotes} -\usepackage[style=apa,sortcites=true,sorting=nyt,backend=biber]{biblatex} -\DeclareLanguageMapping{american}{american-apa} +\usepackage[style=apa,backend=biber]{biblatex} \addbibresource{bibliography.bib} \title{Sample APA-Style Document Using the \textsf{apa7} Package} diff --git a/macros/latex/contrib/apa7/apa7.pdf b/macros/latex/contrib/apa7/apa7.pdf Binary files differindex 342cc96d43..fcfd0c2041 100644 --- a/macros/latex/contrib/apa7/apa7.pdf +++ b/macros/latex/contrib/apa7/apa7.pdf diff --git a/macros/latex/contrib/apa7/samples/longsample.pdf b/macros/latex/contrib/apa7/samples/longsample.pdf Binary files differindex 52c3461ee0..35f4b63630 100644 --- a/macros/latex/contrib/apa7/samples/longsample.pdf +++ b/macros/latex/contrib/apa7/samples/longsample.pdf diff --git a/macros/latex/contrib/apa7/samples/shortsample.pdf b/macros/latex/contrib/apa7/samples/shortsample.pdf Binary files differindex 63b1d5be79..135d919beb 100644 --- a/macros/latex/contrib/apa7/samples/shortsample.pdf +++ b/macros/latex/contrib/apa7/samples/shortsample.pdf diff --git a/macros/latex/contrib/fontsize/fontsize.dtx b/macros/latex/contrib/fontsize/fontsize.dtx index b13a571f55..a7a75d6db6 100644 --- a/macros/latex/contrib/fontsize/fontsize.dtx +++ b/macros/latex/contrib/fontsize/fontsize.dtx @@ -56,14 +56,15 @@ This work has the LPPL maintenance status "author-maintained". %<package>\NeedsTeXFormat{LaTeX2e}[2005/12/01] %<package>\ProvidesPackage{fontsize} %<*package> - [2021/02/10 v0.7 'fontsize' package. Set main font sizes (Ivan Valbusa)] + [2021/03/04 v0.8 'fontsize' package. Set main font sizes (Ivan Valbusa)] %</package> %<*driver> \documentclass[12pt]{ltxdoc} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage[fontsize=12pt]{fontsize} -\usepackage{array,booktabs,siunitx,tabu} +\usepackage{array,booktabs,tabu} +\usepackage{siunitx} \usepackage{multicol} %-------------------------------------------------------- % GRAPHICS @@ -214,6 +215,7 @@ This work has the LPPL maintenance status "author-maintained". % Right brace \} Tilde \~} % % +% \changes{v0.8}{2021/03/04}{Corrected a bug occuring when the line spacing is grater than \SI{163.84}{pt}.} % \changes{v0.7}{2021/02/10}{New font sizing commands \cmd{HUGE}, \cmd{HUGEr}, \cmd{HUGErr}, \cmd{HUGErrr}. Changed default name for the \file{.clo} file to \opt{fontsize}. Updated documentation.} % \changes{v0.6}{2021/02/06}{New font sizing commands from \cmd{small} down. Updated documentation.} % \changes{v0.5}{2021/01/31}{New font sizing commands from \cmd{normalsize} up. New command \cmd{printsamples}. Updated documentation.} @@ -260,8 +262,18 @@ This work has the LPPL maintenance status "author-maintained". %}; % \end{tikzpicture} % \clearpage\thispagestyle{empty} +% \null\vspace{1cm} % -% \null\vfill +%\hfill\begin{minipage}{.5\textwidth} +% \raggedleft\footnotesize +% The serif typeface is Cochineal, created by Michael Sharpe +% on the basis of Sebastian Kosch's Crimson. +% The \texttt{typewriter} font is Inconsolata, +% designed by Raph Levien and the \textsf{sans serif} text +% is typeset in Linux Biolinum, created by Philipp H.~Pol. +%\end{minipage} +% +% \vfill % % ^^A ---------------------------------------------------------------- % ^^A @@ -274,7 +286,7 @@ This work has the LPPL maintenance status "author-maintained". % % \noindent This package is author-maintained. % Permission is granted to copy, distribute and/or modify this software -% under the terms of the \LaTeX{} Project Public License, version 1.3 or +% under the terms of the \hologo{LaTeX} Project Public License, version 1.3 or % later (\url{http://latex-project.org/lppl}). % This software is provided ``as is'', without warranty of any kind, % either expressed or implied, including, but not limited to, the implied @@ -429,10 +441,14 @@ This work has the LPPL maintenance status "author-maintained". %^^A Defines the \meta{text} to be used by \cmd{printsamples}. % % \end{ltxsyntax} +% %^^A--------------------------------------------------------------------- -% \section{New font sizing commands}\label{sec:sizingcmd} +% \subsection{New font sizing commands}\label{sec:sizingcmd} %^^A-------------------------------------------------------------------- -% The package provides three additional font sizing commands for each standard size: +% +% The package provides three additional font sizing commands for each standard size. +% The value of these new sizes (rounded to the second decimal place) are shown in +% table \ref{tab:sizes}. % \medskip % %\def\fshw{Lipsum} @@ -489,11 +505,17 @@ This work has the LPPL maintenance status "author-maintained". % } %\medskip % -% \begin{normalsize} +% \begin{footnotesize} %\alert If you want these commands to work as expected, the font must be -% smoothly scalable. This is the case of many Type 1 and Open Type fonts. -% Anyway, if the font has optical sizes, unusual things can happen: -% some larger sizes may appear smaller. For example, with the Latin Modern 12\,pt typeface a similar situation can be encountered:\medskip +% smoothly scalable. +% This is the case of many Type 1 and Open Type fonts such as Cochineal +% used in this document \parencite{cochineal}, but +% if the font has optical sizes, unusual things can happen: +% some larger sizes may appear smaller. In any case, with the \LaTeX\ +% default font (i.e. Computer Modern) I recommend loading +% \cmd{RequirePackage}|{fix-cm}| just before \cmd{documentclass}. +% For example, with the Latin Modern 12\,pt typeface \parencite{lm} +% a similar situation can be encountered:\medskip % % \begingroup % \centering @@ -509,7 +531,6 @@ This work has the LPPL maintenance status "author-maintained". % \scalebox{3}{\large H} \scalebox{3}{\larger H} \scalebox{3}{\largerr H} % % \endgroup -% \end{normalsize} % \medskip % % In fact the font used for the \cmd{larger} `Hello world' is bigger than @@ -517,7 +538,9 @@ This work has the LPPL maintenance status "author-maintained". % thickness of the stems, which makes the words appear shorter and clearer, % but not less high (as you can see in the figure on the % right which shows the letter H appropriately scaled to see the -% differences better). +% differences better). +% +% \end{footnotesize} % % \clearpage\thispagestyle{empty} % \def\ivalbmidrule{\arrayrulecolor{black!40}\midrule\rowfont{\color{philA}}} @@ -526,7 +549,7 @@ This work has the LPPL maintenance status "author-maintained". % \centering % \centerline{% % \begin{tabu}{lSSSSSSSSS} -%\toprule +%\toprule\rowfont{\color{philA}} % \tcmd{tiny} & 4.00 & 4.25 & 4.50 & 4.75 & 5.00 & 5.25 & 5.50 & 5.75 & 6.00 \\ % \cmd{tinyr} & 4.33 & 4.60 & 4.88 & 5.15 & 5.42 & 5.69 & 5.96 & 6.23 & 6.50 \\ % \cmd{tinyrr} & 4.67 & 4.96 & 5.25 & 5.54 & 5.83 & 6.12 & 6.42 & 6.71 & 7.00 \\ @@ -589,18 +612,14 @@ This work has the LPPL maintenance status "author-maintained". %\clearpage\thispagestyle{plain} % %^^A--------------------------------------------------------------------- +% % \section{Some text samples}\label{sec:example} % %^^A-------------------------------------------------------------------- % The following examples are obtained with the \cmd{printsamples} command (see section \ref{sec:commands}). % -%^^A Below you can see some text samples scaled proportionally -%^^A to match the different values of the selected normal size and line spacing. -% % \printsamples{13.2pt}{11.2pt}[normalsizer,normalsizerr,normalsizerrr,large,larger] % \printsamples{13.4pt}{11.7pt}[normalsizer,normalsizerr,normalsizerrr,large,larger] -% -% \nocite{xkeyval,etoolbox} % % \StopEventually{% % \printbibliography[heading=bibintoc] @@ -614,7 +633,7 @@ This work has the LPPL maintenance status "author-maintained". %^^A--------------------------------------------------------------------- %\textcolor{DarkBlue}{The parts added to the basic code of \file{scrextend} and \file{scrfontsizes} are highlighted in blue.} % -%\noindent All the options of the package are defined via \sty{xkeyval}. +%\noindent All the options of the package are defined via \sty{xkeyval} \parencite{xkeyval}. Only a new package option called \opt{cloname} is defined. % \baddition % \begin{macrocode} \@ifpackageloaded{xkeyval}{}{\RequirePackage{xkeyval}} @@ -624,7 +643,8 @@ This work has the LPPL maintenance status "author-maintained". % % \paragraph{Excerpt from \file{scrextend.sty}} % -% Here the \sty{scrextend} code begins. Only a few names have been changed. +% Here the \sty{scrextend} code begins. All the KOMA related codes have +% been removed and only a few names have been changed. % The value of \cmd{|@|fontsizefilebase} is set to \texttt{fontsize} instead of \texttt{scrsize}. % \begin{macrocode} \DeclareOptionX{fontsize}[10]{% @@ -700,7 +720,25 @@ This work has the LPPL maintenance status "author-maintained". \addtolength{\@tempdimc}{-10\p@}% \edef\@ptsize{\strip@pt\@tempdimc}% \@defaultunits\@tempdimb#1pt\relax\@nnil - \setlength{\@tempdimc}{\dimexpr (100\@tempdimb / \@tempdima * \p@)}% +% \end{macrocode} +% The value of \cmd{@tempdimc} set in \sty{scrextend.sty} +% \begin{center}\footnotesize +% |\setlength{\@tempdimc}{\dimexpr (100\@tempdimb / \@tempdima * \p@)}| +% \end{center} +% returns an error when the the line spacing is greater than \SI{163.84}{pt} +% or the value passed to the \opt{fontsize} option is grater than \SI{136.53}{pt}. +% This is due to the intermediate calculation: +% $100 \verb!\@tempdimb! = \SI{16384}{pt}$, which is +% the maximum dimension that may be stored in plain +% \TeX\ and \LaTeX. +% The problem, which is probably more theoretical than practical, +% can be solved simply by changing it to this (thanks to Claudio Beccari): +% \baddition +% \begin{macrocode} + \setlength{\@tempdimc}{100\dimexpr (\@tempdimb * \p@ / \@tempdima)} +% \end{macrocode} +% \eaddition +% \begin{macrocode} \edef\@tempb{\the\@tempdimc}% \setlength{\@tempdimc}{\@tempdima}% \def\@tempa##1##2##3##4##5\@nnil{\def##1{##2.##3##4}}% @@ -1075,19 +1113,19 @@ This work has the LPPL maintenance status "author-maintained". \noexpand\@setfontsize\noexpand\HUGE {\the\@tempdima}{\the\@tempdimb}% }% - \setlength{\@tempdima}{3,155\@tempdimc}% + \setlength{\@tempdima}{3.155\@tempdimc}% \setlength{\@tempdimb}{\@tempb\@tempdima}% \edef\HUGEr{% \noexpand\@setfontsize\noexpand\HUGEr {\the\@tempdima}{\the\@tempdimb}% }% - \setlength{\@tempdima}{3,304\@tempdimc}% + \setlength{\@tempdima}{3.304\@tempdimc}% \setlength{\@tempdimb}{\@tempb\@tempdima}% \edef\HUGErr{% \noexpand\@setfontsize\noexpand\HUGErr {\the\@tempdima}{\the\@tempdimb}% }% - \setlength{\@tempdima}{3,453\@tempdimc}% + \setlength{\@tempdima}{3.453\@tempdimc}% \setlength{\@tempdimb}{\@tempb\@tempdima}% \edef\HUGErrr{% \noexpand\@setfontsize\noexpand\HUGErrr @@ -1266,7 +1304,7 @@ This work has the LPPL maintenance status "author-maintained". % % \paragraph{Excerpt from \file{scrfontsizes.sty}} % -% Here is a portion of the \sty{scrfontsizes} package. It simply provides the \cmd{generateclofile} command, without the KOMA-related definitions. There are no reserved names for the \file{.clo} files. The command name is a new name for the KOMA \cmd{generatefontfile}. In fact what the command generates is a \file{.clo} file. +% Here is a portion of the \sty{scrfontsizes} package. It simply provides the \cmd{generateclofile} command, without the KOMA related definitions. There are no reserved names for the \file{.clo} files. The command name is a new name for the KOMA \cmd{generatefontfile}. In fact what the command generates is a \file{.clo} file. % \begin{macrocode} \newcommand*{\generateclofile}[1]{% \kernel@ifnextchar [{\@generatefontfile{#1}}{\@@generatefontfile{#1}}% @@ -1850,7 +1888,8 @@ This work has the LPPL maintenance status "author-maintained". % \end{macrocode} % We will now define some internal commands to test the package functions. % Since version 0.6 I have been using the \LaTeX 3 solution provided by -% Enrico Gregorio in place of the previous macros based on \sty{etoolbox}. +% Enrico Gregorio in place of the previous macros based on +% \sty{etoolbox} \parencite{etoolbox}. % \baddition % \begin{macrocode} \def\fontsizelipsum{% @@ -1951,6 +1990,24 @@ This work has the LPPL maintenance status "author-maintained". date = {2020-04-19}, version = {3.30} } + +@manual{lm, + title = {The Latin Modern (LM) Family of Fonts}, + author = {B. Jackowski and J.M. Nowacki}, + url = {http://www.ctan.org/pkg/lm}, + urldate = {2021-03-04}, + date = {2009-10-30}, + version = {2.004} +} + +@manual{cochineal, + title = {The Cochineal Font Package}, + author = {Michael Sharpe}, + url = {http://www.ctan.org/pkg/cochineal}, + urldate = {2021-03-04}, + date = {2020-12-19}, + version = {1.065 } +} %</bib> % \fi % \Finale diff --git a/macros/latex/contrib/fontsize/fontsize.pdf b/macros/latex/contrib/fontsize/fontsize.pdf Binary files differindex e869a963f4..5642de57f8 100644 --- a/macros/latex/contrib/fontsize/fontsize.pdf +++ b/macros/latex/contrib/fontsize/fontsize.pdf diff --git a/macros/latex/contrib/lipsum/README.txt b/macros/latex/contrib/lipsum/README.txt index 455ea0f1fb..6cd309b680 100644 --- a/macros/latex/contrib/lipsum/README.txt +++ b/macros/latex/contrib/lipsum/README.txt @@ -1,9 +1,11 @@ -lipsum +lipsum Access to 150 paragraphs of ``Lorem ipsum'' dummy text. Patrick Happel (patrick.happel@rub.de) -https://github.com/patta42/lipsum + +Currently maintained by Phelype Oleinik +https://github.com/PhelypeOleinik/lipsum ============================================================ @@ -13,7 +15,7 @@ https://github.com/patta42/lipsum -------------------------- lipsum.dtx - lipsum.ins + lipsum.ins lipsum.pdf README.txt (this file) @@ -25,39 +27,39 @@ https://github.com/patta42/lipsum - Run lipsum.ins through latex - Move the resulting .sty file and the resulting .ltd.tex files - to a place where latex finds it. - On a TDS compliant system this should be (substitute $TEXMF + to a place where latex finds it. + On a TDS compliant system this should be (substitute $TEXMF with your local or home texmf directory): - + $TEXMF/tex/latex/lipsum/ - - If you want to produce your own documentation file (maybe + - If you want to produce your own documentation file (maybe dvi instead of pdf) run lipsum.dtx through latex. - - Move the documentation (lipsum.pdf, if you haven't produced - your own file in a different format) in a TDS compliant + - Move the documentation (lipsum.pdf, if you haven't produced + your own file in a different format) in a TDS compliant system to: - $TEXMF/doc/latex/lipsum + $TEXMF/doc/latex/lipsum - If you like to, move the source files (.dtx and .ins) in a source directory of your system. - - - Update your filename database. How to achieve this depends + + - Update your filename database. How to achieve this depends on your system. For teTeX and texlive, `texhash' will work. - - If you are using a non TDS compliant system take a look in + - If you are using a non TDS compliant system take a look in the documentation how to install new packages. 3. License -------------------------- -This material is subject to the LaTeX Project Public License 1.3. See - +This material is subject to the LaTeX Project Public License 1.3. See + https://www.latex-project.org/lppl/ -for the details of that license. +for the details of that license. diff --git a/macros/latex/contrib/lipsum/lipsum.dtx b/macros/latex/contrib/lipsum/lipsum.dtx index 9160311869..233b5c359e 100644 --- a/macros/latex/contrib/lipsum/lipsum.dtx +++ b/macros/latex/contrib/lipsum/lipsum.dtx @@ -12,15 +12,17 @@ % and version 1.3 or later is part of all distributions of LaTeX % version 2005/12/01 or later. % -% Please send error reports and suggestions for improvements to -% Patrick Happel <patrick.happel@rub.de>. -% -% Alternatively, use github: -% https://github.com/patta42/lipsum +% Please send error reports and suggestions for improvements to +% https://github.com/PhelypeOleinik/lipsum % +\def\lipsumversion{2.3} +\def\lipsumdate{2021-03-03} %<*driver> -\ProvidesFile{lipsum.dtx}[2019/01/02 v2.2 Access to 150 of Lorem Ipsum dummy text] +\ProvidesFile{lipsum.dtx}% + [\lipsumdate\space v\lipsumversion\space + Access to 150 of Lorem Ipsum dummy text] \documentclass{l3doc} +\usepackage{xcolor} \usepackage[a4paper, top=2cm, left=8.8cm, right=2cm, bottom=3cm, marginparwidth=6.3cm, marginparsep=.5cm, @@ -35,13 +37,13 @@ middlelinewidth=0pt } \newmdenv[style=expl]{explbox} - + \newmdenv[% style=expl, subtitlebackgroundcolor=yellow!5!white, frametitlebackgroundcolor=yellow!5!white, frametitle={Code}, -] {exploutputbox} +] {exploutputbox} \usepackage{lipsum,multicol} \usepackage[latin, english]{babel} @@ -52,7 +54,7 @@ \renewcommand\maketitle[1]{ \noindent \hspace{-\fullmargin}% - \begin{minipage}{\textwidth+\fullmargin} + \begin{minipage}{\textwidth+\fullmargin} \renewcommand\thefootnote{\fnsymbol{footnote}} \let\thanks\footnote { @@ -111,23 +113,30 @@ \RequirePackage{xparse} \ProvidesExplPackage {lipsum} - {2019/01/02} - {2.2} + {\lipsumdate} + {\lipsumversion} {150 paragraphs of Lorem Ipsum dummy text} %</package> %<*lipsum> -\ProvidesFile{lipsum.ltd.tex}[2019/01/02 v2.2 The Lorem ipsum dummy text] +\ProvidesFile{lipsum.ltd.tex}% + [\lipsumdate\space v\lipsumversion\space + The Lorem ipsum dummy text] %</lipsum> %<*cicero> -\ProvidesFile{cicero.ltd.tex}[2019/01/02 v2.2 Text of Cicero's speech] +\ProvidesFile{cicero.ltd.tex}% + [\lipsumdate\space v\lipsumversion\space + Text of Cicero's speech] -%</cicero> +%</cicero> % \fi % % \title{\pkg{lipsum}} % \subtitle{Access to 150 paragraphs of Lorem Ipsum dummy -% text\thanks{Version: 2.2}} +% text\thanks{Version: \lipsumversion}^^A +% \thanks{Since March 2021, Phelype Oleinik maintains this package +% (\href{mailto:phelype.oleinik@latex-project.org} +% {phelype.oleinik\meta{at}latex-project.org}).}} % \author{Patrick Happel\thanks{patrick.happel@rub.de}} % \date{\today} % \RecordChanges @@ -139,7 +148,7 @@ % \changes{v1.3}{2014/07/19}{Introduced some improvements and provided some % new macros (thanks to tex.stackexchange user egreg).} % \changes{v1.3a}{2017/08/10}{Fixed a type in the documentation (thanks to -% Vincent Belaïche). This version never made its way on CTAN due to some +% Vincent Belaïche). This version never made its way on CTAN due to some % version naming conflicts. Since the change here was only in the % documentation, I first didn't want it to be 1.3a and later had no time to % update it properly.} @@ -153,6 +162,9 @@ % \changes{v2.2}{2018/12/25}{replaced \cs{tex_par:D} by \cs{par} to avoid % incompatibilities with \LaTeX2e's |list|-environment. Thanks to Karl Hagen % for reporting. See \url{ttps://github.com/patta42/lipsum/issues/12}.} +% \changes{v2.3}{2021/03/03}{Remove dependency on an \pkg{xparse} internal +% macro. \pkg{lipsum}'s new home at +% \url{https://github.com/PhelypeOleinik/lipsum}} % % \maketitle{\pkg{lipsum} is a \LaTeX{} package that produces dummy text % to be used in test documents or examples. The paragraphs are taken with @@ -164,16 +176,16 @@ % % \hspace{1em} Please, file bug reports, typos in the documentation or % feature requests as an issue on -% \url{https://github.com/patta42/lipsum/issues}.} +% \url{https://github.com/PhelypeOleinik/lipsum/issues}.} % \begin{documentation} % % \section{Quick usage overview} -% To load the package specify +% To load the package specify % \begin{verbatim} % \usepackage{lipsum} % \end{verbatim} % in the preamble of your document. This package provides several -% macros. \DescribeMacro{\lipsum}The most important one is +% macros. \DescribeMacro{\lipsum}The most important one is % \cs{lipsum}. This macro typesets the \emph{Lorem ipsum} % paragraphs. It has two optional arguments. The first one allows to specify the range % of the paragraphs. For example, \verb|\lipsum[4-57]| typesets the paragraphs 4 to @@ -187,7 +199,7 @@ % % \section{Foreword to Version 2.0}\label{sec:foreword2.0} % Version 2.0 of \pkg{lipsum} is a complete (well, nearly complete) rewrite -% of the code in \pkg{expl3} +% of the code in \pkg{expl3} % syntax. I have never used \pkg{expl3} before and thus the code might be too % complicated, might use wrong or badly chosen data types or weird function % names. I am happy to receive comments on this. @@ -198,7 +210,7 @@ % documents is not a big issue here. The changes are: % \begin{itemize} % \item The package option \opt{nopar} now uses a \cs{space} as terminator, -% instead of \cs{relax}. +% instead of \cs{relax}. % \item The commands \cs{UnpackLipsum} and \cs{UnpackLipsum*} are no longer % available. The effect of \cs{UnpackLipsum} now is default for % \cs{unpacklipsum} (or \cs{unpacklipsum*}, depending on the package @@ -213,8 +225,8 @@ % % \begin{document} % \renewcommand\foo{\color{.!75!red}} -% { \lipsumexp } -% +% { \lipsumexp } +% % \newcounter{mycnt}\setcounter{mycnt}{1} % \renewcommand\foo{% % (\themycnt)\stepcounter{mycnt}} @@ -232,15 +244,15 @@ % \section{Foreword to version 2.2} % As of version 2.2, \pkg{lipsum} provides a simple interface to define other % texts to be used as output of the \cs{lipsum}-family of commands. This was -% heavily inspired by an issue raised by +% heavily inspired by an issue raised by % \emph{svenper} on % github\footnote{\url{https://github.com/patta42/lipsum/issues/13}}. However, % the implementation of this interface might not match the needs of everyone % who wants to provide a dummy text in another language. Comments and -% suggestions on this are very welcome. +% suggestions on this are very welcome. +% +% Please note that the documentation still only refers to the \lips-text. % -% Please note that the documentation still only refers to the \lips-text. -% % \section{Usage} % \pkg{lipsum} was intended to quickly provide a way to fill a page or two to % analyze the page @@ -258,7 +270,7 @@ % \item[\opt{nopar}:] Instead of \cs{par}, \cs{space} is used to % separate the paragraphs. % \end{description} -% +% % \subsection{User Commands} % \DescribeMacro{\lipsum}\DescribeMacro{\lipsum*} % \begin{quote} @@ -276,7 +288,7 @@ % below). \cs{lipsum} terminates every paragraph depending on the package % option (using \cs{par} is the default). \cs{lipsum*} does the same, but % uses a different termination (default is to use a blank space) for each -% paragraph. \emph{As a simplified rule of thumb, \cs{lipsum} prints the +% paragraph. \emph{As a simplified rule of thumb, \cs{lipsum} prints the % paragraphs as multiple paragraphs, \cs{lipsum*} prints them as a single % paragraph}. % @@ -286,7 +298,7 @@ % |\lipsum*[9-12]|, which will output the paragraphs nine to % twelve. \pkg{lipsum} provides 150 paragraphs of \lips\, thus |150| is the % maximum that should be specified. -% +% % \subsection{Outputting Sentences instead of Paragraphs} % Starting with \pkg{lipsum} v2.0, \cs{lipsum} and \cs{lipsum*} allow to % output sentences of the \lips\ dummy text instead of paragraphs. To retrieve @@ -318,7 +330,7 @@ % sentences since paragraph \#104 consists only of 10 sentences. For the % same reason, |\lipsum[104][11-20]| will output nothing. % \item If you need a lot of sentences, consider the \opt{space} option and -% |\lipsum[1-150]|. This should be faster. +% |\lipsum[1-150]|. This should be faster. % \end{itemize} % % \section{Advanced or Developer Macros} @@ -333,7 +345,7 @@ % % \DescribeMacro{\SetLipsumDefault} In order to change the default range of % paragraphs that is used by \cs{lipsum} and friends, specify -% |\SetLipsumDefault{8}| or |\SetLipsumDefault{123-145}|. +% |\SetLipsumDefault{8}| or |\SetLipsumDefault{123-145}|. % % \DescribeMacro{\LipsumPar} To get a single paragraph of the \lips\ dummy % text, use |\LipsumPar{8}| (for the eighth paragraph). This is similar to @@ -397,8 +409,8 @@ % lists of sentences (also indicated by the labelled arrows in the middle). } % \label{fig:tokens} % \end{multicols} -% -% +% +% % \end{widefigure} % \DescribeMacro{\SetLipsumParListStart}\DescribeMacro{\SetLipsumParListStart*} % \DescribeMacro{\SetLipsumParListEnd}\DescribeMacro{\SetLipsumParListEnd*} @@ -407,13 +419,13 @@ % \pkg{lipsum} allows to specify all of the tokens in the list indicated % above except for the item-specific inner and outer \meta{items} (shown as % \meta{item_N_,_s-outer/inner}, \meta{item_N_,_e-outer/inner} above), which -% remain to be implemented. +% remain to be implemented. % % The macros that enable setting these tokens are all available in a normal -% and in a starred version, they apply to \cs{lipsum} and \cs{unpacklipsum} or -% \cs{lipsum*} and \cs{unpacklipsum*}, respectively. +% and in a starred version, they apply to \cs{lipsum} and \cs{unpacklipsum} or +% \cs{lipsum*} and \cs{unpacklipsum*}, respectively. +% % -% % The macro \cs{SetLipsumParListStart}\Arg{tokens} and its starred variant % insert \meta{tokens} at the very beginning of the list of paragraphs % (\meta{list_s} in Figure~\ref{fig:tokens}). \cs{SetLipsumSentenceListStart} @@ -451,12 +463,12 @@ % commands that allow to set a pair of \meta{tokens} to surround every item: % \begin{macrolist} % \item \cs{SetLipsumParListItemSurrounders}\Arg{start}\Arg{end}\DescribeMacro{\SetLipsumParListItemSurrounders} -% \item \cs{SetLipsumParListItemSurrounders*}\Arg{start}\Arg{end}\DescribeMacro{\SetLipsumParListItemSurrounders*} +% \item \cs{SetLipsumParListItemSurrounders*}\Arg{start}\Arg{end}\DescribeMacro{\SetLipsumParListItemSurrounders*} % \item \cs{SetLipsumSentenceListItemSurrounders}\Arg{start}\Arg{end}\DescribeMacro{\SetLipsumSentenceListItemSurrounders} % \item \DescribeMacro{\SetLipsumSentenceListItemSurrounders*} \cs{SetLipsumSentenceListItemSurrounders*}\Arg{start}\Arg{end} -% +% % \end{macrolist} -% +% % \DescribeMacro{\SetLipsumParListItemSeparator} % \DescribeMacro{\SetLipsumParListItemSeparator*} % \DescribeMacro{\SetLipsumSentenceListItemSeparator} @@ -478,7 +490,7 @@ % \begin{widefigure} % \begin{exploutputbox} % \begin{verbatim} -% +% % \SetLipsumSentenceListSurrounders{\begin{itemize}}{\end{itemize}} % \SetLipsumSentenceListItemStart{\item} % \lipsum[10][1-2] @@ -503,7 +515,7 @@ % \cs{LipsumRestoreParList} (for lists of paragraphs), % \DescribeMacro{\LipsumRestoreSentenceList} \cs{LipsumRestoreSentenceList} (for lists of % sentences) and \DescribeMacro{\LipsumRestoreAll} \cs{LipsumRestoreAll} for -% both lists. +% both lists. % \begin{widefigure} % \begin{exploutputbox} % \begin{verbatim} @@ -572,7 +584,7 @@ % \mdfsubtitle{Output} % \lipsum[1][1] % \MakePercentComment\SetLipsumText{cicero}\MakePercentIgnore -% \selectlanguage{latin} +% \selectlanguage{latin} % \hspace*{1em}\lipsum[1] % \end{exploutputbox} % \MakePercentComment\SetLipsumText{lipsum}\MakePercentIgnore @@ -607,7 +619,7 @@ % \begin{verbatim} % \ProvidesPackage{mydummytext} % \RequirePackage{lipsum} -% \SetLipsumText{mydummytext} +% \SetLipsumText{mydummytext} % \end{verbatim} % To make the text accesible via a command \cs{mydummytext}, simply use % \cs{let} to copy the definition of \cs{lipsum}: @@ -655,36 +667,25 @@ % can either be a range as specified above, or a token list containing a % range. Thus, the argument has to be expanded before it is analyzed. This use % case is not available in \pkg{xparse} (at least not in the release -% 2018-10-17). Thus, we have to touch \pkg{xparse}'s internal and generate -% such a variant. We copy it to a \pkg{lipsum} internal variant to avoid name -% clashes with future versions of \pkg{xparse}. -% \begin{function}{\__lipsum_split_argument_expanded:nne -% ,\__xparse_split_argument:nne} +% 2018-10-17). We copy it to a \pkg{lipsum} internal variant to be able to +% generate a variant. +% \begin{function}{\@@_split_argument_expanded:nnn +% ,\@@_split_argument_expanded:nne} % \begin{syntax} -% \cs{__lipsum_split_argument_expanded:nne}\Arg{number}\Arg{token}\Arg{argument} +% \cs{@@_split_argument_expanded:nne}\Arg{number}\Arg{token}\Arg{argument} % \end{syntax} % \begin{arguments} % \item See documentation for \cs{SplitArgument} in % \pkg{xparse} -% \item See documentation for \cs{SplitArgument} in -% \pkg{xparse} % \item The argument fed to the function, which is expanded -% in this case +% in this case. % \end{arguments} % \begin{macrocode} -\cs_generate_variant:Nn \__xparse_split_argument:nnn {nne} -\cs_new_eq:NN - \__lipsum_split_argument_expanded:nne - \__xparse_split_argument:nne +\cs_new_eq:NN \@@_split_argument_expanded:nnn \SplitArgument +\cs_generate_variant:Nn \@@_split_argument_expanded:nnn { nne } % \end{macrocode} % \end{function} -% \begin{function}{str_if_eq:VnTF} -% Allows to compare a string value and a string: -% \begin{macrocode} -\cs_generate_variant:Nn \str_if_eq:nnTF {VnTF} -% \end{macrocode} -% \end{function} -% +% % \subsection{Messages} % Starting from \pkg{lipsum}2.0, some commands from previous versions are % considered deprecated and issue a warning when used. This is the @@ -699,48 +700,48 @@ \string#1~might~not~be~available~in~a~ future~version~of~lipsum.sty.} % \end{macrocode} -% +% % \subsection{Variables} -% \begin{variable}{\g_lipsum_paragraph_seq} +% \begin{variable}{\g_@@_paragraph_seq} % The sequence that stores all the paragraphs. % \begin{macrocode} -\seq_new:N\g_lipsum_paragraph_seq +\seq_new:N\g_@@_paragraph_seq % \end{macrocode} % \end{variable} % \begin{variable}{\g_lipsum_default_range_tl} % The default range for lipsum paragraphs. % \begin{macrocode} -\tl_new:N \g_lipsum_default_range_tl % +\tl_new:N \g_lipsum_default_range_tl % % \end{macrocode} % \end{variable} -% \begin{variable}{\l__lipsum_pars_tl} +% \begin{variable}{\l_@@_pars_tl} % This variables is used to store the token list containing the selected paragraphs. % \begin{macrocode} -\tl_new:N \l__lipsum_pars_tl +\tl_new:N \l_@@_pars_tl % \end{macrocode} % \end{variable} -% \begin{variable}{\l__lipsum_sentences_tl} +% \begin{variable}{\l_@@_sentences_tl} % This variables is used to store the token list containing the selected sentences. % \begin{macrocode} -\tl_new:N \l__lipsum_sentences_tl +\tl_new:N \l_@@_sentences_tl % \end{macrocode} % \end{variable} -% \begin{variable}{ -% \l__lipsum_sentences_seq +% \begin{variable}{ +% \l_@@_sentences_seq % } -% In this sequence, the sentence list is stored. +% In this sequence, the sentence list is stored. % \begin{macrocode} -\seq_new:N \l__lipsum_sentences_seq +\seq_new:N \l_@@_sentences_seq % \end{macrocode} % \end{variable} % \begin{variable}{\l_@@_par_list_start_nostar_tl, % \l_@@_par_list_end_nostar_tl, \l_@@_sentence_list_start_nostar_tl, % \l_@@_sentence_list_end_nostar_tl, \l_@@_par_list_start_star_tl, % \l_@@_par_list_end_star_tl, \l_@@_sentence_star_list_start_tl, -% \l_@@_sentence_star_list_end_tl} +% \l_@@_sentence_star_list_end_tl} % Next are the variables used to store the tokens between the list items for -% lists of paragraph and lists of sentences. -% +% lists of paragraph and lists of sentences. +% % \begin{macrocode} \tl_new:N \l_@@_par_list_start_nostar_tl \tl_new:N \l_@@_par_list_end_nostar_tl @@ -772,7 +773,7 @@ % \l_@@_par_list_itemend_nostar_tl, \l_@@_sentence_list_itemstart_nostar_tl, % \l_@@_sentence_list_itemend_nostar_tl, \l_@@_par_list_itemstart_star_tl, % \l_@@_par_list_itemend_star_tl, \l_@@_sentence_list_itemstart_star_tl, -% \l_@@_sentence_list_itemend_star_tl} +% \l_@@_sentence_list_itemend_star_tl} % The variables that surround each single item of a paragraph or sentence list. % \begin{macrocode} \tl_new:N \l_@@_par_list_itemstart_nostar_tl @@ -787,7 +788,7 @@ % \end{macrocode} % \end{variable} -% \begin{variable}{\l_@@_par_list_start_tl, +% \begin{variable}{\l_@@_par_list_start_tl, % \l_@@_par_list_end_tl, % \l_@@_sentence_list_start_tl, % \l_@@_sentence_list_end_tl, @@ -813,7 +814,7 @@ \tl_new:N\l_@@_sentence_list_itemstart_tl \tl_new:N\l_@@_sentence_list_itemend_tl % \end{macrocode} -% +% % \end{variable} % \begin{variable}{\g_@@_text_str} % Holds the current text loaded for the output of \cs{lipsum} and @@ -822,7 +823,7 @@ \str_new:N\g_@@_text_str % \end{macrocode} % \end{variable} -% +% % \subsection{Developer interface} % \begin{function}{\lipsum_store_as_temp_ints:nn} % \begin{syntax} @@ -853,7 +854,7 @@ % \lipsum_get_terminated_par:n} % These two commands are used to retrieve paragraph \meta{number} from the % \lips\ dummy text. \cs{lipsum_get_terminated_par:n} additionally adds -% \cs{par}. +% \cs{par}. % % \begin{syntax} % \cs{lipsum_get_non_terminated_par:n} \Arg{number}\\ @@ -865,33 +866,33 @@ % paragraphs were stored in \cs{lipsum@i}, \cs{lipsum@ii}, \ldots. % \begin{macrocode} \cs_new:Npn \lipsum_get_non_terminated_par:n #1{ - \seq_item:Nn \g_lipsum_paragraph_seq{#1} + \seq_item:Nn \g_@@_paragraph_seq{#1} } \cs_new:Npn \lipsum_get_terminated_par:n #1 { \lipsum_get_non_terminated_par:n{#1}\par } - + % \end{macrocode} % \end{function} % \begin{function}{\lipsum_add_to_tokenlist:n} % Adds a paragraph \meta{item} to the list of paragraphs % (\cs{l_@@_pars_tl}) and surrounds it by % the user-defined \meta{tokens} -% . +% . % \begin{syntax} % \cs{lipsum_add_to_tokenlist:n}\Arg{number} % \end{syntax} % \begin{macrocode} \cs_new:Npn \lipsum_add_to_tokenlist:n #1 { \tl_put_right:NV - \l__lipsum_pars_tl - \l_@@_par_list_itemstart_tl - \tl_put_right:Nn \l__lipsum_pars_tl { + \l_@@_pars_tl + \l_@@_par_list_itemstart_tl + \tl_put_right:Nn \l_@@_pars_tl { \lipsum_get_non_terminated_par:n{#1} } \tl_put_right:NV - \l__lipsum_pars_tl + \l_@@_pars_tl \l_@@_par_list_itemend_tl } \cs_generate_variant:Nn @@ -903,7 +904,7 @@ % \cs{lipsum_range_to_tokenlist:VV}\Arg{number_1}\Arg{number_2} % \end{syntax} % Adds the paragraphs specified by \meta{number_1} to \meta{number_2} -% to the token list \cs{l_@@_pars_tl}. +% to the token list \cs{l_@@_pars_tl}. % \begin{macrocode} \cs_new:Npn \lipsum_range_to_tokenlist:nn #1#2 { \tl_clear:N \l_@@_pars_tl @@ -921,7 +922,7 @@ \l_@@_pars_tl \l_@@_par_list_itemseparator_tl } - \lipsum_add_to_tokenlist:V {\l_tmpa_int} + \lipsum_add_to_tokenlist:V {\l_tmpa_int} \int_incr:N\l_tmpa_int } \tl_put_right:NV @@ -929,8 +930,8 @@ \l_@@_par_list_end_tl } \cs_generate_variant:Nn - \lipsum_range_to_tokenlist:nn { VV } -% + \lipsum_range_to_tokenlist:nn { VV } +% % \end{macrocode} % \end{function} % \begin{function}{\@@_expanded_paragraphs_terminated_with_space:} @@ -947,9 +948,9 @@ % \end{syntax} % Puts the sentences specified by \meta{sentence range} from the paragraphs % specified by \meta{paragraph range} on the token list -% \cs{l_@@_sentences_tl} and surrounds the \meta{tokens} set by the user. +% \cs{l_@@_sentences_tl} and surrounds the \meta{tokens} set by the user. % \begin{macrocode} -% +% \cs_new:Npn \lipsum_sentences_to_tokenlist:nnn #1#2#3{ % \end{macrocode} % Now, we only need to put the sentences within \meta{sentence range} into @@ -957,8 +958,8 @@ % the token list. % \begin{macrocode} - \tl_clear:N \l__lipsum_sentences_tl - + \tl_clear:N \l_@@_sentences_tl + % \end{macrocode} % Using a regexp turned out to be rather slow for large \meta{paragraph % range}s. Thus, I use a loop similar to the one used by @@ -969,7 +970,7 @@ % \begin{macrocode} \int_compare:nT {#2 >= #1} { - \__lipsum_put_sentence_on_tokenlist:nnnw + \@@_put_sentence_on_tokenlist:nnnw {#1} {#2} {1} @@ -1024,8 +1025,8 @@ \use_none_delimit_by_q_stop:w } { % Not yet list end - \int_compare:nNnTF{#3} > {#2} - { % Counter > End: Leave loop + \int_compare:nNnTF{#3} > {#2} + { % Counter > End: Leave loop \use_none_delimit_by_q_stop:w } { % Counter <= End: Proceed @@ -1037,7 +1038,7 @@ \l_@@_sentences_tl \l_@@_sentence_list_itemseparator_tl } % End Counter < Start true - % Put item on list + % Put item on list \tl_put_right:NV \l_@@_sentences_tl \l_@@_sentence_list_itemstart_tl @@ -1048,7 +1049,7 @@ \l_@@_sentences_tl \l_@@_sentence_list_itemend_tl } % End Counter >= Start: Put item on list - % Call loop again + % Call loop again \exp_args:Nnnf \@@_put_sentence_on_tokenlist:nnnw {#1} @@ -1116,7 +1117,7 @@ % \begin{syntax} % \cs{@@_set_surrounding_tokens_nostar:} % \end{syntax} -% +% % As \cs{@@_set_surrounding_tokens_star:}, but for calls of the non-starred % version of \cs{lipsum} and \cs{unpacklipsum}. % \begin{macrocode} @@ -1177,14 +1178,14 @@ \l_@@_par_list_start_tl{} \tl_set:No \l_@@_par_list_end_tl{} - } + } % \end{macrocode} % \end{function} % \subsection{User- and developer-level commands}\label{sec:code:commands} % \begin{macro}{\NewLipsumPar} % Developer-Level macro to add a paragraph to the dummy text used by % \cs{lipsum} and related commands. To specify a new dummy text, see -% section~\ref{sec:other-texts}. +% section~\ref{sec:other-texts}. % \begin{syntax} % \cs{NewLipsumPar}\Arg{content} % \end{syntax} @@ -1197,7 +1198,7 @@ % \begin{macrocode} \NewDocumentCommand\NewLipsumPar{m}{ - \seq_gput_right:Nn{\g_lipsum_paragraph_seq}{#1} + \seq_gput_right:Nn{\g_@@_paragraph_seq}{#1} } % \end{macrocode} % \end{macro} @@ -1231,7 +1232,7 @@ % % \begin{arguments} % \item \meta{tokens} to be inserted at the beginning of the -% paragraph or sentence list. +% paragraph or sentence list. % \end{arguments} % % \begin{macrocode} @@ -1285,7 +1286,7 @@ \tl_set:No\l_@@_sentence_list_end_star_tl{#2} } { - \tl_set:No\l_@@_sentence_list_end_nostar_tl{#2} + \tl_set:No\l_@@_sentence_list_end_nostar_tl{#2} } } % \end{macrocode} @@ -1407,11 +1408,11 @@ \l_@@_sentence_list_itemend_nostar_tl{#2} } } -% \end{macrocode} +% \end{macrocode} % \end{macro} % \begin{macro}{\SetLipsumParListItemSurrounders, % \SetLipsumParListItemSurrounders*, \SetLipsumSentenceListItemSurrounders, -% \SetLipsumSentenceListItemSurrounders*} +% \SetLipsumSentenceListItemSurrounders*} % Short-hands for setting the \meta{token}s surrounding a single list \meta{item}. % \begin{syntax} % \cs{SetLipsumParListItemSurrounders}\Arg{start}\Arg{end}\\ @@ -1459,12 +1460,12 @@ % \end{syntax} % \begin{arguments} % \item \meta{tokens} to be inserted between two \meta{item}s of a paragraph -% or sentence list. +% or sentence list. % \end{arguments} % \begin{macrocode} \NewDocumentCommand\SetLipsumParListItemSeparator{s+m}{ \IfBooleanTF{#1} - { + { \tl_set:No \l_@@_par_list_itemseparator_star_tl{#2} } @@ -1485,7 +1486,7 @@ } } % \end{macrocode} -% +% % \end{macro} % \begin{macro}{\SetLipsumProtect} % \begin{syntax} @@ -1504,7 +1505,7 @@ % \begin{macro}{\SetLipsumDefault, \setlipsumdefault} % Command to change the default range used by \cs{lipsum} and friends. Note % that the use of \cs{setlipsumdefault} is considered deprecated starting from -% \pkg{lipsum}2.0. +% \pkg{lipsum}2.0. % \begin{syntax} % \cs{SetLipsumDefault}\Arg{range} % \end{syntax} @@ -1530,7 +1531,7 @@ % \end{macrocode} % \end{macro} % The following macros are considered to be user-level commands and thus all -% lower-case. +% lower-case. % \begin{macro}{\lipsum, \lipsum*} % \begin{syntax} % \cs{lipsum}\oarg{paragraph range}\oarg{sentence range} @@ -1575,7 +1576,7 @@ { \lipsum_range_to_tokenlist:VV { \l_tmpa_int }{ \l_tmpb_int } - \tl_use:N \l__lipsum_pars_tl + \tl_use:N \l_@@_pars_tl } { \@@_ensure_parsable_output: @@ -1584,12 +1585,12 @@ \lipsum_store_as_temp_ints:nn #3 \cs_gset_nopar:Nx \@@_expanded_paragraphs_terminated_with_space: - {\tl_use:N\l__lipsum_pars_tl} + {\tl_use:N\l_@@_pars_tl} \lipsum_sentences_to_tokenlist:VVf { \l_tmpa_int } { \l_tmpb_int } - \__lipsum_expanded_paragraphs_terminated_with_space: - \tl_use:N \l__lipsum_sentences_tl + \@@_expanded_paragraphs_terminated_with_space: + \tl_use:N \l_@@_sentences_tl } \group_end: } @@ -1597,13 +1598,13 @@ % \end{macro} % \begin{macro}{\lipsumexp} % The following macros store their results in the macro \cs{lipsumexp}. I -% create it first using \pkg{xparss} before it is overwritten. Don't know if +% create it first using \pkg{xparse} before it is overwritten. Don't know if % this makes sense. % \begin{macrocode} \NewDocumentCommand\lipsumexp{}{} % \end{macrocode} % \end{macro} -% +% % \begin{macro}{\unpacklipsum, \unpacklipsum*} % These two commands do the same as \cs{lipsum} and \cs{lipsum*}, but instead % of typesetting the paragraphs or sentences, they store the expanded content @@ -1611,7 +1612,7 @@ % \opt{space} or by using the \cs{SetLipsum...List} commands, the % corresponding \meta{tokens} between the single items of the list are % expandable, they are expanded. If they arenot expandable, they are---of -% course---not. +% course---not. % \begin{syntax} % \cs{unpacklipsum}\oarg{paragraph range}\oarg{sentence range}\\ % \cs{unpacklipsum*}\oarg{paragraph range}\oarg{sentence range}\\ @@ -1619,18 +1620,18 @@ % \cs{lipsumexp} % \end{syntax} % \begin{macrocode} -\cs_new:Nn \__lipsum_expanded: {} +\cs_new:Nn \@@_expanded: {} \NewDocumentCommand \unpacklipsum { s - >{\__lipsum_split_argument_expanded:nne{1}{-}} + >{\@@_split_argument_expanded:nne{1}{-}} O{\g_lipsum_default_range_tl} - >{\__lipsum_split_argument_expanded:nne{1}{-}} + >{\@@_split_argument_expanded:nne{1}{-}} o } { - + \group_begin: \lipsum_store_as_temp_ints:nn #2 \IfBooleanTF {#1} @@ -1645,9 +1646,9 @@ \lipsum_range_to_tokenlist:VV { \l_tmpa_int } { \l_tmpb_int } \cs_gset:Nx - \__lipsum_expanded: {\tl_use:N\l__lipsum_pars_tl} + \@@_expanded: {\tl_use:N\l_@@_pars_tl} \cs_gset_eq:NN - \lipsumexp \__lipsum_expanded: + \lipsumexp \@@_expanded: } { \@@_ensure_parsable_output: @@ -1655,7 +1656,7 @@ { \l_tmpa_int } { \l_tmpb_int } \cs_gset_nopar:Nx \@@_expanded_paragraphs_terminated_with_space: - { \tl_use:N\l__lipsum_pars_tl } + { \tl_use:N\l_@@_pars_tl } \lipsum_store_as_temp_ints:nn #3 \lipsum_sentences_to_tokenlist:VVf { \l_tmpa_int } @@ -1663,11 +1664,11 @@ \@@_expanded_paragraphs_terminated_with_space: \cs_gset:Nx \@@_expanded: - { \tl_use:N\l__lipsum_sentences_tl } + { \tl_use:N\l_@@_sentences_tl } \cs_gset_eq:NN - \lipsumexp \__lipsum_expanded: + \lipsumexp \@@_expanded: } - \group_end: + \group_end: } % \end{macrocode} % \end{macro} @@ -1692,19 +1693,19 @@ % Used to select and load the text output by \cs{lipsum} and friends. See the % section on loading and defining new outputs for \cs{lipsum} % (section~\ref{sec:other-texts}). It first checks whether the requested text -% is already loaded, and if not, it clears \cs{g_lipsum_paragraph_seq} and +% is already loaded, and if not, it clears \cs{g_@@_paragraph_seq} and % loads the corresponding lipsum text definition file. % \begin{macrocode} \NewDocumentCommand\SetLipsumText{m}{% \IfLipsumText{#1}{}{ - \seq_clear:N\g_lipsum_paragraph_seq + \seq_gclear:N\g_@@_paragraph_seq \file_input:n{#1.ltd} - \str_set:Nn\g_lipsum_text_str{#1} + \str_gset:Nn\g_@@_text_str{#1} } } % \end{macrocode} -% +% % \end{macro} % \subsection{Package options and defaults} % \begin{macrocode} @@ -3451,14 +3452,14 @@ % \newpage % \subsection{The text of Cicero's speech} % \begin{macrocode} -%<*cicero> +%<*cicero> % \end{macrocode} % \begin{macrocode} %% %% This text was provided by github-user %% svenper. See https://github.com/patta42/lipsum/issues/13 -%% +%% \NewLipsumPar{Non eram nescius, Brute, cum, quae summis ingeniis exquisitaque doctrina philosophi Graeco sermone tractavissent, ea Latinis litteris diff --git a/macros/latex/contrib/lipsum/lipsum.ins b/macros/latex/contrib/lipsum/lipsum.ins index 7ffaf5e5bf..a2c3bc6519 100644 --- a/macros/latex/contrib/lipsum/lipsum.ins +++ b/macros/latex/contrib/lipsum/lipsum.ins @@ -1,18 +1,20 @@ -%% -%% Copyright (C) 2018 by Patrick Happel -%% -%% This file may be distributed and/or modified under the -%% conditions of the LaTeX Project Public License, either -%% version 1.3 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.3 or later is part of all distributions of +%% +%% Copyright (C) 2014-2019 by Patrick Happel +%% Copyright (C) 2021 by Phelype Oleinik +%% +%% This file may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either +%% version 1.3 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.3 or later is part of all distributions of %% LaTeX version 2005/12/01 or later. %% \input l3docstrip.tex \askforoverwritefalse +\keepsilent \preamble This file is part of the package lipsum for use with LaTeX2e. @@ -27,11 +29,8 @@ The latest version of this license is in and version 1.3 or later is part of all distributions of LaTeX version 2005/12/01 or later. -Please send error reports and suggestions for improvements to - Patrick Happel <patrick.happel@rub.de> - -Alternatively, use github: - https://github.com/patta42/lipsum +Please send error reports and suggestions for improvements to + https://github.com/PhelypeOleinik/lipsum \endpreamble \postamble @@ -42,21 +41,21 @@ Alternatively, use github: \generate{\file{cicero.ltd.tex}{\from{lipsum.dtx}{cicero}}} \obeyspaces -\Msg{****************************************************} -\Msg{* *} -\Msg{* To finish the installation you have to move the *} +\Msg{****************************************************} +\Msg{* *} +\Msg{* To finish the installation you have to move the *} \Msg{* following files into a directory searched *} -\Msg{* by TeX: } -\Msg{* *} +\Msg{* by TeX: *} +\Msg{* *} \Msg{* lipsum.sty *} \Msg{* lipsum.ltd.tex *} -\Msg{* cicero.ltd.tex *} -\Msg{* *} -\Msg{* To produce the documentation run the file *} -\Msg{* lipsum.dtx through XeLaTeX or luaLaTeX. *} -\Msg{* *} -\Msg{* Happy TeXing! *} -\Msg{* *} +\Msg{* cicero.ltd.tex *} +\Msg{* *} +\Msg{* To produce the documentation run the file *} +\Msg{* lipsum.dtx through XeLaTeX or luaLaTeX. *} +\Msg{* *} +\Msg{* Happy TeXing! *} +\Msg{* *} \Msg{****************************************************} \endbatchfile diff --git a/macros/latex/contrib/lipsum/lipsum.pdf b/macros/latex/contrib/lipsum/lipsum.pdf Binary files differindex adb7b3c1e8..df4fe78450 100644 --- a/macros/latex/contrib/lipsum/lipsum.pdf +++ b/macros/latex/contrib/lipsum/lipsum.pdf diff --git a/macros/luatex/latex/lua-typo/README.md b/macros/luatex/latex/lua-typo/README.md new file mode 100644 index 0000000000..29db098d3b --- /dev/null +++ b/macros/luatex/latex/lua-typo/README.md @@ -0,0 +1,55 @@ +Lua-typo +======== + +Description +----------- +This package tracks common typographic flaws in LuaLaTeX documents, +specially widows, orphans, hyphenated words split over two pages, +consecutive lines ending with hyphens, paragraphs ending on +too short lines, etc. + +Documentation +------------- + +For the impatient: have a look at files demo.tex and demo.pdf to see +a short example of how some flaws are highlighted. + +Then read the documentation in English (file lua-typo.pdf) or in French +(file lua-typo-fr.pdf). + +License +------- + +Released under the LaTeX Project Public License v1.3 or later +See http://www.latex-project.org/lppl.txt +for the details of that license. + +Installation +------------ + +This bundle is meant to be included in most TeX distributions, +but if you need to install it by yourself +1. run "luatex lua-typo.dtx" to strip the comments and create + lua-typo.sty, lua-typo.cfg, lua-typo.ltx and lua-typo-fr.ltx; +2. run "lualatex lua-typo.ltx" to get the full documentation + (lua-typo.pdf) in English; +2. run "lualatex lua-typo-fr.ltx" to get the French documentation + (lua-typo-fr.pdf, code not included). + +Recommended loactions for installation: +- TDS:tex/lualatex/lua-typo/lua-typo.sty +- TDS:tex/lualatex/lua-typo/lua-typo.cfg +- TDS:doc/lualatex/lua-typo/lua-typo.pdf +- TDS:doc/lualatex/lua-typo/demo.pdf +- TDS:doc/lualatex/lua-typo/demo.tex +- TDS:doc/lualatex/lua-typo/README.md +- TDS:source/lualatex/lua-typo/lua-typo.dtx + +Changes +------- + +- First release version: 0.30, March 2021. + +-- +Copyright 2020--2021 Daniel Flipo +E-mail: daniel (dot) flipo (at) free (dot) fr diff --git a/macros/luatex/latex/lua-typo/doc/demo.pdf b/macros/luatex/latex/lua-typo/doc/demo.pdf Binary files differnew file mode 100644 index 0000000000..d7e17c1ab1 --- /dev/null +++ b/macros/luatex/latex/lua-typo/doc/demo.pdf diff --git a/macros/luatex/latex/lua-typo/doc/demo.tex b/macros/luatex/latex/lua-typo/doc/demo.tex new file mode 100644 index 0000000000..e09c822e1d --- /dev/null +++ b/macros/luatex/latex/lua-typo/doc/demo.tex @@ -0,0 +1,89 @@ +\documentclass[a6paper,french,11pt,twoside]{scrartcl} +\usepackage{scrlayer-scrpage} +\lohead{Pierre Desproges} +\lehead{Vivons heureux…} +\rohead{} +\rehead{en attendant la mort} +\usepackage{fourier-otf} +\usepackage{microtype} + +\usepackage{babel} +\frenchsetup{og=«, fg=»} + +\usepackage[All]{lua-typo} % APRÈS babel / polyglossia + +% Mots courts (deux lettres max) à éviter en fin de ligne +\luatypoOneChar{french}{'À à Ô'} +\luatypoTwoChars{french}{"Je Tu Il On"} + +% Pour changer les couleurs : +%\usepackage[svgnames]{xcolor} +%\LuaTypoSetColor1{Fuchsia} +%\LuaTypoSetColor2{ForestGreen} +%\LuaTypoSetColor5{magenta} +%\LuaTypoSetColor6{yellow} + +% Réglage ligne finale trop courte +\setlength{\luatypoLLminWD}{3em} + +%\luatypoPageMin=5 +%\luatypoHyphMax=2 + +\parindent=1em + +\begin{document} + +Le plus effroyablement démuni des pauvres peut toujours espérer +\footnote{Overfull hbox à la ligne précédente.} +décrocher un jour le gros lot de la tombola organisée par +l’association des Pauvres Effroyablement Démunis. +% +Le laideron lui, n’a d’autre échappatoire que de +ronger son frein d’un bec-de-lièvre machinal, de baisser ses yeux quelconques +aux abords des mirroirs qui l’insultent ou de se foutre à l’eau au risque +d’effaroucher les murènes. + +Quelquefois je trouve que Dieu pousse un peu. + +« Les hommes naissent libres et égaux en droit. » + +Qu’on me pardonne mais c’est un phrase que j’ai beaucoup de mal à dire sans +rire. % : « Les hommes naissent libres et égaux en droit. » + +Prenons une star, une belle star. Elle est belle. + +La beauté. Existe-t-il au monde un privilège plus exorbitant que la beauté ? + +Par sa beauté, cette femme n’est-elle pas un peu plus libre +et un peu plus égale , dans le grand combat pour survivre, +que l’\textit{Homo sapiens} moyen qui passe sa vie à se courir +après la queue en attendant la mort ? + +Quel profond imbécile aurait l’outrecuidance de soutenir, au nom des grands +principes révolutionnaires, que l’immonde boudin trapu qui m’a +%collé une contredanse +lâchement verbalisé +tout-à-l’heure +possède les mêmes armes +%pour assoir son bonheur terrestre +que la grande fille féline aux charmes troubles où l’œil se +pose et chancelle avec une lubricité contenue ! +%(Difficilement contenue.) % Variantes pour mettre 1 ou 2 car. en bout de ligne +%(Difficilement contenue hein). Je dois le dire. +%(Difficilement contenue hein). On peut le dire. +%(Difficilement contenue hein). Il faut l’admettre. +(Difficilement contenue hein). À voir. + +Quand on a vos yeux, madame, quand on a votre bouche, votre grain de peau, la +légèreté diaphane de votre démarche et la longueur émouvante de vos cuisses, +c’est une banalité de dire qu’on peut facilement traverser la vie %l’existence +à l’abri des cabats trop lourds gorgés de poireaux, à l’écart de l’uniforme de +contractuelle. + +\end{document} + +%%% Local Variables: +%%% coding: utf-8-unix +%%% TeX-master: t +%%% TeX-engine: luatex +%%% End: diff --git a/macros/luatex/latex/lua-typo/doc/lua-typo-fr.pdf b/macros/luatex/latex/lua-typo/doc/lua-typo-fr.pdf Binary files differnew file mode 100644 index 0000000000..273649ff71 --- /dev/null +++ b/macros/luatex/latex/lua-typo/doc/lua-typo-fr.pdf diff --git a/macros/luatex/latex/lua-typo/doc/lua-typo.pdf b/macros/luatex/latex/lua-typo/doc/lua-typo.pdf Binary files differnew file mode 100644 index 0000000000..16a7f744c6 --- /dev/null +++ b/macros/luatex/latex/lua-typo/doc/lua-typo.pdf diff --git a/macros/luatex/latex/lua-typo/source/lua-typo.dtx b/macros/luatex/latex/lua-typo/source/lua-typo.dtx new file mode 100644 index 0000000000..d1a4b0068a --- /dev/null +++ b/macros/luatex/latex/lua-typo/source/lua-typo.dtx @@ -0,0 +1,1942 @@ +% \CheckSum{337} +% +% \iffalse meta-comment +% +% Copyright © 2020-2021 Daniel Flipo. +% +% This program can be distributed and/or modified under the terms +% 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. +% +% This file has the LPPL maintenance status "maintained". +% +% Lua-Typo package for LaTeX version 2e +% +% Copyright © 2020-2021 by Daniel Flipo +% +% Please report errors to: daniel (dot) flipo (at) free (dot) fr +% +%<*batch> +%<*gobble> +\ifx\jobname\relax\let\documentclass\undefined\fi +\ifx\documentclass\undefined +\csname fi\endcsname +%</gobble> +\input docstrip.tex +\keepsilent +\let\MetaPrefix\relax +\preamble +\endpreamble +\postamble +\endpostamble +\let\MetaPrefix\DoubleperCent +\generate{% + \file{lua-typo.sty}{\from{lua-typo.dtx}{sty}}% {sty,msg,dbg} + \nopreamble + \file{lua-typo.cfg}{\from{lua-typo.dtx}{cfg}}% + \file{lua-typo-fr.ltx}{\from{lua-typo.dtx}{driver,docfr}}% + \file{lua-typo.ltx}{\from{lua-typo.dtx}{driver,doc}}% +} +\endbatchfile +%</batch> +%<*gobble> +\fi +\expandafter\ifx\csname @currname\endcsname\empty +\csname fi\endcsname +%</gobble> +%<*driver> +\documentclass[a4paper]{ltxdoc} +\usepackage[dvipsnames]{xcolor} +\usepackage{fontspec} +\setmainfont{erewhon} +\setsansfont{Cabin}[Scale=MatchLowercase] +\setmonofont{VeraMono.ttf}[ + ItalicFont = VeraMoIt.ttf, + BoldFont = VeraMoBd.ttf, + BoldItalicFont = VeraMoBI.ttf, + Scale = MatchLowercase, + HyphenChar=None, Color=Sepia, + ] +\usepackage[expansion=true, protrusion=true]{microtype} +%<-docfr>\usepackage[british]{babel} +%<-doc>\usepackage[french]{babel} +%<-doc>\frenchsetup{og=«, fg=»} +\usepackage[ShortPages, OverfullLines, UnderfullLines, + Widows, Orphans, EOPHyphens, RepeatedHyphens + ]{lua-typo} +\luatypoLLminWD=3em +\renewcommand*\descriptionlabel[1]{% + \hspace{\labelsep}\texttt{#1}} +\usepackage{array,url,verbatim} +\usepackage[numbered]{hypdoc} +\hypersetup{colorlinks,urlcolor=blue,unicode} +% +%<-doc>\OnlyDescription +%<-doc>\let\FrenchDoc\begingroup\let\endFrenchDoc\endgroup +% +%<-docfr>\let\FrenchDoc\comment\let\endFrenchDoc\endcomment +%<-docfr|doc>\RecordChanges +%<-docfr|doc>\AtEndDocument{% +%<-docfr|doc> \clearpage +%<-docfr|doc> \section{Change History}% +%<-docfr|doc> \GlossaryPrologue{}% +%<-docfr|doc> Changes are listed in reverse order (latest first) from version~0.1 +%<-docfr|doc> \PrintChanges +%<-docfr|doc>} +% +\newcommand*\file[1]{\texttt{#1}} +\newcommand*\pkg[1]{\texttt{#1}} +\newcommand*\opt[1]{\texttt{#1}} +\renewcommand\meta[1]{\texttt{\textsl{\color{Sepia}<#1>}}} +% +\setlength{\parindent}{0pt} +\setlength{\parskip}{.3\baselineskip plus 0.3pt minus 0.3pt} +\begin{document} +\GetFileInfo{lua-typo.sty} +\DocInput{lua-typo.dtx} +\end{document} + +%%% Local Variables: +%%% coding: utf-8 +%%% TeX-engine: luatex +%%% End: +%</driver> +%<*gobble> +\fi +%</gobble> +% \fi +% +% \begin{FrenchDoc} +% \begin{center} +% \textbf{\Large Recherche d’imperfections typographiques\\[3pt] +% avec LuaLaTeX} +% \\[.5\baselineskip]^^A\] +% {\large Daniel Flipo}\\ +% \texttt{daniel.flipo@free.fr} +% \end{center} +% +% \section{De quoi s’agit-il ?} +% +% L’extension \pkg{lua-typo} décrite ci-dessous% +% \footnote{Version \fileversion, mise à jour le \filedate.} +% permet de mettre en lumière par un changement de couleur, les +% lignes typographiquement imparfaites d'un fichier PDF produit par +% LuaLaTex. Une liste des pages concernées est affichée à la fin du +% fichier \file{.log}, permettant un accès rapide aux pages +% potentiellement défectueuses. +% +% Normalement, c’est-à-dire lorsque la justification n’est pas trop +% étroite, (Lua)TeX fait du bon travail, mais il peut rester des +% points à vérifier, notamment des lignes trop pleines ou lavées +% (\emph{Overfull, Underfull box}), des veuves et des orphelines, +% des mots coupés en fin de page ou d’alinéa ou sur plusieurs +% lignes consécutives, des dernières lignes d’alinéa trop courtes ou +% presque pleines, des pages quasi vides. +% La répétition d’un même mot ou partie de mot au début ou à la fin +% de deux lignes consécutives est détectée. +% La présence en fin de ligne de certains mots très courts (une ou +% deux lettres, liste dépendant de la langue) peut également être +% recherchée. +% +% \pkg{lua-typo}, ne fonctionne qu’avec LuaLaTeX et +% \emph{ne corrige aucun des défauts relevés} mais se contente de +% \emph{signaler} au relecteur les points qui peuvent nécessiter une +% correction. Seul un œil humain entrainé peut décider si une ligne +% légèrement lavée est acceptable ou non, ou si la suppression +% d’une césure malvenue ne va pas provoquer des désordres plus +% graves encore. +% +% Je conseille de n’appliquer \pkg{lua-typo} que sur des textes +% « presque au point », d’améliorer ce qui peut l’être puis de +% \emph{supprimer} l’appel à \pkg{lua-typo} afin de ne pas risquer +% de mettre en lumière les imperfections que l’on aura renoncé +% à corriger. Pour appliquer toutes les vérifications prévues par +% \pkg{lua-typo}, il suffit d’ajouter dans le préambule la ligne\\ +% |\usepackage[All]{lua-typo}| +% +% Les fichiers \file{demo.tex} et \file{demo.pdf} fournissent un +% exemple du traitement opéré par \pkg{lua-typo}. +% +% Un grand merci à Jacques André et Thomas Savary pour avoir accepté +% de tester les pré-versions et pour leurs retours riches et toujours +% pertinents ; leurs suggestions et leurs encouragements ont +% grandement contribué à améliorer la première version mise en ligne. +% +% \section{Utilisation} +% +% Comme indiqué plus haut la vérification la plus complète s’obtient +% par :\\ +% |\usepackage[All]{lua-typo}| +% +% Il est possible de choisir les tests à activer de deux +% manières, soit « tout sauf … » soit « seulement ceci et cela ». +% Pour tout activer sauf les options \meta{OptX} et \meta{OptY} :\\ +% |\usepackage[All, |\meta{OptX}|=false, |\meta{OptY}|=false]{lua-typo}|\\ +% ou pour se limiter aux tests \meta{OptX} et \meta{OptY} :\\ +% |\usepackage[|\meta{OptX}|, |\meta{OptY}|, |\meta{OptZ}|]{lua-typo}| +% +% Le tableau suivant donne le nom des options et le type des +% vérifications proposées :\\[12pt] +% \begin{tabular}{>{\ttfamily}ll} +% \multicolumn{1}{l}{Nom} & Imperfection à signaler\\ \hline +% All & Active toutes les options ci-dessous\\ +% ShortLines & Dernière ligne d’alinéa trop courte ?\\ +% BackParindent & Dernière ligne d’alinéa \emph{presque} pleine ?\\ +% ShortPages & Page quasi vide (quelques lines) ?\\ +% OverfullLines & Ligne trop pleine ?\\ +% UnderfullLines & Ligne lavée ? \\ +% Widows & Veuve (haut de page) ?\\ +% Orphans & Orpheline (bas de page)\\ +% EOPHyphens & Mot coupé en bas de page ?\\ +% RepeatedHyphens & Césures sur trop de lignes consécutives ?\\ +% ParLastHyphen & Césure à l’avant-dernière ligne d’un alinéa ?\\ +% EOLShortWords & Mots courts (1 or 2 lettres) en fin de ligne ?\\ +% FirstWordMatch & Même (partie de) mot en début de lignes +% consécutives ?\\ +% LastWordMatch & Même (partie de) mot en fin de lignes +% consécutives ?\\ +% \hline +% \end{tabular}\\[12pt] +% Par exemple, pour limiter les vérifications aux lignes trop pleines +% ou creuses, il suffit de coder :\\ +% |\usepackage[OverfullLines, UnderfullLines]{lua-typo}|\\ +% Pour tout vérifier sauf les coupures répétées en fin de ligne on +% codera :\\ +% |\usepackage[All, RepeatedHyphens=false]{lua-typo}|\\ +% Notez que l’option that \opt{All} doit être la première de la +% liste, les suivantes étant rétirées de la liste complète définie +% par~\opt{All}. +% +% Le nom des différentes options n’étant pas facile à mémoriser, il +% est possible de les retrouver sans devoir consulter la +% documentation ; l’option \opt{ShowOptions} affiche la liste +% complète dans le fichier \file{.log} : +% |\usepackage[ShowOptions]{lua-typo}| +% +% L’option \opt{None}, empêche toute vérification : +% |\usepackage[None]{lua-typo}| +% a pour effet de supprimer complètement tout ajout de code LuaTeX +% (aucune fonction n’est ajoutée aux \emph{callbacks} de LuaTeX). +% Cette option peut-être utile lors de la toute dernière compilation, +% elle n’est pas tout-à-fait équivalente à la mise en commentaire de la +% ligne car les variables utilisées par \pkg{luatypo} restent +% définies ; si certaines ont été modifiées dans le préambule aucun +% message d’erreur du type ``\emph{Undefined Control Sequence}’’ ne +% sera émis à leur sujet. +% +% Terminons par quelques précisions sur ces options. +% \begin{description} +% \item[FirstWordMatch :] les répétitions en début de ligne dans les +% listes ne sont pas signalées. Ceci est voulu car elles résultent +% d’un choix délibéré de l’auteur. +% \item[LastWordMatch:] le dernier mot d’un alinéa qui se termine +% à plus de |1em| (en fait |\luatypoBackPI|) de la marge droite +% n’est jamais signalé comme répétition, même s’il est identique +% au mot de la ligne du dessus. +% De même, s’il est identique au dernier mot de la ligne +% suivante, la répéttion ne sera pas signalée non plus. +% \item[ShortPages :] lorsque le nombre de lignes d’une page est jugé +% insuffisant (voir ci-dessous), seule la dernière ligne de celle-ci +% est mise en couleur. +% \enlargethispage*{\baselineskip} +% \item[RepeatedHyphens :] de même, lorsque le nombre de lignes +% consécutives affectées par des césures dépasse le seuil fixé +% (voir ci-dessous), ne sont coloriées que les coupures en excès. +% \end{description} +% +% Enfin, le contenu des notes de bas de pages n’est pas vérifié +% par \pkg{lua-typo} car celles-ci passent pour l’instant en dessous +% de nos radars… il faut le savoir. +% +% \section{Paramétrage personnalisé} +% +% Pour certaines vérifications faites par \pkg{lua-typo} un +% paramétrage est nécessaire : à partir de quelle limite une dernière +% ligne d’alinéa est-elle considérée comme trop courte ? +% Combien de césures consécutives en bout de ligne sont-elles +% acceptables ? Ces réglages dépendent évidemment du contexte, un +% correcteur de romans aura des exigences plus strictes qu’un auteur +% de documentation technique par exemple… +% +% \pkg{lua-typo} permet de modifier le réglage des curseurs soit dans +% le fichier \file{lua-typo.cfg} soit dans le préambule après l’appel +% de \pkg{lua-typo} ; les réglages placés dans le préambule prévalent +% sur ceux du fichier \file{lua-typo.cfg} qui eux-mêmes prévalent sur +% les réglages internes de l’extension. +% +% Le fichier \file{lua-typo.cfg} fourni avec la distribution reprend +% exactement les réglages internes, il se trouve normalement dans le +% répertoire \textsc{texmfdist} des distributions TeXLive, MikTeX, etc. +% L’utilisateur a la possibilité de recopier ce fichier soit dans son +% répertoire de travail pour un document particulier, soit dans son +% répertoire \textsc{texmfhome} ou \textsc{texmflocal} et de le +% personnaliser comme il l’entend. +% +% Voici la liste complète des paramètres personnalisables avec leur +% valeur par défaut, leurs noms sont systématiquement préfixés par +% |luatypo| afin d’éviter de possible conflits avec d’autres +% extensions. +% \begin{description} +% \item[BackParindent :] la dernière ligne d’un alinéa fixe +% devrait, soit être pleine ---~en fait se terminer à moins de +% |\luatypoBackFuzz=2pt| de la marge droite~---, soit +% s’en éloigner d’au moins de |\luatypoBackPI=1em|. +% +% \item[ShortLines :] |\luatypoLLminWD=2\parindent| fixe la +% longueur minimale acceptable pour la dernière ligne d’un alinéa. +% +% \item[ShortPages :] |\luatypoPageMin=5| fixe le nombre minimal de +% lignes d’une page pour que celle-ci ne pas être +% signalée comme trop courte. +% +% \item[RepeatedHyphens :] |\luatypoHyphMax=2| fixe le nombre maximal +% acceptable de lignes consécutives terminées par une césure. +% +% \item[UnderfullLines :] |\luatypoStretchMax=200| fixe le +% pourcentage maximal acceptable pour l’étirement des +% espaces-mots, au-delà la ligne est déclarée lavée. +% La valeur donnée doit être un entier supérieur ou égal à~100, +% cette valeur 100 correspond à l’étirement maximal prévu par la +% fonte (|\fontdimen3|) ; avec ce réglage attendez-vous à trouver +% une kyrielle de lignes les creuses ! En fait la valeur par défaut +% (200) correspond approximativement à ce que TeX, avec les +% réglages par défaut (|\tolerance=200|, |\hbadness=1000|), +% considère comme \emph{Underfull hbox}. +% +% \item[First/LastWordMatch:] |\luatypoMinFull=3|\hfil et\hfil +% |\luatypoMinPart=4|\hfil nombres\linebreak[4] minimaux de lettres +% identiques (resp. pour un mot complet ou pour une partie de +% mot) au début ou à la fin de deux lignes consécutives +% déclenchant l’avertissement. +% Avec ce réglage (3 et 4), seront détectées deux lignes se +% terminant par « cible» et « invincible » (quatre lettres en +% commun), ainsi que la présence de « mon » en début ou fin de +% deux lignes consécutives (trois lettres en commun). +% +% \item[EOLShortWords:] cette option signale la présence en fin de +% ligne de mots très courts (une ou deux lettres) +% qui sont répertoriés dans une des listes +% suivantes (elles dépendent de la langue courante) :\\ +% |\luatypoOneChar{|\meta{language}|}{'|\meta{list of words}|'}|\\ +% |\luatypoTwoChars{|\meta{language}|}{'|\meta{list of words}|'}| +% +% Lorsque les listes correspondant à la langue du document sont +% vides, aucune vérification n’est effectuée. Pour l’instant, +% il y a deux lignes (non actives) prévues pour le français :\\ +% |\luatypoOneChar{french}{'À à Ô'}|\\ +% |\luatypoTwoChars{french}{'Je Tu Il On'}| +% +% Deux contraintes sont à respecter lorsqu’on veut +% personnaliser ces listes :\\ +% a) le premier argument (langue) \emph{doit être connu de} +% \pkg{babel}, aussi les commandes |\luatypoOneChar| et +% |\luatypoTwoChars|, si elles sont utilisées, doivent l’être +% \emph{après} le chargement de \pkg{babel}, une bonne habitude +% à prendre est donc de toujours charger \pkg{lua-typo} +% \emph{après} \pkg{babel} ; +% b) le second argument \emph{doit être une chaîne de +% caractères}, donc entourée de simples ou doubles +% \emph{quotes} \textsc{ascii} et composées de mots séparés +% par des espaces comme dans les exemples ci-dessus. +% \end{description} +% +% À chacune des vérifications faites par \pkg{lua-typo} peut être +% attachée une couleur spécifique pour mettre en évidence les +% imperfections détectées. +% Actuellement, seulement cinq couleurs sont utilisées par défaut, +% voici leur définition dans \file{lua-typo.cfg} : +% \begin{verbatim} +% \definecolor{mygrey}{gray}{0.6} +% \definecolor{myred}{rgb}{1,0.55,0} +% \luatypoSetColor0{red} % Césure à l’avant-dernière ligne d’un alinéa +% \luatypoSetColor1{red} % Césure en bas de page +% \luatypoSetColor2{red} % Césures sur trop de lignes consécutives +% \luatypoSetColor3{red} % Mot d’une ou deux lettres en fin de ligne +% \luatypoSetColor4{cyan} % Veuve +% \luatypoSetColor5{cyan} % Orpheline +% \luatypoSetColor6{cyan} % Dernière ligne d’alinéa trop courte +% \luatypoSetColor7{mygrey} % Ligne trop pleine +% \luatypoSetColor8{mygrey} % Ligne creuse +% \luatypoSetColor9{red} % Page presque vide (qq. lignes) +% \luatypoSetColor{10}{myred} % Répétitions en début de ligne +% \luatypoSetColor{11}{myred} % Répétitions en fin de ligne +% \luatypoSetColor{12}{mygrey}% Dernière ligne d’alinéa presque pleine +% \end{verbatim} +% \pkg{lua-typo} charge l’extension graphique \pkg{color}. +% Seules les couleurs portant un nom (\emph{named colors}) peuvent +% être utilisées ; pour en définir de nouvelles, il faut donc soit +% utiliser la commande |\definecolor| de l’extension \pkg{color} +% (comme ci-dessus pour |mygrey| ou |myred|), soit charger l’extension +% \pkg{xcolor} package qui donne accès à une kyrielle de noms de +% couleurs. +% \end{FrenchDoc} +% +% \StopEventually{} +% +% \begin{center} +% \textbf{\Large Highlighting Typographical Flaws with LuaLaTeX} +% \\[.5\baselineskip]^^A\] +% {\large Daniel Flipo}\\ +% \texttt{daniel.flipo@free.fr} +% \end{center} +% +% \section{What is it about?} +% +% The file \file{\filename}\footnote{The file described in this +% section has version number \fileversion\ and was last revised on +% \filedate.}, is meant for careful writers and proofreaders who do +% not feel totally satisfied with LaTeX output, the most frequent +% issues being widows and orphans, hyphenated words split across two +% pages, consecutive lines ending with hyphens, paragraphs ending +% on too short or nearly full lines, homeoarchy, etc. +% +% This package, which works with LuaLaTeX only, +% \emph{does not try to correct anything} but just highlights +% potential issues (the offending lines or end of lines are printed +% in colour) and provides at the end of the \file{.log} file a summary +% of pages to be checked and manually corrected if possible. +% My understanding is that automatic correction often introduces new +% issues (underflow/overfull lines) when fixing one of the flaws +% mentionned above, human correction providing much better results. +% For completeness, overfull and underfull lines are also coloured +% (in grey by default) and mentionned in the summary provided at the +% end of the \file{.log} file. +% +% I suggest to add a call |\usepackage[All]{lua-typo}| to the +% preamble of a document which is ``nearly finished’’ +% \emph{and to remove it} once all possible corrections have been +% made: if some flaws remain, getting them printed in colour in +% the final document would be a shame! +% +% See files \file{demo.tex} and \file{demo.pdf} for a short example +% (in French). +% +% I am very grateful to Jacques André and Thomas Savary, who kindly +% tested my beta versions, providing much valuable feedback and +% suggesting many improvements for the first released version. +% Special thanks to both of them! +% +% \section{Usage} +% +% The easiest way to trigger all checks perfomed by \pkg{lua-typo} +% is:\\ +% |\usepackage[All]{lua-typo}| +% +% It is possible to enable or disable some checks through boolean +% options passed to \pkg{lua-typo}; +% you may want to perform all checks except a few, then +% \pkg{lua-typo} should be loaded this way:\\ +% |\usepackage[All, |\meta{OptX}|=false, |\meta{OptY}|=false]{lua-typo}|\\ +% or to enable just a few checks, then do it this way:\\ +% |\usepackage[|\meta{OptX}|, |\meta{OptY}|, |\meta{OptZ}|]{lua-typo}| +% +% \pagebreak +% Here is the full list of possible checks (name and purpose):\\[12pt] +% \begin{tabular}{>{\ttfamily}ll} +% \multicolumn{1}{l}{Name} & Glitch to highlight\\ \hline +% All & Turns all options to \opt{true}\\ +% BackParindent & paragraph’s last line \emph{nearly} full?\\ +% ShortLines & paragraph’s last line too short?\\ +% ShortPages & nearly empty page (just a few lines)?\\ +% OverfullLines & overfull lines?\\ +% UnderfullLines & underfull lines?\\ +% Widows & widows (top of page)?\\ +% Orphans & orphans (bottom of page)\\ +% EOPHyphens & hyphenated word split across two pages?\\ +% RepeatedHyphens & too many consecutive hyphens?\\ +% ParLastHyphen & paragraph’s last full line hyphenated?\\ +% EOLShortWords & short words (1 or 2 chars) at end of line?\\ +% FirstWordMatch & same (part of) word starting two consecutive lines?\\ +% LastWordMatch & same (part of) word ending two consecutive lines?\\ +% \hline +% \end{tabular}\\[12pt] +% For example, if you want \pkg{lua-typo} to only warn about overfull +% and underfull lines, you can load \pkg{lua-typo} like this:\\ +% |\usepackage[OverfullLines, UnderfullLines]{lua-typo}|\\ +% If you want everything to be checked except paragraphs ending on +% a short line try:\\ +% |\usepackage[All, ShortLines=false]{lua-typo}|\\ +% please note that \opt{All} has to be the first one, as options are +% taken into account as they are read \emph{i.e.} from left to right. +% +% The list of all available options is printed to the \file{.log} +% file when option \opt{ShowOptions} is passed to \pkg{lua-typo}, an +% easy way to get their names without having to look into the +% documentation. +% +% With option \opt{None}, \pkg{lua-typo} \emph{does absolutely +% nothing}, all checks are disabled as the main function is not added +% to any LuaTeX callback. It not quite equivalent to commenting out +% the |\usepackage{lua-typo}| line though, as user defined commands +% related to \pkg{lua-typo} are still defined and will not print +% any error message. +% +% Please be aware of the following features: +% \begin{description} +% \item[FirstWordMatch:] the first word of consecutive list items +% is not highlighted, as these repetitions result of the author’s +% choice. +% \item[LastWordMatch:] a paragraphs’ last word ending ``too far’’ +% from the right margin (\emph{i.e.} more than +% |\luatypoBackPI| --default=1em-- away) is never highlighted +% even if it matches the one on the previous line. +% Similarly, if it matches the one on the next line, the latter +% will not be highlighted either. +% \item[ShortPages:] if a page is considered too short, its last +% line only is highlighted, not the whole page. +% \item[RepeatedHyphens:] ditto, when the number of consecutives +% hyphenated lines is too high, only the hyphenated words in +% excess (the last ones) are hightlighted. +% \end{description} +% +% Finally, please note that the footnotes’ contents are not checked +% by \pkg{lua-typo}, I have currently no clue of how to do that, +% hints are welcome! +% +% \section{Customisation} +% +% Some of the checks mentionned above require tuning, for +% instance, when is a last paragraph’s length called too short? +% how many hyphens ending consecutive lines are acceptable? +% \pkg{lua-typo} provides user customisable parameters to set +% what is regarded as acceptable or not. +% +% A default configuration file \file{lua-typo.cfg} is provided +% with all parameters set to their defaults; it is located under +% the \textsc{texmfdist} directory. It is up to the users to copy +% this file into their working directory (or \textsc{texmfhome} or +% \textsc{texmflocal}) and tune the defaults according to their own +% taste. +% +% It is also possible to provide defaults directly in the +% document’s preamble (this overwrites the corresponding settings +% done in the configuration file found on TeX’s search path: current +% directory, then \textsc{texmfhome}, \textsc{texmflocal} and +% finally \textsc{texmfdist}. +% +% Here are the parameters names (all prefixed by |luatypo| in order +% to avoid conflicts with other packages) and their default values: +% \begin{description} +% \item[BackParindent :] paragraphs’ last line should either +% touch the right margin (actually end at less than +% |\luatypoBackFuzz|, default |2pt|, from it) or leave at least +% |\luatypoBackPI|, default |1em|, between its end and the right +% margin. +% +% \item[ShortLines:] |\luatypoLLminWD=2\parindent| sets the +% minimum acceptable length for paragraphs’ last lines. +% +% \item[ShortPages:] |\luatypoPageMin=5| sets the minimum acceptable +% number of lines on a page (chapters’ last page for instance). +% +% \item[RepeatedHyphens:] |\luatypoHyphMax=2| sets the maximum +% acceptable number of consecutive hyphenated lines. +% +% \item[UnderfullLines:] |\luatypoStretchMax=200| sets the maximum +% acceptable percentage of stretch acceptable before a line is +% tagged by \pkg{lua-typo} as underfull; it must be an integer +% over 100, 100 means that the slightest stretch exceeding the +% font tolerance (|\fontdimen3|) will be warned about (be +% prepared for a lot of ``underfull lines’’ with this setting), +% the default value 200 is just below what triggers TeX’s +% ``Underfull hbox’’ message (when |\tolerance=200| and +% |\hbadness=1000|). +% +% \item[First/LastWordMatch:] |\luatypoMinFull=3| and +% |\luatypoMinPart=4| set the minimum number of characters +% required for a match to be pointed out. With this setting (3 +% and 4), two occurrences of the word `out’ at the beginning or +% end of two consecutive lines will be highlighted (three chars, +% `in’ wouldn’t match), whereas a line ending with ``full’’ or +% ``overfull’’ followed by one ending with ``underfull’’ will +% match (four chars): the second occurence of ``full’’ or +% ``erfull’’ will be highlighted. +% +% \item[EOLShortWords:] this check deals with lines ending with +% very short words (one or two characters), not all of them but +% a user selected list depending on the current language.\\ +% |\luatypoOneChar{|\meta{language}|}{'|\meta{list of words}|'}|\\ +% |\luatypoTwoChars{|\meta{language}|}{'|\meta{list of words}|'}| +% +% Currently, defaults (commented out) are suggested for the French +% language only:\\ +% |\luatypoOneChar{french}{'À à Ô'}|\\ +% |\luatypoTwoChars{french}{'Je Tu Il On'}| +% +% Feel free to customise these lists for French or to add your +% own shorts words for other languages but remember that +% a) the first argument (language name) \emph{must be known by} +% \pkg{babel}, so if you add |\luatypoOneChar| or +% |\luatypoTwoChars| commands, please make sure that +% \pkg{lua-typo} is loaded \emph{after} \pkg{babel}; +% b) the second argument \emph{must be a string} +% (\emph{i.e.} surrounded by single or double \textsc{ascii} +% quotes) made of your words separated by spaces. +% +% \end{description} +% +% It is possible to define a specific colour for each +% typographic flaws that \pkg{lua-typo} deals with. +% Currently, only five colours are used in \file{lua-typo.cfg}: +% \begin{verbatim} +% \definecolor{mygrey}{gray}{0.6} +% \definecolor{myred}{rgb}{1,0.55,0} +% \luatypoSetColor0{red} % Paragraph last full line hyphenated +% \luatypoSetColor1{red} % Page last word hyphenated +% \luatypoSetColor2{red} % Hyphens on consecutive lines +% \luatypoSetColor3{red} % Short word at end of line +% \luatypoSetColor4{cyan} % Widow +% \luatypoSetColor5{cyan} % Orphan +% \luatypoSetColor6{cyan} % Paragraph ending on a short line +% \luatypoSetColor7{mygrey} % Overfull lines +% \luatypoSetColor8{mygrey} % Underfull lines +% \luatypoSetColor9{red} % Nearly empty page (a few lines) +% \luatypoSetColor{10}{myred} % First word matches +% \luatypoSetColor{11}{myred} % Last word matches +% \luatypoSetColor{12}{mygrey}% paragraph’s last line nearly full +% \end{verbatim} +% +% \pkg{lua-typo} loads the \pkg{color} package from the LaTeX graphic +% bundle. Only named colours can be used by \pkg{lua-typo}, so you can +% either use the |\definecolor| from \pkg{color} package to define +% yours (as done in the config file for `mygrey’) or load the +% \pkg{xcolor} package which provides a bunch of named colours. +% +% \clearpage +% \section{\TeX{}nical details} +% +% \iffalse +%<*sty> +\NeedsTeXFormat{LaTeX2e}[2020/01/01] +\ProvidesPackage{lua-typo} +%</sty> +%<*dtx> +\ProvidesFile{lua-typo.dtx} +%</dtx> +%<*dtx|sty> + [2021/03/03 v.0.30 Daniel Flipo] +%</dtx|sty> +%<*sty> +% \fi +% +% This package only runs with LuaLaTeX and requires packages +% \pkg{luatexbase}, \pkg{luacode}, \pkg{luacolor} and +% \pkg{atveryend}. +% +% \begin{macrocode} +\ifdefined\directlua + \RequirePackage{luatexbase,luacode,luacolor} + \RequirePackage{kvoptions,atveryend} +\else + \PackageError{This package is meant for LuaTeX only! Aborting} + {No more information available, sorry!} +\fi +% \end{macrocode} +% +% Let’s define the necessary internal counters, dimens, token +% registers and commands… +% +% \begin{macrocode} +\newdimen\luatypoLLminWD +\newdimen\luatypoBackPI +\newdimen\luatypoBackFuzz +\newcount\luatypoStretchMax +\newcount\luatypoHyphMax +\newcount\luatypoPageMin +\newcount\luatypoMinFull +\newcount\luatypoMinPart +\newcount\luatypo@LANGno +\newcount\luatypo@options +\newtoks\luatypo@single +\newtoks\luatypo@double +% \end{macrocode} +% … and define a global table for this package. +% \begin{macrocode} +\begin{luacode} +luatypo = { } +\end{luacode} +% \end{macrocode} +% +% Set up \pkg{kvoptions} initializations. +% +% \begin{macrocode} +\SetupKeyvalOptions{ + family=luatypo, + prefix=LT@, +} +\DeclareBoolOption[false]{ShowOptions} +\DeclareBoolOption[false]{None} +\DeclareBoolOption[false]{All} +\DeclareBoolOption[false]{BackParindent} +\DeclareBoolOption[false]{ShortLines} +\DeclareBoolOption[false]{ShortPages} +\DeclareBoolOption[false]{OverfullLines} +\DeclareBoolOption[false]{UnderfullLines} +\DeclareBoolOption[false]{Widows} +\DeclareBoolOption[false]{Orphans} +\DeclareBoolOption[false]{EOPHyphens} +\DeclareBoolOption[false]{RepeatedHyphens} +\DeclareBoolOption[false]{ParLastHyphen} +\DeclareBoolOption[false]{EOLShortWords} +\DeclareBoolOption[false]{FirstWordMatch} +\DeclareBoolOption[false]{LastWordMatch} +% \end{macrocode} +% Option \opt{All} resets all booleans relative to specific +% typographic checks to \opt{true}. +% \begin{macrocode} +\AddToKeyvalOption{luatypo}{All}{% + \LT@ShortLinestrue \LT@ShortPagestrue + \LT@OverfullLinestrue \LT@UnderfullLinestrue + \LT@Widowstrue \LT@Orphanstrue + \LT@EOPHyphenstrue \LT@RepeatedHyphenstrue + \LT@ParLastHyphentrue \LT@EOLShortWordstrue + \LT@FirstWordMatchtrue \LT@LastWordMatchtrue + \LT@BackParindenttrue +} +\ProcessKeyvalOptions{luatypo} +% \end{macrocode} +% +% Forward these options to the |luatypo| global table. +% Wait until the config file \file{lua-typo.cfg} has been read +% in order to give it a chance of overruling the boolean options. +% This enables the user to permanently change the defaults. +% +% \begin{macrocode} +\AtEndOfPackage{% + \ifLT@None + \directlua{ luatypo.None = true }% + \else + \directlua{ luatypo.None = false }% + \fi + \ifLT@BackParindent + \advance\luatypo@options by 1 + \directlua{ luatypo.BackParindent = true }% + \else + \directlua{ luatypo.BackParindent = false }% + \fi + \ifLT@ShortLines + \advance\luatypo@options by 1 + \directlua{ luatypo.ShortLines = true }% + \else + \directlua{ luatypo.ShortLines = false }% + \fi + \ifLT@ShortPages + \advance\luatypo@options by 1 + \directlua{ luatypo.ShortPages = true }% + \else + \directlua{ luatypo.ShortPages = false }% + \fi + \ifLT@OverfullLines + \advance\luatypo@options by 1 + \directlua{ luatypo.OverfullLines = true }% + \else + \directlua{ luatypo.OverfullLines = false }% + \fi + \ifLT@UnderfullLines + \advance\luatypo@options by 1 + \directlua{ luatypo.UnderfullLines = true }% + \else + \directlua{ luatypo.UnderfullLines = false }% + \fi + \ifLT@Widows + \advance\luatypo@options by 1 + \directlua{ luatypo.Widows = true }% + \else + \directlua{ luatypo.Widows = false }% + \fi + \ifLT@Orphans + \advance\luatypo@options by 1 + \directlua{ luatypo.Orphans = true }% + \else + \directlua{ luatypo.Orphans = false }% + \fi + \ifLT@EOPHyphens + \advance\luatypo@options by 1 + \directlua{ luatypo.EOPHyphens = true }% + \else + \directlua{ luatypo.EOPHyphens = false }% + \fi + \ifLT@RepeatedHyphens + \advance\luatypo@options by 1 + \directlua{ luatypo.RepeatedHyphens = true }% + \else + \directlua{ luatypo.RepeatedHyphens = false }% + \fi + \ifLT@ParLastHyphen + \advance\luatypo@options by 1 + \directlua{ luatypo.ParLastHyphen = true }% + \else + \directlua{ luatypo.ParLastHyphen = false }% + \fi + \ifLT@EOLShortWords + \advance\luatypo@options by 1 + \directlua{ luatypo.EOLShortWords = true }% + \else + \directlua{ luatypo.EOLShortWords = false }% + \fi + \ifLT@FirstWordMatch + \advance\luatypo@options by 1 + \directlua{ luatypo.FirstWordMatch = true }% + \else + \directlua{ luatypo.FirstWordMatch = false }% + \fi + \ifLT@LastWordMatch + \advance\luatypo@options by 1 + \directlua{ luatypo.LastWordMatch = true }% + \else + \directlua{ luatypo.LastWordMatch = false }% + \fi +} +% \end{macrocode} +% +% |ShowOptions| is specific: +% +% \begin{macrocode} +\ifLT@ShowOptions + \GenericWarning{* }{% + *** List of possible options for lua-typo ***\MessageBreak + [Default values between brackets]% + \MessageBreak + ShowOptions [false]\MessageBreak + None [false]\MessageBreak + BackParindent [false]\MessageBreak + ShortLines [false]\MessageBreak + ShortPages [false]\MessageBreak + OverfullLines [false]\MessageBreak + UnderfullLines [false]\MessageBreak + Widows [false]\MessageBreak + Orphans [false]\MessageBreak + EOPHyphens [false]\MessageBreak + RepeatedHyphens [false]\MessageBreak + ParLastHyphen [false]\MessageBreak + EOLShortWords [false]\MessageBreak + FirstWordMatch [false]\MessageBreak + LastWordMatch [false]\MessageBreak + \MessageBreak + *********************************************% + \MessageBreak Lua-typo [ShowOptions] + }% +\fi +% \end{macrocode} +% +% Some defaut values which can be customised in the preamble +% are forwarded to Lua AtBeginDocument. +% +% \begin{macrocode} +\AtBeginDocument{% + \directlua{ + luatypo.HYPHmax = tex.count.luatypoHyphMax + luatypo.PAGEmin = tex.count.luatypoPageMin + luatypo.Stretch = tex.count.luatypoStretchMax + luatypo.MinFull = tex.count.luatypoMinFull + luatypo.MinPart = tex.count.luatypoMinPart + luatypo.LLminWD = tex.dimen.luatypoLLminWD + luatypo.BackPI = tex.dimen.luatypoBackPI + luatypo.BackFuzz = tex.dimen.luatypoBackFuzz + }% +} +% \end{macrocode} +% +% Print the summary of offending pages ---if any-- at the +% (very) end of document unless option |None| has been selected. +% +% \begin{macrocode} +\AtVeryEndDocument{% +\ifnum\luatypo@options = 0 \LT@Nonetrue \fi +\ifLT@None + \directlua{ + texio.write_nl(' ') + texio.write_nl('***********************************') + texio.write_nl('*** lua-typo loaded with NO option:') + texio.write_nl('*** NO CHECK PERFORMED! ***') + texio.write_nl('***********************************') + texio.write_nl(' ') + }% +\else + \directlua{ + texio.write_nl(' ') + texio.write_nl('*************************************') + if luatypo.pagelist == "" then + texio.write_nl('*** lua-typo: No Typo Flaws found.') + else + texio.write_nl('*** lua-typo: WARNING *************') + texio.write_nl('The following pages need attention: ' + .. luatypo.pagelist) + end + texio.write_nl('***********************************') + texio.write_nl(' ') + }% +\fi} +% \end{macrocode} +% +% \begin{macro}{\luatypoOneChar} +% \begin{macro}{\luatypoTwoChars} +% These commands set which short words should be avoided at end of +% lines. The first argument is a language name, say \opt{french}, +% which is turned into a command |\l@french| expanding to a number +% known by luatex, otherwise an error message occurs. +% The UTF8 string entered as second argument has to be converted +% into the font internal coding. +% \begin{macrocode} +\newcommand*{\luatypoOneChar}[2]{% + \def\luatypo@LANG{#1}\luatypo@single={#2}% + \ifcsname l@\luatypo@LANG\endcsname + \luatypo@LANGno=\the\csname l@\luatypo@LANG\endcsname \relax + \directlua{ + local langno = \the\luatypo@LANGno + local string = \the\luatypo@single + luatypo.single[langno] = " " + for p, c in utf8.codes(string) do + local s = string.char(c) + luatypo.single[langno] = luatypo.single[langno] .. s + end +%<dbg> texio.write_nl("SINGLE=" .. luatypo.single[langno]) +%<dbg> texio.write_nl(' ') + }% + \else + \PackageWarning{luatypo}{Unknown language "\luatypo@LANG", + \MessageBreak \protect\luatypoOneChar\space command ignored}% + \fi} +\newcommand*{\luatypoTwoChars}[2]{% + \def\luatypo@LANG{#1}\luatypo@double={#2}% + \ifcsname l@\luatypo@LANG\endcsname + \luatypo@LANGno=\the\csname l@\luatypo@LANG\endcsname \relax + \directlua{ + local langno = \the\luatypo@LANGno + local string = \the\luatypo@double + luatypo.double[langno] = " " + for p, c in utf8.codes(string) do + local s = string.char(c) + luatypo.double[langno] = luatypo.double[langno] .. s + end +%<dbg> texio.write_nl("DOUBLE=" .. luatypo.double[langno]) +%<dbg> texio.write_nl(' ') + }% + \else + \PackageWarning{luatypo}{Unknown language "\luatypo@LANG", + \MessageBreak \protect\luatypoTwoChars\space command ignored}% + \fi} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \vspace*{\baselineskip} +% \begin{macro}{\luatypoSetColor} +% This is a user-level command to customise the colours highlighting +% the nine types of possible typographic flaws. +% The first argument is a number (flaw type), the second the named +% colour associated to it. +% The colour support is based on the \pkg{luacolor} package (color +% attributes). +% \begin{macrocode} +\newcommand*{\luatypoSetColor}[2]{% + \begingroup + \color{#2}% + \directlua{luatypo.colortbl[#1]=\the\LuaCol@Attribute}% + \endgroup +} +% \end{macrocode} +% \end{macro} +% +% The Lua code now, initialisations. +% +% \begin{macrocode} +\begin{luacode} +luatypo.single = { } +luatypo.double = { } +luatypo.colortbl = { } +luatypo.pagelist = "" + +local hyphcount = 0 +local parlines = 0 +local pagelines = 0 +local pageno = 0 +local pageflag = false + +local char_to_discard = { } +char_to_discard[string.byte(",")] = true +char_to_discard[string.byte(".")] = true +char_to_discard[string.byte("!")] = true +char_to_discard[string.byte("?")] = true +char_to_discard[string.byte(":")] = true +char_to_discard[string.byte(";")] = true +char_to_discard[string.byte("-")] = true + +local split_lig = { } +split_lig[0xFB00] = "ff" +split_lig[0xFB01] = "fi" +split_lig[0xFB02] = "fl" +split_lig[0xFB03] = "ffi" +split_lig[0xFB04] = "ffl" + +local DISC = node.id("disc") +local GLYPH = node.id("glyph") +local GLUE = node.id("glue") +local KERN = node.id("kern") +local HLIST = node.id("hlist") +local LPAR = node.id("local_par") +local MKERN = node.id("margin_kern") +local PENALTY = node.id("penalty") +% \end{macrocode} +% GLUE subtypes: +% \begin{macrocode} +local USRSKIP = 0 +local PARSKIP = 3 +local LFTSKIP = 8 +local RGTSKIP = 9 +local TOPSKIP = 10 +local PARFILL = 15 +% \end{macrocode} +% HLIST subtypes: +% \begin{macrocode} +local LINE = 1 +local BOX = 2 +% \end{macrocode} +% Penalty subtypes: +% \begin{macrocode} +local USER = 0 +local HYPH = 0x2D + +local effective_glue = node.effective_glue +local set_attribute = node.set_attribute +local slide = node.slide +local traverse = node.traverse +local traverse_id = node.traverse_id +local has_field = node.has_field +local uses_font = node.uses_font +local is_glyph = node.is_glyph + +% \end{macrocode} +% +% This auxillary function colours glyphs and discretionaries. +% It requires two arguments: a node and a (named) colour. +% +% \begin{macrocode} +local color_node = function (node, color) + local attr = oberdiek.luacolor.getattribute() + if node.id == DISC then + local pre = node.pre + local post = node.post + local replace = node.replace + if pre then + set_attribute(pre,attr,color) +%<dbg> texio.write_nl('PRE=' .. tostring(pre.char)) + end + if post then + set_attribute(post,attr,color) +%<dbg> texio.write_nl('POST=' .. tostring(post.char)) + end + if replace then + set_attribute(replace,attr,color) +%<dbg> texio.write_nl('REPL=' .. tostring(replace.char)) + end +%<dbg> texio.write_nl(' ') + else + set_attribute(node,attr,color) + end +end +% \end{macrocode} +% +% This auxillary function colours the content of an |\hbox|. +% It requires two arguments: a node (the box) and a (named) colour. +% +% \begin{macrocode} +local color_hbox = function (head, color) + local first = head.head + for n in traverse(first) do + color_node(n, color) + end +end +% +% This auxillary function colours a whole line. It requires two +% arguments: a line’s node and a (named) colour. +% +% \begin{macrocode} +local color_line = function (head, color) + local first = head.head + for n in traverse(first) do + if n.id == HLIST and n.subtype == BOX then + color_hbox(n, color) + else + color_node(n, color) + end + end +end +% \end{macrocode} +% +% The next three functions deal with ``homeoarchy’’, \emph{i.e.} +% lines beginning or ending with the same (part of) word. +% While comparing two words, the only significant nodes are glyphs +% and ligatures, dicretionnaries other than ligatures, kerns +% (letterspacing) should be discarded. +% For each word to be compared we build a ``signature’’ made of +% glyphs and split ligatures. +% +% The first function adds a node to a signature of type string. +% It returns the augmented string and its length. +% The last argument is a boolean needed when building a signature +% backwards (see |check_last_word|). +% \begin{macrocode} +local signature = function (node, string, swap) + local n = node + local str = string + if n.id == GLYPH then + local b, id = is_glyph(n) + if b and not char_to_discard[b] then +% \end{macrocode} +% Punctuation has to be discarded; the French apostrophe (right quote +% U+2019) has a char code ``out of range’’, we replace it with U+0027; +% Other glyphs should have char codes less than 0x100 (or 0x180?) or +% be ligatures… standard ones (U+FB00 to U+FB04) are converted using +% table |split_lig|. +% \begin{macrocode} + if b == 0x2019 then b = 0x27 end + if b < 0x100 then + str = str .. string.char(b) + elseif split_lig[b] then + local c = split_lig[b] + if swap then + c = string.reverse(c) + end + str = str .. c + end + end + elseif n.id == DISC then +% \end{macrocode} +% Ligatures are split into |pre| and |post| and both parts are +% stored. In case of \emph{ffl, ffi}, the post part is also +% a ligature… +% \begin{macrocode} + local pre = n.pre + local post = n.post + local c1 = "" + local c2 = "" + if pre and pre.char and pre.char ~= HYPH and pre.char < 0x100 then + c1 = string.char(pre.char) + end + if post and post.char then + if post.char < 0x100 then + c2 = string.char(post.char) + elseif split_lig[post.char] then + c2 = split_lig[post.char] + if swap then + c2 = string.reverse(c2) + end + end + end + if swap then + str = str .. c2 .. c1 + else + str = str .. c1 .. c2 + end + end + local len = string.len(str) + return len, str +end +% \end{macrocode} +% +% This auxillary function looks for lines ending with the same letters. +% It requires four arguments: a string (previous line’s signature), +% a node (the last one on the current line), a (named) colour and a +% boolean to cancel the coloration in some cases (end of paragraphs). +% It prints the matching part at end of linewith with the supplied +% colour and returns the current line’s last word and a boolean (match). +% +% \begin{macrocode} +local check_last_word = function (old, node, color, flag) + local match = false + local new = "" + local len = 0 + if flag then +% \end{macrocode} +% Get the last glyph one the line, skipping discretionaries, +% margin kerns, etc., unless |flag| cancels the whole process. +% \begin{macrocode} + local swap = true + local lastn = node + while lastn and lastn.id ~= GLYPH and lastn.prev do + lastn = lastn.prev + end +% \end{macrocode} +% A signature is built from the last two words on the current line. +% \begin{macrocode} + local n = lastn + repeat + len, new = signature (n, new, swap) + n = n.prev + until not n or n.id == GLUE + if n and n.id == GLUE then + new = new .. "_" + len = len + 1 + repeat + n = n.prev + len, new = signature (n, new, swap) + until n.id == GLUE or not n.prev + end + new = string.reverse(new) +%<dbg> texio.write_nl('EOLsigold=' .. old) +%<dbg> texio.write(' EOLsig=' .. new) + local MinFull = luatypo.MinFull + local MinPart = luatypo.MinPart + MinFull = math.min(MinPart,MinFull) + local k = MinPart + local oldlast = string.gsub (old, '%w+_', '') + local newlast = string.gsub (new, '%w+_', '') + len = string.len(newlast) + if len < MinPart then + k = MinPart + 1 + end + local oldsub = string.sub(old,-k) + local newsub = string.sub(new,-k) + local maxlen = string.len(new) + if oldsub == newsub then +%<dbg> texio.write_nl('EOLnewsub=' .. newsub) + match = true + elseif oldlast == newlast and len >= MinFull then +%<dbg> texio.write_nl('EOLnewlast=' .. newlast) + match = true + oldsub = oldlast + newsub = newlast + k = len + end + if match then +% \end{macrocode} +% Minimal partial match; any more glyphs matching? +% \begin{macrocode} + local osub = oldsub + local nsub = newsub + while osub == nsub and k < maxlen do + k = k +1 + osub = string.sub(old,-k) + nsub = string.sub(new,-k) + if osub == nsub then + newsub = nsub + end + end +%<dbg> texio.write_nl('EOLfullmatch=' .. newsub) +%<msg> texio.write_nl('***MATCH=' .. newsub .. +%<msg> " on page " .. pageno) +%<msg> texio.write_nl(' ') +% \end{macrocode} +% Lest's colour the matching string. +% \begin{macrocode} + oldsub = string.reverse(newsub) + local newsub = "" + local k = string.len(oldsub) + local n = lastn + repeat + if n and n.id ~= GLUE then + color_node(n, color) + len, newsub = signature(n, newsub, swap) + elseif n then + newsub = newsub .. "_" + len = len + 1 + end + n = n.prev + until not n or newsub == oldsub or len >= k + end + end + return new, match +end +% \end{macrocode} +% +% Same thing for beginning of lines: check the first two words and +% compare their signature with the previous line’s. +% +% \begin{macrocode} +local check_first_word = function (old, node, color, flag) + local match = false + local swap = false + local new = "" + local len = 0 + local start = node + local n = start + while n and n.id ~= GLUE do + len, new = signature (n, new, swap) + n = n.next + end + n = n.next + new = new .. "_" + while n and n.id ~= GLUE do + len, new = signature (n, new, swap) + n = n.next + end +%<dbg> texio.write_nl('BOLsigold=' .. old) +%<dbg> texio.write(' BOLsig=' .. new) +% \end{macrocode} +% When called with flag |false|, |check_first_word| returns +% the first word’s signature, but doesn’t compare it with the +% previous line’s. +% \begin{macrocode} + if flag then + local MinFull = luatypo.MinFull + local MinPart = luatypo.MinPart + MinFull = math.min(MinPart,MinFull) + local k = MinPart + local L = MinPart -1 + local oldsub = "" + local newsub = "" + local oldfirst = string.gsub (old, '_%w+', '') + local newfirst = string.gsub (new, '_%w+', '') + len = string.len(newfirst) + if len < MinPart then + k = MinPart + 1 + end + local maxlen = string.len(new) + local oldsub = string.sub(old,1,L) + local newsub = string.sub(new,1,L) + if oldsub == newsub then +%<dbg> texio.write_nl('BOLnewsub=' .. newsub) + match = true + k = L + elseif oldfirst == newfirst and len >= MinFull then +%<dbg> texio.write_nl('BOLnewfirst=' .. newfirst) + match = true + oldsub = oldfirst + newsub = newfirst + k = len + end + if match then +% \end{macrocode} +% Minimal partial match; any more glyphs matching? +% \begin{macrocode} + local osub = oldsub + local nsub = newsub + while osub == nsub and k < maxlen do + k = k + 1 + osub = string.sub(old,1,k) + nsub = string.sub(new,1,k) + if osub == nsub then + newsub = nsub + end + end + if k < MinPart then + match =false + end + end + if match then +%<dbg> texio.write_nl('BOLfullmatch=' .. newsub) +%<msg> texio.write_nl('***MATCH=' .. newsub .. +%<msg> " on page " .. pageno) +%<msg> texio.write_nl(' ') +% \end{macrocode} +% Lest's colour the matching string. +% \begin{macrocode} + oldsub = newsub + local newsub = "" + local k = string.len(oldsub) + local n = start + repeat + if n and n.id ~= GLUE then + color_node(n, color) + len, newsub = signature(n, newsub, swap) + elseif n then + newsub = newsub .. "_" + len = len + 1 + end + n = n.next + until not n or newsub == oldsub or len >= k + end + end + return new, match +end +% \end{macrocode} +% +% This auxillary function looks for a short word (one or two chars) +% at end of lines, compares it to a given list and colours it if +% matches. The argument must be a node of type GLYPH, usually +% the last line’s node.\\ +% TODO: where does ``out of range’’ starts? U+0100? U+0180? +% +% \begin{macrocode} +local check_regexpr = function (glyph) + local COLOR = luatypo.colortbl[3] + local lang = glyph.lang + local match = false + local lchar, id = is_glyph(glyph) + local previous = glyph.prev +% \end{macrocode} +% First look for single chars unless the list of words is empty. +% \begin{macrocode} + if lang and luatypo.single[lang] then +% \end{macrocode} +% For single char words, the previous node is a glue. +% \begin{macrocode} + if lchar and lchar < 0x100 and previous and previous.id == GLUE then + match = string.find(luatypo.single[lang], string.char(lchar)) + if match then + color_node(glyph,COLOR) +%<msg> texio.write_nl('***MATCH=' .. string.char(lchar) .. +%<msg> " on page " .. pageno) +%<msg> texio.write_nl(' ') + end + end + end +% \end{macrocode} +% Look for two chars words unless the list of words is empty. +% \begin{macrocode} + if lang and luatypo.double[lang] then + if lchar and previous and previous.id == GLYPH then + local pchar, id = is_glyph(previous) + local pprev = previous.prev +% \end{macrocode} +% For two chars words, the previous node is a glue… +% \begin{macrocode} + if pchar and pchar < 0x100 and pprev and pprev.id == GLUE then + local pattern = string.char(pchar) .. string.char(lchar) + match = string.find(luatypo.double[lang], pattern) + if match then + color_node(previous,COLOR) + color_node(glyph,COLOR) +%<msg> texio.write_nl('***MATCH=' .. pattern .. +%<msg> " on page " .. pageno) +%<msg> texio.write_nl(' ') + end + end +% \end{macrocode} +% …unless a kern is found between the two chars. +% \begin{macrocode} + elseif lchar and previous and previous.id == KERN then + local pprev = previous.prev + if pprev and pprev.id == GLYPH then + local pchar, id = is_glyph(pprev) + local ppprev = pprev.prev + if pchar and pchar < 0x100 and ppprev and ppprev.id == GLUE then + local pattern = string.char(pchar) .. string.char(lchar) + match = string.find(luatypo.double[lang], pattern) + if match then + color_node(pprev,COLOR) + color_node(glyph,COLOR) +%<msg> texio.write_nl('***MATCH=' .. pattern .. +%<msg> " on page " .. pageno) +%<msg> texio.write_nl(' ') + end + end + end + end + end + return match +end +% \end{macrocode} +% +% This auxillary function prints the first part of an hyphenated word +% up to the discretionary, with a supplied colour. +% It requires two arguments: a DISC node and a (named) colour. +% +% \begin{macrocode} +local show_pre_disc = function (disc, color) + local n = disc + while n.id ~= GLUE do + color_node(n, color) + n = n.prev + end + return n +end +% \end{macrocode} +% +% This is the main function which will be added to the +% |"pre_output_filter"| callback unless option |None| is selected. +% +% \begin{macrocode} +luatypo.check_page = function (head) + local PAGEmin = luatypo.PAGEmin + local HYPHmax = luatypo.HYPHmax + local LLminWD = luatypo.LLminWD + local BackPI = luatypo.BackPI + local BackFuzz = luatypo.BackFuzz + local BackParindent = luatypo.BackParindent + local ShortLines = luatypo.ShortLines + local ShortPages = luatypo.ShortPages + local OverfullLines = luatypo.OverfullLines + local UnderfullLines = luatypo.UnderfullLines + local Widows = luatypo.Widows + local Orphans = luatypo.Orphans + local EOPHyphens = luatypo.EOPHyphens + local RepeatedHyphens = luatypo.RepeatedHyphens + local FirstWordMatch = luatypo.FirstWordMatch + local ParLastHyphen = luatypo.ParLastHyphen + local EOLShortWords = luatypo.EOLShortWords + local LastWordMatch = luatypo.LastWordMatch + local Stretch = math.max(luatypo.Stretch/100,1) + + local orphanflag = false + local widowflag = false + local lwhyphflag = false + local match1 = false + local match2 = false + local firstwd = "" + local lastwd = "" + while head do + local nextnode = head.next + local prevnode = head.prev + local pprevnode = nil + if prevnode then + pprevnode = prevnode.prev + end +% \end{macrocode} +% If the current node is a glue of type topskip, we are starting new +% page, let’s reset some counters and flags : |pageflag| will be set +% to |true| if a possible typographic flaw is found on this page, +% and trigger the addition of this page number to the summary list. +% |hyphcount| hold the number the consecutive hyphenated lines. +% \begin{macrocode} + if head.id == GLUE and head.subtype == TOPSKIP then + pageflag = false + match1 = false + pageno = tex.getcount("c@page") + hyphcount = 0 + pagelines = 0 + firstwd = "" + lastwd = "" + elseif head.id == HLIST and head.subtype == LINE then +% \end{macrocode} +% The current node is a line, |first| is the line’s first node. +% Skip margin kern or leftskip if any. +% \begin{macrocode} + local first = head.head + if first.id == MKERN or + (first.id == GLUE and first.subtype == LFTSKIP) then + first = first.next + end + pagelines = pagelines + 1 + local ListItem = false +% \end{macrocode} +% Is this line really a text line (one glyph at least)? +% \begin{macrocode} + local textline = true + local n = first + while (n and n.id ~= GLYPH) and + not (n.id == GLUE and n.subtype == RGTSKIP) do + n = n.next + end + if n.id == GLUE then + textline = false + end +% \end{macrocode} +% Is this line overfull or underfull? +% \begin{macrocode} + if head.glue_set == 1 and head.glue_sign == 2 and + head.glue_order == 0 and OverfullLines then +%<msg> texio.write_nl('***OVERFULL line on page ' .. pageno) +%<msg> texio.write_nl(' ') + pageflag = true + local COLOR = luatypo.colortbl[7] + color_line (head, COLOR) + elseif head.glue_set >= Stretch and head.glue_sign == 1 and + head.glue_order == 0 and UnderfullLines then +%<msg> texio.write_nl('***UNDERFULL line on page ' .. +%<msg> tex.getcount("c@page")) +%<msg> texio.write_nl(' ') + local COLOR = luatypo.colortbl[8] + pageflag = true + color_line (head, COLOR) + end +% \end{macrocode} +% Now let’s analyse the beginning of the current line. +% \begin{macrocode} + if first.id == LPAR then +% \end{macrocode} +% It starts a paragraph, +% \begin{macrocode} + hyphcount = 0 + parlines = 1 + if not nextnode then +% \end{macrocode} +% No more nodes: we are at the page bottom, this ligne is +% an orphan (unless it is the unique line of the paragraph)… see below. +% \begin{macrocode} + orphanflag = true + end +% \end{macrocode} +% List items begin with LPAR followed by an hbox. +% \begin{macrocode} + local nn = first.next + if nn and nn.id == HLIST and nn.subtype == BOX then + ListItem = true + end + else + parlines = parlines + 1 + end +% \end{macrocode} +% Let’s track lines beginning with the same word (except lists). +% \begin{macrocode} + if FirstWordMatch then + local flag = not ListItem + local COLOR = luatypo.colortbl[10] + firstwd, match1 = check_first_word(firstwd, first, COLOR, flag) + if match1 then + pageflag = true + end + end +% \end{macrocode} +% Let’s check the end of line: |ln| (usually a rightskip) and |pn| +% are the last two nodes. +% \begin{macrocode} + local ln = slide(first) + local pn = ln.prev + if pn and pn.id == GLUE and pn.subtype == PARFILL then +% \end{macrocode} +% The paragraph ends with this line, it is not an orphan then… +% \begin{macrocode} + hyphcount = 0 + orphanflag = false +% \end{macrocode} +% but it is a widow if it is the page’s first line and it does’nt +% start a new paragraph. Orphans and widows will be colored later. +% \begin{macrocode} + if pagelines == 1 and parlines > 1 then + widowflag = true + end +% \end{macrocode} +% |PFskip| is the rubber length (in sp) added to complete the line. +% \begin{macrocode} + local PFskip = effective_glue(pn,head) + if ShortLines then + local llwd = tex.hsize - PFskip +%<dbg> local PFskip_pt = PFskip/65536 +%<dbg> local llwd_pt = llwd/65536 +%<dbg> texio.write_nl('PFskip= ' .. PFskip_pt .. ' pt') +%<dbg> texio.write_nl('llwd= ' .. llwd_pt .. ' pt') +% \end{macrocode} +% |llwd| is the line’s length. Is it too short? +% \begin{macrocode} + if llwd < LLminWD then +%<msg> texio.write_nl('***Last line too short, page ' .. pageno) +%<msg> texio.write_nl(' ') + pageflag = true + local COLOR = luatypo.colortbl[6] + local attr = oberdiek.luacolor.getattribute() +% \end{macrocode} +% let’s colour the whole line. +% \begin{macrocode} + color_line (head, COLOR) + end + end +% \end{macrocode} +% Is this line nearly full? (ending too close to the right margin) +% \begin{macrocode} + if BackParindent and PFskip < BackPI and PFskip > BackFuzz then +%<msg> texio.write_nl('***Last line nearly full, page ' .. pageno) +%<msg> texio.write_nl(' ') + pageflag = true + local COLOR = luatypo.colortbl[12] + local attr = oberdiek.luacolor.getattribute() + color_line (head, COLOR) + end +% \end{macrocode} +% Does the last word and the one on the previous line match? +% \begin{macrocode} + if LastWordMatch then + local COLOR = luatypo.colortbl[11] + local flag = textline + if PFskip > BackPI then + flag = false + end + lastwd, match1 = check_last_word(lastwd, pn, COLOR, flag) + if match1 then + pageflag = true + end + end + elseif pn and pn.id == DISC then +% \end{macrocode} +% The current line ends with an hyphen. +% \begin{macrocode} + hyphcount = hyphcount + 1 + if LastWordMatch then + local COLOR = luatypo.colortbl[11] + lastwd, match1 = check_last_word(lastwd, ln, COLOR, true) + if match1 then + pageflag = true + end + end + if hyphcount > HYPHmax and RepeatedHyphens then + local COLOR = luatypo.colortbl[2] + local pg = show_pre_disc (pn,COLOR) + pageflag = true +%<msg> texio.write_nl('***HYPH issue page ' .. pageno) +%<msg> texio.write_nl(' ') + end + if not nextnode and EOPHyphens then +% \end{macrocode} +% No more nodes: this hyphen occurs on the page last line. +% \begin{macrocode} + lwhyphflag = true + end + if nextnode and ParLastHyphen then +% \end{macrocode} +% Does the next line end the current paragraph? If so, |nextnode| is +% a `linebreak penalty’, the next one is a `baseline skip’ and the +% node after a `hlist of subtype line’ with |glue_order=2|. +% \begin{macrocode} + local nnnode = nextnode.next + local nnnnode = nil + if nnnode and nnnode.next then + nnnnode = nnnode.next + if nnnnode and nnnnode.id == HLIST and + nnnnode.subtype == 1 and nnnnode.glue_order == 2 then + local COLOR = luatypo.colortbl[0] + local pg = show_pre_disc (pn,COLOR) + pageflag = true + end + end + end + elseif pn and pn.id == GLYPH then +% \end{macrocode} +% \enlargethispage*{\baselineskip} +% The current line ends with a character, reset |hyphcount| and +% compare the end of line’s word with the one on previous line. +% \begin{macrocode} + hyphcount = 0 + if LastWordMatch then + local COLOR = luatypo.colortbl[11] + lastwd, match1 = check_last_word(lastwd, pn, COLOR, true) + end +% \end{macrocode} +% Look for a short unwanted short word at the end of the current +% line. +% \begin{macrocode} + if EOLShortWords then + match2 = check_regexpr(pn) + end + if match1 or match2 then + pageflag = true + end +% \end{macrocode} +% Microtype sometimes adds a margin kern at the right margin, +% |check_regexpr| has to operate on the previous node then. +% \begin{macrocode} + elseif pn and pn.id == MKERN then + hyphcount = 0 + local ppn = pn.prev + if ppn and ppn.id == GLYPH then + if LastWordMatch then + local COLOR = luatypo.colortbl[11] + lastwd, match1 = check_last_word(lastwd, pn, COLOR, true) + end + if EOLShortWords then + match2 = check_regexpr(ppn) + end + if match1 or match2 then + pageflag = true + end + end +% \end{macrocode} +% If the current line ends with anything else (no hyphen), +% reset |hyphcount|. +% \begin{macrocode} + else + hyphcount = 0 + end +% \end{macrocode} +% Colour the whole line if is is a widow. +% \begin{macrocode} + if widowflag and Widows then + pageflag = true + widowflag = false +%<msg> texio.write_nl('***WIDOW on top of page ' .. pageno) +%<msg> texio.write_nl(' ') + local COLOR = luatypo.colortbl[4] + color_line (head, COLOR) + end +% \end{macrocode} +% Colour the whole line if is is a orphan. +% \begin{macrocode} + if orphanflag and Orphans then +%<msg> texio.write_nl('***ORPHAN at bottom of page ' .. pageno) +%<msg> texio.write_nl(' ') + pageflag = true + local COLOR = luatypo.colortbl[5] + color_line (head, COLOR) + end +% \end{macrocode} +% Colour (differently) the last word if hyphenated. +% \begin{macrocode} + if lwhyphflag and EOPHyphens then +%<msg> texio.write_nl('***LAST WORD SPLIT page ' .. pageno) +%<msg> texio.write_nl(' ') + local COLOR = luatypo.colortbl[1] + local pg = show_pre_disc (pn,COLOR) + pageflag = true + end +% \end{macrocode} +% Track empty pages: check the number of lines at end of page. +% Widows are already detected; get the last line and colour it. +% NOTE: there are usually two consecutive nodes of type 12-0 at +% end of pages… +% \begin{macrocode} + elseif not nextnode and head.id == GLUE and + head.subtype == USRSKIP then + if pagelines > 1 and pagelines < PAGEmin and ShortPages then + pageflag = true + local COLOR = luatypo.colortbl[9] +%<msg> texio.write_nl('***Only ' .. pagelines .. +%<msg> ' lines on page ' .. pageno) +%<msg> texio.write_nl(' ') + local node = head + while node.id ~= HLIST or node.subtype ~= LINE do + node = node.prev + end + color_line(node, COLOR) + end + end + head = nextnode + end +% \end{macrocode} +% Add this page number to the summary if any flaw has been found on it. +% \begin{macrocode} + if pageflag then + luatypo.pagelist = luatypo.pagelist .. tostring(pageno) .. ", " + end + return true +end +return luatypo.check_page +\end{luacode} +% \end{macrocode} +% +% Add the |luatypo.check_page| function to the |pre_output_filter| +% callback, unless option |None| is selected ; remember that the +% |None| boolean’s value is forwarded to Lua `AtEndOfPackage’… +% \begin{macrocode} +\AtEndOfPackage{% + \directlua{ + if not luatypo.None then + luatexbase.add_to_callback + ("pre_output_filter",luatypo.check_page,"check_page") + end + } +} +% \end{macrocode} +% +% Load a local config file if present in LaTeX’s search path. +% Otherwise, set reasonnable defaults. +% \begin{macrocode} + +\InputIfFileExists{lua-typo.cfg}% + {\PackageInfo{lua-typo.sty}{'lua-typo.cfg' file loaded}}% + {\PackageInfo{lua-typo.sty}{'lua-typo.cfg' file not found. + \MessageBreak Providing default values.}% + \definecolor{mygrey}{gray}{0.6}% + \definecolor{myred}{rgb}{1,0.55,0} + \luatypoSetColor0{red}% Paragraph last full line hyphenated + \luatypoSetColor1{red}% Page last word hyphenated + \luatypoSetColor2{red}% Hyphens ending two many consecutive lines + \luatypoSetColor3{red}% Short word at end of line + \luatypoSetColor4{cyan}% Widow + \luatypoSetColor5{cyan}% Orphan + \luatypoSetColor6{cyan}% Paragraph ending on a short line + \luatypoSetColor7{blue}% Overfull lines + \luatypoSetColor8{blue}% Underfull lines + \luatypoSetColor9{red}% Nearly empty page + \luatypoSetColor{10}{myred}% First word matches + \luatypoSetColor{11}{myred}% Last word matches + \luatypoSetColor{12}{mygrey}% Paragraph ending on a nearly full line + \luatypoBackPI=1em\relax + \luatypoBackFuzz=2pt\relax + \luatypoLLminWD=2\parindent\relax + \luatypoStretchMax=200\relax + \luatypoHyphMax=2\relax + \luatypoPageMin=5\relax + \luatypoMinFull=4\relax + \luatypoMinPART=4\relax + }% +% \end{macrocode} +% \iffalse +%</sty> +% \fi +% +% \clearpage +% \section{Configuration file} +% +% \iffalse +%<*cfg> +% \fi +% +% \let\theCodelineNo\relax +% \begin{macrocode} +%%% Configuration file for lua-typo.sty +%%% These settings can also be overruled in the preamble. + +%% Minimum gap between end of paragraphs’ last lines and the right margin +\luatypoBackPI=1em\relax +\luatypoBackFuzz=2pt\relax + +%% Minimum length of paragraphs’ last lines +\luatypoLLminWD=2\parindent\relax + +%% Maximum number of consecutive hyphenated lines +\luatypoHyphMax=2\relax + +%% Nearly empty pages: minimum number of lines +\luatypoPageMin=5\relax + +%% Maximum acceptable stretch before a line is tagged as Underfull +\luatypoStretchMax=200\relax + +%% Minimum number of matching characters for words at begin/end of line +\luatypoMinFull=3\relax +\luatypoMinPart=4\relax + +%% Default colours = red, cyan, mygrey +\definecolor{mygrey}{gray}{0.6} +\definecolor{myred}{rgb}{1,0.55,0} +\luatypoSetColor0{red} % Paragraph last full line hyphenated +\luatypoSetColor1{red} % Page last word hyphenated +\luatypoSetColor2{red} % Hyphens ending two many consecutive lines +\luatypoSetColor3{red} % Short word at end of line +\luatypoSetColor4{cyan} % Widow +\luatypoSetColor5{cyan} % Orphan +\luatypoSetColor6{cyan} % Paragraph ending on a short line +\luatypoSetColor7{blue} % Overfull lines +\luatypoSetColor8{blue} % Underfull lines +\luatypoSetColor9{red} % Nearly empty page (just a few lines) +\luatypoSetColor{10}{myred} % First word matches +\luatypoSetColor{11}{myred} % Last word matches +\luatypoSetColor{12}{mygrey}% Paragraph ending on a nearly full line + +%% Language specific settings (example for French only currently): +%% short words (two letters max) to be avoided at end of lines. +%% French: +%%\luatypoOneChar{french}{'À à Ô'} +%%\luatypoTwoChars{french}{'Je Tu Il On'} +% \end{macrocode} +% +%\iffalse +%</cfg> +% \fi +% +% \iffalse +%<*dtx> +% \fi +%% +%% \CharacterTable +%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z +%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z +%% Digits \0\1\2\3\4\5\6\7\8\9 +%% Exclamation \! Double quote \" Hash (number) \# +%% Dollar \$ Percent \% Ampersand \& +%% Acute accent \' Left paren \( Right paren \) +%% Asterisk \* Plus \+ Comma \, +%% Minus \- Point \. Solidus \/ +%% Colon \: Semicolon \; Less than \< +%% Equals \= Greater than \> Question mark \? +%% Commercial at \@ Left bracket \[ Backslash \\ +%% Right bracket \] Circumflex \^ Underscore \_ +%% Grave accent \` Left brace \{ Vertical bar \| +%% Right brace \} Tilde \~} +%% +% \iffalse +%</dtx> +% \fi +% +% \Finale +\endinput + +%%% Local Variables: +%%% fill-column: 72 +%%% coding: utf-8 +%%% TeX-engine: luatex +%%% End: |