fix ref issues

This commit is contained in:
matthias@quintern.xyz 2025-02-23 10:19:47 +01:00
parent 16aacd72d8
commit d803b2308a
3 changed files with 23 additions and 12 deletions

View File

@ -123,11 +123,11 @@
\ttxt{\eng{ \ttxt{\eng{
Applies a L2 norm penalty on the weights. Applies a L2 norm penalty on the weights.
This ensures unimportant features are less regarded and do not encode noise. 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{ }\ger{
Reduziert Gewichte mit der L2-Norm. Reduziert Gewichte mit der L2-Norm.
Dadurch werden unwichtige Features nicht berücksichtigt (kleines Gewicht) und enkodieren nicht Noise. 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} \end{formula}

View File

@ -54,6 +54,9 @@
% Class defining commands shared by all formula environments % Class defining commands shared by all formula environments
% 1: key % 1: key
\newenvironment{formulainternal}[1]{ \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 % [1]: language
% 2: name % 2: name
% 3: description % 3: description
@ -70,12 +73,12 @@
% [1]: label to use % [1]: label to use
% 2: Abbreviation to use for references % 2: Abbreviation to use for references
\newcommand{\abbrLabel}[2][#1]{ \newcommand{\abbrLabel}[2][#1]{
\abbrLink[f:\fqname]{##1}{##2} \abbrLink[f:\fqname:#1]{##1}{##2}
} }
% makes this formula referencable with \absRef{<name>} % makes this formula referencable with \absRef{<name>}
% [1]: label to use % [1]: label to use
\newcommand{\absLabel}[1][#1]{ \newcommand{\absLabel}[1][#1]{
\absLink[f:\fqname]{##1} \absLink[\fqname:#1]{f:\fqname:#1}{##1}
} }
\newcommand{\newFormulaEntry}{ \newcommand{\newFormulaEntry}{

View File

@ -167,11 +167,19 @@
absLabels = absLabels or {} absLabels = absLabels or {}
abbrLabels = abbrLabel or {} abbrLabels = abbrLabel or {}
} }
% [1]: target (fqname to point to) % [1]: translation key, if different from target
% 2: key % 2: target (fqname to point to)
\newcommand{\absLink}[2][sec:\fqname]{ % 3: key
\newcommand{\absLink}[3][\relax]{
\directLuaAuxExpand{ \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) % [1]: target (fqname to point to)
@ -186,15 +194,15 @@
} }
% [1]: text % [1]: text
% 2: key % 2: key
\newrobustcmd{\absRef}[2][\relax]{% \newcommand{\absRef}[2][]{%
\directlua{ \directlua{
if absLabels["#2"] == nil then if absLabels["#2"] == nil then
tex.sprint(string.sanitize(\luastring{#2}) .. "???") tex.sprint(string.sanitize(\luastring{#2}) .. "???")
else else
if "#1" == "" then %-- if [#1] is not given, use translation of key as text, else us given text if \luastring{#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"] .. "}}") tex.sprint("\\hyperref[" .. absLabels["#2"]["fqname"] .. "]{\\GT{" .. absLabels["#2"]["translation"] .. "}}")
else else
tex.sprint("\\hyperref[" .. absLabels["#2"] .. "]{\luaescapestring{#1}}") tex.sprint("\\hyperref[" .. absLabels["#2"]["fqname"] .. "]{\luaescapestring{#1}}")
end end
end end
} }