michal-h21 / rdfref

Cross-referencing system for LaTeX, inspired with RDF
16 stars 3 forks source link

problem with the dependency graph of equations: a more complex equation #12

Open ouboub opened 2 weeks ago

ouboub commented 2 weeks ago

Hi I tried to replace

\begin{rdfequation}[eq:hello]
  a = b + c
  % each label for equation must use the eq: prefix
  % \rdflabel{eq:hello}
\end{rdfequation}

By

\begin{rdfequation}[eq:1]
\boxed{
  \begin{aligned}
      E(t)&:= \langle V(t),V(t)\rangle_m= \left\Vert V(t) \right\Vert_{m}^{2}= \|\partial_t   u_h+\varkappa u_h\|_{H^m}^2+\|\partial_x u_h\|_{ H^m}^2.\\
    \sqrt{E(t)}&:=  \left\Vert V(t) \right\Vert_{m}\\
    \sqrt{E(0)}&:=  \left\Vert V(0) \right\Vert_{m}=\alpha\\
  \end{aligned}
}

I could compile the file (using amssymb for \varkappa) and run dot2tex1 but when I tried to compile the orginal file with the generated graph.tex I obtained the following error

./graph.tex:17: Misplaced alignment tab character &.
l.17 ...[right] {$$boxed  { begin  {aligned} E(t)&
                                                  := };
./graph.tex:18: Undefined control sequence.
l.18   \draw
             (734.37bp,286.42bp) node[left] {angle V(t),V(t)};
./graph.tex:19: Undefined control sequence.
l.19   \draw
             (135.37bp,271.42bp) node[right] {angle _m= };
./graph.tex:19: Missing $ inserted.
<inserted text> 
                $
l.19 ...w (135.37bp,271.42bp) node[right] {angle _
                                                  m= };
./graph.tex:19: Extra }, or forgotten $.
l.19 ...35.37bp,271.42bp) node[right] {angle _m= }
                                                  ;
./graph.tex:20: Undefined control sequence.
l.20   \draw
             (734.37bp,256.42bp) node[left] {eft Vert V(t) };
./graph.tex:21: Undefined control sequence.
l.21   \draw
             (135.37bp,241.42bp) node[right] {ight Vert _{m}^{2}= |partial _...

./graph.tex:21: Misplaced alignment tab character &.
l.21 ...2+|partial _x u_h|_{ H^m}^2. sqrt  {E(t)}&
                                                  :=  };
./graph.tex:22: Undefined control sequence.
l.22   \draw
             (734.37bp,226.42bp) node[left] {eft Vert V(t) };
./graph.tex:23: Undefined control sequence.
l.23   \draw
             (135.37bp,211.42bp) node[right] {ight Vert _{m} sqrt  {E(0)}&:=...

./graph.tex:23: Misplaced alignment tab character &.
l.23 ... node[right] {ight Vert _{m} sqrt  {E(0)}&
                                                  :=  };
./graph.tex:24: Undefined control sequence.
l.24   \draw
             (734.37bp,196.42bp) node[left] {eft Vert V(0) };
./graph.tex:25: Undefined control sequence.
l.25   \draw
             (434.87bp,181.42bp) node {ight Vert _{m}=alpha  end  {aligned} ...

./graph.tex:25: Extra }, or forgotten $.
<recently read> }

l.25 ...{ight Vert _{m}=alpha  end  {aligned} }$$}
                                                  ;
./graph.tex:26: Missing $ inserted.
<inserted text> 
                $
l.26 \end{scope}

./graph.tex:26: Missing } inserted.
<inserted text> 
                }
l.26 \end{scope}

./graph.tex:26: Missing } inserted.
<inserted text> 
                }
l.26 \end{scope}

./graph.tex:26: Package tikz Error: Giving up on this path. Did you forget a semicolon?.

What is wrong?

graph.txt

ouboub commented 2 weeks ago

well not even

\begin{rdfequation}[eq:hello]
%  a = b + c
    \varkappa \left(e^{\varkappa t}-1\right)\alpha\beta+ t\sup_{[0,t]}\left\Vert a(s,\cdot) \left(1+u(s) \right)^3 \right\Vert_{H^m}\leq \left(e^{\varkappa t}-1\right)\sqrt{E(0)},  
  % each label for equation must use the eq: prefix
  % \rdflabel{eq:hello}
