Closed kiryph closed 1 year ago
Thanks for the report. Is MacTeX 2022 essentially TeXLive 2022 (with macOS gui)?
Is MacTeX 2022 essentially TeXLive 2022 (with macOS gui)?
Yes, MacTeX 2022 is TeXLive 2022. It is a macOS installer of TeXLive with some macOS GUI applications bundled (e.g. the Editor TeXShop and the Bib Management Software BibDesk which I actually do not use but neovim+vimtex).
yes, I can reproduce this.
It seems that tikzpicture
plays fast and rough with \newlabel
macro. Indeed,
\documentclass{article}
\usepackage{tikz}
\usepackage{sagetex}
\begin{document}
\[
\sagestr{latex(x^2+1)}
\]
\end{document}
works just fine, and the corresponding ..sage.sout
file is
% This file was *autogenerated* from z.sagetex.sage with
% sagetex.py version 2021/10/16 v3.6
\newlabel{@sageinline0}{{%
x^{2} + 1}{}{}{}{}}
%4245208a0c868fead4f0a36f6d32b191% md5sum of corresponding .sage file (minus "goboom", "current_tex_line", and pause/unpause lines)
where the difference is in
x^{2} + 1}{}{}{}{}}
vs, in you example,
\begin{tikzpicture}%
%... lots of lines
\end{tikzpicture}}{}{}{}{}}
no, tikzpicture
by itself is OK - e.g. if I replace the picture in .sage.sout
of your example with
\begin{tikzpicture}%
\node (a) at (0,0){example node};
\end{tikzpicture}
then all is fine. So it's what's inside your generated tikz picture that breaks the thing.
Thanks for looking into this.
So it's what's inside your generated tikz picture that breaks the thing.
The code generating the tikz picture is here:
The blog post https://jplab.github.io/polytope.html I have referenced mentions Sage 9.2. I am happen to have Sage 9.3 (released May 9, 2021) using SageTeX 3.5 and Sage 9.7 installed but both versions have this issue. I am not keen to install also Sage 9.2 to see what it looked like when it worked.
could be the TeX version that matters.
Actually I can reproduce this without sagetex
.
Away from the kbd now.
could be the TeX version that matters. Actually I can reproduce this without sagetex.
I have actually installed Sage 9.2 and yes, the issue persists as you anticipated.
So the difference is the TeXLive Version.
I am not sure who to bother now.
The generated tikz code compiles on its own with the new TeXLive version. Sagetex without tikz polyhedra works as well. For example, the tikz code in http://mirrors.ctan.org/macros/latex/contrib/sagetex/example.tex works as well (uncommenting necessary).
IMHO, it is the tikz code from sage polyhedra which runs into problems.
Since the development of Sage moves to github
Sage development is scheduled to move to GitHub in February 2023
I will postpone this matter a little bit.
I'll leave this open if you do not mind until a solution is found. If you want to close it, since sagetex itself should be ruled out to mitigate the problem, feel free to do so.
I fugured it out. The problem is that \sagestr{}
assumes it gets one paragraph (otherwise the \newlabel
macro used there gives this error) , but it's not the case here.
For the example at hand, one can manually remove the empty line (there is just one) in the ..sout
file before running LaTeX for the 2nd time, and it works.
One way to fix this, in Sage itself, would be to make sure that tikz()
method does not produce empty lines.
Another, in SageTex, would be to sanitize input to \sagestr{}
, so that it does not have empty lines.
here is the fix in Sage itself:
--- a/src/sage/geometry/polyhedron/plot.py
+++ b/src/sage/geometry/polyhedron/plot.py
@@ -1532,7 +1532,7 @@ class Projection(SageObject):
tikz_pic += "%% facet_color = {}\n".format(facet_color)
tikz_pic += "%% opacity = {}\n".format(opacity)
tikz_pic += "%% vertex_color = {}\n".format(vertex_color)
- tikz_pic += "%% axis = {}\n\n".format(axis)
+ tikz_pic += "%% axis = {}\n%%\n".format(axis)
# Draws the axes if True
if axis:
@@ -1681,7 +1681,7 @@ class Projection(SageObject):
tikz_pic += "%% facet_color = {}\n".format(facet_color)
tikz_pic += "%% opacity = {}\n".format(opacity)
tikz_pic += "%% vertex_color = {}\n".format(vertex_color)
- tikz_pic += "%% axis = {}\n\n".format(axis)
+ tikz_pic += "%% axis = {}\n%%\n".format(axis)
# Draws the axes if True
if axis:
@@ -1881,7 +1881,7 @@ class Projection(SageObject):
tikz_pic += "%% facet_color = {}\n".format(facet_color)
tikz_pic += "%% opacity = {}\n".format(opacity)
tikz_pic += "%% vertex_color = {}\n".format(vertex_color)
- tikz_pic += "%% axis = {}\n\n".format(axis)
+ tikz_pic += "%% axis = {}\n%%\n".format(axis)
# Draws the axes if True
if axis:
I'll put it on Sage ticket - perhaps there yet more similar places to fix.
@dimpase Thank you for figuring it out.
One way to fix this, in Sage itself, would be to make sure that tikz() method does not produce empty lines.
Another, in SageTex, would be to sanitize input to \sagestr{}, so that it does not have empty lines.
Ideally, I would do both. I also would show a message to the user when sanitising was necessary.
It could happen that a user is writing the input for \sagestr{}
with empty lines and should be informed that the input was corrected. The content of the file .sout
is not something a user directly writes and therefore is surprised that a generated files throws errors which will not happen anymore.
A TeX guru doesn't recommend to do such sanitizing, see
https://tex.stackexchange.com/a/536802/7110
I'll add the no \par
requirement to the docs, and try to improve the error message.
A TeX guru doesn't recommend to do such sanitizing, see https://tex.stackexchange.com/a/536802/7110
I'll add the no \par requirement to the docs, and try to improve the error message.
Sounds good to me.
903d1c77422d06d91710650dc67a2504a6ffc0f9 adds this piece of documention.
Consider following minimal LaTeX file:
It is derived from
Compiling with
gives me follwoing error:
Manually expanding content within
\newlabel{@sageinline0}{{
from.sout
into the LaTeX file allows me to have the result:Also the example given on https://doc.sagemath.org/html/en/tutorial/sagetex.html works. It seems only a tikz related issue.
Possibly related issues:
Environment
/usr/local/texlive/texmf-local
: