-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pgfmath and pgfplots enhancements #2237
Conversation
Studying some adjacent issues in the ar5iv reports I also spotted a few important discrepancies in our pgfmath bindings as used by pgfplots, specifically in ar5iv#335, which is based on arXiv:2201.11903. The last batch of commits resolves the interpretation issues of the pgf figures there fully - gradually adding some tests as well. |
The dominoes test also renders perfectly now. Which allows the distraction of noticing text size (= domino numbers) is a just a little large. That is also the case for the axes labels in the pgfplots examples. In ar5iv, I currently have a CSS directive anchored at But I am recording that only as an informal comment for now, since I am unsure if there is a general sizing distinction, or this is limited to a few special cases of examples. |
7e7e280
to
bc243ff
Compare
The last commit ccd423f fixes dginev/ar5iv#318 and dginev/ar5iv#402 Edit: as well as dginev/ar5iv#175 and dginev/ar5iv#149 |
…to display in tikzmath
…rg of pgf FUNCTION; Digest on apply to set \pgfmathresult
19aab54
to
3596344
Compare
<resource src="LaTeXML.css" type="text/css"/> | ||
<resource src="ltx-article.css" type="text/css"/> | ||
<para xml:id="p1"> | ||
<picture height="191.5" tex="\hbox to219.56pt{\vbox to138.4pt{\pgfpicture\makeatletter\raise 0.0pt\hbox{% \hskip 32.25624pt\lower-16.86601pt\hbox to0.0pt{\pgfsys@beginscope% \pgfsys@invoke{ }\definecolor{pgfstrokecolor}{rgb}{0,0,0}% \pgfsys@color@rgb@stroke{0}{0}{0}\pgfsys@invoke{ }\pgfsys@color@rgb@fill{0}{0}% {0}\pgfsys@invoke{ }\pgfsys@setlinewidth{0.4pt}\pgfsys@invoke{ }\nullfont\hbox to% 0.0pt{\pgfsys@beginscope\pgfsys@invoke{ }\par{}{{}}{} {}{}{{}}{}{{ {\pgfsys@beginscope\pgfsys@setlinewidth{0.32pt}\pgfsys@setdash{}{0.0pt}% \pgfsys@roundcap\pgfsys@roundjoin{} {}{}{} {}{}{} \pgfsys@moveto{-1.19998pt}{1.59998pt}\pgfsys@curveto{-1.09998pt}{0.99998pt}{0.% 0pt}{0.09999pt}{0.29999pt}{0.0pt}\pgfsys@curveto{0.0pt}{-0.09999pt}{-1.09998pt% }{-0.99998pt}{-1.19998pt}{-1.59998pt}\pgfsys@stroke\pgfsys@endscope}} }{}{}{{}}\pgfsys@moveto{0.0pt}{0.0pt}\pgfsys@lineto{170.25656pt}{0.0pt}% \pgfsys@stroke\pgfsys@invoke{ }{{}{{}}{}{}{{}}{{{}}{{{}}{\pgfsys@beginscope% \pgfsys@invoke{ }\pgfsys@transformcm{1.0}{0.0}{0.0}{1.0}{170.25656pt}{0.0pt}% \pgfsys@invoke{ }\pgfsys@invoke{ \lxSVG@closescope }\pgfsys@invoke{% \lxSVG@closescope }\pgfsys@endscope}}{{}}}}\hbox{\hbox{{\pgfsys@beginscope% \pgfsys@invoke{ }{{}{}{{ {}{}}}{ {}{}} {{}{{}}}{{}{}}{}{{}{}} { }{{{{}}\pgfsys@beginscope\pgfsys@invoke{ }\pgfsys@transformcm{1.0}{0.0}{0.0}{1% .0}{157.46713pt}{-11.033pt}\pgfsys@invoke{ }\hbox{{\definecolor{pgfstrokecolor% }{rgb}{0,0,0}\pgfsys@color@rgb@stroke{0}{0}{0}\pgfsys@invoke{ }% \pgfsys@color@rgb@fill{0}{0}{0}\pgfsys@invoke{ }\hbox{{$f/f_{N}$}} }}\pgfsys@invoke{\lxSVG@closescope }\pgfsys@endscope}}} \pgfsys@invoke{\lxSVG@closescope }\pgfsys@endscope}}} {}{{}}{}{{}}{}{{}}{}{{}}{}{{}}{}{{}}{}\pgfsys@moveto{0.0pt}{0.0pt}% \pgfsys@moveto{56.90552pt}{0.0pt}\pgfsys@moveto{113.81104pt}{0.0pt}% \pgfsys@stroke\pgfsys@invoke{ }\hbox{\hbox{\hbox{\hbox{{\pgfsys@beginscope% \pgfsys@invoke{ }{{}{}{{ {}{}}}{ {}{}} {{}{{}}}{{}{}}{}{{}{}} { }{{{{}}\pgfsys@beginscope\pgfsys@invoke{ }\pgfsys@transformcm{1.0}{0.0}{0.0}{1% .0}{-2.5pt}{-9.97743pt}\pgfsys@invoke{ }\hbox{{\definecolor{pgfstrokecolor}{% rgb}{0,0,0}\pgfsys@color@rgb@stroke{0}{0}{0}\pgfsys@invoke{ }% \pgfsys@color@rgb@fill{0}{0}{0}\pgfsys@invoke{ }\hbox{{0}} }}\pgfsys@invoke{\lxSVG@closescope }\pgfsys@endscope}}} \pgfsys@invoke{\lxSVG@closescope }\pgfsys@endscope}}}\hbox{{\pgfsys@beginscope% \pgfsys@invoke{ }{{}{}{{ {}{}}}{ {}{}} {{}{{}}}{{}{}}{}{{}{}} { }{{{{}}\pgfsys@beginscope\pgfsys@invoke{ }\pgfsys@transformcm{1.0}{0.0}{0.0}{1% .0}{54.40552pt}{-9.97743pt}\pgfsys@invoke{ }\hbox{{\definecolor{pgfstrokecolor% }{rgb}{0,0,0}\pgfsys@color@rgb@stroke{0}{0}{0}\pgfsys@invoke{ }% \pgfsys@color@rgb@fill{0}{0}{0}\pgfsys@invoke{ }\hbox{{1}} }}\pgfsys@invoke{\lxSVG@closescope }\pgfsys@endscope}}} \pgfsys@invoke{\lxSVG@closescope }\pgfsys@endscope}}}\hbox{{\pgfsys@beginscope% \pgfsys@invoke{ }{{}{}{{ {}{}}}{ {}{}} {{}{{}}}{{}{}}{}{{}{}} { }{{{{}}\pgfsys@beginscope\pgfsys@invoke{ }\pgfsys@transformcm{1.0}{0.0}{0.0}{1% .0}{111.31104pt}{-9.97743pt}\pgfsys@invoke{ }\hbox{{\definecolor{% pgfstrokecolor}{rgb}{0,0,0}\pgfsys@color@rgb@stroke{0}{0}{0}\pgfsys@invoke{ }% \pgfsys@color@rgb@fill{0}{0}{0}\pgfsys@invoke{ }\hbox{{2}} }}\pgfsys@invoke{\lxSVG@closescope }\pgfsys@endscope}}} \pgfsys@invoke{\lxSVG@closescope }\pgfsys@endscope}}} {}{{}}{}{{}}{}{{}}{}{{}}{}\pgfsys@moveto{28.45276pt}{99.58466pt}\pgfsys@moveto% {113.81104pt}{99.58466pt}\pgfsys@stroke\pgfsys@invoke{ }\hbox{\hbox{\hbox{{% \pgfsys@beginscope\pgfsys@invoke{ }{{}{}{{ {}{}}}{ {}{}} {{}{{}}}{{}{}}{}{{}{}} { }{{{{}}\pgfsys@beginscope\pgfsys@invoke{ }\pgfsys@transformcm{1.0}{0.0}{0.0}{1% .0}{7.5305pt}{97.15411pt}\pgfsys@invoke{ }\hbox{{\definecolor{pgfstrokecolor}{% rgb}{0,0,0}\pgfsys@color@rgb@stroke{0}{0}{0}\pgfsys@invoke{ }% \pgfsys@color@rgb@fill{0}{0}{0}\pgfsys@invoke{ }\hbox{{{\scriptsize Constant % flux}}} }}\pgfsys@invoke{\lxSVG@closescope }\pgfsys@endscope}}} \pgfsys@invoke{\lxSVG@closescope }\pgfsys@endscope}}}\hbox{{\pgfsys@beginscope% \pgfsys@invoke{ }{{}{}{{ {}{}}}{ {}{}} {{}{{}}}{{}{}}{}{{}{}} { }{{{{}}\pgfsys@beginscope\pgfsys@invoke{ }\pgfsys@transformcm{1.0}{0.0}{0.0}{1% .0}{89.2624pt}{97.83466pt}\pgfsys@invoke{ }\hbox{{\definecolor{pgfstrokecolor}% {rgb}{0,0,0}\pgfsys@color@rgb@stroke{0}{0}{0}\pgfsys@invoke{ }% \pgfsys@color@rgb@fill{0}{0}{0}\pgfsys@invoke{ }\hbox{{{\scriptsize Field % weakening}}} }}\pgfsys@invoke{\lxSVG@closescope }\pgfsys@endscope}}} \pgfsys@invoke{\lxSVG@closescope }\pgfsys@endscope}}} \par{}{{}}{} {}{}{{}}{}{}{}{}{{}}\pgfsys@moveto{0.0pt}{0.0pt}\pgfsys@lineto{0.0pt}{113.3510% 4pt}\pgfsys@stroke\pgfsys@invoke{ }{{}{{}}{}{}{{}}{{{}}{{{}}{% \pgfsys@beginscope\pgfsys@invoke{ }\pgfsys@transformcm{0.0}{1.0}{-1.0}{0.0}{0.% 0pt}{113.35104pt}\pgfsys@invoke{ }\pgfsys@invoke{ \lxSVG@closescope }% \pgfsys@invoke{\lxSVG@closescope }\pgfsys@endscope}}{{}}}}\hbox{\hbox{{% \pgfsys@beginscope\pgfsys@invoke{ }{{}{}{{{}{}}}{{}{}} {{}{{}}}{{}{}}{}{{}{}} { }{{{{}}\pgfsys@beginscope\pgfsys@invoke{ }\pgfsys@transformcm{1.0}{0.0}{0.0}{1% .0}{-28.92323pt}{111.3666pt}\pgfsys@invoke{ }\hbox{{\definecolor{% pgfstrokecolor}{rgb}{0,0,0}\pgfsys@color@rgb@stroke{0}{0}{0}\pgfsys@invoke{ }% \pgfsys@color@rgb@fill{0}{0}{0}\pgfsys@invoke{ }\hbox{{$U_{s},\varPsi_{s}$}} }}\pgfsys@invoke{\lxSVG@closescope }\pgfsys@endscope}}} \pgfsys@invoke{\lxSVG@closescope }\pgfsys@endscope}}} {}{{}}{} {}{}\pgfsys@beginscope\pgfsys@invoke{ }\pgfsys@setdash{0.4pt,2.0pt}{0.0pt}% \pgfsys@invoke{ }{}\pgfsys@moveto{56.90552pt}{0.0pt}\pgfsys@lineto{56.90552pt}% {113.81104pt}\pgfsys@stroke\pgfsys@invoke{ } \pgfsys@invoke{\lxSVG@closescope }\pgfsys@endscope\par{}{{}}{} {}{} {}{}\pgfsys@beginscope\pgfsys@invoke{ }\pgfsys@setlinewidth{0.8pt}% \pgfsys@invoke{ }{}\pgfsys@moveto{0.0pt}{0.0pt}\pgfsys@lineto{56.90552pt}{56.9% 0552pt}\pgfsys@lineto{170.71655pt}{56.90552pt}\pgfsys@stroke\pgfsys@invoke{ } \pgfsys@invoke{\lxSVG@closescope }\pgfsys@endscope{}{{}}{}{{}}{}\pgfsys@moveto% {28.45276pt}{42.67914pt}\pgfsys@stroke\pgfsys@invoke{ }\hbox{\hbox{{% \pgfsys@beginscope\pgfsys@invoke{ }{{}{}{{ {}{}}}{ {}{}} {{}{{}}}{{}{}}{}{{}{}} { }{{{{}}\pgfsys@beginscope\pgfsys@invoke{ }\pgfsys@transformcm{1.0}{0.0}{0.0}{1% .0}{23.18124pt}{39.86525pt}\pgfsys@invoke{ }\hbox{{\definecolor{pgfstrokecolor% }{rgb}{0,0,0}\pgfsys@color@rgb@stroke{0}{0}{0}\pgfsys@invoke{ }% \pgfsys@color@rgb@fill{0}{0}{0}\pgfsys@invoke{ }\hbox{{$U_{s}$}} }}\pgfsys@invoke{\lxSVG@closescope }\pgfsys@endscope}}} \pgfsys@invoke{\lxSVG@closescope }\pgfsys@endscope}}} \par{}{{}}{} {}{}{}{{}{}}{{}{}{{{}{}{}}}}\pgfsys@beginscope\pgfsys@invoke{ }% \pgfsys@setlinewidth{0.8pt}\pgfsys@invoke{ }\pgfsys@setdash{3.0pt,3.0pt}{0.0pt% }\pgfsys@invoke{ }{}\pgfsys@moveto{0.0pt}{85.35828pt}\pgfsys@lineto{56.90552pt% }{85.35828pt}\pgfsys@curveto{69.7096pt}{72.5542pt}{113.81104pt}{28.45276pt}{17% 0.71655pt}{28.45276pt}\pgfsys@stroke\pgfsys@invoke{ } \pgfsys@invoke{\lxSVG@closescope }\pgfsys@endscope{}{{}}{}{{}}{}\pgfsys@moveto% {71.1319pt}{85.35828pt}\pgfsys@stroke\pgfsys@invoke{ }\hbox{\hbox{{% \pgfsys@beginscope\pgfsys@invoke{ }{{}{}{{ {}{}}}{ {}{}} {{}{{}}}{{}{}}{}{{}{}} { }{{{{}}\pgfsys@beginscope\pgfsys@invoke{ }\pgfsys@transformcm{1.0}{0.0}{0.0}{1% .0}{65.9305pt}{82.54439pt}\pgfsys@invoke{ }\hbox{{\definecolor{pgfstrokecolor}% {rgb}{0,0,0}\pgfsys@color@rgb@stroke{0}{0}{0}\pgfsys@invoke{ }% \pgfsys@color@rgb@fill{0}{0}{0}\pgfsys@invoke{ }\hbox{{$\varPsi_{s}$}} }}\pgfsys@invoke{\lxSVG@closescope }\pgfsys@endscope}}} \pgfsys@invoke{\lxSVG@closescope }\pgfsys@endscope}}} \par \pgfsys@invoke{\lxSVG@closescope }\pgfsys@endscope{}{}{}\hss}% \pgfsys@discardpath\pgfsys@invoke{\lxSVG@closescope }\pgfsys@endscope\hss}}% \lxSVG@closescope\endpgfpicture}}" width="303.8" xml:id="p1.pic1"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While studying the XML in the tests here, I have been wondering if we should add a switch to disable the tex
attribute in the <picture>
element, especially when they come from some pgf/tikz source.
The expanded low-level pgf instructions get overwhelming quite quickly, and contain LaTeXML-only macros (such as \lxSVG@close
) so they won't be reusable in other, non-latexml, contexts.
But even if we keep them in general, I can imagine various spurious diffs in these tests later on, e.g. if we refactor internal macro names.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, interesting: all the more so since the exact source snippets differ between texlives. I generated the tests on texlive 2022, and our 2018-2021 CI versions all failed on the source line.
@brucemiller the newly added pgf and tikz tests are now part of the
That should allow some freedom to move until we have figured out how to make the XML easy to regenerate when texlives switch. The current XML was generated under texlive 2022. Also, here is a shortlist of notes that are still not fully polished in the Silviu unit test, which some of us may return to when we re-focus on Tikz again:
I have rebased to master, and am largely out of time to keep fine-tuning here, so please consider this ready for review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Scary, but seems right. Thanks!!
This is a draft PR, which may already benefit from some visibility/discussion.
I started with a motivating issue ar5iv#390, which caught an important oversight with the perl-eval optimization for pgfmath. Namely, the
^
is a valid char in both pgf and perl, but it means binary-xor in perl, and a classic power in pgf.I also spotted the reports of the precision errors, where a$T_{0.000000}$ instead of $T_0$ , where the
$T_\x$
was getting typeset as\x
was computed via pgfmathparse. Which lead me down a deeper rabbit hole, and added the falling dominoes test to my tests. That example also revealed that expressions such as3*sin \x
are validly parse-able - here as3*(sin(\x))
- so I added a grammar case for a function call on a bare argument.The PR now includes a first pgfmath unit test, which is gradually growing in coverage of the math operators, in order to try and get closer to the precision and eval-accuracy of the native pgf driver.
I have some more work in increasing that test's coverage, and then I'd like to try some more diverse tests, to ensure I didn't cause some unexpected regressions. But the original issue in the ar5iv report should already be patched here.