From e136252b4485d1003f5296cdb07feb27417d9070 Mon Sep 17 00:00:00 2001 From: Robert Alessi Date: Fri, 5 Mar 2021 11:35:53 +0100 Subject: allow to set for the apparatus a language different from the one of the edition text --- ekdosis.dtx | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 67 insertions(+), 15 deletions(-) diff --git a/ekdosis.dtx b/ekdosis.dtx index 8b19765..0b5ec2f 100644 --- a/ekdosis.dtx +++ b/ekdosis.dtx @@ -2979,6 +2979,11 @@ texts=latin[xml:lang="la"]+\textcolor{red}{;}+ % document to change the default setting. Leaving this argument empty % as in \cs{SetDefaultRule}|{}| removes the line. % +% \DescribeMacro{\SetApparatusLanguage} \newfeature[v1.2] +% \cs{SetApparatusLang}\marg{languagename} can be used when it is +% needed to apply in the apparatus criticus a language different from +% the one that is selected in the edition text. +% % \paragraph{General Command} % \DescribeMacro{\SetApparatus} \cs{SetApparatus}\marg{csv list of % apparatus settings}\label{ref:apparatus-settings-b}\\ @@ -3011,8 +3016,14 @@ texts=latin[xml:lang="la"]+\textcolor{red}{;}+ % also be used to remove the line.\\ % \DescribeOption{norule}\hfill\tcboxverb{Default: not set}\\ % |norule| does not accept any value and has the same effect as -% |rule=none|.\label{ref:apparatus-settings-e} -% +% |rule=none|.\label{ref:apparatus-settings-e}\\ +% \DescribeOption{lang} |lang|$=$\meta{languagename} +% \newfeature[v1.2]\hfill\tcboxverb{Default: not set}\\ +% |lang=| is used as described above when it is needed +% to apply in the apparatus criticus a language different from the one +% that is selected in the edition text. |languagename| can be any +% value accepted by \pkg{babel} or \pkg{polyglossia}. +% % As an example, an apparatus criticus with references to line numbers % printed in normal font, a colon as a separator between lemma texts % and variant readings, a broad space as a delimiter between entries @@ -3106,6 +3117,7 @@ texts=latin[xml:lang="la"]+\textcolor{red}{;}+ % \DescribeOption{ehook} % \DescribeOption{rule} % \DescribeOption{norule} +% \DescribeOption{lang} % With regard to layout, any declared layer inherits the default values % described above in \vref{sec:single-layer-app}. That said, as the % optional argument of \cs{DeclareApparatus} accepts the exact same @@ -6418,6 +6430,7 @@ Sample text with a \textcolor{red}{word} in red. store bhook = \bhook@val, store ehook = \ehook@val, store maxentries = \limit@val, + store lang = \lang@val, initial direction = LR, initial delim = {}, initial ehook = {\csname ekd@end@apparatus\endcsname} @@ -6449,7 +6462,8 @@ Sample text with a \textcolor{red}{word} in red. \luastringO{\sep@val}, \luastringO{\bhook@val}, \luastringO{\ehook@val}, - \luastringO{\limit@val} + \luastringO{\limit@val}, + \luastringO{\lang@val} )} \egroup } @@ -6584,7 +6598,9 @@ Sample text with a \textcolor{red}{word} in red. initial delim = {}, store rule = \ekd@default@rule, initial rule = \rule{0.4\columnwidth}{0.4pt}, - noval norule = \def\ekd@default@rule{\mbox{}} + noval norule = \def\ekd@default@rule{\mbox{}}, + store lang = \ekd@singleapp@lang, + initial lang = \ltx@ifpackageloaded{babel}{\languagename}{} } % \end{macrocode} % \begin{macro}{\SetApparatus} @@ -6642,6 +6658,17 @@ Sample text with a \textcolor{red}{word} in red. \NewDocumentCommand{\SetUnitDelimiter}{m}{\def\ekd@unit@delim{#1}} % \end{macrocode} % \end{macro} +% \begin{macro}{\SetApparatusLanguage} +% \changes{v1.2}{2021/03/05}{defines an alternate language to be +% applied in apparatus entries} +% \cs{SetApparatusLang}\marg{languagename} can be used when +% it is needed to apply in the apparatus criticus a language +% different from the one that is selected in the edition text. +% \begin{macrocode} +\NewDocumentCommand{\SetApparatusLanguage}{m}{% + \def\ekd@singleapp@lang{#1}} +% \end{macrocode} +% \end{macro} % \begin{macro}{\footnoteruletrue} % \begin{macro}{\footnoterulefalse} % As \pkg{ekdosis} takes care of drawing a rule separating the main @@ -7062,6 +7089,19 @@ Sample text with a \textcolor{red}{word} in red. } % \end{macrocode} % \end{macro} +% \begin{macro}{\app@lang} +% This macro is used internally by \cs{lem}, \cs{rdg} and \cs{note} to +% set the language for apparatus entries. +% \begin{macrocode} +\def\app@lang{% + \ifekd@mapps + \luadirect{tex.sprint(ekdosis.getapplang(\luastring{\ekdan@type}))}% + \else + \ekd@singleapp@lang + \fi +} +% \end{macrocode} +% \end{macro} % \begin{macro}{\lem} % \cs{lem}\oarg{options}\marg{lemma text} inserts \meta{lemma text} % both in the edition text and in the apparatus criticus by default, @@ -7145,8 +7185,8 @@ Sample text with a \textcolor{red}{word} in red. \ifdefined\ekdlr@pre% \space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi \ltx@ifpackageloaded{babel}% - {{\noexpand\selectlanguage{\languagename}% - \unexpanded\expandafter{\ekd@lemmastyle}% + {{\unexpanded\expandafter{\ekd@lemmastyle}% + \noexpand\selectlanguage{\app@lang}% \unexpanded\expandafter{\ekdlr@alt}}}% {\unexpanded\expandafter{\ekd@lemmastyle}% \unexpanded\expandafter{\ekdlr@alt}}% @@ -7156,8 +7196,8 @@ Sample text with a \textcolor{red}{word} in red. \ifdefined\ekdlr@pre% \space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi \ltx@ifpackageloaded{babel}% - {{\noexpand\selectlanguage{\languagename}% - \unexpanded\expandafter{\ekd@lemmastyle}% + {{\unexpanded\expandafter{\ekd@lemmastyle}% + \noexpand\selectlanguage{\app@lang}% \unexpanded{#2}}}{% {\unexpanded\expandafter{\ekd@lemmastyle}\unexpanded{#2}}}% \ifdefined\ekdlr@post% @@ -7234,7 +7274,7 @@ Sample text with a \textcolor{red}{word} in red. \ifdefined\ekdlr@pre% \space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi \ltx@ifpackageloaded{babel}% - {{\noexpand\selectlanguage{\languagename}% + {{\noexpand\selectlanguage{\app@lang}% \unexpanded\expandafter{\ekdlr@alt}}}% {\unexpanded\expandafter{\ekdlr@alt}}% \ifdefined\ekdlr@post% @@ -7243,7 +7283,7 @@ Sample text with a \textcolor{red}{word} in red. \ifdefined\ekdlr@pre% \space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi \ltx@ifpackageloaded{babel}% - {{\noexpand\selectlanguage{\languagename}\unexpanded{#2}}}{% + {{\noexpand\selectlanguage{\app@lang}\unexpanded{#2}}}{% {\unexpanded{#2}}}% \ifdefined\ekdlr@post% \space\unexpanded\expandafter{\ekdlr@post}\space\else\fi @@ -7342,8 +7382,8 @@ Sample text with a \textcolor{red}{word} in red. \current@ref@arg{\ekdn@labelb}{\ekdn@labele}%\hskip .25em \ifdefined\ekdn@lem \ltx@ifpackageloaded{babel}% - {{\noexpand\selectlanguage{\languagename}% - \unexpanded\expandafter{\ekd@lemmastyle}% + {{\unexpanded\expandafter{\ekd@lemmastyle}% + \noexpand\selectlanguage{\app@lang}% \unexpanded\expandafter{\ekdn@lem}}}% {\unexpanded\expandafter{\ekd@lemmastyle}% \unexpanded\expandafter{\ekdn@lem}}% @@ -7351,7 +7391,7 @@ Sample text with a \textcolor{red}{word} in red. \unexpanded\expandafter{\ekdn@sep}\fi \else\fi% \ltx@ifpackageloaded{babel}% - {{\noexpand\selectlanguage{\languagename}\unexpanded{#2}}}{% + {{\noexpand\selectlanguage{\app@lang}\unexpanded{#2}}}{% {\unexpanded{#2}}}}}% \ifekd@mapps% \unconditional@appin[\ekdan@type]{\note@contents}% @@ -9603,7 +9643,8 @@ function ekdosis.newapparatus(teitype, appsep, appbhook, appehook, - applimit) + applimit, + applang) if isintable(apparatuses, teitype) then tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\"" @@ -9617,12 +9658,23 @@ function ekdosis.newapparatus(teitype, sep = appsep, bhook = appbhook, ehook = appehook, - limit = applimit}) + limit = applimit, + lang = applang}) end bagunits[teitype] = 1 return true end +function ekdosis.getapplang(teitype) + i = get_a_index(teitype, apparatuses) + if apparatuses[i].lang ~= "" + then + return apparatuses[i].lang + else + return "\\languagename" + end +end + function ekdosis.getappdelim(str) for i = 1,#apparatuses do -- cgit v1.2.3