diff --git a/mathics/builtin/graphics.py b/mathics/builtin/graphics.py index ceba0407f..61b60b000 100644 --- a/mathics/builtin/graphics.py +++ b/mathics/builtin/graphics.py @@ -411,7 +411,7 @@ class _Size(_GraphicsDirective): def init(self, graphics, item=None, value=None): super(_Size, self).init(graphics, item) if item is not None: - self.value = item.elements[0].round_to_float() + self.value = item.elements[0].round_to_float() * 0.7 elif value is not None: self.value = value else: diff --git a/mathics/format/asy.py b/mathics/format/asy.py index 3bccc8ae2..2dd97edd3 100644 --- a/mathics/format/asy.py +++ b/mathics/format/asy.py @@ -417,12 +417,11 @@ def inset_box(self, **options) -> str: edge_color=self.color, edge_opacity=opacity_value, fontsize=font_size ) asy = """// InsetBox -label("$%s$", (%s,%s), (%s,%s), %s);\n""" % ( +label("$%s$", (%s,%s), %s, %s);\n""" % ( content, x, y, - -self.opos[0], - -self.opos[1], + "align=SW", pen, ) return asy diff --git a/mathics/format/svg.py b/mathics/format/svg.py index 302ceecfd..bfc39ee7b 100644 --- a/mathics/format/svg.py +++ b/mathics/format/svg.py @@ -387,6 +387,7 @@ def inset_box(self, **options) -> str: font_color=self.color, edge_color=self.color, face_color=self.color, + stroke_width=0.2, opacity=self.opacity.opacity, ) text_pos_opts = f'x="{x}" y="{y}" ox="{self.opos[0]}" oy="{self.opos[1]}"' diff --git a/test/format/test_format.py b/test/format/test_format.py index fe33f8be7..a44e1a873 100644 --- a/test/format/test_format.py +++ b/test/format/test_format.py @@ -4,7 +4,6 @@ import pytest from mathics.core.symbols import Symbol -from mathics.session import MathicsSession # from mathics.core.builtin import BoxConstruct, Predefined @@ -724,7 +723,16 @@ # "System`OutputForm": '', # }, "latex": { - "System`StandardForm": '\n\\begin{asy}\nusepackage("amsmath");\nsize(5.8333cm, 5.8333cm);\n\n\nclip(box((-1,-1), (1,1)));\n\n\\end{asy}\n', + "System`StandardForm": """ +\\begin{asy} +usepackage("amsmath"); +size(5.8333cm, 5.8333cm); + + +clip(box((-1,-1), (1,1))); + +\\end{asy} +""", "System`TraditionalForm": '\n\\begin{asy}\nusepackage("amsmath");\nsize(5.8333cm, 5.8333cm);\n\n\nclip(box((-1,-1), (1,1)));\n\n\\end{asy}\n', "System`InputForm": "\\text{Graphics}\\left[\\left\\{\\right\\}\\right]", "System`OutputForm": '\n\\begin{asy}\nusepackage("amsmath");\nsize(5.8333cm, 5.8333cm);\n\n\nclip(box((-1,-1), (1,1)));\n\n\\end{asy}\n', @@ -745,10 +753,37 @@ # "System`OutputForm": '', # }, "latex": { - "System`StandardForm": '\n\\begin{asy}\nusepackage("amsmath");\nsize(4.9cm, 5.8333cm);\n\n// InsetBox\nlabel("$a^b$", (147.0,175.0), (0,0), rgb(0, 0, 0)+fontsize(3));\n\nclip(box((136.5,162.5), (157.5,187.5)));\n\n\\end{asy}\n', - "System`TraditionalForm": '\n\\begin{asy}\nusepackage("amsmath");\nsize(4.9cm, 5.8333cm);\n\n// InsetBox\nlabel("$a^b$", (147.0,175.0), (0,0), rgb(0, 0, 0)+fontsize(3));\n\nclip(box((136.5,162.5), (157.5,187.5)));\n\n\\end{asy}\n', + "System`StandardForm": """ +\\begin{asy} +usepackage("amsmath"); +size(4.9cm, 5.8333cm); + +// InsetBox\nlabel("$a^b$", (147.0,175.0), align=SW, rgb(0, 0, 0)+fontsize(3)); + +clip(box((136.5,162.5), (157.5,187.5))); + +\\end{asy} +""", + "System`TraditionalForm": """ +\\begin{asy} +usepackage("amsmath"); +size(4.9cm, 5.8333cm); + +// InsetBox\nlabel("$a^b$", (147.0,175.0), align=SW, rgb(0, 0, 0)+fontsize(3)); + +clip(box((136.5,162.5), (157.5,187.5))); + +\\end{asy} +""", "System`InputForm": "\\text{Graphics}\\left[\\left\\{\\text{Text}\\left[\\text{Power}\\left[a, b\\right], \\left\\{0, 0\\right\\}\\right]\\right\\}\\right]", - "System`OutputForm": '\n\\begin{asy}\nusepackage("amsmath");\nsize(4.9cm, 5.8333cm);\n\n// InsetBox\nlabel("$a^b$", (147.0,175.0), (0,0), rgb(0, 0, 0)+fontsize(3));\n\nclip(box((136.5,162.5), (157.5,187.5)));\n\n\\end{asy}\n', + "System`OutputForm": """ +\\begin{asy}\nusepackage("amsmath"); +size(4.9cm, 5.8333cm); + +// InsetBox\nlabel("$a^b$", (147.0,175.0), align=SW, rgb(0, 0, 0)+fontsize(3)); + +clip(box((136.5,162.5), (157.5,187.5)));\n\n\\end{asy} +""", }, }, "TableForm[{Graphics[{Text[a^b,{0,0}]}], Graphics[{Text[a^b,{0,0}]}]}]": { @@ -766,10 +801,26 @@ # "System`OutputForm": '\n\n\n', # }, "latex": { - "System`StandardForm": '\\begin{array}{c} \n\\begin{asy}\nusepackage("amsmath");\nsize(2.45cm, 2.9167cm);\n\n// InsetBox\nlabel("$a^b$", (73.5,87.5), (0,0), rgb(0, 0, 0)+fontsize(3));\n\nclip(box((63,75), (84,100)));\n\n\\end{asy}\n\\\\ \n\\begin{asy}\nusepackage("amsmath");\nsize(2.45cm, 2.9167cm);\n\n// InsetBox\nlabel("$a^b$", (73.5,87.5), (0,0), rgb(0, 0, 0)+fontsize(3));\n\nclip(box((63,75), (84,100)));\n\n\\end{asy}\n\\end{array}', - "System`TraditionalForm": '\\begin{array}{c} \n\\begin{asy}\nusepackage("amsmath");\nsize(2.45cm, 2.9167cm);\n\n// InsetBox\nlabel("$a^b$", (73.5,87.5), (0,0), rgb(0, 0, 0)+fontsize(3));\n\nclip(box((63,75), (84,100)));\n\n\\end{asy}\n\\\\ \n\\begin{asy}\nusepackage("amsmath");\nsize(2.45cm, 2.9167cm);\n\n// InsetBox\nlabel("$a^b$", (73.5,87.5), (0,0), rgb(0, 0, 0)+fontsize(3));\n\nclip(box((63,75), (84,100)));\n\n\\end{asy}\n\\end{array}', - "System`InputForm": "\\text{TableForm}\\left[\\left\\{\\text{Graphics}\\left[\\left\\{\\text{Text}\\left[\\text{Power}\\left[a, b\\right], \\left\\{0, 0\\right\\}\\right]\\right\\}\\right], \\text{Graphics}\\left[\\left\\{\\text{Text}\\left[\\text{Power}\\left[a, b\\right], \\left\\{0, 0\\right\\}\\right]\\right\\}\\right]\\right\\}\\right]", - "System`OutputForm": '\\begin{array}{c} \n\\begin{asy}\nusepackage("amsmath");\nsize(2.45cm, 2.9167cm);\n\n// InsetBox\nlabel("$a^b$", (73.5,87.5), (0,0), rgb(0, 0, 0)+fontsize(3));\n\nclip(box((63,75), (84,100)));\n\n\\end{asy}\n\\\\ \n\\begin{asy}\nusepackage("amsmath");\nsize(2.45cm, 2.9167cm);\n\n// InsetBox\nlabel("$a^b$", (73.5,87.5), (0,0), rgb(0, 0, 0)+fontsize(3));\n\nclip(box((63,75), (84,100)));\n\n\\end{asy}\n\\end{array}', + "System`StandardForm": """\\begin{array}{c} \n\\begin{asy} +usepackage("amsmath"); +size(2.45cm, 2.9167cm); + +// InsetBox\nlabel("$a^b$", (73.5,87.5), align=SW, rgb(0, 0, 0)+fontsize(3)); + +clip(box((63,75), (84,100))); + +\\end{asy} +\\\\ \n\\begin{asy} +usepackage("amsmath"); +size(2.45cm, 2.9167cm); + +// InsetBox\nlabel("$a^b$", (73.5,87.5), align=SW, rgb(0, 0, 0)+fontsize(3)); + +clip(box((63,75), (84,100))); + +\\end{asy} +\\end{array}""", + "System`TraditionalForm": """\\begin{array}{c} \n\\begin{asy}\nusepackage("amsmath");\nsize(2.45cm, 2.9167cm);\n\n// InsetBox\nlabel("$a^b$", (73.5,87.5), align=SW, rgb(0, 0, 0)+fontsize(3));\n\nclip(box((63,75), (84,100)));\n\n\\end{asy}\n\\\\ \n\\begin{asy}\nusepackage("amsmath");\nsize(2.45cm, 2.9167cm);\n\n// InsetBox\nlabel("$a^b$", (73.5,87.5), align=SW, rgb(0, 0, 0)+fontsize(3));\n\nclip(box((63,75), (84,100)));\n\n\\end{asy}\n\\end{array}""", }, }, }