diff --git a/mathics/doc/latex_doc.py b/mathics/doc/latex_doc.py index e5689b371..70df4c67b 100644 --- a/mathics/doc/latex_doc.py +++ b/mathics/doc/latex_doc.py @@ -58,7 +58,7 @@ # We keep track of the number of \begin{asy}'s we see so that # we can assocation asymptote file numbers with where they are # in the document -asy_count = 0 +next_asy_number = 1 ITALIC_RE = re.compile(r"(?s)<(?Pi)>(?P.*?)") @@ -565,10 +565,11 @@ def latex(self, doc_data: dict) -> str: test_text = result["result"] if test_text: # is not None and result['result'].strip(): - if test_text.find("\\begin{asy}") >= 0: - global asy_count - asy_count += 1 - text += f"%% mathics-{asy_count}.asy\n" + asy_count = test_text.count("\\begin{asy}") + if asy_count >= 0: + global next_asy_number + text += f"%% mathics-{next_asy_number}.asy\n" + next_asy_number += asy_count text += "\\begin{testresult}%s\\end{testresult}" % result["result"] text += "\\end{testcase}"