Repository: ManimCommunity/manim

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.




Discussion:
As far as I can understand this process, the fix seems reasonable. 

I am tagging @cobordism who appears to be the primary author for InCodeTexExample to see their thoughts.
Is this just an error with the MacOS default installation of tex / dvisvgm? 

I have never had issues with pdf output and indeed I _needed_ pdf for some of the advanced fonts templates.
But ok. If this example also compiles with .dvi, then by all means... we can set the compiler to latex and the output to .dvi in this example, but we should keep the hint that one _could_ set it to .pdf in the comment
Thanks, @cobordism for the input.

I think the issue is with both Mac and Linux and as such manim community troubleshooting docs have done a good job at documenting the Ghostscript environment variable setup. I saw it later when I thought about at least documenting it. 

Nevertheless, my concern is primarily about the first user experience of using the TexTemplate to add packages as described above.

@MrMallIronmaker I will send the PR ... would be just a deletion of a line and a comment as @cobordism  suggested to inform the user that there are other possible outputs.

Hi, since the PR hasn’t been sent yet can I do it?
I was going through the code and found out that the default is already latex and .dvi so we could just leave it as that and we can then have a print statement saying that it is in latex and .dvi and if we want to change it we can go to the code and change it later on
It is ok to explicitly set the argument to the default. Especially in an 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 = "latex"
        myTemplate.output_format = ".dvi"

        # 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)
        ```

Resolving patch:
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 @@ def construct(self):
         # 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


Test patch: