diff options
author | Norbert Preining <norbert@preining.info> | 2023-07-24 03:04:00 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2023-07-24 03:04:00 +0000 |
commit | 19444d4440a66200b03e05b567996375d0404a46 (patch) | |
tree | 450f6790376fe84313c8b2840fe51307bcac2f9e /macros | |
parent | 8e64fc98a1773bc22a0f010f106d56a028e48597 (diff) |
CTAN sync 202307240303
Diffstat (limited to 'macros')
26 files changed, 1202 insertions, 678 deletions
diff --git a/macros/latex/contrib/create-theorem/README.md b/macros/latex/contrib/create-theorem/README.md index 5b741c38c5..c731811c3d 100644 --- a/macros/latex/contrib/create-theorem/README.md +++ b/macros/latex/contrib/create-theorem/README.md @@ -1,6 +1,6 @@ <!-- Copyright (C) 2021-2023 by Jinwen XU --> -# `create-theorem` - Initializing theorem-like environments with multilingual support +# `create-theorem` - Initializing and configuring theorem-like environments, with multilingual support The package `create-theorem` provides the commands `\NameTheorem`, `\CreateTheorem` and `\SetTheorem` for naming, initializing and configuring theorem-like environments. All of these commands have key-value based interface and are especially useful in multi-language documents, allowing the easy declaration of theorem-like environments that can automatically adapt to the language settings. diff --git a/macros/latex/contrib/create-theorem/create-theorem-doc.pdf b/macros/latex/contrib/create-theorem/create-theorem-doc.pdf Binary files differindex 977be9c913..7f2154adcb 100644 --- a/macros/latex/contrib/create-theorem/create-theorem-doc.pdf +++ b/macros/latex/contrib/create-theorem/create-theorem-doc.pdf diff --git a/macros/latex/contrib/create-theorem/create-theorem-doc.tex b/macros/latex/contrib/create-theorem/create-theorem-doc.tex index d7ef8a56d9..c61a73a87e 100644 --- a/macros/latex/contrib/create-theorem/create-theorem-doc.tex +++ b/macros/latex/contrib/create-theorem/create-theorem-doc.tex @@ -46,6 +46,7 @@ crefformat, crefthe,crefthename, Crefthe,Crefthename, + crefthevariantname,Crefthevariantname, crefthemark, selectlanguage, languagename, @@ -106,10 +107,10 @@ \begin{document} -\def\PackageVersion{2023/07/14} +\def\PackageVersion{2023/07/23} \def\PackageSubVersion{} -\title{\createtheorempackage{}\\\smallskip\itshape Initializing theorem-like environments with multilingual support} +\title{\createtheorempackage{}\\\smallskip\itshape Initializing and configuring theorem-like environments, with multilingual support} \author{Jinwen XU} \thanks{Corresponding to: \texttt{\createtheorempackage{} \PackageVersion\PackageSubVersion}} \date{\TheDate{\PackageVersion}[only-year-month], in Beijing} @@ -217,20 +218,32 @@ Supported keys are: \begin{code} [(*\meta{singular definite article}*)]{(*\meta{singular name}*)}[(*\meta{plural definite article}*)]{(*\meta{plural name}*)} \end{code} + This would be useful for languages like French, Italian, Spanish, etc. + \item Also supports the syntax of \lstinline|\crefthevariantname|, thus you can assign different set of names for different variants/declensions (the first line in the configuration is the default name set, which is used in case no variants is specified when referencing): +\begin{code} +(*\commandoption{crefname}*) = { + (*\meta{language name}*) = { [...]{...}[...]{...} + , (*\meta{variant 1}*) = [...]{...}[...]{...} + , (*\meta{variant 2}*) = [...]{...}[...]{...} + ... + } + } +\end{code} + This would be useful for languages like German, Russian, etc. \end{itemize} \item \commandoption{crefname style}\lstinline| = |\meta{style} \begin{itemize} - \item The style of the \textquote{crefname}, you can specify the font, text style, color, etc. + \item The style of \textquote{crefname} when referencing, you may specify the font, text style, color, etc. \item Synonymous names: \commandoption{crefname-style} \,$|$\, \commandoption{crefnamestyle} \end{itemize} \item \commandoption{Crefname}\lstinline| = |\meta{configuration} \begin{itemize} \item The name for \lstinline|\Cref| the environment, its syntax is the same as that of \commandoption{crefname}. - \item Also supports the syntax of \lstinline|\Crefthename|. + \item Also supports the syntax of \lstinline|\Crefthename| and \lstinline|\Crefthevariantname|. \end{itemize} \item \commandoption{Crefname style}\lstinline| = |\meta{style} \begin{itemize} - \item The style of the \textquote{Crefname}, you can specify the font, text style, color, etc. + \item The style of \textquote{Crefname} when referencing, you may specify the font, text style, color, etc. \item Synonymous names: \commandoption{Crefname-style} \,$|$\, \commandoption{Crefnamestyle} \end{itemize} \item \commandoption{numbering style}\lstinline| = |\meta{style} @@ -263,7 +276,6 @@ The syntax of \lstinline|\CreateTheorem| is as follows: When the \meta{key-value configuration} is empty, don't forget to include the second pair of curly brackets, for example, \lstinline|\CreateTheorem{theorem}{}|. \end{tip} -\enlargethispage{2\baselineskip} Supported keys are: \vspace{-.2\baselineskip} \begin{itemize}[label=,leftmargin=1.25em,itemindent=-1.25em] @@ -289,6 +301,7 @@ Supported keys are: \item If you are using \textsf{ntheorem} as the backend, then you need to load it with option \packageoption{thmmarks}. \item Synonymous names: \commandoption{qed symbol} \,$|$\, \commandoption{qed-symbol} \,$|$\, \commandoption{qedsymbol} \end{itemize} +\pagebreak \item \commandoption{parent counter}\lstinline| = |\meta{parent counter} \begin{itemize} \item Specifying the \meta{parent counter} for the current environment, \emph{i.e.}, numbering will restart whenever that sectional level is encountered. @@ -309,7 +322,6 @@ Supported keys are: \item It must be placed \emph{before} \commandoption{qed} if you want the starred version to have a Q.E.D symbol. \item Synonymous names: \commandoption{create-starred-version} \,$|$\, \commandoption{createstarredversion} \,$|$\, \\\phantom{Synonymous names: }\commandoption{create numberless version} \,$|$\, \commandoption{create-numberless-version}~\,$|$\\\phantom{Synonymous names: }\commandoption{createnumberlessversion} \end{itemize} -\pagebreak \item \commandoption{copy existed}\lstinline| = |\meta{existed environment} \begin{itemize} \item Defining the current environment to be the same as \meta{existed environment}. @@ -329,6 +341,7 @@ Supported keys are: \medskip Please note that, for the sake of generality, the environment \meta{env} and its starred relative \meta{env}\texttt{*} do \emph{not} share the same set of names when they are separately defined. However, with proper usage of \commandoption{create starred version} and \commandoption{copy existed}, you should already be able to produce all of the following combinations that shares the same set of names: 1$)$ numbered \meta{env}, numbered \meta{env}\texttt{*} ; 2$)$ numbered \meta{env}, unnumbered \meta{env}\texttt{*} ; 3$)$ unnumbered \meta{env}, numbered \meta{env}\texttt{*} ; and 4$)$ unnumbered \meta{env}, unnumbered \meta{env}\texttt{*}. I left it as an easy exercise for you ;-) +The answer can be found in section \labelcref{subsec:numbering}. \medskip \subsection[Configuring theorem-like environments]{Configuring theorem-like environments with \texttt{\textcolor{code-main}{\textbackslash SetTheorem}}} @@ -384,6 +397,7 @@ In some cases, you may define an internal environment (for example, a generic ve The command \lstinline|\NameTheorem| introduced earlier is for defining the names of a given environment for each language, which is more natural to use within a real-life document. However, for package/class authors wishing to maintain their language configuration files, it would be more convenient to use the following \lstinline|\NameTheorems|, which assigns the names for a given language all at once, made it possible to preset the names inside external files. +\enlargethispage*{\baselineskip} The syntax of \lstinline|\NameTheorems| is as follows (please note that the \meta{language name} here should be consistent with \lstinline|\languagename|): \begin{code} \NameTheorems{(*\meta{language name}*)}{(*\meta{key-value configuration}*)} @@ -409,15 +423,14 @@ Supported keys are (notice that you \emph{cannot} set the styles via \lstinline| (*\meta{name of environment}*) = {(*\meta{singular name}*)}{(*\meta{plural name}*)} } \end{code} - \item Also supports the syntax of \lstinline|\crefthename|, thus you can assign names of the form: -\begin{code} -[(*\meta{singular definite article}*)]{(*\meta{singular name}*)}[(*\meta{plural definite article}*)]{(*\meta{plural name}*)} -\end{code} + \item Also supports the syntax of \lstinline|\crefthename| and \lstinline|\crefthevariantname|.\\ + Please refer to the description of \lstinline|\NameTheorem| for more details. \end{itemize} \item \commandoption{Crefname}\lstinline| = |\meta{configuration} \begin{itemize} \item The names for \lstinline|\Cref| the environments, its syntax is the same as that of \commandoption{crefname}. - \item Also supports the syntax of \lstinline|\Crefthename|. + \item Also supports the syntax of \lstinline|\Crefthename| and \lstinline|\Crefthevariantname|.\\ + Please refer to the description of \lstinline|\NameTheorem| for more details. \end{itemize} \end{itemize} @@ -460,30 +473,51 @@ or to do it in one turn: \end{code} \smallskip -This is not exciting at all. Now, let's say we are writing a bilingual note in English and French. (I shall omit the \lstinline|\NameTheorem| version and do it all at once in \lstinline|\CreateTheorem|.) +This is not exciting at all. Now, let's say we are writing a trilingual note in English, French and German. (I shall omit the \lstinline|\NameTheorem| version and do it all at once in \lstinline|\CreateTheorem|.) \begin{code} \CreateTheorem{idea} { (*\commandoption{name}*) = { (*\commandoption{heading}*) = { english = Idea, - french = Idée, }, + french = Idée, + ngerman = Idee, }, (*\commandoption{crefname}*) = { english = {idea}{ideas}, - french = [l']{idée}[les]{idées}, }, + french = [l']{idée}[les]{idées}, + ngerman = { {Idee}{Idee} + , Nominativ = [die]{Idee}[die]{Ideen} + , Genitiv = [der]{Idee}[der]{Ideen} + , Dativ = [der]{Idee}[den]{Ideen} + , Akkusativ = [die]{Idee}[die]{Ideen} + } }, (*\commandoption{Crefname}*) = { english = {Idea}{Ideas}, - french = [L']{idée}[Les]{idées}, }, + french = [L']{idée}[Les]{idées}, + ngerman = { {Idee}{Idee} + , Nominativ = [Die]{Idee}[Die]{Ideen} + , Genitiv = [Der]{Idee}[Der]{Ideen} + , Dativ = [Der]{Idee}[Den]{Ideen} + , Akkusativ = [Die]{Idee}[Die]{Ideen} + } }, }, (*\commandoption{parent counter}*) = section, } \end{code} -With this, if you use \lstinline|\selectlanguage{french}|, the {\normalfont\texttt{idea}} environment shall be automatically displayed as \textquote{Idée}. And if you \lstinline|\crefthe| it, the definite article and the name showed up properly just as expected. +With this, if you use \lstinline|\selectlanguage{french}|, the {\normalfont\texttt{idea}} environment shall be automatically displayed as \textquote{Idée}. And if you \lstinline|\crefthe| it, the definite article and the name would show up properly just as expected. + +The same happens for German with \lstinline|\selectlanguage{ngerman}|, and when referencing an {\normalfont\texttt{idea}} environment, you may specify the declension as with \lstinline|\crefthe[|\meta{prep}\lstinline|,variant=Nominativ]{|\meta{label}\lstinline|}|, or simply with shortcut such as \lstinline|\crefthe[|\meta{prep}\lstinline|,nom.]{|\meta{label}\lstinline|}|. + +\begin{tip} + For more datailed usage of the referencing command \lstinline|\crefthe|, please refer to the documentation of the package \textsf{crefthe}. +\end{tip} -Next we shall deal with the problem of numbering. Let's continue to use this environment {\normalfont\texttt{idea}} for demonstration -- suppose that we have already set the names with \lstinline|\NameTheorem|. +\bigskip +Next we shall deal with the problem of numbering. Let's continue to use this environment {\normalfont\texttt{idea}} for demonstration --- suppose that we have already set the names with \lstinline|\NameTheorem|. \medskip \subsection{Let's play with numbering} +\label{subsec:numbering} Remember the exercise I left you in the previous section? Let's do it together now. @@ -535,13 +569,12 @@ This is essentially the combination of the first two cases --- we need to create \medskip In each case, the two environments {\normalfont\texttt{idea}} and {\normalfont\texttt{idea*}} share the same set of names. -\enlargethispage{\baselineskip} \begin{tip}[Attention] - The sole purpose of this section is to demonstrate the feature of this package -- some combinations are not recommended to use in the actual documents. + The sole purpose of this section is to demonstrate the feature of this package --- some combinations are not recommended to use in the actual documents. \end{tip} -\subsection{The \emph{proofless} version -- theorems with a Q.E.D. symbol} +\subsection{The \emph{proofless} version --- theorems with a Q.E.D. symbol} Sometimes you may encounter a theorem without a proof, in which case you might want a Q.E.D. symbol when the theorem is finished. This can be easily achieved via: @@ -628,7 +661,7 @@ A typical configuration looks like this: } \end{code} -Here is another example for French: +Here is an example for French: \begin{code} \NameTheorems { french } @@ -642,27 +675,56 @@ Here is another example for French: , (*\commandoption{crefname}*) = { , theorem = [le]{théorème}[les]{théorèmes} , proposition = [la]{proposition}[les]{propositions} - , example = [l']{example}[les]{examples} + , example = [l']{exemple}[les]{exemples} ... } , (*\commandoption{Crefname}*) = { , theorem = [Le]{théorème}[Les]{théorèmes} , proposition = [La]{proposition}[Les]{propositions} - , example = [L']{example}[Les]{examples} + , example = [L']{exemple}[Les]{exemples} + ... + } + } +\end{code} + +And an example for German: + +\begin{code} +\NameTheorems { ngerman } + { + , (*\commandoption{heading}*) = { + , theorem = Satz + ... + } + , (*\commandoption{crefname}*) = { + , theorem = { {Satz}{Sätze} + , Nominativ = [der]{Satz}[die]{Sätze} + , Genitiv = [des]{Satzes}[der]{Sätze} + , Dativ = [dem]{Satz}[den]{Sätzen} + , Akkusativ = [den]{Satz}[die]{Sätze} + } + ... + } + , (*\commandoption{Crefname}*) = { + , theorem = { {Satz}{Sätze} + , Nominativ = [Der]{Satz}[Die]{Sätze} + , Genitiv = [Des]{Satzes}[Der]{Sätze} + , Dativ = [Dem]{Satz}[Den]{Sätzen} + , Akkusativ = [Den]{Satz}[Die]{Sätze} + } ... } } \end{code} \medskip -The configuration using \lstinline|\NameTheorems| is compatible with that using \lstinline|\NameTheorem| and there is no need to worry about duplicated definitions -- new settings will automatically overwrite the old ones. +The configuration using \lstinline|\NameTheorems| is compatible with that using \lstinline|\NameTheorem| and there is no need to worry about duplicated definitions --- new settings will automatically overwrite the old ones. -\bigskip +\clearpage \section{Known issues} \begin{itemize} - \item The current mechanism does not work well for German, a problem originated in the package \textsf{crefthe}. The author plans to adopt a more refined approach in a later version so as to support the various grammatical situations in German. \item \createtheorempackage{} modifies some undocumented internal macros of \textsf{cleveref}, so the behaviour might not be stable if \textsf{cleveref} gets updated. \item The counter aliasing function is still not perfect, (sometimes) causing incorrect ordering in the result of \lstinline|\cref|. \item There might be inaccuracies in the translation of those preset names. diff --git a/macros/latex/contrib/create-theorem/create-theorem.sty b/macros/latex/contrib/create-theorem/create-theorem.sty index 7eefe80b81..a488ad7bc3 100644 --- a/macros/latex/contrib/create-theorem/create-theorem.sty +++ b/macros/latex/contrib/create-theorem/create-theorem.sty @@ -12,7 +12,7 @@ \NeedsTeXFormat{LaTeX2e}[2022-06-01] \ProvidesExplPackage {create-theorem} - {2023/07/14} {} + {2023/07/23} {} {Initializing theorem-like environments with multilingual support} \keys_define:nn { create-theorem } @@ -201,17 +201,31 @@ \cs_new:Nn \__crthm_set_name_crefname:nnn % #1 = env name % #2 = language name - % #3 = corresponding crefname {..}{..} or [..]{..}[..]{..} + % #3 = corresponding crefname {..}{..} or [..]{..}[..]{..}, or a set of crefnames for different variants { - \__crthm_set_name_crefname_generic:w { #1 } { #2 } #3 { c } + \str_if_in:nnTF { #3 } { = } + { + \crefthe_parse_variant:n { #3 } + \crefthe_pass_variant_to:n { \__crthm_set_name_crefname_generic:w { #1 } { #2 } } { c } + } + { + \__crthm_set_name_crefname_generic:w { #1 } { #2 } #3 { c } + } } \cs_new:Nn \__crthm_set_name_Crefname:nnn % #1 = env name % #2 = language name - % #3 = corresponding Crefname {..}{..} or [..]{..}[..]{..} + % #3 = corresponding Crefname {..}{..} or [..]{..}[..]{..}, or a set of crefnames for different variants { - \__crthm_set_name_crefname_generic:w { #1 } { #2 } #3 { C } + \str_if_in:nnTF { #3 } { = } + { + \crefthe_parse_variant:n { #3 } + \crefthe_pass_variant_to:n { \__crthm_set_name_crefname_generic:w { #1 } { #2 } } { C } + } + { + \__crthm_set_name_crefname_generic:w { #1 } { #2 } #3 { C } + } } \NewExpandableDocumentCommand \__crthm_set_name_crefname_generic:w { m m O{} m O{} m m } @@ -773,17 +787,31 @@ \cs_new:Nn \__crthm_set_name_per_lang_crefname:nnn % #1 = language name % #2 = env name - % #3 = corresponding crefname {..}{..} or [..]{..}[..]{..} + % #3 = corresponding crefname {..}{..} or [..]{..}[..]{..}, or a set of crefnames for different variants { - \__crthm_set_name_crefname_generic:w { #2 } { #1 } #3 { c } + \str_if_in:nnTF { #3 } { = } + { + \crefthe_parse_variant:n { #3 } + \crefthe_pass_variant_to:n { \__crthm_set_name_crefname_generic:w { #2 } { #1 } } { c } + } + { + \__crthm_set_name_crefname_generic:w { #2 } { #1 } #3 { c } + } } \cs_new:Nn \__crthm_set_name_per_lang_Crefname:nnn % #1 = language name % #2 = env name - % #3 = corresponding Crefname {..}{..} or [..]{..}[..]{..} + % #3 = corresponding Crefname {..}{..} or [..]{..}[..]{..}, or a set of crefnames for different variants { - \__crthm_set_name_crefname_generic:w { #2 } { #1 } #3 { C } + \str_if_in:nnTF { #3 } { = } + { + \crefthe_parse_variant:n { #3 } + \crefthe_pass_variant_to:n { \__crthm_set_name_crefname_generic:w { #2 } { #1 } } { C } + } + { + \__crthm_set_name_crefname_generic:w { #2 } { #1 } #3 { C } + } } @@ -1146,7 +1174,12 @@ , crefname = { , english = {application}{applications} , french = [l']{application}[les]{applications} - , ngerman = {Anwendung}{Anwendungen} + , ngerman = { {Anwendung}{Anwendungen} + , Nominativ = [die]{Anwendung}[die]{Anwendungen} + , Genitiv = [der]{Anwendung}[der]{Anwendungen} + , Dativ = [der]{Anwendung}[den]{Anwendungen} + , Akkusativ = [die]{Anwendung}[die]{Anwendungen} + } , italian = [l']{applicazione}[le]{applicazioni} , portuguese = [a]{aplicação}[as]{aplicações} , brazilian = [a]{aplicação}[as]{aplicações} @@ -1159,7 +1192,12 @@ , Crefname = { , english = {Application}{Applications} , french = [L']{application}[Les]{applications} - , ngerman = {Anwendung}{Anwendungen} + , ngerman = { {Anwendung}{Anwendungen} + , Nominativ = [Die]{Anwendung}[Die]{Anwendungen} + , Genitiv = [Der]{Anwendung}[Der]{Anwendungen} + , Dativ = [Der]{Anwendung}[Den]{Anwendungen} + , Akkusativ = [Die]{Anwendung}[Die]{Anwendungen} + } , italian = [L']{applicazione}[Le]{applicazioni} , portuguese = [A]{aplicação}[As]{aplicações} , brazilian = [A]{aplicação}[As]{aplicações} @@ -1176,7 +1214,7 @@ , heading = { , english = Assertion , french = Assertion - , ngerman = Behauptung + , ngerman = Assertion , italian = Asserzione , portuguese = Asserção , brazilian = Asserção @@ -1189,7 +1227,12 @@ , crefname = { , english = {assertion}{assertions} , french = [l']{assertion}[les]{assertions} - , ngerman = {Behauptung}{Behauptungen} + , ngerman = { {Assertion}{Assertionen} + , Nominativ = [die]{Assertion}[die]{Assertionen} + , Genitiv = [der]{Assertion}[der]{Assertionen} + , Dativ = [der]{Assertion}[den]{Assertionen} + , Akkusativ = [die]{Assertion}[die]{Assertionen} + } , italian = [l']{asserzione}[le]{asserzioni} , portuguese = [a]{asserção}[as]{asserções} , brazilian = [a]{asserção}[as]{asserções} @@ -1202,7 +1245,12 @@ , Crefname = { , english = {Assertion}{Assertions} , french = [L']{assertion}[Les]{assertions} - , ngerman = {Behauptung}{Behauptungen} + , ngerman = { {Assertion}{Assertionen} + , Nominativ = [Die]{Assertion}[Die]{Assertionen} + , Genitiv = [Der]{Assertion}[Der]{Assertionen} + , Dativ = [Der]{Assertion}[Den]{Assertionen} + , Akkusativ = [Die]{Assertion}[Die]{Assertionen} + } , italian = [L']{asserzione}[Le]{asserzioni} , portuguese = [A]{asserção}[As]{asserções} , brazilian = [A]{asserção}[As]{asserções} @@ -1232,7 +1280,12 @@ , crefname = { , english = {assumption}{assumptions} , french = [la]{supposition}[les]{suppositions} - , ngerman = {Annahme}{Annahmen} + , ngerman = { {Annahme}{Annahmen} + , Nominativ = [die]{Annahme}[die]{Annahmen} + , Genitiv = [der]{Annahme}[der]{Annahmen} + , Dativ = [der]{Annahme}[den]{Annahmen} + , Akkusativ = [die]{Annahme}[die]{Annahmen} + } , italian = [la]{supposizione}[le]{supposizioni} , portuguese = [a]{suposição}[as]{suposições} , brazilian = [a]{suposição}[as]{suposições} @@ -1245,7 +1298,12 @@ , Crefname = { , english = {Assumption}{Assumptions} , french = [La]{supposition}[Les]{suppositions} - , ngerman = {Annahme}{Annahmen} + , ngerman = { {Annahme}{Annahmen} + , Nominativ = [Die]{Annahme}[Die]{Annahmen} + , Genitiv = [Der]{Annahme}[Der]{Annahmen} + , Dativ = [Der]{Annahme}[Den]{Annahmen} + , Akkusativ = [Die]{Annahme}[Die]{Annahmen} + } , italian = [la]{supposizione}[le]{supposizioni} , portuguese = [A]{suposição}[As]{suposições} , brazilian = [A]{suposição}[As]{suposições} @@ -1275,7 +1333,12 @@ , crefname = { , english = {axiom}{axioms} , french = [l']{axiome}[les]{axiomes} - , ngerman = {Axiom}{Axiome} + , ngerman = { {Axiom}{Axiome} + , Nominativ = [das]{Axiom}[die]{Axiome} + , Genitiv = [des]{Axioms}[der]{Axiome} + , Dativ = [dem]{Axiom}[den]{Axiomen} + , Akkusativ = [das]{Axiom}[die]{Axiome} + } , italian = [l']{assioma}[gli]{assiomi} , portuguese = [o]{axioma}[os]{axiomas} , brazilian = [o]{axioma}[os]{axiomas} @@ -1288,7 +1351,12 @@ , Crefname = { , english = {Axiom}{Axioms} , french = [L']{axiome}[Les]{axiomes} - , ngerman = {Axiom}{Axiome} + , ngerman = { {Axiom}{Axiome} + , Nominativ = [Das]{Axiom}[Die]{Axiome} + , Genitiv = [Des]{Axioms}[Der]{Axiome} + , Dativ = [Dem]{Axiom}[Den]{Axiomen} + , Akkusativ = [Das]{Axiom}[Die]{Axiome} + } , italian = [L']{assioma}[Gli]{assiomi} , portuguese = [O]{axioma}[Os]{axiomas} , brazilian = [O]{axioma}[Os]{axiomas} @@ -1305,7 +1373,7 @@ , heading = { , english = Claim , french = Affirmation - , ngerman = Affirmation + , ngerman = Behauptung , italian = Affermazione , portuguese = Afirmação , brazilian = Afirmação @@ -1318,7 +1386,12 @@ , crefname = { , english = {claim}{claims} , french = [l']{affirmation}[les]{affirmations} - , ngerman = {Affirmation}{Affirmationen} + , ngerman = { {Behauptung}{Behauptungen} + , Nominativ = [die]{Behauptung}[die]{Behauptungen} + , Genitiv = [der]{Behauptung}[der]{Behauptungen} + , Dativ = [der]{Behauptung}[den]{Behauptungen} + , Akkusativ = [die]{Behauptung}[die]{Behauptungen} + } , italian = [l']{affermazione}[le]{affermazioni} , portuguese = [a]{afirmação}[as]{afirmações} , brazilian = [a]{afirmação}[as]{afirmações} @@ -1331,7 +1404,12 @@ , Crefname = { , english = {Claim}{Claims} , french = [L']{affirmation}[Les]{affirmations} - , ngerman = {Affirmation}{Affirmationen} + , ngerman = { {Behauptung}{Behauptungen} + , Nominativ = [Die]{Behauptung}[Die]{Behauptungen} + , Genitiv = [Der]{Behauptung}[Der]{Behauptungen} + , Dativ = [Der]{Behauptung}[Den]{Behauptungen} + , Akkusativ = [Die]{Behauptung}[Die]{Behauptungen} + } , italian = [L']{affermazione}[Le]{affermazioni} , portuguese = [A]{afirmação}[As]{afirmações} , brazilian = [A]{afirmação}[As]{afirmações} @@ -1361,7 +1439,12 @@ , crefname = { , english = {conclusion}{conclusions} , french = [la]{conclusion}[Les]{conclusions} - , ngerman = {Schlussfolgerung}{Schlussfolgerungen} + , ngerman = { {Schlussfolgerung}{Schlussfolgerungen} + , Nominativ = [die]{Schlussfolgerung}[die]{Schlussfolgerungen} + , Genitiv = [der]{Schlussfolgerung}[der]{Schlussfolgerungen} + , Dativ = [der]{Schlussfolgerung}[den]{Schlussfolgerungen} + , Akkusativ = [die]{Schlussfolgerung}[die]{Schlussfolgerungen} + } , italian = [la]{conclusione}[le]{conclusioni} , portuguese = [a]{conclusão}[as]{conclusões} , brazilian = [a]{conclusão}[as]{conclusões} @@ -1374,7 +1457,12 @@ , Crefname = { , english = {Conclusion}{Conclusions} , french = [La]{conclusion}[Les]{conclusions} - , ngerman = {Schlussfolgerung}{Schlussfolgerungen} + , ngerman = { {Schlussfolgerung}{Schlussfolgerungen} + , Nominativ = [Die]{Schlussfolgerung}[Die]{Schlussfolgerungen} + , Genitiv = [Der]{Schlussfolgerung}[Der]{Schlussfolgerungen} + , Dativ = [Der]{Schlussfolgerung}[Den]{Schlussfolgerungen} + , Akkusativ = [Die]{Schlussfolgerung}[Die]{Schlussfolgerungen} + } , italian = [La]{conclusione}[Le]{conclusioni} , portuguese = [A]{conclusão}[As]{conclusões} , brazilian = [A]{conclusão}[As]{conclusões} @@ -1404,7 +1492,12 @@ , crefname = { , english = {conjecture}{conjectures} , french = [la]{conjecture}[les]{conjectures} - , ngerman = {Vermutung}{Vermutungen} + , ngerman = { {Vermutung}{Vermutungen} + , Nominativ = [die]{Vermutung}[die]{Vermutungen} + , Genitiv = [der]{Vermutung}[der]{Vermutungen} + , Dativ = [der]{Vermutung}[den]{Vermutungen} + , Akkusativ = [die]{Vermutung}[die]{Vermutungen} + } , italian = [la]{congettura}[le]{congetture} , portuguese = [a]{conjetura}[as]{conjeturas} , brazilian = [a]{conjectura}[as]{conjecturas} @@ -1417,7 +1510,12 @@ , Crefname = { , english = {Conjecture}{Conjectures} , french = [La]{conjecture}[Les]{conjectures} - , ngerman = {Vermutung}{Vermutungen} + , ngerman = { {Vermutung}{Vermutungen} + , Nominativ = [Die]{Vermutung}[Die]{Vermutungen} + , Genitiv = [Der]{Vermutung}[Der]{Vermutungen} + , Dativ = [Der]{Vermutung}[Den]{Vermutungen} + , Akkusativ = [Die]{Vermutung}[Die]{Vermutungen} + } , italian = [La]{congettura}[Le]{congetture} , portuguese = [A]{conjetura}[As]{conjeturas} , brazilian = [A]{conjectura}[As]{conjecturas} @@ -1447,7 +1545,12 @@ , crefname = { , english = {construction}{constructions} , french = [la]{construction}[les]{constructions} - , ngerman = {Konstruktion}{Konstruktionen} + , ngerman = { {Konstruktion}{Konstruktionen} + , Nominativ = [die]{Konstruktion}[die]{Konstruktionen} + , Genitiv = [der]{Konstruktion}[der]{Konstruktionen} + , Dativ = [der]{Konstruktion}[den]{Konstruktionen} + , Akkusativ = [die]{Konstruktion}[die]{Konstruktionen} + } , italian = [la]{costruzione}[le]{costruzioni} , portuguese = [a]{construção}[as]{construções} , brazilian = [a]{construção}[as]{construções} @@ -1460,7 +1563,12 @@ , Crefname = { , english = {Construction}{Constructions} , french = [La]{construction}[Les]{constructions} - , ngerman = {Konstruktion}{Konstruktionen} + , ngerman = { {Konstruktion}{Konstruktionen} + , Nominativ = [Die]{Konstruktion}[Die]{Konstruktionen} + , Genitiv = [Der]{Konstruktion}[Der]{Konstruktionen} + , Dativ = [Der]{Konstruktion}[Den]{Konstruktionen} + , Akkusativ = [Die]{Konstruktion}[Die]{Konstruktionen} + } , italian = [La]{costruzione}[Le]{costruzioni} , portuguese = [A]{construção}[As]{construções} , brazilian = [A]{construção}[As]{construções} @@ -1490,7 +1598,12 @@ , crefname = { , english = {convention}{conventions} , french = [la]{convention}[les]{conventions} - , ngerman = {Konvention}{Konventionen} + , ngerman = { {Konvention}{Konventionen} + , Nominativ = [die]{Konvention}[die]{Konventionen} + , Genitiv = [der]{Konvention}[der]{Konventionen} + , Dativ = [der]{Konvention}[den]{Konventionen} + , Akkusativ = [die]{Konvention}[die]{Konventionen} + } , italian = [la]{convenzione}[le]{convenzioni} , portuguese = [a]{convenção}[as]{convenções} , brazilian = [a]{convenção}[as]{convenções} @@ -1503,7 +1616,12 @@ , Crefname = { , english = {Convention}{Conventions} , french = [La]{convention}[Les]{conventions} - , ngerman = {Konvention}{Konventionen} + , ngerman = { {Konvention}{Konventionen} + , Nominativ = [Die]{Konvention}[Die]{Konventionen} + , Genitiv = [Der]{Konvention}[Der]{Konventionen} + , Dativ = [Der]{Konvention}[Den]{Konventionen} + , Akkusativ = [Die]{Konvention}[Die]{Konventionen} + } , italian = [La]{convenzione}[Le]{convenzioni} , portuguese = [A]{convenção}[As]{convenções} , brazilian = [A]{convenção}[As]{convenções} @@ -1533,7 +1651,12 @@ , crefname = { , english = {corollary}{corollaries} , french = [le]{corollaire}[les]{corollaires} - , ngerman = {Korollar}{Korollare} + , ngerman = { {Korollar}{Korollare} + , Nominativ = [das]{Korollar}[die]{Korollare} + , Genitiv = [des]{Korollars}[der]{Korollare} + , Dativ = [dem]{Korollar}[den]{Korollaren} + , Akkusativ = [das]{Korollar}[die]{Korollare} + } , italian = [il]{corollario}[i]{corollari} , portuguese = [o]{corolário}[os]{corolários} , brazilian = [o]{corolário}[os]{corolários} @@ -1546,7 +1669,12 @@ , Crefname = { , english = {Corollary}{Corollaries} , french = [Le]{corollaire}[Les]{corollaires} - , ngerman = {Korollar}{Korollare} + , ngerman = { {Korollar}{Korollare} + , Nominativ = [Das]{Korollar}[Die]{Korollare} + , Genitiv = [Des]{Korollars}[Der]{Korollare} + , Dativ = [Dem]{Korollar}[Den]{Korollaren} + , Akkusativ = [Das]{Korollar}[Die]{Korollare} + } , italian = [Il]{corollario}[I]{corollari} , portuguese = [O]{corolário}[Os]{corolários} , brazilian = [O]{corolário}[Os]{corolários} @@ -1576,7 +1704,12 @@ , crefname = { , english = {definition}{definitions} , french = [la]{définition}[les]{définitions} - , ngerman = {Definition}{Definitionen} + , ngerman = { {Definition}{Definitionen} + , Nominativ = [die]{Definition}[die]{Definitionen} + , Genitiv = [der]{Definition}[der]{Definitionen} + , Dativ = [der]{Definition}[den]{Definitionen} + , Akkusativ = [die]{Definition}[die]{Definitionen} + } , italian = [la]{definizione}[le]{definizioni} , portuguese = [a]{definição}[as]{definições} , brazilian = [a]{definição}[as]{definições} @@ -1589,7 +1722,12 @@ , Crefname = { , english = {Definition}{Definitions} , french = [La]{définition}[Les]{définitions} - , ngerman = {Definition}{Definitionen} + , ngerman = { {Definition}{Definitionen} + , Nominativ = [Die]{Definition}[Die]{Definitionen} + , Genitiv = [Der]{Definition}[Der]{Definitionen} + , Dativ = [Der]{Definition}[Den]{Definitionen} + , Akkusativ = [Die]{Definition}[Die]{Definitionen} + } , italian = [La]{definizione}[Le]{definizioni} , portuguese = [A]{definição}[As]{definições} , brazilian = [A]{definição}[As]{definições} @@ -1619,7 +1757,12 @@ , crefname = { , english = {example}{examples} , french = [l']{exemple}[les]{exemples} - , ngerman = {Beispiel}{Beispiele} + , ngerman = { {Beispiel}{Beispiele} + , Nominativ = [das]{Beispiel}[die]{Beispiele} + , Genitiv = [des]{Beispiels}[der]{Beispiele} + , Dativ = [dem]{Beispiel}[den]{Beispielen} + , Akkusativ = [das]{Beispiel}[die]{Beispiele} + } , italian = [l']{esempio}[gli]{esempi} , portuguese = [o]{exemplo}[os]{exemplos} , brazilian = [o]{exemplo}[os]{exemplos} @@ -1632,7 +1775,12 @@ , Crefname = { , english = {Example}{Examples} , french = [L']{exemple}[Les]{exemples} - , ngerman = {Beispiel}{Beispiele} + , ngerman = { {Beispiel}{Beispiele} + , Nominativ = [Das]{Beispiel}[Die]{Beispiele} + , Genitiv = [Des]{Beispiels}[Der]{Beispiele} + , Dativ = [Dem]{Beispiel}[Den]{Beispielen} + , Akkusativ = [Das]{Beispiel}[Die]{Beispiele} + } , italian = [L']{esempio}[Gli]{esempi} , portuguese = [O]{exemplo}[Os]{exemplos} , brazilian = [O]{exemplo}[Os]{exemplos} @@ -1662,7 +1810,12 @@ , crefname = { , english = {exercise}{exercises} , french = [l']{exercice}[les]{exercices} - , ngerman = {Übung}{Übungen} + , ngerman = { {Übung}{Übungen} + , Nominativ = [die]{Übung}[die]{Übungen} + , Genitiv = [der]{Übung}[der]{Übungen} + , Dativ = [der]{Übung}[den]{Übungen} + , Akkusativ = [die]{Übung}[die]{Übungen} + } , italian = [l']{esercizio}[gli]{esercizi} , portuguese = [o]{exercício}[os]{exercícios} , brazilian = [o]{exercício}[os]{exercícios} @@ -1675,7 +1828,12 @@ , Crefname = { , english = {Exercise}{Exercises} , french = [L']{exercice}[Les]{exercices} - , ngerman = {Übung}{Übungen} + , ngerman = { {Übung}{Übungen} + , Nominativ = [Die]{Übung}[Die]{Übungen} + , Genitiv = [Der]{Übung}[Der]{Übungen} + , Dativ = [Der]{Übung}[Den]{Übungen} + , Akkusativ = [Die]{Übung}[Die]{Übungen} + } , italian = [L']{esercizio}[Gli]{esercizi} , portuguese = [O]{exercício}[Os]{exercícios} , brazilian = [O]{exercício}[Os]{exercícios} @@ -1692,7 +1850,7 @@ , heading = { , english = Fact , french = Fait - , ngerman = Fakt + , ngerman = Tatsache , italian = Fatto , portuguese = Facto , brazilian = Fato @@ -1705,7 +1863,12 @@ , crefname = { , english = {fact}{facts} , french = [le]{fait}[les]{faits} - , ngerman = {Fakt}{Fakten} + , ngerman = { {Tatsache}{Tatsachen} + , Nominativ = [die]{Tatsache}[die]{Tatsachen} + , Genitiv = [der]{Tatsache}[der]{Tatsachen} + , Dativ = [der]{Tatsache}[den]{Tatsachen} + , Akkusativ = [die]{Tatsache}[die]{Tatsachen} + } , italian = [il]{fatto}[i]{fatti} , portuguese = [o]{facto}[os]{factos} , brazilian = [o]{fato}[os]{fatos} @@ -1718,7 +1881,12 @@ , Crefname = { , english = {Fact}{Facts} , french = [Le]{fait}[Les]{faits} - , ngerman = {Fakt}{Fakten} + , ngerman = { {Tatsache}{Tatsachen} + , Nominativ = [Die]{Tatsache}[Die]{Tatsachen} + , Genitiv = [Der]{Tatsache}[Der]{Tatsachen} + , Dativ = [Der]{Tatsache}[Den]{Tatsachen} + , Akkusativ = [Die]{Tatsache}[Die]{Tatsachen} + } , italian = [Il]{fatto}[I]{fatti} , portuguese = [O]{facto}[Os]{factos} , brazilian = [O]{fato}[Os]{fatos} @@ -1748,7 +1916,12 @@ , crefname = { , english = {hypothesis}{hypotheses} , french = [l']{hypothèse}[les]{hypothèses} - , ngerman = {Hypothese}{Hypothesen} + , ngerman = { {Hypothese}{Hypothesen} + , Nominativ = [die]{Hypothese}[die]{Hypothesen} + , Genitiv = [der]{Hypothese}[der]{Hypothesen} + , Dativ = [der]{Hypothese}[den]{Hypothesen} + , Akkusativ = [die]{Hypothese}[die]{Hypothesen} + } , italian = [l']{ipotesi}[le]{ipotesi} , portuguese = [a]{hipótese}[as]{hipóteses} , brazilian = [a]{hipótese}[as]{hipóteses} @@ -1761,7 +1934,12 @@ , Crefname = { , english = {Hypothesis}{Hypotheses} , french = [L']{hypothèse}[Les]{hypothèses} - , ngerman = {Hypothese}{Hypothesen} + , ngerman = { {Hypothese}{Hypothesen} + , Nominativ = [Die]{Hypothese}[Die]{Hypothesen} + , Genitiv = [Der]{Hypothese}[Der]{Hypothesen} + , Dativ = [Der]{Hypothese}[Den]{Hypothesen} + , Akkusativ = [Die]{Hypothese}[Die]{Hypothesen} + } , italian = [L']{ipotesi}[Le]{ipotesi} , portuguese = [A]{hipótese}[As]{hipóteses} , brazilian = [A]{hipótese}[As]{hipóteses} @@ -1791,7 +1969,12 @@ , crefname = { , english = {lemma}{Lemmas} , french = [le]{lemme}[les]{lemmes} - , ngerman = {Lemma}{Lemmata} + , ngerman = { {Lemma}{Lemmata} + , Nominativ = [das]{Lemma}[die]{Lemmata} + , Genitiv = [des]{Lemmas}[der]{Lemmata} + , Dativ = [dem]{Lemma}[den]{Lemmata} + , Akkusativ = [das]{Lemma}[die]{Lemmata} + } , italian = [il]{lemma}[i]{lemmi} , portuguese = [o]{lema}[os]{lemas} , brazilian = [o]{lema}[os]{lemas} @@ -1804,7 +1987,12 @@ , Crefname = { , english = {Lemma}{Lemmas} , french = [Le]{lemme}[Les]{lemmes} - , ngerman = {Lemma}{Lemmata} + , ngerman = { {Lemma}{Lemmata} + , Nominativ = [Das]{Lemma}[Die]{Lemmata} + , Genitiv = [Des]{Lemmas}[Der]{Lemmata} + , Dativ = [Dem]{Lemma}[Den]{Lemmata} + , Akkusativ = [Das]{Lemma}[Die]{Lemmata} + } , italian = [Il]{lemma}[I]{lemmi} , portuguese = [O]{lema}[Os]{lemas} , brazilian = [O]{lema}[Os]{lemas} @@ -1834,7 +2022,12 @@ , crefname = { , english = {notation}{notations} , french = [la]{notation}[les]{notations} - , ngerman = {Notation}{Notationen} + , ngerman = { {Notation}{Notationen} + , Nominativ = [die]{Notation}[die]{Notationen} + , Genitiv = [der]{Notation}[der]{Notationen} + , Dativ = [der]{Notation}[den]{Notationen} + , Akkusativ = [die]{Notation}[die]{Notationen} + } , italian = [la]{notazione}[le]{notazioni} , portuguese = [a]{notação}[as]{notações} , brazilian = [a]{notação}[as]{notações} @@ -1847,7 +2040,12 @@ , Crefname = { , english = {Notation}{Notations} , french = [La]{notation}[Les]{notations} - , ngerman = {Notation}{Notationen} + , ngerman = { {Notation}{Notationen} + , Nominativ = [Die]{Notation}[Die]{Notationen} + , Genitiv = [Der]{Notation}[Der]{Notationen} + , Dativ = [Der]{Notation}[Den]{Notationen} + , Akkusativ = [Die]{Notation}[Die]{Notationen} + } , italian = [La]{notazione}[Le]{notazioni} , portuguese = [A]{notação}[As]{notações} , brazilian = [A]{notação}[As]{notações} @@ -1877,7 +2075,12 @@ , crefname = { , english = {observation}{observations} , french = [la]{observation}[les]{observations} - , ngerman = {Beobachtung}{Beobachtungen} + , ngerman = { {Beobachtung}{Beobachtungen} + , Nominativ = [die]{Beobachtung}[die]{Beobachtungen} + , Genitiv = [der]{Beobachtung}[der]{Beobachtungen} + , Dativ = [der]{Beobachtung}[den]{Beobachtungen} + , Akkusativ = [die]{Beobachtung}[die]{Beobachtungen} + } , italian = [l']{osservazione}[le]{osservazioni} , portuguese = [a]{observação}[as]{observações} , brazilian = [a]{observação}[as]{observações} @@ -1890,7 +2093,12 @@ , Crefname = { , english = {Observation}{Observations} , french = [La]{observation}[Les]{observations} - , ngerman = {Beobachtung}{Beobachtungen} + , ngerman = { {Beobachtung}{Beobachtungen} + , Nominativ = [Die]{Beobachtung}[Die]{Beobachtungen} + , Genitiv = [Der]{Beobachtung}[Der]{Beobachtungen} + , Dativ = [Der]{Beobachtung}[Den]{Beobachtungen} + , Akkusativ = [Die]{Beobachtung}[Die]{Beobachtungen} + } , italian = [L']{osservazione}[Le]{osservazioni} , portuguese = [A]{observação}[As]{observações} , brazilian = [A]{observação}[As]{observações} @@ -1920,7 +2128,12 @@ , crefname = { , english = {postulate}{postulates} , french = [le]{postulat}[les]{postulats} - , ngerman = {Postulat}{Postulate} + , ngerman = { {Postulat}{Postulate} + , Nominativ = [das]{Postulat}[die]{Postulate} + , Genitiv = [des]{Postulates}[der]{Postulate} + , Dativ = [dem]{Postulat}[den]{Postulaten} + , Akkusativ = [das]{Postulat}[die]{Postulate} + } , italian = [il]{postulato}[i]{postulati} , portuguese = [o]{postulado}[os]{postulados} , brazilian = [o]{postulado}[os]{postulados} @@ -1933,7 +2146,12 @@ , Crefname = { , english = {Postulate}{Postulates} , french = [Le]{postulat}[Les]{postulats} - , ngerman = {Postulat}{Postulate} + , ngerman = { {Postulat}{Postulate} + , Nominativ = [Das]{Postulat}[Die]{Postulate} + , Genitiv = [Des]{Postulates}[Der]{Postulate} + , Dativ = [Dem]{Postulat}[Den]{Postulaten} + , Akkusativ = [Das]{Postulat}[Die]{Postulate} + } , italian = [Il]{postulato}[I]{postulati} , portuguese = [O]{postulado}[Os]{postulados} , brazilian = [O]{postulado}[Os]{postulados} @@ -1963,7 +2181,12 @@ , crefname = { , english = {problem}{problems} , french = [le]{problème}[les]{problèmes} - , ngerman = {Problem}{Probleme} + , ngerman = { {Problem}{Probleme} + , Nominativ = [das]{Problem}[die]{Probleme} + , Genitiv = [des]{Problems}[der]{Probleme} + , Dativ = [dem]{Problem}[den]{Problemen} + , Akkusativ = [das]{Problem}[die]{Probleme} + } , italian = [il]{problema}[i]{problemi} , portuguese = [o]{problema}[os]{problemas} , brazilian = [o]{problema}[os]{problemas} @@ -1976,7 +2199,12 @@ , Crefname = { , english = {Problem}{Problems} , french = [Le]{problème}[Les]{problèmes} - , ngerman = {Problem}{Probleme} + , ngerman = { {Problem}{Probleme} + , Nominativ = [Das]{Problem}[Die]{Probleme} + , Genitiv = [Des]{Problems}[Der]{Probleme} + , Dativ = [Dem]{Problem}[Den]{Problemen} + , Akkusativ = [Das]{Problem}[Die]{Probleme} + } , italian = [Il]{problema}[I]{problemi} , portuguese = [O]{problema}[Os]{problemas} , brazilian = [O]{problema}[Os]{problemas} @@ -2006,7 +2234,12 @@ , crefname = { , english = {property}{properties} , french = [la]{propriété}[les]{propriétés} - , ngerman = {Eigenschaft}{Eigenschaften} + , ngerman = { {Eigenschaft}{Eigenschaften} + , Nominativ = [die]{Eigenschaft}[die]{Eigenschaften} + , Genitiv = [der]{Eigenschaft}[der]{Eigenschaften} + , Dativ = [der]{Eigenschaft}[den]{Eigenschaften} + , Akkusativ = [die]{Eigenschaft}[die]{Eigenschaften} + } , italian = [la]{proprietà}[le]{proprietà} , portuguese = [a]{propriedade}[as]{propriedades} , brazilian = [a]{propriedade}[as]{propriedades} @@ -2019,7 +2252,12 @@ , Crefname = { , english = {Property}{Properties} , french = [La]{propriété}[Les]{propriétés} - , ngerman = {Eigenschaft}{Eigenschaften} + , ngerman = { {Eigenschaft}{Eigenschaften} + , Nominativ = [Die]{Eigenschaft}[Die]{Eigenschaften} + , Genitiv = [Der]{Eigenschaft}[Der]{Eigenschaften} + , Dativ = [Der]{Eigenschaft}[Den]{Eigenschaften} + , Akkusativ = [Die]{Eigenschaft}[Die]{Eigenschaften} + } , italian = [La]{proprietà}[Le]{proprietà} , portuguese = [A]{propriedade}[As]{propriedades} , brazilian = [A]{propriedade}[As]{propriedades} @@ -2049,7 +2287,12 @@ , crefname = { , english = {proposition}{propositions} , french = [la]{proposition}[les]{propositions} - , ngerman = {Proposition}{Propositionen} + , ngerman = { {Proposition}{Propositionen} + , Nominativ = [die]{Proposition}[die]{Propositionen} + , Genitiv = [der]{Proposition}[der]{Propositionen} + , Dativ = [der]{Proposition}[den]{Propositionen} + , Akkusativ = [die]{Proposition}[die]{Propositionen} + } , italian = [la]{proposizione}[le]{proposte} , portuguese = [a]{proposição}[as]{proposições} , brazilian = [a]{proposição}[as]{proposições} @@ -2062,7 +2305,12 @@ , Crefname = { , english = {Proposition}{Propositions} , french = [La]{proposition}[Les]{propositions} - , ngerman = {Proposition}{Propositionen} + , ngerman = { {Proposition}{Propositionen} + , Nominativ = [Die]{Proposition}[Die]{Propositionen} + , Genitiv = [Der]{Proposition}[Der]{Propositionen} + , Dativ = [Der]{Proposition}[Den]{Propositionen} + , Akkusativ = [Die]{Proposition}[Die]{Propositionen} + } , italian = [La]{proposizione}[Le]{proposte} , portuguese = [A]{proposição}[As]{proposições} , brazilian = [A]{proposição}[As]{proposições} @@ -2092,7 +2340,12 @@ , crefname = { , english = {question}{questions} , french = [la]{question}[les]{questions} - , ngerman = {Frage}{Fragen} + , ngerman = { {Frage}{Fragen} + , Nominativ = [die]{Frage}[die]{Fragen} + , Genitiv = [der]{Frage}[der]{Fragen} + , Dativ = [der]{Frage}[den]{Fragen} + , Akkusativ = [die]{Frage}[die]{Fragen} + } , italian = [la]{domanda}[le]{domande} , portuguese = [a]{pergunta}[as]{perguntas} , brazilian = [a]{pergunta}[as]{perguntas} @@ -2105,7 +2358,12 @@ , Crefname = { , english = {Question}{Questions} , french = [La]{question}[Les]{questions} - , ngerman = {Frage}{Fragen} + , ngerman = { {Frage}{Fragen} + , Nominativ = [Die]{Frage}[Die]{Fragen} + , Genitiv = [Der]{Frage}[Der]{Fragen} + , Dativ = [Der]{Frage}[Den]{Fragen} + , Akkusativ = [Die]{Frage}[Die]{Fragen} + } , italian = [La]{domanda}[Le]{domande} , portuguese = [A]{pergunta}[As]{perguntas} , brazilian = [A]{pergunta}[As]{perguntas} @@ -2122,7 +2380,7 @@ , heading = { , english = Recall , french = Rappel - , ngerman = Rückruf + , ngerman = Erinnerung , italian = Richiamo , portuguese = Recordação , brazilian = Recordação @@ -2135,7 +2393,12 @@ , crefname = { , english = {recall}{recalls} , french = [le]{rappel}[les]{rappels} - , ngerman = {Rückruf}{Rückrufe} + , ngerman = { {Erinnerung}{Erinnerungen} + , Nominativ = [die]{Erinnerung}[die]{Erinnerungen} + , Genitiv = [der]{Erinnerung}[der]{Erinnerungen} + , Dativ = [der]{Erinnerung}[den]{Erinnerungen} + , Akkusativ = [die]{Erinnerung}[die]{Erinnerungen} + } , italian = [il]{richiamo}[i]{richiami} , portuguese = [a]{recordação}[as]{recordações} , brazilian = [a]{recordação}[as]{recordações} @@ -2148,7 +2411,12 @@ , Crefname = { , english = {Recall}{Recalls} , french = [Le]{rappel}[Les]{rappels} - , ngerman = {Rückruf}{Rückrufe} + , ngerman = { {Erinnerung}{Erinnerungen} + , Nominativ = [Die]{Erinnerung}[Die]{Erinnerungen} + , Genitiv = [Der]{Erinnerung}[Der]{Erinnerungen} + , Dativ = [Der]{Erinnerung}[Den]{Erinnerungen} + , Akkusativ = [Die]{Erinnerung}[Die]{Erinnerungen} + } , italian = [Il]{richiamo}[I]{richiami} , portuguese = [A]{recordação}[As]{recordações} , brazilian = [A]{recordação}[As]{recordações} @@ -2178,7 +2446,12 @@ , crefname = { , english = {remark}{remarks} , french = [la]{remarque}[les]{remarques} - , ngerman = {Bemerkung}{Bemerkungen} + , ngerman = { {Bemerkung}{Bemerkungen} + , Nominativ = [die]{Bemerkung}[die]{Bemerkungen} + , Genitiv = [der]{Bemerkung}[der]{Bemerkungen} + , Dativ = [der]{Bemerkung}[den]{Bemerkungen} + , Akkusativ = [die]{Bemerkung}[die]{Bemerkungen} + } , italian = [il]{commento}[i]{commenti} , portuguese = [o]{comentário}[os]{comentários} , brazilian = [o]{comentário}[os]{comentários} @@ -2191,7 +2464,12 @@ , Crefname = { , english = {Remark}{Remarks} , french = [La]{remarque}[Les]{remarques} - , ngerman = {Bemerkung}{Bemerkungen} + , ngerman = { {Bemerkung}{Bemerkungen} + , Nominativ = [Die]{Bemerkung}[Die]{Bemerkungen} + , Genitiv = [Der]{Bemerkung}[Der]{Bemerkungen} + , Dativ = [Der]{Bemerkung}[Den]{Bemerkungen} + , Akkusativ = [Die]{Bemerkung}[Die]{Bemerkungen} + } , italian = [Il]{commento}[I]{commenti} , portuguese = [O]{comentário}[Os]{comentários} , brazilian = [O]{comentário}[Os]{comentários} @@ -2221,7 +2499,12 @@ , crefname = { , english = {theorem}{theorems} , french = [le]{théorème}[les]{théorèmes} - , ngerman = {Satz}{Sätze} + , ngerman = { {Satz}{Sätze} + , Nominativ = [der]{Satz}[die]{Sätze} + , Genitiv = [des]{Satzes}[der]{Sätze} + , Dativ = [dem]{Satz}[den]{Sätzen} + , Akkusativ = [den]{Satz}[die]{Sätze} + } , italian = [il]{teorema}[i]{teoremi} , portuguese = [o]{teorema}[os]{teoremas} , brazilian = [o]{teorema}[os]{teoremas} @@ -2234,7 +2517,12 @@ , Crefname = { , english = {Theorem}{Theorems} , french = [Le]{théorème}[Les]{théorèmes} - , ngerman = {Satz}{Sätze} + , ngerman = { {Satz}{Sätze} + , Nominativ = [Der]{Satz}[Die]{Sätze} + , Genitiv = [Des]{Satzes}[Der]{Sätze} + , Dativ = [Dem]{Satz}[Den]{Sätzen} + , Akkusativ = [Den]{Satz}[Die]{Sätze} + } , italian = [Il]{teorema}[I]{teoremi} , portuguese = [O]{teorema}[Os]{teoremas} , brazilian = [O]{teorema}[Os]{teoremas} diff --git a/macros/latex/contrib/crefthe/crefthe-doc.pdf b/macros/latex/contrib/crefthe/crefthe-doc.pdf Binary files differindex 3cc6dce323..8731eb2d97 100644 --- a/macros/latex/contrib/crefthe/crefthe-doc.pdf +++ b/macros/latex/contrib/crefthe/crefthe-doc.pdf diff --git a/macros/latex/contrib/crefthe/crefthe-doc.tex b/macros/latex/contrib/crefthe/crefthe-doc.tex index 82d7460683..904cb5eee7 100644 --- a/macros/latex/contrib/crefthe/crefthe-doc.tex +++ b/macros/latex/contrib/crefthe/crefthe-doc.tex @@ -117,7 +117,7 @@ \begin{document} -\def\PackageVersion{2023/07/22} +\def\PackageVersion{2023/07/23} \title{\crefthepackage{}\\\smallskip\itshape Cross referencing with proper definite articles} \author{Jinwen XU} @@ -133,7 +133,7 @@ \section{The motivation} -By default, with \textsf{cleveref}'s \lstinline|\cref| to reference theorem-like environments, the names do not contain definite articles. While this might be acceptable for English, it is certainly not good enough for languages such as French, Italian, Portuguese, Spanish, etc. --- in these cases there shall be grammatical errors and would give you a strong feeling that it is machine-generated. +By default, with \textsf{cleveref}'s \lstinline|\cref| to reference theorem-like environments, the names do not contain definite articles. While this might be acceptable for English, it is certainly not good enough for languages such as French, German, Italian, Portuguese, Spanish, etc. --- in these cases there shall be grammatical errors and would give you a strong feeling that it is machine-generated. However, even if we manually add the definite articles to the names, there would still be other problems. As an example, if we define the French names to be: @@ -257,38 +257,82 @@ In German, there are four declensions: nominative (\texttt{Nominativ}), genitive } \end{code} -The first line in the configuration is the default set of names when no variant is specified. It is recommended, though not required. +\begin{tip} + The first line in the configuration is the default set of names when no variant is specified. It is recommended, though not required. +\end{tip} After this, you may refer to a theorem via \begin{code} -\crefthe[(*\meta{prep}*),variant=(*\meta{declension}*)]{(*\meta{label}*)} +\crefthe[(*\meta{prep}*),(*\commandoption{variant}*)=(*\meta{declension}*)]{(*\meta{label}*)} \end{code} You may also use the shortcuts (\texttt{nom.}, \texttt{gen.}, \texttt{dat.} and \texttt{akk.}), such as: \begin{code} -\crefthe[(*\meta{prep}*),Nom]{(*\meta{label}*)} \crefthe[(*\meta{prep}*),Nom.]{(*\meta{label}*)} -\crefthe[(*\meta{prep}*),nom]{(*\meta{label}*)} \crefthe[(*\meta{prep}*),nom.]{(*\meta{label}*)} +\crefthe[(*\meta{prep}*),(*\commandoption{Nom}*)]{(*\meta{label}*)} \crefthe[(*\meta{prep}*),(*\commandoption{Nom.}*)]{(*\meta{label}*)} +\crefthe[(*\meta{prep}*),(*\commandoption{nom}*)]{(*\meta{label}*)} \crefthe[(*\meta{prep}*),(*\commandoption{nom.}*)]{(*\meta{label}*)} \end{code} These four are all equivalent and you may choose one to use according to your preference. +Article contractions are by default enabled for German, but if you don't want this, you may use the package option \packageoption{disable german article contractions}. + +\section{Using abbreviation form} + +There is another usage of \lstinline|\crefthevariantname|: setting the abbreviation form. This allows you to use both the full form and the abbreviation form in the same document. For example, you may set + +\begin{code} +\crefthevariantname{theorem} + { + {theorem}{theorems} + , abbr. = {th.}{ths.} + } +\end{code} + +Then, when referencing, you can use the command option \commandoption{abbr.} to enable the abbreviation form: + +\begin{code} +\crefthe[(*\commandoption{abbr.}*)]{(*\meta{label}*)} +\end{code} + \section{Regarding the upper and lower cases} -As in \textsf{cleveref}, these commands have corresponding uppercased version: \lstinline|\Crefthename|,\linebreak \lstinline|\Crefthe|, \lstinline|\nameCrefthe| and \lstinline|\nameCrefsthe|, similar to \lstinline|\Crefname|, \lstinline|\Cref|, \lstinline|\nameCref|\linebreak and \lstinline|\nameCrefs|, reserved for using at the beginning of a sentence. \lstinline|\Crefthe| (and the name-only relatives) can handle case changing automatically: for example, with \lstinline|\Crefthe[À]{thm1,thm2,prop3}|, you will get something like +As in \textsf{cleveref}, these commands have corresponding uppercased version: \lstinline|\Crefthename|,\linebreak \lstinline|\Crefthe|, \lstinline|\nameCrefthe| and \lstinline|\nameCrefsthe|, similar to \lstinline|\Crefname|, \lstinline|\Cref|, \lstinline|\nameCref|\linebreak and \lstinline|\nameCrefs|, reserved for using at the beginning of a sentence. For languages with declensions, such as German, there is also a \lstinline|\Crefthevariantname|, whose usage is similar to the \lstinline|\crefthevariantname| introduced above. + +\lstinline|\Crefthe| (and the name-only relatives) can handle case changing automatically: for example, with \lstinline|\Crefthe[À]{thm1,thm2,prop3}|, you will get something like \begin{demo} \textbf{Aux} théorèmes 1 et 2 et \textbf{à la} proposition 3 \end{demo} -Of course you will have to define the \lstinline|\Crefthename|s separately, for example as: +Of course, you would have to define the \lstinline|\Crefthename|s separately, for example as: \begin{code} \Crefthename{theorem}[Le]{théorème}[Les]{théorèmes} \Crefthename{proposition}[La]{proposition}[Les]{propositions} \end{code} +\section{On the coordination of gender and number} + +In many languages, adjectives and verbs need to be properly inflected for the gender and singular or plural of the noun. Take French as example, you may see the following expressions: +\begin{itemize} + \item La proposition précédent\textbf{e}/suivant\textbf{e}... (The previous/next proposition...) + \item La proposition est illustré\textbf{e} par... (The proposition is illustrated by...) +\end{itemize} +Thus if you later decide to change this proposition (feminine) into a theorem (masculine), you would have to modify the adjectives and verbs accordingly. Similar things happens in many other languages, and it is not quite realistic to fully automate such modifications. + +The name-only relatives \lstinline|\namecrefthe|, \lstinline|\nameCrefthe| etc. are designed for this purpose. They do not automatically solve these kinds of problems, but you may later search for the \meta{label} of the environment that changes, and modify the surrounding context manually --- in other words, these commands serve as recorders: if you write the word like \textquote{theorem} or \textquote{proposition} directly in the text, then later it would be unclear which part of your text needs to be update when the environment itself changes. + +There is another case. For example, if you wish to say \textquote{ce théorème} (\textquote{this theorem}), the pre-defined set of names that contains definite articles would be somewhat redundant. In such situation, you may use the command option \commandoption{noun} to show only the noun: + +\begin{code} +\namecref[(*\commandoption{noun}*)]{(*\meta{label}*)} +\end{code} + +But then of course you shall need to write the word \textquote{Ce/Cet/Cette} (these are all different forms of \textquote{This} in French) by yourself --- and if you later decide to change the type of the environment to which this \meta{label} refers, don't forget to change this word accordingly. + +\pagebreak \section{For writing multi-language documents} To place hyperlinks at the correct place, \lstinline|\crefthename| touches the corresponding format macro \lstinline|\crefformat| internally, which makes the format language-dependent. If you are writing multi-language documents, you may consider putting \lstinline|\crefthename| inside your language configuration so as to reset it each time you select a new language. @@ -329,8 +373,8 @@ There are so many people I wish to express my gratitude to during the developmen \section{Known issues} \begin{itemize} \item \crefthepackage{} currently works for French, German, Italian, Portuguese (European and Brazilian) and Spanish --- certainly more languages would be added to this list in the future. - \item For now, you cannot specify the masculine/masculine/... of words. This means, for instance, that you cannot make the suffix adjective automatically adopted to the word when using \lstinline|\namecref| --- as an example, if you wish to say \textquote{la proposition suivante} (in French), you would have to write the feminine adjective manually. The situation should be improved with the introduction of a new key-value configuration system, which is currently on the todo-list. - Meanwhile, you may consider the package \textsf{zref-clever}, which has a much more powerful and sophisticated interface for configuring cross referencing. + % \item For now, you cannot specify the masculine/masculine/... of words. This means, for instance, that you cannot make the suffix adjective automatically adopted to the word when using \lstinline|\namecref| --- as an example, if you wish to say \textquote{la proposition suivante} (in French), you would have to write the feminine adjective manually. The situation should be improved with the introduction of a new key-value configuration system, which is currently on the todo-list. + % Meanwhile, you may consider the package \textsf{zref-clever}, which has a much more powerful and sophisticated interface for configuring cross referencing. \item The names of theorem-like environments are not provided here, you need to define them by yourself. However, users are encouraged to use the \ProjLib{} toolkit (more specifically, the internal package \textsf{create-theorem}), which already handles everything for you. \end{itemize} diff --git a/macros/latex/contrib/crefthe/crefthe.sty b/macros/latex/contrib/crefthe/crefthe.sty index e1ce211bb6..4097b0aefc 100644 --- a/macros/latex/contrib/crefthe/crefthe.sty +++ b/macros/latex/contrib/crefthe/crefthe.sty @@ -12,7 +12,7 @@ \NeedsTeXFormat{LaTeX2e}[2022-06-01] \ProvidesExplPackage {crefthe} - {2023/07/22} {} + {2023/07/23} {} {Cross referencing with proper definite articles} \keys_define:nn { crefthe } @@ -21,6 +21,12 @@ , overwrite .initial:n = { false } , nameinlink .bool_set:N = \l__crefthe_nameinlink_bool , nameinlink .initial:n = { false } + + , disable-german-article-contractions .bool_set:N = \l__crefthe_disable_contractions_for_german_bool + , disable-german-article-contractions .initial:n = { false } + , disable~german~article~contractions .bool_set:N = \l__crefthe_disable_contractions_for_german_bool + , disable german article contractions .bool_set:N = \l__crefthe_disable_contractions_for_german_bool + , unknown .code:n = { \PassOptionsToPackage { \CurrentOption } { cleveref } } } @@ -89,6 +95,8 @@ \keys_define:nn { crefthe-setting } { + , noun .code:n = { \RenewDocumentCommand \crefthemark { m } {} } + , variant .tl_set:N = \l__crefthe_variant_tl % , nom .meta:n = { variant = Nominativ } @@ -125,6 +133,8 @@ % #5 = label % #6 = original command, such as \crefthe_cref_original:w or \crefthe_Cref_original:w { + \group_begin: + \tl_set:Nn \l__crefthe_variant_tl {} \bool_gset_false:N \g__crefthe_has_prep_bool \tl_set:Nn \l__crefthe_prep_tl {} @@ -137,6 +147,11 @@ \bool_set_false:N \l__crefthe_variant_matched_bool \str_if_in:nnF { ##1 } { = } {% for keys without values + \str_case:nnT { ##1 } + { + { abbr } { \tl_set:Nn \l__crefthe_variant_tl { abbr. } } + { abbr. } { \tl_set:Nn \l__crefthe_variant_tl { abbr. } } + } { \bool_set_true:N \l__crefthe_variant_matched_bool } \str_if_eq:VnT \languagename { ngerman } { \str_case:nnT { ##1 } @@ -182,12 +197,12 @@ } } } - \group_begin: \bool_if:NTF #1 { #6 * { #5 } } { #6 { #5 } } - \group_end: \tl_gclear:N \l__crefthe_prep_each_tl + + \group_end: } % \__crefthe_prep_mode: defines the default mode for supported languages @@ -493,25 +508,30 @@ { De~le } { Du } { De~les } { Des } } -\tl_const:Nn \c_crefthe_contraction_rule_ngerman_tl - { - { an~dem } { am } - { an~das } { ans } - { bei~dem } { beim } - { in~dem } { im } - { in~das } { ins } - { von~dem } { vom } - { zu~dem } { zum } - { zu~der } { zur } - { An~dem } { Am } - { An~das } { Ans } - { Bei~dem } { Beim } - { In~dem } { Im } - { In~das } { Ins } - { Von~dem } { Vom } - { Zu~dem } { Zum } - { Zu~der } { Zur } + +\bool_if:NF \l__crefthe_disable_contractions_for_german_bool + { + \tl_const:Nn \c_crefthe_contraction_rule_ngerman_tl + { + { an~dem } { am } + { an~das } { ans } + { bei~dem } { beim } + { in~dem } { im } + { in~das } { ins } + { von~dem } { vom } + { zu~dem } { zum } + { zu~der } { zur } + { An~dem } { Am } + { An~das } { Ans } + { Bei~dem } { Beim } + { In~dem } { Im } + { In~das } { Ins } + { Von~dem } { Vom } + { Zu~dem } { Zum } + { Zu~der } { Zur } + } } + \tl_const:Nn \c_crefthe_contraction_rule_italian_tl { { a~il } { al } @@ -585,6 +605,7 @@ { Su~gli } { Sugli } { Su~le } { Sulle } } + \tl_const:Nn \c_crefthe_contraction_rule_spanish_tl { { a~el } { al } @@ -592,6 +613,7 @@ { A~el } { Al } { De~el } { Del } } + \tl_const:Nn \c_crefthe_contraction_rule_portuguese_tl { { a~o } { ao } diff --git a/macros/luatex/generic/lutabulartools/README.md b/macros/luatex/generic/lutabulartools/README.md index 51055a89e5..ee3381533b 100644 --- a/macros/luatex/generic/lutabulartools/README.md +++ b/macros/luatex/generic/lutabulartools/README.md @@ -7,7 +7,7 @@ macro-enabled spreadsheet named "LaTeX-Tabular-Generator.xlsm" to help make tabl # License (MIT) -Copyright (C) 2021-2022 Kale Ewasiuk +Copyright (C) 2021-2023 Kale Ewasiuk Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/macros/luatex/generic/lutabulartools/lutabulartools.lua b/macros/luatex/generic/lutabulartools/lutabulartools.lua index 3ea2151834..92ce236715 100644 --- a/macros/luatex/generic/lutabulartools/lutabulartools.lua +++ b/macros/luatex/generic/lutabulartools/lutabulartools.lua @@ -1,6 +1,6 @@ --% Kale Ewasiuk (kalekje@gmail.com) ---% 2023-07-18 ---% Copyright (C) 2021-2022 Kale Ewasiuk +--% 2023-07-22 +--% Copyright (C) 2021-2023 Kale Ewasiuk --% --% Permission is hereby granted, free of charge, to any person obtaining a copy --% of this software and associated documentation files (the "Software"), to deal @@ -23,15 +23,16 @@ --% OR OTHER DEALINGS IN THE SOFTWARE. -local pl = _G['penlight'] or _G['pl'] -- penlight for this namespace is pl -if (__PL_EXTRAS__ == nil) or (__PENLIGHT__ == nil) then - tex.sprint('\\PackageError{lutabulartools}{penlight package with extras (or extrasglobals) option must be loaded before this package}{}') - tex.print('\\stop') -end -local T = pl.tablex + local lutabt = {} +local pl = penlight +local T = pl.tablex + +lutabt.luakeys = require'luakeys'() -- note: YAMLvars.sty will have checked existence of this already + + lutabt.tablelevel = 0 lutabt.debug = false @@ -98,7 +99,7 @@ end function lutabt.set_tabular(sett) - sett = luakeys.parse(sett) + sett = lutabt.luakeys.parse(sett) local trim = '' for k, v in pairs(sett) do if k == 'tbrule' then @@ -435,7 +436,7 @@ function lutabt.mrX.off() end function lutabt.mrX.set_midruleX(new_sett, def) - lutabt.mrX.settings = T.update(lutabt.mrX.settings, T.union(lutabt.mrX.resets, luakeys.parse(new_sett))) + lutabt.mrX.settings = T.update(lutabt.mrX.settings, T.union(lutabt.mrX.resets, lutabt.luakeys.parse(new_sett))) lutabt.debugtalk(lutabt.mrX.settings, 'new midruleX settings') if lutabt.mrX.settings.head ~= nil then lutabt.mrX.settings.cntr = -1*tonumber(lutabt.mrX.settings.head) diff --git a/macros/luatex/generic/lutabulartools/lutabulartools.pdf b/macros/luatex/generic/lutabulartools/lutabulartools.pdf Binary files differindex 6443b2873a..eab8203760 100644 --- a/macros/luatex/generic/lutabulartools/lutabulartools.pdf +++ b/macros/luatex/generic/lutabulartools/lutabulartools.pdf diff --git a/macros/luatex/generic/lutabulartools/lutabulartools.sty b/macros/luatex/generic/lutabulartools/lutabulartools.sty index c1e74802c0..ee36589cd5 100644 --- a/macros/luatex/generic/lutabulartools/lutabulartools.sty +++ b/macros/luatex/generic/lutabulartools/lutabulartools.sty @@ -1,6 +1,6 @@ % Kale Ewasiuk (kalekje@gmail.com) -% 2023-07-18 -% Copyright (C) 2021-2022 Kale Ewasiuk +% 2023-07-22 +% Copyright (C) 2021-2023 Kale Ewasiuk % % Permission is hereby granted, free of charge, to any person obtaining a copy % of this software and associated documentation files (the "Software"), to deal @@ -23,7 +23,7 @@ % OR OTHER DEALINGS IN THE SOFTWARE. \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{lutabulartools}[2023-07-18] +\ProvidesPackage{lutabulartools}[2023-07-22] \RequirePackage{booktabs} \RequirePackage{multirow} @@ -34,7 +34,7 @@ \RequirePackage{xcolor} \RequirePackage{colortbl} \RequirePackage{luacode} -\RequirePackage{penlight} % NEEDED, extras option must be used so penlight should be loaded before this... +\RequirePackage{penlightplus} % NEEDED, extras option must be used so penlight should be loaded before this... \luadirect{lutabt = require('lutabulartools')} diff --git a/macros/luatex/generic/lutabulartools/lutabulartools.tex b/macros/luatex/generic/lutabulartools/lutabulartools.tex index 9be8dbd330..b9a4c96254 100644 --- a/macros/luatex/generic/lutabulartools/lutabulartools.tex +++ b/macros/luatex/generic/lutabulartools/lutabulartools.tex @@ -1,6 +1,6 @@ % Kale Ewasiuk (kalekje@gmail.com) -% 2023-07-18 -% Copyright (C) 2021-2022 Kale Ewasiuk +% 2023-07-22 +% Copyright (C) 2021-2023 Kale Ewasiuk % % Permission is hereby granted, free of charge, to any person obtaining a copy % of this software and associated documentation files (the "Software"), to deal @@ -67,7 +67,7 @@ \usepackage{ltxtable} \usepackage{longtable} -\usepackage[pl,extras]{penlight} +\usepackage{penlightplus} \RequirePackage{lutabulartools} @@ -100,7 +100,7 @@ so if you have specific settings for these packages, load the \cmd{lutabulartool {xcolor}, {colortbl}, {luacode}, -{penlight}}. +{penlightplus}}. \section{\texttt{\textbackslash settabular}} @@ -455,6 +455,14 @@ Here's an example with long table. Notice the gray rules reliably appear 3 rows %\LTXtable{\linewidth}{ltxexample} - +\begin{tabular}{c} + \\ + \\ + \\ + \\ + \\ + \\ + \\ +\end{tabular} \end{document} diff --git a/macros/luatex/generic/penlight/README.md b/macros/luatex/generic/penlight/README.md index ca66c41b74..a80a51c22e 100644 --- a/macros/luatex/generic/penlight/README.md +++ b/macros/luatex/generic/penlight/README.md @@ -1,11 +1,11 @@ # penlight -- Lua libraries for use in LuaLaTeX -This LuaLaTeX package provides a wrapper to use the [penlight](https://github.com/lunarmodules/Penlight) Lua libraries with LuaLaTeX, with some extra functionality added. +This LuaLaTeX package provides a wrapper to use the [penlight](https://github.com/lunarmodules/Penlight) Lua libraries with LuaLaTeX. # License -Copyright (C) 2021-2022 Kale Ewasiuk +Copyright (C) 2021-2023 Kale Ewasiuk Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/macros/luatex/generic/penlight/penlight.pdf b/macros/luatex/generic/penlight/penlight.pdf Binary files differindex a063e8922a..3932e74389 100644 --- a/macros/luatex/generic/penlight/penlight.pdf +++ b/macros/luatex/generic/penlight/penlight.pdf diff --git a/macros/luatex/generic/penlight/penlight.sty b/macros/luatex/generic/penlight/penlight.sty index 4f5900e3b8..7a7c94b6a7 100644 --- a/macros/luatex/generic/penlight/penlight.sty +++ b/macros/luatex/generic/penlight/penlight.sty @@ -1,6 +1,6 @@ % Kale Ewasiuk (kalekje@gmail.com) -% 2023-07-18 -% Copyright (C) 2021-2022 Kale Ewasiuk +% 2023-07-22 +% Copyright (C) 2021-2023 Kale Ewasiuk % % Permission is hereby granted, free of charge, to any person obtaining a copy % of this software and associated documentation files (the "Software"), to deal @@ -22,124 +22,15 @@ % OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE % OR OTHER DEALINGS IN THE SOFTWARE. -\ProvidesPackage{penlight}[2023-07-18] +\ProvidesPackage{penlight}[2023-07-22] -\RequirePackage{luacode} +\directlua{penlight = require'penlight'} -\IfFileExists{luakeys.lua}{}{\PackageError{penlight}{This package requires that luakeys be installed}{}} +\DeclareOption{pl}{\directlua{pl = penlight}} - -\DeclareOption{pl}{\luadirect{ - pl = require'penlight' - __PENLIGHT__ = 'pl' -}} -\DeclareOption{penlight}{\luadirect{ - penlight = require'penlight' - __PENLIGHT__ = 'penlight' -}} - - -\DeclareOption{stringx}{\luadirect{_G[__PENLIGHT__].stringx.import()}} -\DeclareOption{format}{\luadirect{_G[__PENLIGHT__].stringx.format_operator()}} -\DeclareOption{func}{\luadirect{_G[__PENLIGHT__].utils.import(__PENLIGHT__..'.func')}} -\DeclareOption{extras}{\luadirect{require'penlightextras'} - \gdef\penlight@loadextras{} -} -\DeclareOption{extrasglobals}{\luadirect{ - __PL_GLOBALS__ = true - require'penlightextras' - } - \gdef\penlight@loadextras{} -} +\DeclareOption{stringx}{\directlua{penlight.stringx.import()}} +\DeclareOption{format}{\directlua{penlight.stringx.format_operator()}} +\DeclareOption{func}{\directlua{penlight.utils.import(penlight.func)}} +\DeclareOption{import}{\ExecuteOptions{stringx,format,func}} \ProcessOptions*\relax - -\luadirect{ -if __PENLIGHT__ == nil then - tex.sprint('\\PackageError{penlight}{"penlight" or "pl" option must be passed to penlight as the first option}{}') -end -} - -\ifdefined\penlight@loadextras - -\global\newcommand{\writePDFmetadata}{\luadirect{_G[__PENLIGHT__].tex.writePDFmetadata()}} - -\NewDocumentCommand{\writePDFmetadatakv}{ s m }{ -\IfBooleanTF{#1}{% if *, overwrite everything - \luadirect{ - __PDFmetadata__ = luakeys.parse(\luastring{#2}) - _G[__PENLIGHT__].tex.writePDFmetadata() - }}{ - \luadirect{ - __PDFmetadata__ = __PDFmetadata__ or {} - _G[__PENLIGHT__].tablex.update(__PDFmetadata__, luakeys.parse(\luastring{#2})) - _G[__PENLIGHT__].tex.writePDFmetadata() - }} -} - - -\gdef\luastringT#1{\luastring{\unexpanded\expandafter\expandafter\expandafter{#1}}} % expand luastring twice -\global\let\luastringF\luastring % fully expanded luastring - -% allow control over expansion of arguments to a latex function -\NewDocumentCommand{\MakeluastringCommands}{O{} m }{% #1 the desired commands #2 defaults - \luadirect{_G[__PENLIGHT__].tex.aliasluastring(\luastring{#2},\luastring{#1})}% -} - -\NewDocumentCommand{\splitToComma}{ O{nn} m m }{% - \MakeluastringCommands[nn]{#1}% - \luadirect{_G[__PENLIGHT__].tex.split2comma(\plluastringA{#2},\plluastringB{#3})}% -} - -\NewDocumentCommand{\splitToItems}{ O{NN} m m }{% - \MakeluastringCommands[nn]{#1}% - \luadirect{_G[__PENLIGHT__].tex.split2items(\plluastringA{#2},\plluastringB{#3})}% -} - - -% -% -%\NewDocumentCommand{\tblnew}{m}{\luadirect{ -% _G[\luastring{#1}] = {} -%}} -% -%\NewDocumentCommand{\tblfrkv}{m m O{} }{\luadirect{ -% _G[\luastring{#1}] = luakeys.parse(\luastring{#2}, luakeys.parse(\luastring{#3})) -%}} -% -%\NewDocumentCommand{\tblset}{m m m}{\luadirect{ -% _G[\luastring{#1}][\luastring{#2}] = \luastring{#3} -%}} -% -%\NewDocumentCommand{\tblget}{m m}{\luadirect{ -% tex.sprint(tostring(_G[\luastring{#1}][\luastring{#2}])) -%}} -% -%\NewDocumentCommand{\tblidx}{m m}{\luadirect{ -% tex.sprint(tostring(_G[\luastring{#1}][#2])) -%}} -% -% -%\NewDocumentCommand{\tblupd}{ m m}{\luadirect{ -% _G[__PENLIGHT__].tablex.update(_G[\luastring{#1}], _G[\luastring{#2}]) -%}} -% -%\NewDocumentCommand{\tblupdkv}{ m m }{\luadirect{ -% _G[__PENLIGHT__].tablex.update(_G[\luastring{#1}], luakeys.parse(\luastring{#2})) -%}} -% -%% todo need a get table function. If blank is passed, the last table referenced is used. -%\NewDocumentCommand{\tblfrkvII}{ m m m }{\luadirect{ -% _G[\luastring{#1}] = _G[__PENLIGHT__].tablex.update(luakeys.parse(\luastring{#2}), luakeys.parse(\luastring{#3})) -%}} - - -%\NewDocumentCommand{\tbldo}{m m O{} }{\luadirect{ -% % tex.sprint(tostring(_G[\luastring{#1}][#2])) -% % todo allow one to use pl tablex function here, -% % {tbl}{update}[arg1][arg2] -% _G[__PENLIGHT__].tablex[\luastring[#1]](_G[\luastring{}], _G[\luastring{}]) -%}} - - -\else\fi
\ No newline at end of file diff --git a/macros/luatex/generic/penlight/penlight.tex b/macros/luatex/generic/penlight/penlight.tex index edba4933e8..93d7bdbfc3 100644 --- a/macros/luatex/generic/penlight/penlight.tex +++ b/macros/luatex/generic/penlight/penlight.tex @@ -1,6 +1,6 @@ % Kale Ewasiuk (kalekje@gmail.com) -% 2023-07-18 -% Copyright (C) 2021-2022 Kale Ewasiuk +% 2023-07-22 +% Copyright (C) 2021-2023 Kale Ewasiuk % % Permission is hereby granted, free of charge, to any person obtaining a copy % of this software and associated documentation files (the "Software"), to deal @@ -53,207 +53,56 @@ \date{\today} -\RequirePackage[pl,extras]{penlight} +\RequirePackage{luacode} +\RequirePackage[pl,import]{penlight} \title{penlight} \subtitle{Lua libraries for use in LuaLaTeX} \begin{document} -%{\Huge todo add split to text example with ltxexample\\reference the exact version of penlight used in this library. consider no globals by default\\ COVERT existing examples to extras globals, document hyperref} \maketitle - Documentation for the Lua library this includes can be found here:\\ - \mbox{\url{https://lunarmodules.github.io/Penlight}} - \\ This package uses version \cmd{1.13.1} + Documentation for Penlight can be found here:\\ +\mbox{\url{https://lunarmodules.github.io/Penlight}} +\\\\ This package uses version \cmd{1.13.1} - \subsection*{Required Package Option} - The first option sent to this package MUST be one of: \\ - \texttt{[penlight]} \ \ \ or \ \ \ \texttt{[pl]}.\\ - All Penlight sub-modules are then available under this global variable by either\\ - \texttt{penlight.XYZ} or \texttt{pl.XYZ} +\subsection*{Importing Penlight from within LaTeX} +Loading this package runs the Lua code: \texttt{penlight = require'penlight'} +Other options for the package are: +\vspace{1em} - - \subsection*{texlua usage} -If you want to use Penlight (and extras) with the \texttt{texlua} intrepreter (no document made, only for Lua files, useful for testing), -you can access it by setting \cmd{__SKIP_TEX__ = true} and adding the package to path. For example: - \begin{verbatim} -package.path = package.path .. ';'..'path/to/texmf/tex/latex/penlight/?.lua' -penlight = require'penlight' --- below is optional -__SKIP_TEX__ = true --only required if you want to use - --penlightextras without a LaTeX run -__PL_GLOBALS__ = true -- optional, include global definitions -__SKIP_LUAKEYS__ = true -- luakeys is laoded in penlightextras be default, you may skip it with this -require'penlightextras' -\end{verbatim} +\hspace*{-6ex}\begin{tabular}{lp{4.8in}} +\texttt{pl} & adds the alias \texttt{pl = penlight}\\\\ +\texttt{stringx} & will import additional string functions into the string meta table via\\ + & \texttt{require('penlight.stringx').import()}\\\\ +\texttt{format} & allows the \% operator for Python-style string formatting via\\ + & \texttt{require('penlight.stringx').format\_operator()}\\\\ +\texttt{func} & allows placeholder expressions eg. \texttt{\_1+1} to be used via\\ + & \texttt{penlight.utils.import(penlight.func)}\\\\ +\texttt{import} & does the above three\\ +\end{tabular} -\pagebreak +An example usage is: \cmd{\usepackage[pl,import]{penlight}} -\subsection*{Additional Package Options} +%https://lunarmodules.github.io/Penlight/libraries/pl.func.html +%https://lunarmodules.github.io/Penlight/libraries/pl.stringx.html - \noindent - \hspace*{-6ex}\begin{tabular}{lp{4.8in}} - \texttt{stringx} & will import additional string functions into the string meta table.\\ - & this will be ran in pre-amble: \texttt{require('pl.stringx').import()}\\ - \texttt{format} & allows \% operator for Python-style string formating\\ - & this will be ran in pre-amble: \texttt{require('pl.stringx').format\_operator()}\\ - & \mbox{\url{https://lunarmodules.github.io/Penlight/libraries/pl.stringx.html#format_operator}} - \\ - \texttt{func} & allows placehold expressions eg. \texttt{\_1+1} to be used \\ - & this will be ran in pre-amble: \texttt{penlight.utils.import('pl.func')}\\ - & \url{https://lunarmodules.github.io/Penlight/libraries/pl.func}\\ - \texttt{extras} & does the above three (\cmd{func,stringx,format}); adds some additional functions to \cmd{penlight} module; and adds the \cmd{pl.tex} sub-module.\\ - \texttt{extrasglobals} & does the above \texttt{extras} but makes many of the functions global variables as well. - \end{tabular} +\subsection*{Importing Penlight from within Lua} +Instead of using penlight.sty, you can simply:\\ +\texttt{penlight = require'penlight'} ~~~ from within Lua. +\newpage +\section*{} +This package used to contain \cmd{penlightextras.lua}. +That functionality now belongs to a standalone package named \cmd{penlightplus}. +\section*{} +Disclaimer: I am not the author of the Lua Penlight library. +Penlight is Copyright \textcopyright 2009-2016 Steve Donovan, David Manura. +The distribution of Penlight used for this library is: +\url{https://github.com/lunarmodules/penlight}\\\\ +The author of this library has merged all penlight sub-modules into a single file for this distribution. - -\subsection*{Extras} -Note: this option is considered experimental. -The following global variables are defined: - -\llcmd{__SKIP_TEX__} If using the \cmd{penlight} package with \cmd{texlua} (good for troubleshooting), set this global before loading \cmd{penlight}\\ -The gloals flags below are taken care of in the package options:\\ -\llcmd{__PL_}\cmd{GLOBALS__} If using package with \cmd{texlua} and you don't want to set some globals (described in next sections), set this global before to \cmd{true} loading \cmd{penlight}\\ -\cmd{__SKIP_LUAKEYS__}\\ -\cmd{__PL_NO_HYPERREF__}\\ -\cmd{__PL_EXTRAS__} false, 1 or 2\\ - -\subsubsection*{penlight additions} - -Some functionality is added to penlight/lua. - -\llcmd{pl.hasval(x)} Python-like boolean testing\\ -\llcmd{COMP'xyz'()} Python-like comprehensions:\\\url{https://lunarmodules.github.io/Penlight/libraries/pl.comprehension.html}\\ -\llcmd{math.mod(n,d)}, \cmd{math.mod2(n)} math modulous\\ -\llcmd{string.}\cmd{totable(s)} string a table of characters\\ -\llcmd{string.}\cmd{delspace(s)} clear spaces from string\\ -\llcmd{pl.}\cmd{char(n)} return letter corresponding to 1=a, 2=b, etc.\\ -\llcmd{pl.}\cmd{Char(n)} return letter corresponding to 1=A, 2=B, etc.\\ - -\llcmd{pl.utils.}\cmd{filterfiles}\cmd{(dir,filt,rec)} Get files from dir and apply glob-like filters. Set rec to \cmd{true} to include sub directories\\ - - -\subsubsection*{A \cmd{pl.tex.} module is added} -\llcmd{add_bkt}\cmd{_cnt(n), }\cmd{close_bkt_cnt(n), reset_bkt_cnt} functions to keep track of adding curly brackets as strings. \cmd{add} will return \cmd{n} (default 1) \{'s and increment a counter. \cmd{close} will return \cmd{n} \}'s (default will close all brackets) and decrement.\\ -\llcmd{_NumBkts} internal integer for tracking the number of brackets\\ -\llcmd{opencmd(cs)} prints \cmd{\cs}\{ and adds to the bracket counters.\\ -\\ -\llcmd{_xNoValue,}\cmd{_xTrue,_xFalse}: \cmd{xparse} equivalents for commands\\ -\\ -\llcmd{prt(x),prtn(x)} print without or with a newline at end. Tries to help with special characters or numbers printing.\\ -\llcmd{prtl(l),prtt(t)} print a literal string, or table\\ -\llcmd{wrt(x), wrtn(x)} write to log\\ -\llcmd{help_wrt}\cmd{(s1, s2)} pretty-print something to console. S2 is a flag to help you find.\\ -\llcmd{prt_array2d(tt)} pretty print a 2d array\\ -\\ -\llcmd{pkgwarn}\cmd{(pkg, msg1, msg2)} throw a package warning\\ -\llcmd{pkgerror}\cmd{(pkg, msg1, msg2, stop)} throw a package error. If stop is true, immediately ceases compile.\\ -\\ -\llcmd{defcmd}\cmd{(cs, val)} like \cmd{\gdef}\\ -\llcmd{newcmd}\cmd{(cs, val)} like \cmd{\newcommand}\\ -\llcmd{renewcmd}\cmd{(cs, val)} like \cmd{\renewcommand}\\ -\llcmd{prvcmd}\cmd{(cs, val)} like \cmd{\providecommand}\\ -\llcmd{deccmd}\cmd{(cs, dft, overwrite)} declare a command. If \cmd{dft} (default) is \cmd{nil}, \cmd{cs} is set -to a package warning saying \cmd{'cs' was declared and used in document, but never set}. If \cmd{overwrite} -is true, it will overwrite an existing command (using \cmd{defcmd}), otherwise, it will throw error like \cmd{newcmd}.\\ -\llcmd{get_ref_info(l)}accesses the \cmd{\r@label} and returns a table\\ - - - -\subsubsection*{global extras} -If \cmd{extrasglobals} is used and NOT \cmd{extras}, many additional globals are set for shortcuts\\ -All \cmd{pl.tex} modules are made global.\\ -\cmd{pl.hasval}, \cmd{pl.COMP}, \cmd{pl.utils.kpairs}, \cmd{pl.utils.npairs} become globals with the function name.\\ - - - -\subsection*{Macro helpers} -\cmd{\MakeluastringCommands[def]{spec}} will let \cmd{\plluastring(A|B|C..)} be \cmd{\luastring(N|O|T|F)} -based on the letters that \cmd{spec} is set to (or \cmd{def} if nothing is provided) -This is useful if you want to write a command with flexibility on argument expansion. -The user can specify \cmd{n}, \cmd{o}, \cmd{t}, and \cmd{f} (case insensitve) if they want -no, once, twice, or full expansion. - -% BELOW IS FOR TROUBLESHOOTING ABOVE -%\def\NOTexp{\ONEexp} -%\def\ONEexp{\TWOexp} -%\def\TWOexp{\TREexp} -%\def\TREexp{Fully expanded} -% -%\NewDocumentCommand{\luastringExpTest}{m m}{ -% \MakeluastringCommands{#1} -% \luadirect{texio.write_nl('VVVVVVVVVVVVVVVVVVVVVVVVVVVVV')} -% \luadirect{texio.write_nl(\plluastringA{#2}..' | Not')} -% \luadirect{texio.write_nl(\plluastringB{#2}..' | Once')} -% \luadirect{texio.write_nl(\plluastringC{#2}..' | Twice')} -% \luadirect{texio.write_nl(\plluastringD{#2}..' | Full')} -% \luadirect{texio.write_nl('VVVVVVVVVVVVVVVVVVVVVVVVVVVVV')} -%} -% -%\luastringExpTest{ n o t f }{\NOTexp} - - - - -\subsection*{Split stuff} -Splitting text (or a cmd) into oxford comma format via: -\cmd{\splitToComma[expansion level]{text}{text to split on}}: - -\begin{LTXexample} - --\splitToComma{ j doe }{\and}-\\ --\splitToComma{ j doe \and s else }{\and}-\\ --\splitToComma{ j doe \and s else \and a per }{\and}-\\ --\splitToComma{ j doe \and s else \and a per \and f guy}{\and}- - -\def\authors{j doe \and s else \and a per \and f guy} -\splitToComma[o]{\authors}{\and} -\end{LTXexample} - -The expansion level is up to two characters, \cmd{n|o|t|f}, to control teh expasion of each argument. - -\begin{LTXexample} -spliToItems: -\begin{itemize} - \splitToItems{kale\and john}{\and} - \splitToItems{kale -john -someone else}{-} -\end{itemize} -\end{LTXexample} - - - - - - \section*{} - Disclaimer: I am not the author of the Lua Penlight library. - Penlight is Copyright \textcopyright 2009-2016 Steve Donovan, David Manura. - The distribution of Penlight used for this library is: -\url{https://github.com/lunarmodules/penlight}\\ - The author of this library has merged all Lua sub-modules into one file for this package. - -% \tblfrkv{tbl_def}{kale=cool,paul=gay,craig=fun} -% \tblfrkv{tbl}{kale,paul=gay} %[naked_as_value=true] -% -% \tblget{tbl}{kale}% -% \tblget{tbl}{paul}% -% \tblget{tbl}{craig}% -% -% \tblupd{tbl_def}{tbl}% -% -% \tblfrkvII{tbl}{kale=cool,paul=gay,craig=fun}{kale=weak,paul=sad} -% \tblget{tbl}{craig}% -% \tblget{tbl}{paul}% -% \tblget{tbl}{kale}% -% -% \NewDocumentCommand{\THINg}{ O{} m}{% -% \tblfrkvII{setti}{color=red,size=small}{#1} % make settings and update based on [arg=] -% {\color{\tblget{setti}{color}}\tblget{setti}{size} #2} -% } -% -% \THINg[color=blue,size=tiny]{Kale} - \end{document}
\ No newline at end of file diff --git a/macros/luatex/generic/penlightplus/README.md b/macros/luatex/generic/penlightplus/README.md new file mode 100644 index 0000000000..cc80374347 --- /dev/null +++ b/macros/luatex/generic/penlightplus/README.md @@ -0,0 +1,28 @@ +# penlightplus + +Additions to the Penlight Lua Libraries. + + +# License + +Copyright (C) 2021-2023 Kale Ewasiuk + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE +OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/macros/luatex/generic/penlight/penlightextras.lua b/macros/luatex/generic/penlightplus/penlightplus.lua index 5f5f76aefb..ffdbe89bc5 100644 --- a/macros/luatex/generic/penlight/penlightextras.lua +++ b/macros/luatex/generic/penlightplus/penlightplus.lua @@ -1,6 +1,6 @@ --% Kale Ewasiuk (kalekje@gmail.com) ---% 2023-07-18 ---% Copyright (C) 2021-2022 Kale Ewasiuk +--% 2023-07-22 +--% Copyright (C) 2021-2023 Kale Ewasiuk --% --% Permission is hereby granted, free of charge, to any person obtaining a copy --% of this software and associated documentation files (the "Software"), to deal @@ -22,37 +22,29 @@ --% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE --% OR OTHER DEALINGS IN THE SOFTWARE. + + + +__PL_PLUS__ = true __PL_SKIP_TEX__ = __PL_SKIP_TEX__ or false --if declared true before here, it will use regular print functions -- (for troubleshooting with texlua instead of actual use in lua latex) -__PL_SKIP_LUAKEYS__ = __PL_SKIP_LUAKEYS__ or false __PL_GLOBALS__ = __PL_GLOBALS__ or false -__PL_EXTRAS__ = 1 __PL_NO_HYPERREF__ = __PL_NO_HYPERREF__ or false --- __PENLIGHT__ = 'penlight' or 'pl' --- requires penlight -local pl = _G['penlight'] or _G['pl'] -- penlight for this namespace is pl - -if not __PL_SKIP_LUAKEYS__ then - luakeys = require'luakeys'() -end +penlight.luakeys = require'luakeys'() --- some bonus string operations, % text operator, and functional programming -pl.stringx.import() -pl.stringx.format_operator() -pl.utils.import'pl.func' -- allow placeholder expressions _1 +1 etc. -pl.COMP = require'pl.comprehension'.new() -- for comprehensions +penlight.COMP = require'pl.comprehension'.new() -- for comprehensions -- http://lua-users.org/wiki/SplitJoin -- todo read me!! -pl.tex = {} -- adding a sub-module for tex related stuff +penlight.tex = {} -- adding a sub-module for tex related stuff -local bind = bind or pl.func.bind +local bind = bind or penlight.func.bind -function pl.hasval(x) -- if something has value +function penlight.hasval(x) -- if something has value if (type(x) == 'function') or (type(x) == 'CFunction') or (type(x) == 'userdata') then return true elseif (x == nil) or (x == false) or (x == 0) or (x == '') or (x == {}) then @@ -71,9 +63,9 @@ end -- Some simple and helpful LaTeX functions -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- xparse defaults -pl.tex._xTrue = '\\BooleanTrue ' -pl.tex._xFalse = '\\BooleanFalse ' -pl.tex._xNoValue = '-NoValue-' +penlight.tex._xTrue = '\\BooleanTrue ' +penlight.tex._xFalse = '\\BooleanFalse ' +penlight.tex._xNoValue = '-NoValue-' --Generic LuaLaTeX utilities for print commands or environments @@ -81,97 +73,97 @@ if not __PL_SKIP_TEX__ then local function check_special_chars(s) -- todo extend to toher special chars? if type(s) == 'string' then if string.find(s, '[\n\r\t\0]') then - pl.tex.pkgwarn('penlight', 'printing string with special (eg. newline) char, possible unexpected behaviour on string: '..s) + penlight.tex.pkgwarn('penlight', 'printing string with special (eg. newline) char, possible unexpected behaviour on string: '..s) end end end -- NOTE: usage is a bit different than default. If number is first arg, you CANT change catcode. -- We don't need that under normal use, use tex.print or tex.sprint if you need - function pl.tex.prt(s, ...) -- print something, no new line after + function penlight.tex.prt(s, ...) -- print something, no new line after check_special_chars(s) if type(s) == 'number' then s = tostring(s) end tex.sprint(s, ...) --can print lists as well, but will NOT put new line between them or anything printed end - function pl.tex.prtn(s, ...) -- print with new line after, can print lists or nums. C-function not in Lua, apparantly + function penlight.tex.prtn(s, ...) -- print with new line after, can print lists or nums. C-function not in Lua, apparantly s = s or '' check_special_chars(s) if type(s) == 'number' then s = tostring(s) end tex.print(s, ...) end - pl.tex.wrt = texio.write - pl.tex.wrtn = texio.write_nl + penlight.tex.wrt = texio.write + penlight.tex.wrtn = texio.write_nl else - pl.tex.prt = io.write - pl.tex.prtn = print --print with new line - pl.tex.wrt = io.write - pl.tex.wrtn = io.write_nl + penlight.tex.prt = io.write + penlight.tex.prtn = print --print with new line + penlight.tex.wrt = io.write + penlight.tex.wrtn = io.write_nl end -function pl.tex.prtl(str) -- prints a literal/lines string in latex, adds new line between them +function penlight.tex.prtl(str) -- prints a literal/lines string in latex, adds new line between them for line in str:gmatch"[^\n]*" do -- gets all characters up to a new line - pl.tex.prtn(line) + penlight.tex.prtn(line) end end -- todo option to specify between character? one for first table, on for recursives? -function pl.tex.prtt(tab, d1, d2) -- prints a table with new line between each item +function penlight.tex.prtt(tab, d1, d2) -- prints a table with new line between each item d1 = d1 or '' d2 = d2 or '\\leavevmode\\\\' for _, t in pairs(tab) do -- if type(t) ~= 'table' then if d1 == '' then - pl.tex.prtn(t) + penlight.tex.prtn(t) else - pl.tex.prt(t, d1) + penlight.tex.prt(t, d1) end else - pl.tex.prtn(d2) - pl.tex.prtt(t,d1,d2) + penlight.tex.prtn(d2) + penlight.tex.prtt(t,d1,d2) end end end -function pl.tex.help_wrt(s1, s2) -- helpful printing, makes it easy to debug, s1 is object, s2 is note +function penlight.tex.help_wrt(s1, s2) -- helpful printing, makes it easy to debug, s1 is object, s2 is note local wrt2 = wrt or texio.write_nl or print s2 = s2 or '' wrt2('\nvvvvv '..s2..'\n') if type(s1) == 'table' then - wrt2(pl.pretty.write(s1)) + wrt2(penlight.pretty.write(s1)) else wrt2(tostring(s1)) end wrt2('\n^^^^^\n') end -pl.help_wrt = pl.tex.help_wrt +penlight.help_wrt = penlight.tex.help_wrt -function pl.tex.prt_array2d(t) +function penlight.tex.prt_array2d(t) for _, r in ipairs(t) do local s = '' for _, v in ipairs(r) do s = s.. tostring(v)..', ' end - pl.tex.prt(s) - pl.tex.prt('\n') + penlight.tex.prt(s) + penlight.tex.prt('\n') end end -- -- -- -- -- -function pl.tex.pkgwarn(pkg, msg1, msg2) +function penlight.tex.pkgwarn(pkg, msg1, msg2) pkg = pkg or '' msg1 = msg1 or '' msg2 = msg2 or '' tex.sprint('\\PackageWarning{'..pkg..'}{'..msg1..'}{'..msg2..'}') end -function pl.tex.pkgerror(pkg, msg1, msg2, stop) +function penlight.tex.pkgerror(pkg, msg1, msg2, stop) pkg = pkg or '' msg1 = msg1 or '' msg2 = msg2 or '' - stop = pl.hasval(stop) + stop = penlight.hasval(stop) tex.sprint('\\PackageError{'..pkg..'}{'..msg1..'}{'..msg2..'}') if stop then tex.sprint('\\stop') end -- stop on the spot (say that 10 times) end @@ -179,18 +171,18 @@ end --definition helpers -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -function pl.tex.defmacro(cs, val) -- , will not work if val contains undefined tokens (so pre-define them if using..) +function penlight.tex.defmacro(cs, val) -- , will not work if val contains undefined tokens (so pre-define them if using..) val = val or '' -- however this works for arbitrary command names (\@hello-123 etc allowed) token.set_macro(cs, val, 'global') end -function pl.tex.defcmd(cs, val) -- fixes above issue, but only chars allowed in cs (and no @) +function penlight.tex.defcmd(cs, val) -- fixes above issue, but only chars allowed in cs (and no @) val = val or '' tex.sprint('\\gdef\\'..cs..'{'..val..'}') end -function pl.tex.defcmdAT(cs, val) -- allows @ in cs, +function penlight.tex.defcmdAT(cs, val) -- allows @ in cs, --however should only be used in preamble. I avoid \makeatother because I've ran into issues with cls and sty files using it. val = val or '' tex.sprint('\\makeatletter\\gdef\\'..cs..'{'..val..'}') @@ -198,34 +190,34 @@ end -function pl.tex.prvcmd(cs, val) -- provide command via lua +function penlight.tex.prvcmd(cs, val) -- provide command via lua if token.is_defined(cs) then -- do nothing if token is defined already --pkgwarn('penlight', 'Definition '..cs..' is being overwritten') else - pl.tex.defcmd(cs, val) + penlight.tex.defcmd(cs, val) end end -function pl.tex.newcmd(cs, val) -- provide command via lua +function penlight.tex.newcmd(cs, val) -- provide command via lua if token.is_defined(cs) then - pl.tex.pkgerror('penlight: newcmd',cs..' already defined') + penlight.tex.pkgerror('penlight: newcmd',cs..' already defined') else - pl.tex.defcmd(cs, val) + penlight.tex.defcmd(cs, val) end end -function pl.tex.renewcmd(cs, val) -- provide command via lua +function penlight.tex.renewcmd(cs, val) -- provide command via lua if token.is_defined(cs) then - pl.tex.defcmd(cs, val) + penlight.tex.defcmd(cs, val) else - pl.tex.pkgerror('penlight: renewcmd',cs..' not defined') + penlight.tex.pkgerror('penlight: renewcmd',cs..' not defined') end end -function pl.tex.deccmd(cs, def, overwrite) -- declare a definition, placeholder throws an error if it used but not set! - overwrite = pl.hasval(overwrite) +function penlight.tex.deccmd(cs, def, overwrite) -- declare a definition, placeholder throws an error if it used but not set! + overwrite = penlight.hasval(overwrite) local decfun - if overwrite then decfun = pl.tex.defcmd else decfun = pl.tex.newcmd end + if overwrite then decfun = penlight.tex.defcmd else decfun = penlight.tex.newcmd end if def == nil then decfun(cs, pkgerror('penlight', cs..' was declared and used in document, but never set')) else @@ -257,26 +249,26 @@ end -- when nesting commands, this makes it helpful to not worry about brackets -pl.tex._NumBkts = 0 +penlight.tex._NumBkts = 0 --prt(opencmd('textbf')..opencmd('texttt')..'bold typwriter'..close_bkt_cnt()) -function pl.tex.opencmd(cmd) +function penlight.tex.opencmd(cmd) return '\\'..cmd..add_bkt_cnt() end -function pl.tex.reset_bkt_cnt(n) +function penlight.tex.reset_bkt_cnt(n) n = n or 0 _NumBkts = n end -function pl.tex.add_bkt_cnt(n) +function penlight.tex.add_bkt_cnt(n) -- add open bracket n times, returns brackets n = n or 1 _NumBkts = _NumBkts + n return ('{'):rep(n) end -function pl.tex.close_bkt_cnt(n) +function penlight.tex.close_bkt_cnt(n) n = n or _NumBkts local s = ('}'):rep(n) _NumBkts = _NumBkts - n @@ -285,12 +277,12 @@ end -function pl.tex.aliasluastring(s, d) +function penlight.tex.aliasluastring(s, d) s = s:delspace():upper():tolist() d = d:delspace():upper():tolist() - for i, S in pl.seq.enum(d:slice_assign(1,#s,s)) do + for i, S in penlight.seq.enum(d:slice_assign(1,#s,s)) do if (S == 'E') or (S == 'F') then S = '' end -- E or F is fully expanded - pl.tex.prtn('\\let\\plluastring'..pl.Char(i)..'\\luastring'..S) + penlight.tex.prtn('\\let\\plluastring'..penlight.Char(i)..'\\luastring'..S) end end @@ -298,7 +290,7 @@ end -function pl.tex.get_ref_info(l) +function penlight.tex.get_ref_info(l) local n = 5 if __PL_NO_HYPERREF__ then local n = 2 @@ -306,19 +298,19 @@ function pl.tex.get_ref_info(l) local r = token.get_macro('r@'..l) local t = {} if r == nil then - t = pl.tablex.new(n, 0) -- make all 0s + t = penlight.tablex.new(n, 0) -- make all 0s r = '-not found-' else t = {r:match(("(%b{})"):rep(n))} - t = pl.tablex.map(string.trimfl, t) + t = penlight.tablex.map(string.trimfl, t) end t[#t+1] = r -- add the og return of label - --pl.help_wrt(t, 'ref info') + --penlight.help_wrt(t, 'ref info') return t end -- todo add regex pattern for cref info ---function pl.tex.get_ref_info_all_cref(l) +--function penlight.tex.get_ref_info_all_cref(l) -- local r = token.get_macro('r@'..l..'@cref') -- if r == nil then -- return r, 0, 0 @@ -364,11 +356,11 @@ local number = P{"number", -function pl.char(num) +function penlight.char(num) return string.char(string.byte("a")+num-1) end -function pl.Char(num) +function penlight.Char(num) return string.char(string.byte("A")+num-1) end @@ -434,7 +426,7 @@ function str_mt.__index.totable(str) end function str_mt.__index.tolist(str) - return pl.List(str) + return penlight.List(str) end @@ -454,7 +446,7 @@ end -- -- -- -- function stuff -function pl.clone_function(fn) +function penlight.clone_function(fn) local dumped = string.dump(fn) local cloned = loadstring(dumped) local i = 1 @@ -474,15 +466,15 @@ end -- -- -- -- -- -- -- -- -- -- -- -- functions below extend the operator module -function pl.operator.strgt(a,b) return tostring(a) > tostring(b) end -function pl.operator.strlt(a,b) return tostring(a) < tostring(b) end +function penlight.operator.strgt(a,b) return tostring(a) > tostring(b) end +function penlight.operator.strlt(a,b) return tostring(a) < tostring(b) end -- -- -- -- functions below are helpers for arrays and 2d local function compare_elements(a, b, op, ele) - op = op or pl.oper.gt + op = op or penlight.oper.gt ele = ele or 1 return op(a[ele], b[ele]) end @@ -499,32 +491,32 @@ end -- table stuff below -function pl.tablex.map_slice(func, T, j1, j2) +function penlight.tablex.map_slice(func, T, j1, j2) if type(j1) == 'string' then - return pl.array2d.map_slice(func, {T}, ','..j1)[1] + return penlight.array2d.map_slice(func, {T}, ','..j1)[1] else - return pl.array2d.map_slice(func, {T}, 1, j1, 1, j2)[1] + return penlight.array2d.map_slice(func, {T}, 1, j1, 1, j2)[1] end end -pl.array2d.map_slice1 = pl.tablex.map_slice +penlight.array2d.map_slice1 = penlight.tablex.map_slice -- todo option for multiple filters with AND logic, like the filter files?? -function pl.tablex.filterstr(t, exp, case) +function penlight.tablex.filterstr(t, exp, case) -- case = case sensitive - case = pl.hasval(case) + case = penlight.hasval(case) -- apply lua patterns to a table to filter iter -- str or table of str's can be passed, OR logic is used if table is passed if case then - return pl.tablex.filter(t, bind(string.containsany,_1,exp)) + return penlight.tablex.filter(t, bind(string.containsany,_1,exp)) else - return pl.tablex.filter(t, bind(string.containsanycase,_1,exp)) + return penlight.tablex.filter(t, bind(string.containsanycase,_1,exp)) end end -function pl.utils.filterfiles(...) +function penlight.utils.filterfiles(...) -- f1 is a series of filtering patterns, or condition -- f2 is a series of filtering patters, or condition -- (f1_a or f2_...) and (f2 .. ) must match @@ -547,11 +539,11 @@ function pl.utils.filterfiles(...) end local files - if r then files = pl.dir.getallfiles(dir) - else files = pl.dir.getfiles(dir) + if r then files = penlight.dir.getallfiles(dir) + else files = penlight.dir.getfiles(dir) end for i=nstart,args.n do - files = pl.tablex.filter(files, pl.func.compose(bind(string.containsanycase,_1, args[i]), pl.path.basename)) + files = penlight.tablex.filter(files, penlight.func.compose(bind(string.containsanycase,_1, args[i]), penlight.path.basename)) end return files end @@ -562,54 +554,54 @@ end -- -- -- -- -- -- -- -- functions below extend the array2d module -function pl.array2d.map_slice(func, M, i1, j1, i2, j2) -- map a function to a slice of a Matrix - func = pl.utils.function_arg(1, func) - for i,j in pl.array2d.iter(M, true, i1, j1, i2, j2) do +function penlight.array2d.map_slice(func, M, i1, j1, i2, j2) -- map a function to a slice of a Matrix + func = penlight.utils.function_arg(1, func) + for i,j in penlight.array2d.iter(M, true, i1, j1, i2, j2) do M[i][j] = func(M[i][j]) end return M end -pl.array2d.map_slice2 = pl.array2d.map_slice +penlight.array2d.map_slice2 = penlight.array2d.map_slice -function pl.array2d.map_cols(func, M, j1, j2) -- map function to columns of matrix +function penlight.array2d.map_cols(func, M, j1, j2) -- map function to columns of matrix if type(j1) == 'string' then - return pl.array2d.map_slice(func, M, ','..j1) + return penlight.array2d.map_slice(func, M, ','..j1) else j2 = j2 or -1 - return pl.array2d.map_slice(func, M, 1, j1, -1, j2) + return penlight.array2d.map_slice(func, M, 1, j1, -1, j2) end end -pl.array2d.map_columns = pl.array2d.map_cols +penlight.array2d.map_columns = penlight.array2d.map_cols -function pl.array2d.map_rows(func, M, i1, i2) -- map function to rows of matrix +function penlight.array2d.map_rows(func, M, i1, i2) -- map function to rows of matrix if type(i1) == 'string' then - return pl.array2d.map_slice(func, M, i1) + return penlight.array2d.map_slice(func, M, i1) else i2 = i2 or -1 - return pl.array2d.map_slice(func, M, i1, 1, i2, -1) + return penlight.array2d.map_slice(func, M, i1, 1, i2, -1) end end -- -- -- -- -- -- -- -- -function pl.array2d.sortOP(M, op, ele) -- sort a 2d array based on operator criteria, ele is column, ie sort on which element +function penlight.array2d.sortOP(M, op, ele) -- sort a 2d array based on operator criteria, ele is column, ie sort on which element M_new = {} - for row in pl.seq.sort(M, comp_2ele_func(op, ele)) do + for row in penlight.seq.sort(M, comp_2ele_func(op, ele)) do M_new[#M_new+1] = row end return M_new end -function pl.array2d.like(M1, v) +function penlight.array2d.like(M1, v) v = v or 0 - r, c = pl.array2d.size(M1) - return pl.array2d.new(r,c,v) + r, c = penlight.array2d.size(M1) + return penlight.array2d.new(r,c,v) end -function pl.array2d.from_table(t) -- turns a labelled table to a 2d, label-free array +function penlight.array2d.from_table(t) -- turns a labelled table to a 2d, label-free array t_new = {} for k, v in pairs(t) do if type(v) == 'table' then @@ -625,10 +617,10 @@ function pl.array2d.from_table(t) -- turns a labelled table to a 2d, label-free return t_new end -function pl.array2d.toTeX(M, EL) --puts & between columns, can choose to end line with \\ if EL is true (end-line) +function penlight.array2d.toTeX(M, EL) --puts & between columns, can choose to end line with \\ if EL is true (end-line) EL = EL or false if EL then EL = '\\\\' else EL = '' end - return pl.array2d.reduce2(_1..EL.._2, _1..'&'.._2, M)..EL + return penlight.array2d.reduce2(_1..EL.._2, _1..'&'.._2, M)..EL end @@ -649,7 +641,7 @@ local function parse_numpy1d(i1, i2, iS) return i1, i2 end -function pl.array2d.parse_numpy2d_str(s) +function penlight.array2d.parse_numpy2d_str(s) s = s:gsub('%s+', '') _, _, i1, iS, i2, j1, jS, j2 = string.find(s, "(%-?%d*)(:?)(%-?%d*),?(%-?%d*)(:?)(%-?%d*)") i1, i2 = parse_numpy1d(i1, i2, iS) @@ -658,12 +650,12 @@ function pl.array2d.parse_numpy2d_str(s) end -local _parse_range = pl.clone_function(pl.array2d.parse_range) +local _parse_range = penlight.clone_function(penlight.array2d.parse_range) -function pl.array2d.parse_range(s) -- edit parse range to do numpy string if no letter passed - pl.utils.assert_arg(1,s,'string') +function penlight.array2d.parse_range(s) -- edit parse range to do numpy string if no letter passed + penlight.utils.assert_arg(1,s,'string') if not s:find'%a' then - return pl.array2d.parse_numpy2d_str(s) + return penlight.array2d.parse_numpy2d_str(s) end return _parse_range(s) end @@ -674,68 +666,68 @@ end -- https://tex.stackexchange.com/questions/38150/in-lualatex-how-do-i-pass-the-content-of-an-environment-to-lua-verbatim -pl.tex.recordedbuf = "" -function pl.tex.readbuf(buf) +penlight.tex.recordedbuf = "" +function penlight.tex.readbuf(buf) i,j = string.find(buf, '\\end{%w+}') if i==nil then -- if not ending an environment - pl.tex.recordedbuf = pl.tex.recordedbuf .. buf .. "\n" + penlight.tex.recordedbuf = penlight.tex.recordedbuf .. buf .. "\n" return "" else return nil end end -function pl.tex.startrecording() - pl.tex.recordedbuf = "" - luatexbase.add_to_callback('process_input_buffer', pl.tex.readbuf, 'readbuf') +function penlight.tex.startrecording() + penlight.tex.recordedbuf = "" + luatexbase.add_to_callback('process_input_buffer', penlight.tex.readbuf, 'readbuf') end -function pl.tex.stoprecording() +function penlight.tex.stoprecording() luatexbase.remove_from_callback('process_input_buffer', 'readbuf') - pl.tex.recordedbuf = pl.tex.recordedbuf:gsub("\\end{%w+}\n","") + penlight.tex.recordedbuf = penlight.tex.recordedbuf:gsub("\\end{%w+}\n","") end __PDFmetadata__ = {} -pl.tex.add_xspace_intext = true +penlight.tex.add_xspace_intext = true -function pl.tex.updatePDFtable(k, v, o) -- key val overwrite +function penlight.tex.updatePDFtable(k, v, o) -- key val overwrite k = k:upfirst() - if pl.hasval(o) or (__PDFmetadata__[k] == nil) then + if penlight.hasval(o) or (__PDFmetadata__[k] == nil) then __PDFmetadata__[k] = v end end -pl.tex.writePDFmetadata = function(t) -- write PDF metadata to xmpdata file +penlight.tex.writePDFmetadata = function(t) -- write PDF metadata to xmpdata file t = t or __PDFmetadata__ local str = '' for k, v in pairs(t) do k = k:upfirst() str = str..'\\'..k..'{'..v..'}'..'\n' end - pl.utils.writefile(tex.jobname..'.xmpdata', str) + penlight.utils.writefile(tex.jobname..'.xmpdata', str) end -function pl.tex.clear_cmds_str(s) +function penlight.tex.clear_cmds_str(s) return s:gsub('%s+', ' '):gsub('\\\\',' '):gsub('\\%a+',''):gsub('{',' '):gsub('}',' '):gsub('%s+',' '):strip() end -function pl.tex.makePDFvarstr(s) +function penlight.tex.makePDFvarstr(s) s = s:gsub('%s*\\sep%s+','\0'):gsub('%s*\\and%s+','\0') -- turn \and into \sep - s = pl.tex.clear_cmds_str(s) + s = penlight.tex.clear_cmds_str(s) s = s:gsub('\0','\\sep ') - --pl.tex.help_wrt(s,'PDF var string') + --penlight.tex.help_wrt(s,'PDF var string') return s end -function pl.tex.makeInTextstr(s) +function penlight.tex.makeInTextstr(s) local s, c_and = s:gsub('%s*\\and%s+','\0') - s = pl.tex.clear_cmds_str(s) - if pl.tex.add_xspace_intext then + s = penlight.tex.clear_cmds_str(s) + if penlight.tex.add_xspace_intext then s = s..'\\xspace' end if c_and == 1 then @@ -744,13 +736,13 @@ function pl.tex.makeInTextstr(s) s = s:gsub('\0',', ', c_and - 1) s = s:gsub('\0',', and ') end - --pl.tex.help_wrt(s,'in text var string') + --penlight.tex.help_wrt(s,'in text var string') return s end --todo decide on above or below -function pl.tex.list2comma(t) +function penlight.tex.list2comma(t) local s = '' if #t == 1 then s = t[1] @@ -762,28 +754,27 @@ function pl.tex.list2comma(t) return s end -function pl.tex.split2comma(s, d) - local t = pl.List(s:split(d)):map(string.strip) - pl.tex.prt(pl.tex.list2comma(t)) +function penlight.tex.split2comma(s, d) + local t = penlight.List(s:split(d)):map(string.strip) + penlight.tex.prt(penlight.tex.list2comma(t)) end -function pl.tex.split2items(s, d) - local t = pl.List(s:split(d)):map(string.strip) +function penlight.tex.split2items(s, d) + local t = penlight.List(s:split(d)):map(string.strip) for n, v in ipairs(t) do - pl.tex.prtn('\\item '..v) + penlight.tex.prtn('\\item '..v) end end -if pl.hasval(__PL_GLOBALS__) then - __PL_EXTRAS__ = 2 +if penlight.hasval(__PL_GLOBALS__) then -- iterators - kpairs = pl.utils.kpairs - npairs = pl.utils.npairs + kpairs = penlight.utils.kpairs + npairs = penlight.utils.npairs --enum = utils.enum - for k,v in pairs(pl.tablex) do -- extend the table table to contain tablex functions + for k,v in pairs(penlight.tablex) do -- extend the table table to contain tablex functions if k == 'sort' then table.sortk = v elseif k == 'move' then @@ -795,27 +786,27 @@ if pl.hasval(__PL_GLOBALS__) then table.join = table.concat -- alias -- todo should tablex have all table functions - pl.tablex.concat = table.concat - pl.tablex.insert = table.insert - pl.tablex.maxn = table.maxn - pl.tablex.remove = table.remove - pl.tablex.sort = table.sort + penlight.tablex.concat = table.concat + penlight.tablex.insert = table.insert + penlight.tablex.maxn = table.maxn + penlight.tablex.remove = table.remove + penlight.tablex.sort = table.sort - hasval = pl.hasval - COMP = pl.COMP + hasval = penlight.hasval + COMP = penlight.COMP -- shortcuts --- http://stevedonovan.github.io/Penlight/api/libraries/pl.utils.html - pl.writefile = pl.utils.writefile - pl.readfile = pl.utils.readfile - pl.readlines = pl.utils.readfile - pl.filterfiles = pl.utils.filterfiles +-- http://stevedonovan.github.io/Penlight/api/libraries/penlight.utils.html + penlight.writefile = penlight.utils.writefile + penlight.readfile = penlight.utils.readfile + penlight.readlines = penlight.utils.readfile + penlight.filterfiles = penlight.utils.filterfiles - pl.a2 = pl.array2d - pl.tbl = pl.tablex + penlight.a2 = penlight.array2d + penlight.tbl = penlight.tablex - for k,v in pairs(pl.tex) do -- make tex functions global + for k,v in pairs(penlight.tex) do -- make tex functions global _G[k] = v end @@ -825,42 +816,42 @@ end - --_xTrue = pl.tex._xTrue - --_xFalse = pl.tex._xFalse - --_xNoValue = pl.tex._xNoValue + --_xTrue = penlight.tex._xTrue + --_xFalse = penlight.tex._xFalse + --_xNoValue = penlight.tex._xNoValue -- - --prt = pl.tex.prt - --prtn = pl.tex.prtn - --wrt = pl.tex.wrt - --wrtn = pl.tex.wrtn + --prt = penlight.tex.prt + --prtn = penlight.tex.prtn + --wrt = penlight.tex.wrt + --wrtn = penlight.tex.wrtn -- - --prtl = pl.tex.prtl - --prtt = pl.tex.prtt + --prtl = penlight.tex.prtl + --prtt = penlight.tex.prtt -- - --help_wrt = pl.tex.help_wrt - --prt_array2d = pl.tex.prt_array2d + --help_wrt = penlight.tex.help_wrt + --prt_array2d = penlight.tex.prt_array2d -- - --pkgwarn = pl.tex.pkgwarn - --pkgerror = pl.tex.pkgerror + --pkgwarn = penlight.tex.pkgwarn + --pkgerror = penlight.tex.pkgerror -- - --defcmd = pl.tex.defcmd - --prvcmd = pl.tex.prvcmd - --newcmd = pl.tex.newcmd - --renewcmd = pl.tex.renewcmd - --deccmd = pl.tex.deccmd + --defcmd = penlight.tex.defcmd + --prvcmd = penlight.tex.prvcmd + --newcmd = penlight.tex.newcmd + --renewcmd = penlight.tex.renewcmd + --deccmd = penlight.tex.deccmd -- - --_NumBkts = pl.tex._NumBkts - --opencmd = pl.tex.opencmd - --reset_bkt_cnt = pl.tex.reset_bkt_cnt - --add_bkt_cnt = pl.tex.add_bkt_cnt - --close_bkt_cnt = pl.tex.close_bkt_cnt + --_NumBkts = penlight.tex._NumBkts + --opencmd = penlight.tex.opencmd + --reset_bkt_cnt = penlight.tex.reset_bkt_cnt + --add_bkt_cnt = penlight.tex.add_bkt_cnt + --close_bkt_cnt = penlight.tex.close_bkt_cnt -- graveyard -- luakeys parses individual keys as ipairs, this changes the list to a pure map ---function pl.luakeystomap(t) +--function penlight.luakeystomap(t) -- local t_new = {} -- for k, v in pairs(t) do -- if type(k) == 'number' then @@ -874,7 +865,7 @@ end --if luakeys then -- if luakeys is already loaded -- function luakeys.parseN(s, ...) -- local t = luakeys.parse(s,...) --- t = pl.luakeystomap(t) +-- t = penlight.luakeystomap(t) -- return t -- end --end @@ -893,13 +884,13 @@ end -- -- -- -- functions below extend the array2d module ---function pl.array2d.map_slice1(func, L, i1, i2) -- map a function to a slice of an array, can use PlcExpr +--function penlight.array2d.map_slice1(func, L, i1, i2) -- map a function to a slice of an array, can use PlcExpr -- i2 = i2 or i1 -- local len = #L -- i1 = check_index(i1, len) -- i2 = check_index(i2, len) -- func = check_func(func) --- for i in pl.seq.range(i1,i2) do +-- for i in penlight.seq.range(i1,i2) do -- L[i] = func(L[i]) -- end -- return L @@ -907,8 +898,8 @@ end -- used this below when iter was not working.. --i1, j1, i2, j2 = check_slice(M, i1, j1, i2, j2) - --for i in pl.seq.range(i1,i2) do - -- for j in pl.seq.range(j1,j2) do + --for i in penlight.seq.range(i1,i2) do + -- for j in penlight.seq.range(j1,j2) do --end -- penlight may have fixed this --local function check_index(ij, rc) -- converts array index to positive value if negative @@ -926,7 +917,7 @@ end -- end --end --local function check_slice(M, i1, j1, i2, j2) -- ensure a slice is valid; i.e. all positive numbers --- r, c = pl.array2d.size(M) +-- r, c = penlight.array2d.size(M) -- i1 = check_index(i1 or 1, r) -- i2 = check_index(i2 or r, r) -- j1 = check_index(j1 or 1, c) diff --git a/macros/luatex/generic/penlightplus/penlightplus.pdf b/macros/luatex/generic/penlightplus/penlightplus.pdf Binary files differnew file mode 100644 index 0000000000..89b8236d66 --- /dev/null +++ b/macros/luatex/generic/penlightplus/penlightplus.pdf diff --git a/macros/luatex/generic/penlightplus/penlightplus.sty b/macros/luatex/generic/penlightplus/penlightplus.sty new file mode 100644 index 0000000000..0d49ff90d0 --- /dev/null +++ b/macros/luatex/generic/penlightplus/penlightplus.sty @@ -0,0 +1,119 @@ +% Kale Ewasiuk (kalekje@gmail.com) +% 2023-07-22 +% Copyright (C) 2021-2023 Kale Ewasiuk +% +% Permission is hereby granted, free of charge, to any person obtaining a copy +% of this software and associated documentation files (the "Software"), to deal +% in the Software without restriction, including without limitation the rights +% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +% copies of the Software, and to permit persons to whom the Software is +% furnished to do so, subject to the following conditions: +% +% The above copyright notice and this permission notice shall be included in +% all copies or substantial portions of the Software. +% +% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +% ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +% TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +% PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +% SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR +% ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +% ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE +% OR OTHER DEALINGS IN THE SOFTWARE. + +\ProvidesPackage{penlightplus}[2023-07-22] + +\RequirePackage{luacode} +\RequirePackage{luakeys} +\RequirePackage[import]{penlight} + +\DeclareOption{globals}{\luadirect{__PL_GLOBALS__ = true}} +\DeclareOption{pl}{\directlua{pl = penlight}} +\ProcessOptions*\relax + +\luadirect{require'penlightplus'} + + + + +\global\newcommand{\writePDFmetadata}{\luadirect{penlight.tex.writePDFmetadata()}} + +\NewDocumentCommand{\writePDFmetadatakv}{ s m }{ +\IfBooleanTF{#1}{% if *, overwrite everything + \luadirect{ + __PDFmetadata__ = penlight.luakeys.parse(\luastring{#2}) + penlight.tex.writePDFmetadata() + }}{ + \luadirect{ + __PDFmetadata__ = __PDFmetadata__ or {} + penlight.tablex.update(__PDFmetadata__, penlight.luakeys.parse(\luastring{#2})) + penlight.tex.writePDFmetadata() + }} +} + + +\gdef\luastringT#1{\luastring{\unexpanded\expandafter\expandafter\expandafter{#1}}} % expand luastring twice +\global\let\luastringF\luastring % fully expanded luastring + +% allow control over expansion of arguments to a latex function +\NewDocumentCommand{\MakeluastringCommands}{O{} m }{% #1 the desired commands #2 defaults + \luadirect{penlight.tex.aliasluastring(\luastring{#2},\luastring{#1})}% +} + +\NewDocumentCommand{\splitToComma}{ O{nn} m m }{% + \MakeluastringCommands[nn]{#1}% + \luadirect{penlight.tex.split2comma(\plluastringA{#2},\plluastringB{#3})}% +} + +\NewDocumentCommand{\splitToItems}{ O{NN} m m }{% + \MakeluastringCommands[nn]{#1}% + \luadirect{penlight.tex.split2items(\plluastringA{#2},\plluastringB{#3})}% +} + + +% +% +%\NewDocumentCommand{\tblnew}{m}{\luadirect{ +% _G[\luastring{#1}] = {} +%}} +% +%\NewDocumentCommand{\tblfrkv}{m m O{} }{\luadirect{ +% _G[\luastring{#1}] = penlight.luakeys.parse(\luastring{#2}, penlight.luakeys.parse(\luastring{#3})) +%}} +% +%\NewDocumentCommand{\tblset}{m m m}{\luadirect{ +% _G[\luastring{#1}][\luastring{#2}] = \luastring{#3} +%}} +% +%\NewDocumentCommand{\tblget}{m m}{\luadirect{ +% tex.sprint(tostring(_G[\luastring{#1}][\luastring{#2}])) +%}} +% +%\NewDocumentCommand{\tblidx}{m m}{\luadirect{ +% tex.sprint(tostring(_G[\luastring{#1}][#2])) +%}} +% +% +%\NewDocumentCommand{\tblupd}{ m m}{\luadirect{ +% penlight.tablex.update(_G[\luastring{#1}], _G[\luastring{#2}]) +%}} +% +%\NewDocumentCommand{\tblupdkv}{ m m }{\luadirect{ +% penlight.tablex.update(_G[\luastring{#1}], penlight.luakeys.parse(\luastring{#2})) +%}} +% +%% todo need a get table function. If blank is passed, the last table referenced is used. +%\NewDocumentCommand{\tblfrkvII}{ m m m }{\luadirect{ +% _G[\luastring{#1}] = penlight.tablex.update(penlight.luakeys.parse(\luastring{#2}), luakeys.parse(\luastring{#3})) +%}} + + +%\NewDocumentCommand{\tbldo}{m m O{} }{\luadirect{ +% % tex.sprint(tostring(_G[\luastring{#1}][#2])) +% % todo allow one to use pl tablex function here, +% % {tbl}{update}[arg1][arg2] +% penlight.tablex[\luastring[#1]](_G[\luastring{}], _G[\luastring{}]) +%}} + + diff --git a/macros/luatex/generic/penlightplus/penlightplus.tex b/macros/luatex/generic/penlightplus/penlightplus.tex new file mode 100644 index 0000000000..50f87fa38b --- /dev/null +++ b/macros/luatex/generic/penlightplus/penlightplus.tex @@ -0,0 +1,227 @@ +% Kale Ewasiuk (kalekje@gmail.com) +% 2023-07-22 +% Copyright (C) 2021-2023 Kale Ewasiuk +% +% Permission is hereby granted, free of charge, to any person obtaining a copy +% of this software and associated documentation files (the "Software"), to deal +% in the Software without restriction, including without limitation the rights +% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +% copies of the Software, and to permit persons to whom the Software is +% furnished to do so, subject to the following conditions: +% +% The above copyright notice and this permission notice shall be included in +% all copies or substantial portions of the Software. +% +% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +% ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +% TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +% PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +% SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR +% ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +% ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE +% OR OTHER DEALINGS IN THE SOFTWARE. + + +\documentclass[11pt,parskip=half]{scrartcl} +\setlength{\parindent}{0ex} +\newcommand{\llcmd}[1]{\leavevmode\llap{\texttt{\detokenize{#1}}}} +\newcommand{\cmd}[1]{\texttt{\detokenize{#1}}} +\newcommand{\qcmd}[1]{``\cmd{#1}''} +\usepackage{url} +\usepackage{xcolor} +\usepackage{showexpl} +\lstset{explpreset={justification=\raggedright,pos=r,wide=true}} +\setlength\ResultBoxRule{0mm} +\lstset{ + language=[LaTeX]TeX, + basicstyle=\ttfamily\small, + commentstyle=\ttfamily\small\color{gray}, + frame=none, + numbers=left, + numberstyle=\ttfamily\small\color{gray}, + prebreak=\raisebox{0ex}[0ex][0ex]{\color{gray}\ensuremath{\hookleftarrow}}, + extendedchars=true, + breaklines=true, + tabsize=4, +} +\addtokomafont{title}{\raggedright} +\addtokomafont{author}{\raggedright} +\addtokomafont{date}{\raggedright} +\author{Kale Ewasiuk (\url{kalekje@gmail.com})} +\usepackage[yyyymmdd]{datetime}\renewcommand{\dateseparator}{--} +\date{\today} + + +\RequirePackage{penlightplus} + +\title{penlightplus} +\subtitle{Additions to the Penlight Lua Libraries} + +\begin{document} +% + +\maketitle + +This package first loads the \cmd{[import]penlight} package.\\ +The \texttt{pl} option may be passed to this package to create an alias for \cmd{penlight}.\\ +\texttt{globals} option may be used to make several of the functions global (as discussed below). + +\subsection*{texlua usage} +If you want to use penlightplus.lua with the \texttt{texlua} interpreter +(no document is made, but useful for testing your Lua code), +you can access it by setting \cmd{__SKIP_TEX__ = true} before loading. For example: + \begin{verbatim} +package.path = package.path .. ';'..'path/to/texmf/tex/latex/penlightplus/?.lua' +package.path = package.path .. ';'..'path/to/texmf/tex/latex/penlight/?.lua' +penlight = require'penlight' + +__SKIP_TEX__ = true --only required if you want to use + --penlightplus without a LaTeX run +__PL_GLOBALS__ = true -- optional, include global definitions +require'penlightplus' +\end{verbatim} + + + + + + +\subsection*{} + +The following global variables are defined: + +\llcmd{__SKIP_TEX__} If using the \cmd{penlightplus} package with \cmd{texlua} (good for troubleshooting), set this global before loading \cmd{penlight}\\ +The gloals flags below are taken care of in the package options:\\ +\llcmd{__PL_}\cmd{GLOBALS__} If using package with \cmd{texlua} and you don't want to set some globals (described in next sections), set this global before to \cmd{true} loading \cmd{penlight}\\ +\cmd{__PL_NO_HYPERREF__} a flag used to change the behaviour of a function, depending on if you don't use the hyperref package\\ + +\subsubsection*{penlight additions} + +Some functionality is added to penlight/lua. + +\llcmd{pl.hasval(x)} Python-like boolean testing\\ +\llcmd{COMP'xyz'()} Python-like comprehensions:\\\url{https://lunarmodules.github.io/Penlight/libraries/pl.comprehension.html}\\ +\llcmd{math.mod(n,d)}, \cmd{math.mod2(n)} math modulous\\ +\llcmd{string.}\cmd{totable(s)} string a table of characters\\ +\llcmd{string.}\cmd{delspace(s)} clear spaces from string\\ +\llcmd{pl.}\cmd{char(n)} return letter corresponding to 1=a, 2=b, etc.\\ +\llcmd{pl.}\cmd{Char(n)} return letter corresponding to 1=A, 2=B, etc.\\ + +\llcmd{pl.utils.}\cmd{filterfiles}\cmd{(dir,filt,rec)} Get files from dir and apply glob-like filters. Set rec to \cmd{true} to include sub directories\\ + + +\subsubsection*{A \cmd{pl.tex.} module is added} +\llcmd{add_bkt}\cmd{_cnt(n), }\cmd{close_bkt_cnt(n), reset_bkt_cnt} functions to keep track of adding curly brackets as strings. \cmd{add} will return \cmd{n} (default 1) \{'s and increment a counter. \cmd{close} will return \cmd{n} \}'s (default will close all brackets) and decrement.\\ +\llcmd{_NumBkts} internal integer for tracking the number of brackets\\ +\llcmd{opencmd(cs)} prints \cmd{\cs}\{ and adds to the bracket counters.\\ +\\ +\llcmd{_xNoValue,}\cmd{_xTrue,_xFalse}: \cmd{xparse} equivalents for commands\\ +\\ +\llcmd{prt(x),prtn(x)} print without or with a newline at end. Tries to help with special characters or numbers printing.\\ +\llcmd{prtl(l),prtt(t)} print a literal string, or table\\ +\llcmd{wrt(x), wrtn(x)} write to log\\ +\llcmd{help_wrt}\cmd{(s1, s2)} pretty-print something to console. S2 is a flag to help you find.\\ +\llcmd{prt_array2d(tt)} pretty print a 2d array\\ +\\ +\llcmd{pkgwarn}\cmd{(pkg, msg1, msg2)} throw a package warning\\ +\llcmd{pkgerror}\cmd{(pkg, msg1, msg2, stop)} throw a package error. If stop is true, immediately ceases compile.\\ +\\ +\llcmd{defcmd}\cmd{(cs, val)} like \cmd{\gdef}\\ +\llcmd{newcmd}\cmd{(cs, val)} like \cmd{\newcommand}\\ +\llcmd{renewcmd}\cmd{(cs, val)} like \cmd{\renewcommand}\\ +\llcmd{prvcmd}\cmd{(cs, val)} like \cmd{\providecommand}\\ +\llcmd{deccmd}\cmd{(cs, dft, overwrite)} declare a command. If \cmd{dft} (default) is \cmd{nil}, \cmd{cs} is set +to a package warning saying \cmd{'cs' was declared and used in document, but never set}. If \cmd{overwrite} +is true, it will overwrite an existing command (using \cmd{defcmd}), otherwise, it will throw error like \cmd{newcmd}.\\ +\llcmd{get_ref_info(l)}accesses the \cmd{\r@label} and returns a table\\ + + + +\subsubsection*{global extras} +If \cmd{extrasglobals} is used and NOT \cmd{extras}, many additional globals are set for shortcuts\\ +All \cmd{pl.tex} modules are made global.\\ +\cmd{pl.hasval}, \cmd{pl.COMP}, \cmd{pl.utils.kpairs}, \cmd{pl.utils.npairs} become globals with the function name.\\ + + + +\subsection*{Macro helpers} +\cmd{\MakeluastringCommands[def]{spec}} will let \cmd{\plluastring(A|B|C..)} be \cmd{\luastring(N|O|T|F)} +based on the letters that \cmd{spec} is set to (or \cmd{def} if nothing is provided) +This is useful if you want to write a command with flexibility on argument expansion. +The user can specify \cmd{n}, \cmd{o}, \cmd{t}, and \cmd{f} (case insensitve) if they want +no, once, twice, or full expansion. + +% BELOW IS FOR TROUBLESHOOTING ABOVE +%\def\NOTexp{\ONEexp} +%\def\ONEexp{\TWOexp} +%\def\TWOexp{\TREexp} +%\def\TREexp{Fully expanded} +% +%\NewDocumentCommand{\luastringExpTest}{m m}{ +% \MakeluastringCommands{#1} +% \luadirect{texio.write_nl('VVVVVVVVVVVVVVVVVVVVVVVVVVVVV')} +% \luadirect{texio.write_nl(\plluastringA{#2}..' | Not')} +% \luadirect{texio.write_nl(\plluastringB{#2}..' | Once')} +% \luadirect{texio.write_nl(\plluastringC{#2}..' | Twice')} +% \luadirect{texio.write_nl(\plluastringD{#2}..' | Full')} +% \luadirect{texio.write_nl('VVVVVVVVVVVVVVVVVVVVVVVVVVVVV')} +%} +% +%\luastringExpTest{ n o t f }{\NOTexp} + + + + +\subsection*{Split stuff} +Splitting text (or a cmd) into oxford comma format via: +\cmd{\splitToComma[expansion level]{text}{text to split on}}: + +\begin{LTXexample} + +-\splitToComma{ j doe }{\and}-\\ +-\splitToComma{ j doe \and s else }{\and}-\\ +-\splitToComma{ j doe \and s else \and a per }{\and}-\\ +-\splitToComma{ j doe \and s else \and a per \and f guy}{\and}- + +\def\authors{j doe \and s else \and a per \and f guy} +\splitToComma[o]{\authors}{\and} +\end{LTXexample} + +The expansion level is up to two characters, \cmd{n|o|t|f}, to control teh expasion of each argument. + +\begin{LTXexample} +spliToItems: +\begin{itemize} + \splitToItems{kale\and john}{\and} + \splitToItems{kale -john -someone else}{-} +\end{itemize} +\end{LTXexample} + + + + + + +% \tblfrkv{tbl_def}{kale=cool,paul=gay,craig=fun} +% \tblfrkv{tbl}{kale,paul=gay} %[naked_as_value=true] +% +% \tblget{tbl}{kale}% +% \tblget{tbl}{paul}% +% \tblget{tbl}{craig}% +% +% \tblupd{tbl_def}{tbl}% +% +% \tblfrkvII{tbl}{kale=cool,paul=gay,craig=fun}{kale=weak,paul=sad} +% \tblget{tbl}{craig}% +% \tblget{tbl}{paul}% +% \tblget{tbl}{kale}% +% +% \NewDocumentCommand{\THINg}{ O{} m}{% +% \tblfrkvII{setti}{color=red,size=small}{#1} % make settings and update based on [arg=] +% {\color{\tblget{setti}{color}}\tblget{setti}{size} #2} +% } +% +% \THINg[color=blue,size=tiny]{Kale} + +\end{document}
\ No newline at end of file diff --git a/macros/luatex/latex/yamlvars/README.md b/macros/luatex/latex/yamlvars/README.md index 031de6c53a..509e5366c9 100644 --- a/macros/luatex/latex/yamlvars/README.md +++ b/macros/luatex/latex/yamlvars/README.md @@ -1,13 +1,13 @@ # YAMLvars -- parse a YAML document and create definitions in LaTeX This LuaLaTeX package provides a YAML parser and some functions to declare and define LaTeX definitions using YAML files. -It uses the [`markdown-tinyyaml`](https://github.com/api7/lua-tinyyaml) parser that is shipped with the [`markdown`](https://ctan.org/pkg/markdown) package. +It uses the [`tinyyaml`](https://ctan.org/pkg/lua-tinyyaml) parser. # License -Copyright (C) 2021-2022 Kale Ewasiuk +Copyright (C) 2021-2023 Kale Ewasiuk Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/macros/luatex/latex/yamlvars/yamlvars.lua b/macros/luatex/latex/yamlvars/yamlvars.lua index 1d0da9a312..479880a3e8 100644 --- a/macros/luatex/latex/yamlvars/yamlvars.lua +++ b/macros/luatex/latex/yamlvars/yamlvars.lua @@ -1,6 +1,6 @@ --% Kale Ewasiuk (kalekje@gmail.com) ---% 2023-07-18 ---% Copyright (C) 2021-2022 Kale Ewasiuk +--% 2023-07-22 +--% Copyright (C) 2021-2023 Kale Ewasiuk --% --% Permission is hereby granted, free of charge, to any person obtaining a copy --% of this software and associated documentation files (the "Software"), to deal @@ -28,12 +28,9 @@ YAMLvars = {} -- self table YAMLvars.yaml = require'tinyyaml' -- note: YAMLvars.sty will have checked existence of this already -local luakeys = require'luakeys'() -- note: YAMLvars.sty will have checked existence of this already +YAMLvars.luakeys = require'luakeys'() -- note: YAMLvars.sty will have checked existence of this already -local pl = _G['penlight'] or _G['pl'] -- penlight for this namespace is pl -if (__PL_EXTRAS__ == nil) or (__PENLIGHT__ == nil) then - tex.sprint('\\PackageError{yamlvars}{penlight package with extras (or extrasnoglobals) option must be loaded before this package}{}') -end +local pl = penlight -- UI tables to extend functionality YAMLvars.xfm = {} @@ -75,7 +72,7 @@ function YAMLvars.updatesettskv(kv, res, def) YAMLvars.setts2default() end - local kv = luakeys.parse(kv) + local kv = YAMLvars.luakeys.parse(kv) if type(kv.xfm) == 'string' then kv.xfm = pl.stringx.split(kv.xfm) end diff --git a/macros/luatex/latex/yamlvars/yamlvars.pdf b/macros/luatex/latex/yamlvars/yamlvars.pdf Binary files differindex a91095c832..4719837d3c 100644 --- a/macros/luatex/latex/yamlvars/yamlvars.pdf +++ b/macros/luatex/latex/yamlvars/yamlvars.pdf diff --git a/macros/luatex/latex/yamlvars/yamlvars.sty b/macros/luatex/latex/yamlvars/yamlvars.sty index 20ea6d33d1..733ee80b69 100644 --- a/macros/luatex/latex/yamlvars/yamlvars.sty +++ b/macros/luatex/latex/yamlvars/yamlvars.sty @@ -1,6 +1,6 @@ % Kale Ewasiuk (kalekje@gmail.com) -% 2023-07-18 -% Copyright (C) 2021-2022 Kale Ewasiuk +% 2023-07-22 +% Copyright (C) 2021-2023 Kale Ewasiuk % % Permission is hereby granted, free of charge, to any person obtaining a copy % of this software and associated documentation files (the "Software"), to deal @@ -25,13 +25,12 @@ \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{yamlvars}[2023-07-18] +\ProvidesPackage{yamlvars}[2023-07-22] \RequirePackage{luacode} -\RequirePackage{xspace} \RequirePackage{etoolbox} \RequirePackage{luakeys} -\RequirePackage{penlight} % no option passed here, but extras must be used, error will be thrown if not +\RequirePackage{penlightplus} % no option passed here, but extras must be used, error will be thrown if not %\IfFileExists{tinyyaml.lua}{}{\PackageError{yamlvars}{This package requires installation of the 'tinyyaml' package, please install it and try again}{}} @@ -94,19 +93,19 @@ YAMLvars.xfmDefault = {'lb2nl','addxspace'} }} -\newenvironment{declareYAMLvars}{\luadirect{_G[__PENLIGHT__].tex.startrecording()}}{\luadirect{_G[__PENLIGHT__].tex.stoprecording()} - \luadirect{YAMLvars.declareYAMLvarsStr(_G[__PENLIGHT__].tex.recordedbuf)} +\newenvironment{declareYAMLvars}{\luadirect{penlight.tex.startrecording()}}{\luadirect{penlight.tex.stoprecording()} + \luadirect{YAMLvars.declareYAMLvarsStr(penlight.tex.recordedbuf)} } \NewDocumentEnvironment{parseYAMLvars}{}% {\luadirect{ - _G[__PENLIGHT__].tex.startrecording() + penlight.tex.startrecording() }}% {\luadirect{ - _G[__PENLIGHT__].tex.stoprecording() + penlight.tex.stoprecording() }} -\AfterEndEnvironment{parseYAMLvars}{\luadirect{YAMLvars.parseYAMLvarsStr(_G[__PENLIGHT__].tex.recordedbuf)}} +\AfterEndEnvironment{parseYAMLvars}{\luadirect{YAMLvars.parseYAMLvarsStr(penlight.tex.recordedbuf)}} % necessary hack to get rohead and lohead to work.. % .. https://tex.stackexchange.com/questions/637018/setting-koma-heading-within-lua/637021?noredirect=1#comment1587387_637021 @@ -116,10 +115,10 @@ YAMLvars.xfmDefault = {'lb2nl','addxspace'} -\newenvironment{parseYAMLpdfdata}{\luadirect{_G[__PENLIGHT__].tex.startrecording()}}{ - \luadirect{_G[__PENLIGHT__].tex.stoprecording() - YAMLvars.yaml2PDFmetadata(_G[__PENLIGHT__].tex.recordedbuf) - _G[__PENLIGHT__].tex.writePDFmetadata() +\newenvironment{parseYAMLpdfdata}{\luadirect{penlight.tex.startrecording()}}{ + \luadirect{penlight.tex.stoprecording() + YAMLvars.yaml2PDFmetadata(penlight.tex.recordedbuf) + penlight.tex.writePDFmetadata() } } diff --git a/macros/luatex/latex/yamlvars/yamlvars.tex b/macros/luatex/latex/yamlvars/yamlvars.tex index cd6888cea8..552fc21988 100644 --- a/macros/luatex/latex/yamlvars/yamlvars.tex +++ b/macros/luatex/latex/yamlvars/yamlvars.tex @@ -1,6 +1,6 @@ % Kale Ewasiuk (kalekje@gmail.com) -% 2023-07-18 -% Copyright (C) 2021-2022 Kale Ewasiuk +% 2023-07-22 +% Copyright (C) 2021-2023 Kale Ewasiuk % % Permission is hereby granted, free of charge, to any person obtaining a copy % of this software and associated documentation files (the "Software"), to deal @@ -53,7 +53,6 @@ \date{\today} -\usepackage[pl,extrasglobals]{penlight} \usepackage[overwritedefs]{yamlvars} \title{YAMLvars} \subtitle{a YAML variable parser for LuaLaTeX} @@ -115,10 +114,9 @@ The YAML specification: \url{https://yaml.org/spec/}\\ Many of the ``transform'' and ``processing'' functions built-in to this package rely on other packages, like -\texttt{hyperref}, for example, but it is not loaded, and this package will only load -\cmd{penlight}, -\cmd{luacode}, -\cmd{xspace}, and +\texttt{hyperref}, or \texttt{xspace} for example, but they are not loaded, and this package will only load +\cmd{penlightplus}, +\cmd{luacode}, \cmd{luakeys}, and \cmd{etoolbox}. \section{Declaring variables} |