prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Suggestion to improve user experience w.r.t InCodeTexTemplate example
  ## Enhancement proposal
  
  At present on macOS (with MacTex latest or even older installations) if you run InCodeTexTemplate from example_scenes/customtex.py it would fail for quite a lot of people with the following error
  
  ![dvisvgm](https://user-images.githubusercontent.com/127006/113961056-14fa7880-97eb-11eb-82b9-db34c4115d0f.png)
  
  As you can see that I have version 2.11. The error message suggests having version 2.4 or greater.
  
  Unfortunately here the issue is not because of the version rather it is because of `ghostscript` installation which is required by `dvisvgm`. Interesting I do have the `ghostscript` installed on my machine yet `dvisvgm` is not able to see.
  
  In order for `dvisvgm` to see it, I have to make sure that a certain environment variable is set. See image below:
  
  ![Screenink_1](https://user-images.githubusercontent.com/127006/113961559-ddd89700-97eb-11eb-8c04-6bb8c5a5f845.png)
  
  After this, the `example_scenes/customtex.py` would work fine.
  
  I have described the resolution (which could be classified as an installation issue) in case others are facing it. The issue with Ghostscript and mactex is not unique to manim hence should not be considered a bug related to manim. That said, the error message is a bit misleading and handling errors properly is always a challenging problem in s/w engineering.
  
  That said, my suggestion here is to modify the `example_scenes/customtex.py` to not advertise the `pdf` output. Here is the snippet from the example:
  
  ```
  class InCodeTexTemplate(Scene):
      """This example scene demonstrates how to modify the tex template
      for a particular scene from the code for the scene itself.
      """
  
      def construct(self):
          # Create a new template
          myTemplate = TexTemplate()
  
          # Add packages to the template
          myTemplate.add_to_preamble(r"\usepackage{esvect}")
  
          # Set the compiler and output format (default: latex and .dvi)
          # possible tex compilers: "latex", "pdflatex", "xelatex", "lualatex", "luatex"
          # possible output formats: ".dvi",  ".pdf", and ".xdv"
          myTemplate.tex_compiler = "pdflatex"
          myTemplate.output_format = ".pdf"
  
          # To use this template in a Tex() or MathTex() object
          # use the keyword argument tex_template
          text = MathTex(r"\vv{vb}", tex_template=myTemplate)
          self.play(Write(text))
          self.wait(1)
  ```
  
  Here is my rationale for not advertising the `pdf` output -
  
  a) The example is first and foremost about the ability to add imports for additional packages in the preamble of tex document
  
  b) Some of the imports indeed require a custom compiler so it is okay to suggest that you could change the compiler
  
  c) Forgive me for making a bit biased opinion here as I may be ignoring some use case but I am not able to see the use of generating the `pdf` as the output as ultimately the goal is to get the `svg` anyways.
  
  Usage of `pdf` will invite issues with `ghostscript` described above leading to a bad first user experience w.r.t usage of the feature of `TexTemplate`. I think it is a great feature to add preamble dynamically!
  
  I have been using latex for many years and even I got stumbled by this Ghostscript issue and had to manually print the output of `dvisvgm` to figure it therefore I have a reason to believe that the beginners would have a bad experience because of this.
  
  IMHO, modifying the example would be a better thing to do given the audience and primary functionality of manim.
  
  
  
  </issue>
  <code>
  [start of example_scenes/customtex.py]
  1 from manim import *
  2 
  3 
  4 class TexTemplateFromCLI(Scene):
  5     """This scene uses a custom TexTemplate file.
  6     The path of the TexTemplate _must_ be passed with the command line
  7     argument `--tex_template <path to template>`.
  8     For this scene, you can use the custom_template.tex file next to it.
  9     This scene will fail to render if a tex_template.tex that doesn't
  10     import esvect is passed, and will throw a LaTeX error in that case.
  11     """
  12 
  13     def construct(self):
  14         text = MathTex(r"\vv{vb}")
  15         self.play(Write(text))
  16         self.wait(1)
  17 
  18 
  19 class InCodeTexTemplate(Scene):
  20     """This example scene demonstrates how to modify the tex template
  21     for a particular scene from the code for the scene itself.
  22     """
  23 
  24     def construct(self):
  25         # Create a new template
  26         myTemplate = TexTemplate()
  27 
  28         # Add packages to the template
  29         myTemplate.add_to_preamble(r"\usepackage{esvect}")
  30 
  31         # Set the compiler and output format (default: latex and .dvi)
  32         # possible tex compilers: "latex", "pdflatex", "xelatex", "lualatex", "luatex"
  33         # possible output formats: ".dvi",  ".pdf", and ".xdv"
  34         myTemplate.tex_compiler = "pdflatex"
  35         myTemplate.output_format = ".pdf"
  36 
  37         # To use this template in a Tex() or MathTex() object
  38         # use the keyword argument tex_template
  39         text = MathTex(r"\vv{vb}", tex_template=myTemplate)
  40         self.play(Write(text))
  41         self.wait(1)
  42
  [end of example_scenes/customtex.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/example_scenes/customtex.py b/example_scenes/customtex.py
  --- a/example_scenes/customtex.py
  +++ b/example_scenes/customtex.py
  @@ -31,8 +31,8 @@
           # Set the compiler and output format (default: latex and .dvi)
           # possible tex compilers: "latex", "pdflatex", "xelatex", "lualatex", "luatex"
           # possible output formats: ".dvi",  ".pdf", and ".xdv"
  -        myTemplate.tex_compiler = "pdflatex"
  -        myTemplate.output_format = ".pdf"
  +        myTemplate.tex_compiler = "latex"
  +        myTemplate.output_format = ".dvi"
   
           # To use this template in a Tex() or MathTex() object
           # use the keyword argument tex_template
  
verification_info: {"golden_diff": "diff --git a/example_scenes/customtex.py b/example_scenes/customtex.py\n--- a/example_scenes/customtex.py\n+++ b/example_scenes/customtex.py\n@@ -31,8 +31,8 @@\n         # Set the compiler and output format (default: latex and .dvi)\n         # possible tex compilers: \"latex\", \"pdflatex\", \"xelatex\", \"lualatex\", \"luatex\"\n         # possible output formats: \".dvi\",  \".pdf\", and \".xdv\"\n-        myTemplate.tex_compiler = \"pdflatex\"\n-        myTemplate.output_format = \".pdf\"\n+        myTemplate.tex_compiler = \"latex\"\n+        myTemplate.output_format = \".dvi\"\n \n         # To use this template in a Tex() or MathTex() object\n         # use the keyword argument tex_template\n", "issue": "Suggestion to improve user experience w.r.t InCodeTexTemplate example\n## Enhancement proposal\r\n\r\nAt present on macOS (with MacTex latest or even older installations) if you run InCodeTexTemplate from example_scenes/customtex.py it would fail for quite a lot of people with the following error\r\n\r\n![dvisvgm](https://user-images.githubusercontent.com/127006/113961056-14fa7880-97eb-11eb-82b9-db34c4115d0f.png)\r\n\r\nAs you can see that I have version 2.11. The error message suggests having version 2.4 or greater.\r\n\r\nUnfortunately here the issue is not because of the version rather it is because of `ghostscript` installation which is required by `dvisvgm`. Interesting I do have the `ghostscript` installed on my machine yet `dvisvgm` is not able to see.\r\n\r\nIn order for `dvisvgm` to see it, I have to make sure that a certain environment variable is set. See image below:\r\n\r\n![Screenink_1](https://user-images.githubusercontent.com/127006/113961559-ddd89700-97eb-11eb-8c04-6bb8c5a5f845.png)\r\n\r\nAfter this, the `example_scenes/customtex.py` would work fine.\r\n\r\nI have described the resolution (which could be classified as an installation issue) in case others are facing it. The issue with Ghostscript and mactex is not unique to manim hence should not be considered a bug related to manim. That said, the error message is a bit misleading and handling errors properly is always a challenging problem in s/w engineering.\r\n\r\nThat said, my suggestion here is to modify the `example_scenes/customtex.py` to not advertise the `pdf` output. Here is the snippet from the example:\r\n\r\n```\r\nclass InCodeTexTemplate(Scene):\r\n    \"\"\"This example scene demonstrates how to modify the tex template\r\n    for a particular scene from the code for the scene itself.\r\n    \"\"\"\r\n\r\n    def construct(self):\r\n        # Create a new template\r\n        myTemplate = TexTemplate()\r\n\r\n        # Add packages to the template\r\n        myTemplate.add_to_preamble(r\"\\usepackage{esvect}\")\r\n\r\n        # Set the compiler and output format (default: latex and .dvi)\r\n        # possible tex compilers: \"latex\", \"pdflatex\", \"xelatex\", \"lualatex\", \"luatex\"\r\n        # possible output formats: \".dvi\",  \".pdf\", and \".xdv\"\r\n        myTemplate.tex_compiler = \"pdflatex\"\r\n        myTemplate.output_format = \".pdf\"\r\n\r\n        # To use this template in a Tex() or MathTex() object\r\n        # use the keyword argument tex_template\r\n        text = MathTex(r\"\\vv{vb}\", tex_template=myTemplate)\r\n        self.play(Write(text))\r\n        self.wait(1)\r\n```\r\n\r\nHere is my rationale for not advertising the `pdf` output -\r\n\r\na) The example is first and foremost about the ability to add imports for additional packages in the preamble of tex document\r\n\r\nb) Some of the imports indeed require a custom compiler so it is okay to suggest that you could change the compiler\r\n\r\nc) Forgive me for making a bit biased opinion here as I may be ignoring some use case but I am not able to see the use of generating the `pdf` as the output as ultimately the goal is to get the `svg` anyways.\r\n\r\nUsage of `pdf` will invite issues with `ghostscript` described above leading to a bad first user experience w.r.t usage of the feature of `TexTemplate`. I think it is a great feature to add preamble dynamically!\r\n\r\nI have been using latex for many years and even I got stumbled by this Ghostscript issue and had to manually print the output of `dvisvgm` to figure it therefore I have a reason to believe that the beginners would have a bad experience because of this.\r\n\r\nIMHO, modifying the example would be a better thing to do given the audience and primary functionality of manim.\r\n\r\n\n", "before_files": [{"content": "from manim import *\n\n\nclass TexTemplateFromCLI(Scene):\n    \"\"\"This scene uses a custom TexTemplate file.\n    The path of the TexTemplate _must_ be passed with the command line\n    argument `--tex_template <path to template>`.\n    For this scene, you can use the custom_template.tex file next to it.\n    This scene will fail to render if a tex_template.tex that doesn't\n    import esvect is passed, and will throw a LaTeX error in that case.\n    \"\"\"\n\n    def construct(self):\n        text = MathTex(r\"\\vv{vb}\")\n        self.play(Write(text))\n        self.wait(1)\n\n\nclass InCodeTexTemplate(Scene):\n    \"\"\"This example scene demonstrates how to modify the tex template\n    for a particular scene from the code for the scene itself.\n    \"\"\"\n\n    def construct(self):\n        # Create a new template\n        myTemplate = TexTemplate()\n\n        # Add packages to the template\n        myTemplate.add_to_preamble(r\"\\usepackage{esvect}\")\n\n        # Set the compiler and output format (default: latex and .dvi)\n        # possible tex compilers: \"latex\", \"pdflatex\", \"xelatex\", \"lualatex\", \"luatex\"\n        # possible output formats: \".dvi\",  \".pdf\", and \".xdv\"\n        myTemplate.tex_compiler = \"pdflatex\"\n        myTemplate.output_format = \".pdf\"\n\n        # To use this template in a Tex() or MathTex() object\n        # use the keyword argument tex_template\n        text = MathTex(r\"\\vv{vb}\", tex_template=myTemplate)\n        self.play(Write(text))\n        self.wait(1)\n", "path": "example_scenes/customtex.py"}]}