\end{rdfequation}

works!

michal-h21 commented 1 week ago

Yes, I've found that this is an issue with dot2tex. It needs to use texlbl option to use raw LaTeX code. So this sort of works:

\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\numberwithin{equation}{section}
\usepackage{tikz}
\usepackage{shellesc}
\usepackage{rdfref}
\NewDocumentEnvironment{rdfequation}{o +b}{
  \begin{equation}
    #2 
    \IfBlankF{#1}{
      \rdflabel{#1}
      \AssignProperty{#1}{eq:value}{$#2$}
    }
  \end{equation}
}{}

\newwrite\graphwrite

\makeatletter
\newcommand\graphout[1]{\protected@write\graphwrite{\let\owrite\write\def\write{\immediate\owrite}}{#1}}

% #1 name of the graph (default \jobname-graph) -- it needs to be different than name of any existing file!
% #2 RDF property to be printed
% #3 list of allowed rdf:type for objects
% #4 list of allowed rdf:type for subjects
% don't forget to call latex with --shell-escape 
\NewDocumentCommand\RdfDrawGraph{O{\jobname-graph} O{rdfs:label} m m}{%
  \immediate\openout\graphwrite=#1.dot\relax%
  \graphout{digraph hello\@charlb} % save graph header
  \RdfLoopReferences{#3}{#4}{%
    \StrSubstitute{\currentobject}{:}{_}[\objectlabel]
    \StrSubstitute{\currentsubject}{:}{_}[\subjectlabel]
    \graphout{\objectlabel [texlbl="\GetProperty{\currentobject}{#2}"]}
    \graphout{\subjectlabel [texlbl="\GetProperty{\currentsubject}{#2}"]}
    \graphout{\objectlabel-> \subjectlabel} %
  }
  \graphout{\@charrb}% save footer
  \immediate\closeout\graphwrite%
  \ShellEscape{dot2tex --figonly  -t raw -o #1.tmp #1.dot }%
  \InputIfFileExists{#1.tmp}{}%
}
\makeatother

\begin{document}

% we need to declare some properties for the eq: prefix 
\AddRdfType{eq}{
  \AddPropertyEx{rdf:type}{eq:equation}
  \AddPropertyEx{doc:pageNo}{\thepage}
  % this will be used in the graph label, change to your liking
  \AddPropertyEx{rdfs:label}{Equation \theequation}
}

\makeatletter
\AddRdfType{sec}{
  \AddPropertyEx{rdf:type}{sec:sectioning}
  \AddPropertyEx{doc:pageNo}{\thepage}
  % this will be used in the graph label, change to your liking
  \AddPropertyEx{rdfs:label}{Section \@currentlabel}
}
\makeatother

\section{first section}
\rdflabel{sec:first}
\begin{rdfequation}[eq:hello]
  a = b + c
\end{rdfequation}

This equation links to equation~\rdfref{eq:second}, as well as to equation~\rdfref{eq:third}.

\begin{rdfequation}[eq:1]
\boxed{
  \begin{aligned}
      E(t)&:= \langle V(t),V(t)\rangle_m= \left\Vert V(t) \right\Vert_{m}^{2}= \|\partial_t   u_h+\varkappa u_h\|_{H^m}^2+\|\partial_x u_h\|_{ H^m}^2.\\
    \sqrt{E(t)}&:=  \left\Vert V(t) \right\Vert_{m}\\
    \sqrt{E(0)}&:=  \left\Vert V(0) \right\Vert_{m}=\alpha\\
  \end{aligned}
}
\end{rdfequation}

This links to~\rdfref{eq:hello}.

\section{another}
\rdflabel{sec:another}

\begin{rdfequation}[eq:second]
  a = d + \frac{c}{d}
\end{rdfequation}

Link to another equation~\rdfref{eq:third}, in section~\rdfpageref{sec:first}.

\begin{rdfequation}[eq:third]
  d = x + y
\end{rdfequation}

\RdfLoopReferences{}{eq:equation,sec:sectioning}{%
  \GetProperty{\currentobject}{rdfs:label} -> \GetProperty{\currentsubject}{rdfs:label}, %
}

\RdfDrawGraph[\jobname-graph][eq:value]{}{eq:equation}

\end{document}

The change is to declare nodes with texlbl options:

\NewDocumentCommand\RdfDrawGraph{O{\jobname-graph} O{rdfs:label} m m}{%
  \immediate\openout\graphwrite=#1.dot\relax%
  \graphout{digraph hello\@charlb} % save graph header
  \RdfLoopReferences{#3}{#4}{%
    \StrSubstitute{\currentobject}{:}{_}[\objectlabel]
    \StrSubstitute{\currentsubject}{:}{_}[\subjectlabel]
    \graphout{\objectlabel [texlbl="\GetProperty{\currentobject}{#2}"]}
    \graphout{\subjectlabel [texlbl="\GetProperty{\currentsubject}{#2}"]}
    \graphout{\objectlabel-> \subjectlabel} %
  }
  \graphout{\@charrb}% save footer
  \immediate\closeout\graphwrite%
  \ShellEscape{dot2tex --figonly  -t raw -o #1.tmp #1.dot }%
  \InputIfFileExists{#1.tmp}{}%
}

There is a problem, though. It seems that TikZ cannot correctly determine size of the boxed math:

image

ouboub commented 1 week ago

Yes, I've found that this is an issue with dot2tex. It needs to use texlbl option to use raw LaTeX code. So this sort of works:

I have some problems.

  1. I pulled
  2. I took your example, called it equation-complex.tex and compiled it, which it did.
  3. then I run (as I did before `dot2tex --figonly -t raw equation-complex-graph.dot > graph.tex
  4. I complied equation-complex.tex but there was no graph displayed.

what do I miss?

equation-complex.pdf

michal-h21 commented 1 week ago

dot2tex is called automatically in the new example, but you must use the --shell-escape option for LaTeX. I used LuaLaTeX:

$ lualatex --shell-escape equation-complex.tex

You seem to use PDFLaTeX, which leads in ¿ instead of > in the loop. You can fix it using \usepackage[T1]{fontenc}.

ouboub commented 1 week ago

$ lualatex --shell-escape equation-complex.tex

You seem to use PDFLaTeX, which leads in ¿ instead of > in the loop. You can fix it using \usepackage[T1]{fontenc}.

Well I tried lualatex --shell-escape equation-complex.tex and I can reproduce your result. But the point is there is a problem with the size of box/ellipse, not sure how to deal with this.

michal-h21 commented 1 week ago

But the point is there is a problem with the size of box/ellipse, not sure how to deal with this.

It seems that this issue will be hard to overcome, because TikZ nodes don't really support display math. I tried to enclose the equation in minipage, but it didn't help at all. I think this method is good mostly for smaller math snippets, not large equations.

ouboub commented 1 week ago

It seems that this issue will be hard to overcome, because TikZ nodes don't really support display math. I tried to enclose the equation in minipage, but it didn't help at all. I think this method is good mostly for smaller math snippets, not large equations.

What's about {tikzcd}? Quiver for example produces this source cod

\documentclass[preview,border={5cm 4cm 28cm 4cm},multi=true,multi={minipage}]{standalone}
%                              left buttom right  top
\usepackage{latexsym}
\usepackage{varwidth}
\usepackage{empheq}
\usepackage{quiver}
\begin{document}

\begin{minipage}{1.0\linewidth}
\[\begin{tikzcd}
    \begin{array}{c} \boxed{  \begin{aligned}     \sqrt{E(t)} & \leq e^{-\varkappa(t-t_0)}\sqrt{E(t_0)} + \varkappa^2\int_{t_0}^te^{-\varkappa(t-s)} \left\Vert u_h(s) \right\Vert_{H^{m}}ds \\     & + \int_{t_0}^te^{-\varkappa (t-s)}e^{-\varkappa s} \left\Vert a(s,\cdot) \left( 1+u(s) \right)^3 \right\Vert_{H^m}ds   \end{aligned}.} \end{array} & {\boxed{    \sup_{[0,T^+]}\| u(t)\|_{ H^m}\leq \alpha\beta.}} \\
    \\
    \begin{array}{c} \boxed{     \begin{aligned}       \sqrt{E(t)} & \leq e^{-\varkappa t}\sqrt{E(0)} + \varkappa^2\int_{0}^te^{-\varkappa (t-s)} \alpha\beta ds + \int_{0}^te^{-\varkappa (t-s)}e^{-\varkappa s} \left\Vert a(s,\cdot) \left( 1+u(s) \right)^3 \right\Vert_{H^m} ds\\       & \leq e^{-\varkappa t}\sqrt{E(0)} +\varkappa \left(1 -e^{-\varkappa t}\right)\alpha\beta+ te^{-\varkappa t}\sup_{[0,t]}\left\Vert a(s,\cdot) \left( 1+u(s) \right)^3 \right\Vert_{H^m}.     \end{aligned} } \end{array} & \bullet \\
    {\boxed{e^{\varkappa t} \sqrt{E(t)} \leq \sqrt{E(0)} +\varkappa \left(e^{\varkappa t} -1 \right)\alpha\beta+ t\sup_{[0,t]}\left\Vert a(s,\cdot) \left( 1+u(s) \right)^3 \right\Vert_{H^m}.}} & {\boxed{    \varkappa \left(e^{\varkappa t}-1\right)\alpha\beta+ t\sup_{[0,t]}\left\Vert a(s,\cdot) \left(1+u(s) \right)^3 \right\Vert_{H^m}\leq \left(e^{\varkappa t}-1\right)\sqrt{E(0)},}} & \begin{array}{c} \boxed{   \begin{aligned}       E(t)&:= \langle V(t),V(t)\rangle_m= \left\Vert V(t) \right\Vert_{m}^{2}= \|\partial_t   u_h+\varkappa u_h\|_{H^m}^2+\|\partial_x u_h\|_{ H^m}^2.\\     \sqrt{E(t)}&:=  \left\Vert V(t) \right\Vert_{m}\\     \sqrt{E(0)}&:=  \left\Vert V(0) \right\Vert_{m}=\alpha\\   \end{aligned} } \end{array} \\
    & \begin{array}{c}   \boxed{     \begin{aligned}       t\sup_{[0,t]}\left\Vert a(s,\cdot) \left(1+u(s) \right)^3 \right\Vert_{H^m} &\leq \left(e^{\varkappa t}-1\right)\sqrt{E(0)}-\varkappa \left(e^{\varkappa t}-1\right)\alpha\beta \\                                                                   &\leq\left(e^{\varkappa t}-1\right)\alpha(1-\beta\varkappa)     \end{aligned}   } \end{array} \\
    {\boxed{    E(t)\leq E(0).}} & {\boxed{    t\sup_{[0,t]}\left\Vert a(s,\cdot) \left(1+u(s) \right)^3 \right\Vert_{H^m}\leq \left(e^{\varkappa t}-1\right)\alpha\left(\beta-\varkappa\right).}} & {\boxed{    \left\Vert a(s,\cdot) \left(1+u(s) \right)^3 \right\Vert_{H^m}\leq C(2\alpha\beta)\|a(s,\cdot)\|_{H^m}.}} \\
    & {\boxed{    \sup_{[0,\infty)}\|a(t,\cdot)\|_{H^m}\leq \epsilon_0.}} & {\boxed{    \epsilon_0=\frac{\varkappa\alpha(\beta-\varkappa)}{C(2\alpha\beta)}.}}
    \arrow[from=1-1, to=3-1]
    \arrow[from=1-2, to=3-1]
    \arrow[from=3-1, to=4-1]
    \arrow[from=4-1, to=6-1]
    \arrow[from=4-2, to=5-2]
    \arrow[from=4-2, to=6-1]
    \arrow[from=4-3, to=6-2]
    \arrow[from=5-2, to=6-2]
    \arrow[from=6-3, to=7-2]
    \arrow[from=7-3, to=7-2]
\end{tikzcd}\]
\end{minipage}
\end{document}
michal-h21 commented 1 week ago

With tikzcd, you would need to place nodes yourself. It doesn't look like something that could be easily done.

But I've found a solution with dot2tex. It has the --autosize option, which produces a node with correct size. It doesn't calculate size of the ellipsis correctly thought, so I had to use rectangles for nodes instead.

\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\numberwithin{equation}{section}
\usepackage{tikz}
\usepackage{shellesc}
\usetikzlibrary{graphs,graphdrawing,calc} 
\usegdlibrary{layered}
\usepackage[T1]{fontenc}
\usepackage{rdfref}
\NewDocumentEnvironment{rdfequation}{o +b}{
  \begin{equation}
    #2 
    \IfBlankF{#1}{
      \rdflabel{#1}
      \AssignProperty{#1}{eq:value}{$#2$}
    }
  \end{equation}
}{}

\newwrite\graphwrite

\makeatletter
\newcommand\graphout[1]{\protected@write\graphwrite{\let\owrite\write\def\write{\immediate\owrite}}{#1}}

% #1 name of the graph (default \jobname-graph) -- it needs to be different than name of any existing file!
% #2 RDF property to be printed
% #3 list of allowed rdf:type for objects
% #4 list of allowed rdf:type for subjects
% don't forget to call latex with --shell-escape 
\NewDocumentCommand\RdfDrawGraph{O{\jobname-graph} O{rdfs:label} m m}{%
  \immediate\openout\graphwrite=#1.dot\relax%
  \graphout{digraph hello\@charlb} % save graph header
  \RdfLoopReferences{#3}{#4}{%
    \StrSubstitute{\currentobject}{:}{_}[\objectlabel]
    \StrSubstitute{\currentsubject}{:}{_}[\subjectlabel]
    \graphout{\objectlabel [shape="rectangle",texlbl="\GetProperty{\currentobject}{#2}"]}
    \graphout{\subjectlabel [shape="rectangle",texlbl="\GetProperty{\currentsubject}{#2}"]}
    \graphout{\objectlabel-> \subjectlabel} %
  }
  \graphout{\@charrb}% save footer
  \immediate\closeout\graphwrite%
  \ShellEscape{dot2tex --figonly --autosize -t raw -o #1.tmp #1.dot }%
  \InputIfFileExists{#1.tmp}{}%
}
\makeatother

\begin{document}

% we need to declare some properties for the eq: prefix 
\AddRdfType{eq}{
  \AddPropertyEx{rdf:type}{eq:equation}
  \AddPropertyEx{doc:pageNo}{\thepage}
  % this will be used in the graph label, change to your liking
  \AddPropertyEx{rdfs:label}{Equation \theequation}
}

\makeatletter
\AddRdfType{sec}{
  \AddPropertyEx{rdf:type}{sec:sectioning}
  \AddPropertyEx{doc:pageNo}{\thepage}
  % this will be used in the graph label, change to your liking
  \AddPropertyEx{rdfs:label}{Section \@currentlabel}
}
\makeatother

\section{first section}
\rdflabel{sec:first}
\begin{rdfequation}[eq:hello]
  a = b + c
\end{rdfequation}

This equation links to equation~\rdfref{eq:second}, as well as to equation~\rdfref{eq:third}.

\begin{rdfequation}[eq:1]
\boxed{
  \begin{aligned}
      E(t)&:= \langle V(t),V(t)\rangle_m= \left\Vert V(t) \right\Vert_{m}^{2}= \|\partial_t   u_h+\varkappa u_h\|_{H^m}^2+\|\partial_x u_h\|_{ H^m}^2.\\
    \sqrt{E(t)}&:=  \left\Vert V(t) \right\Vert_{m}\\
    \sqrt{E(0)}&:=  \left\Vert V(0) \right\Vert_{m}=\alpha\\
  \end{aligned}
}
\end{rdfequation}

This links to~\rdfref{eq:hello}.

\section{another}
\rdflabel{sec:another}

\begin{rdfequation}[eq:second]
  a = d + \frac{c}{d}
\end{rdfequation}

Link to another equation~\rdfref{eq:third}, in section~\rdfpageref{sec:first}.

\begin{rdfequation}[eq:third]
  d = x + y
\end{rdfequation}

\RdfLoopReferences{}{eq:equation,sec:sectioning}{%
  \GetProperty{\currentobject}{rdfs:label} -> \GetProperty{\currentsubject}{rdfs:label}, %
}

\RdfDrawGraph[\jobname-graph][eq:value]{}{eq:equation}

\end{document}

image

ouboub commented 1 week ago

But I've found a solution with dot2tex. It has the --autosize option, which produces a node with correct size. It doesn't calculate size of the ellipsis correctly thought, so I had to use rectangles for nodes instead.

This is simply fantastic!!! Really great thank you so much. Now the "only" remaining goal should be, to make the package a bit more user friendly, by this I mean to introduce some macros, so that the user does not have to insert this rather complex constructs in the file. Thanks again

ouboub commented 1 week ago

This is simply fantastic!!! Really great thank you so much. Now the "only" remaining goal should be, to make the package a bit more user friendly, by this I mean to introduce some macros, so that the user does not have to insert this rather complex constructs in the file. Thanks again

I cried to early victory. Look at this example, please

\documentclass[12pt]{article}
\usepackage{a4wide}
\setlength{\parindent}{0pt}
\sloppy
\parskip=5pt plus 5pt
\oddsidemargin-10pt
\usepackage[T1]{fontenc}
\usepackage{amssymb,amsfonts,amsmath,amsthm}
\usepackage{tikz}
\usepackage{shellesc}
\usetikzlibrary{graphs,graphdrawing,calc} 
\usegdlibrary{layered}
\usepackage[T1]{fontenc}
\usepackage{rdfref}
\NewDocumentEnvironment{rdfequation}{o +b}{
  \begin{equation}
    #2 
    \IfBlankF{#1}{
      \rdflabel{#1}
      \AssignProperty{#1}{eq:value}{$#2$}
    }
  \end{equation}
}{}
\newwrite\graphwrite

\makeatletter
\newcommand\graphout[1]{\protected@write\graphwrite{\let\owrite\write\def\write{\immediate\owrite}}{#1}}

% #1 name of the graph (default \jobname-graph) -- it needs to be different than name of any existing file!
% #2 RDF property to be printed
% #3 list of allowed rdf:type for objects
% #4 list of allowed rdf:type for subjects
% don't forget to call latex with --shell-escape 
\NewDocumentCommand\RdfDrawGraph{O{\jobname-graph} O{rdfs:label} m m}{%
  \immediate\openout\graphwrite=#1.dot\relax%
  \graphout{digraph hello\@charlb} % save graph header
  \RdfLoopReferences{#3}{#4}{%
    \StrSubstitute{\currentobject}{:}{_}[\objectlabel]
    \StrSubstitute{\currentsubject}{:}{_}[\subjectlabel]
    \graphout{\objectlabel [shape="rectangle",texlbl="\GetProperty{\currentobject}{#2}"]}
    \graphout{\subjectlabel [shape="rectangle",texlbl="\GetProperty{\currentsubject}{#2}"]}
    \graphout{\objectlabel-> \subjectlabel} %
  }
  \graphout{\@charrb}% save footer
  \immediate\closeout\graphwrite%
  \ShellEscape{dot2tex --figonly --autosize -t raw -o #1.tmp #1.dot }%
  \InputIfFileExists{#1.tmp}{}%
}
\makeatother

\begin{document}
% we need to declare some properties for the eq: prefix 
\AddRdfType{eq}{
  \AddPropertyEx{rdf:type}{eq:equation}
  \AddPropertyEx{doc:pageNo}{\thepage}
  % this will be used in the graph label, change to your liking
  \AddPropertyEx{rdfs:label}{Equation \theequation}
}

\makeatletter
\AddRdfType{sec}{
  \AddPropertyEx{rdf:type}{sec:sectioning}
  \AddPropertyEx{doc:pageNo}{\thepage}
  % this will be used in the graph label, change to your liking
  \AddPropertyEx{rdfs:label}{Section \@currentlabel}
}
\makeatother

\section{first section}
\rdflabel{sec:first}
\begin{rdfequation}[eq:first]
  \begin{aligned}     \sqrt{E(t)} & \leq e^{-\varkappa(t-t_0)}\sqrt{E(t_0)} + \varkappa^2\int_{t_0}^te^{-\varkappa(t-s)} \left\Vert u_h(s) \right\Vert_{H^{m}}ds \\     & + \int_{t_0}^te^{-\varkappa (t-s)}e^{-\varkappa s} \left\Vert a(s,\cdot) \left( 1+u(s) \right)^3 \right\Vert_{H^m}ds   \end{aligned}.
\end{rdfequation}

This equation links to equation~\rdfref{eq:second}, as well as to equation~\rdfref{eq:third}.
\begin{rdfequation}[eq:1]
     \begin{aligned}       \sqrt{E(t)} & \leq e^{-\varkappa t}\sqrt{E(0)} + \varkappa^2\int_{0}^te^{-\varkappa (t-s)} \alpha\beta ds + \int_{0}^te^{-\varkappa (t-s)}e^{-\varkappa s} \left\Vert a(s,\cdot) \left( 1+u(s) \right)^3 \right\Vert_{H^m} ds\\       & \leq e^{-\varkappa t}\sqrt{E(0)} +\varkappa \left(1 -e^{-\varkappa t}\right)\alpha\beta+ te^{-\varkappa t}\sup_{[0,t]}\left\Vert a(s,\cdot) \left( 1+u(s) \right)^3 \right\Vert_{H^m}.
     \end{aligned} 
\end{rdfequation}

This links to~\rdfref{eq:first}.
\section{another}
\rdflabel{sec:another}

\begin{rdfequation}[eq:second]
e^{\varkappa t} \sqrt{E(t)} \leq \sqrt{E(0)} +\varkappa \left(e^{\varkappa t} -1 \right)\alpha\beta+ t\sup_{[0,t]}\left\Vert a(s,\cdot) \left( 1+u(s) \right)^3 \right\Vert_{H^m}.
\end{rdfequation}

Link to another equation~\rdfref{eq:third}, in section~\rdfpageref{sec:first}.
\begin{rdfequation}[eq:third]
    E(t)\leq E(0)
\end{rdfequation}
\end{document}

I can run without problems lualatex --shell-escape test-equations.tex in the command line, however if I add the lines that should produce the graph, namly

\documentclass[12pt]{article}
\usepackage{a4wide}
\setlength{\parindent}{0pt}
\sloppy
\parskip=5pt plus 5pt
\oddsidemargin-10pt
\usepackage[T1]{fontenc}
\usepackage{amssymb,amsfonts,amsmath,amsthm}
\usepackage{tikz}
\usepackage{shellesc}
\usetikzlibrary{graphs,graphdrawing,calc} 
\usegdlibrary{layered}
\usepackage[T1]{fontenc}
\usepackage{rdfref}
\NewDocumentEnvironment{rdfequation}{o +b}{
  \begin{equation}
    #2 
    \IfBlankF{#1}{
      \rdflabel{#1}
      \AssignProperty{#1}{eq:value}{$#2$}
    }
  \end{equation}
}{}
\newwrite\graphwrite

\makeatletter
\newcommand\graphout[1]{\protected@write\graphwrite{\let\owrite\write\def\write{\immediate\owrite}}{#1}}

% #1 name of the graph (default \jobname-graph) -- it needs to be different than name of any existing file!
% #2 RDF property to be printed
% #3 list of allowed rdf:type for objects
% #4 list of allowed rdf:type for subjects
% don't forget to call latex with --shell-escape 
\NewDocumentCommand\RdfDrawGraph{O{\jobname-graph} O{rdfs:label} m m}{%
  \immediate\openout\graphwrite=#1.dot\relax%
  \graphout{digraph hello\@charlb} % save graph header
  \RdfLoopReferences{#3}{#4}{%
    \StrSubstitute{\currentobject}{:}{_}[\objectlabel]
    \StrSubstitute{\currentsubject}{:}{_}[\subjectlabel]
    \graphout{\objectlabel [shape="rectangle",texlbl="\GetProperty{\currentobject}{#2}"]}
    \graphout{\subjectlabel [shape="rectangle",texlbl="\GetProperty{\currentsubject}{#2}"]}
    \graphout{\objectlabel-> \subjectlabel} %
  }
  \graphout{\@charrb}% save footer
  \immediate\closeout\graphwrite%
  \ShellEscape{dot2tex --figonly --autosize -t raw -o #1.tmp #1.dot }%
  \InputIfFileExists{#1.tmp}{}%
}
\makeatother

\begin{document}
% we need to declare some properties for the eq: prefix 
\AddRdfType{eq}{
  \AddPropertyEx{rdf:type}{eq:equation}
  \AddPropertyEx{doc:pageNo}{\thepage}
  % this will be used in the graph label, change to your liking
  \AddPropertyEx{rdfs:label}{Equation \theequation}
}

\makeatletter
\AddRdfType{sec}{
  \AddPropertyEx{rdf:type}{sec:sectioning}
  \AddPropertyEx{doc:pageNo}{\thepage}
  % this will be used in the graph label, change to your liking
  \AddPropertyEx{rdfs:label}{Section \@currentlabel}
}
\makeatother

\section{first section}
\rdflabel{sec:first}
\begin{rdfequation}[eq:first]
  \begin{aligned}     \sqrt{E(t)} & \leq e^{-\varkappa(t-t_0)}\sqrt{E(t_0)} + \varkappa^2\int_{t_0}^te^{-\varkappa(t-s)} \left\Vert u_h(s) \right\Vert_{H^{m}}ds \\     & + \int_{t_0}^te^{-\varkappa (t-s)}e^{-\varkappa s} \left\Vert a(s,\cdot) \left( 1+u(s) \right)^3 \right\Vert_{H^m}ds   \end{aligned}.
\end{rdfequation}

This equation links to equation~\rdfref{eq:second}, as well as to equation~\rdfref{eq:third}.
\begin{rdfequation}[eq:1]
     \begin{aligned}       \sqrt{E(t)} & \leq e^{-\varkappa t}\sqrt{E(0)} + \varkappa^2\int_{0}^te^{-\varkappa (t-s)} \alpha\beta ds + \int_{0}^te^{-\varkappa (t-s)}e^{-\varkappa s} \left\Vert a(s,\cdot) \left( 1+u(s) \right)^3 \right\Vert_{H^m} ds\\       & \leq e^{-\varkappa t}\sqrt{E(0)} +\varkappa \left(1 -e^{-\varkappa t}\right)\alpha\beta+ te^{-\varkappa t}\sup_{[0,t]}\left\Vert a(s,\cdot) \left( 1+u(s) \right)^3 \right\Vert_{H^m}.
     \end{aligned} 
\end{rdfequation}

This links to~\rdfref{eq:first}.

\section{another}
\rdflabel{sec:another}

\begin{rdfequation}[eq:second]
e^{\varkappa t} \sqrt{E(t)} \leq \sqrt{E(0)} +\varkappa \left(e^{\varkappa t} -1 \right)\alpha\beta+ t\sup_{[0,t]}\left\Vert a(s,\cdot) \left( 1+u(s) \right)^3 \right\Vert_{H^m}.
\end{rdfequation}

Link to another equation~\rdfref{eq:third}, in section~\rdfpageref{sec:first}.
\begin{rdfequation}[eq:third]
    E(t)\leq E(0)
\end{rdfequation}
\RdfLoopReferences{}{eq:equation,sec:sectioning}{%
  \GetProperty{\currentobject}{rdfs:label} -> \GetProperty{\currentsubject}{rdfs:label}, %
}

\RdfDrawGraph[\jobname-graph][eq:value]{}{eq:equation}
\end{document}

then I can compile it once, but in the second run I obtain

! Undefined control sequence.
l.19 ...E(t_0)} + \varkappa ^2\DOTSI \intop \ilimits
                                                  @ _{t_0}^te^{-\varkappa (t...

what the heck is DOTSI? regards

michal-h21 commented 1 week ago

It seems to be caused by the \int command, which is not robust. Try to add this to your preamble, somewhere after \usepackage{rdfref}:

\robustify\int
ouboub commented 1 week ago

Thanks, as I can see, the auto-size option is at its limits, so I changed to 10 pt