From d803b2308aede6db1fa0bfa10b4d2cb6db7db96f Mon Sep 17 00:00:00 2001 From: "matthias@quintern.xyz" Date: Sun, 23 Feb 2025 10:19:47 +0100 Subject: [PATCH] fix ref issues --- src/comp/ml.tex | 4 ++-- src/pkg/mqformula.sty | 7 +++++-- src/pkg/mqfqname.sty | 24 ++++++++++++++++-------- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/comp/ml.tex b/src/comp/ml.tex index 2e34a9b..f9638b9 100644 --- a/src/comp/ml.tex +++ b/src/comp/ml.tex @@ -123,11 +123,11 @@ \ttxt{\eng{ Applies a L2 norm penalty on the weights. This ensures unimportant features are less regarded and do not encode noise. - \\Corresponds to assuming a \fqEqRef{math:pt:bayesian:prior} \absRef{multivariate_normal_distribution} with $\vec{mu} = 0$ and independent components ($\mat{\Sigma}$) for the weights. + \\Corresponds to assuming a \fqEqRef{math:pt:bayesian:prior} \absRef{multivariate_normal_distribution} with $\vec{\mu} = 0$ and independent components ($\mat{\Sigma}$) for the weights. }\ger{ Reduziert Gewichte mit der L2-Norm. Dadurch werden unwichtige Features nicht berücksichtigt (kleines Gewicht) und enkodieren nicht Noise. - \\Entspricht der Annahme einer \absRef[Normalverteilung]{multivariate_normal_distribution} mit $\vec{mu}=0$ und unanhängingen Komponenten ($\mat{Sigma}$ diagonaol) der die Gewichte als \fqEqRef{math:pt:bayesian:prior}. + \\Entspricht der Annahme einer \absRef[Normalverteilung]{multivariate_normal_distribution} mit $\vec{\mu}=0$ und unanhängingen Komponenten ($\mat{Sigma}$ diagonaol) der die Gewichte als \fqEqRef{math:pt:bayesian:prior}. }} \end{formula} diff --git a/src/pkg/mqformula.sty b/src/pkg/mqformula.sty index a626b45..4d77bad 100644 --- a/src/pkg/mqformula.sty +++ b/src/pkg/mqformula.sty @@ -54,6 +54,9 @@ % Class defining commands shared by all formula environments % 1: key \newenvironment{formulainternal}[1]{ + % TODO refactor, using fqname@enter and leave + % TODO There is no real need to differentiate between fqnames and sections, + % TODO thus change the meaning of f: from formula to fqname and change sec to f % [1]: language % 2: name % 3: description @@ -70,12 +73,12 @@ % [1]: label to use % 2: Abbreviation to use for references \newcommand{\abbrLabel}[2][#1]{ - \abbrLink[f:\fqname]{##1}{##2} + \abbrLink[f:\fqname:#1]{##1}{##2} } % makes this formula referencable with \absRef{} % [1]: label to use \newcommand{\absLabel}[1][#1]{ - \absLink[f:\fqname]{##1} + \absLink[\fqname:#1]{f:\fqname:#1}{##1} } \newcommand{\newFormulaEntry}{ diff --git a/src/pkg/mqfqname.sty b/src/pkg/mqfqname.sty index 68153cc..ecdfdf4 100644 --- a/src/pkg/mqfqname.sty +++ b/src/pkg/mqfqname.sty @@ -167,11 +167,19 @@ absLabels = absLabels or {} abbrLabels = abbrLabel or {} } -% [1]: target (fqname to point to) -% 2: key -\newcommand{\absLink}[2][sec:\fqname]{ +% [1]: translation key, if different from target +% 2: target (fqname to point to) +% 3: key +\newcommand{\absLink}[3][\relax]{ \directLuaAuxExpand{ - absLabels["#2"] = [[#1]] + absLabels["#3"] = {} + absLabels["#3"]["fqname"] = [[#2]] + absLabels["#3"]["translation"] = [[#1]] or [[#2]] + % if [[#1]] == "" then + % absLabels["#3"]["translation"] = [[#2]] + % else + % absLabels["#3"]["translation"] = [[#1]] + % end } } % [1]: target (fqname to point to) @@ -186,15 +194,15 @@ } % [1]: text % 2: key -\newrobustcmd{\absRef}[2][\relax]{% +\newcommand{\absRef}[2][]{% \directlua{ if absLabels["#2"] == nil then tex.sprint(string.sanitize(\luastring{#2}) .. "???") else - if "#1" == "" then %-- if [#1] is not given, use translation of key as text, else us given text - tex.sprint("\\hyperref[" .. absLabels["#2"] .. "]{\\GT{" .. absLabels["#2"] .. "}}") + if \luastring{#1} == "" then %-- if [#1] is not given, use translation of key as text, else us given text + tex.sprint("\\hyperref[" .. absLabels["#2"]["fqname"] .. "]{\\GT{" .. absLabels["#2"]["translation"] .. "}}") else - tex.sprint("\\hyperref[" .. absLabels["#2"] .. "]{\luaescapestring{#1}}") + tex.sprint("\\hyperref[" .. absLabels["#2"]["fqname"] .. "]{\luaescapestring{#1}}") end end }