Menu

#197 tikz not working on Mac

v1.0_(example)
open
None
5
2024-12-02
2024-11-19
Ethan Brown
No

I have used texmaths in libreoffice for several years to embed latex-rendered equations in slide decks. When I used a linux machine, I would use the tikz package to render custom symbols using texmaths. I recently switched to a mac, and the same code no longer renders the tikz images. I do not get any error, but the parts of the formulas called by tikz do not render.

On my mac, I use libreoffice version 24.8.3.2 with texmaths version 0.52.3. I run the following lines in my preamble:

\usepackage{tikz} %tikz is used to draw the glyphs
\usetikzlibrary{arrows,scopes} %tikz libraries used to draw the glyphs
\usepackage[papersize={145mm,45mm},left=0.1ex, right=0.1ex]{geometry} %change paper size, so it is easier to see the glyphs

%defining script r (scalar)
\newcommand{\rc}{%
\resizebox{!}{1.25ex}{%
    \begin{tikzpicture}[>=round cap]
        \clip (0.09em,-0.05ex) rectangle (0.61em,0.81ex);
        \draw [line width=.11ex, <->, rounded corners=0.13ex] (0.1em,0.1ex) .. controls (0.24em,0.4ex) .. (0.35em,0.8ex) .. controls (0.29em,0.725ex) .. (0.25em,0.6ex) .. controls (0.7em,0.8ex) and (0.08em,-0.4ex) .. (0.55em,0.25ex);
    \end{tikzpicture}%
}%
}
%defining bold script r (vector)
\newcommand{\brc}{%
\resizebox{!}{1.3ex}{%
    \begin{tikzpicture}[>=round cap]
        \clip (0.085em,-0.1ex) rectangle (0.61em,0.875ex);
        \draw [line width=.4ex, <->, rounded corners=0.13ex] (0.1em,0.1ex) .. controls (0.24em,0.4ex) .. (0.35em,0.8ex) .. controls (0.29em,0.725ex) .. (0.25em,0.6ex) .. controls (0.7em,0.8ex) and (0.08em,-0.4ex) .. (0.55em,0.25ex);
    \end{tikzpicture}%
}%
}
%defining bold script r with a hat (unit vector)
\newcommand{\hrc}{\hat{\brc}}

Then I generate equations such as:

\brc = \rc \hrc = \textbf{r} - \textbf{r}'

The output shown below in the attachment is correct on the first line (rendered on my linux machine), but is incorrect on the second line generated by my mac. My mac is rendering the rest of the equation, but skips the tikz package commands.

foobar

I have verified that tikz is present in my latex installation, and other compilers on my computer (like TeXShop) render these equations correctly.

1 Attachments

Discussion

  • Roland Baudin

    Roland Baudin - 2024-11-19

    Hi, I tested your example in Linux (Ubuntu 24.04) and Windows 10 (22H2). It works as expected.
    So the problem might be in your MacTex installation. Maybe it's corrupted or incomplete. I suggest you reinstall it completely.

     
    • Roland Baudin

      Roland Baudin - 2024-11-20

      I did another test in a Mac OS X (Monterey) VM with LibreOffice 24.8.3.2 and TexMaths 0.52.3. I used a fresh install of MacTeX 2024.

      Everything worked and your example rendered well. I just had to adjust the line width of the bold symbol to .2ex instead of .4ex, otherwise it was too bold.

      So there is probably something wrong in your MacTeX install. You should reinstall it completely and your example should work then.

       

      Last edit: Roland Baudin 2024-11-20
  • Ethan Brown

    Ethan Brown - 2024-11-20

    I tried a fresh installation of MacTeX with no change. It still renders correctly in TeXShop, but TexMaths has the same problem as before. It looks like the MacTex installation is fine. Could it be a library issue for the tikz package? I'm not sure how to see where TexMaths looks for individual packages.

    My mac OS is Sonoma 14.5. Are there any known issues with this OS that could be causing the problem?

     
    • Roland Baudin

      Roland Baudin - 2024-11-21

      IMHO it's not the system version.
      Could you send me the contents of the folder:
      /Users/<your_user_name>/Library/Application Support/LibreOffice/4/user/TexMaths
      after you have compiled the problematic equation.
      And maybe also a screenshot of the TexMaths Config first tab.
      Thanks.</your_user_name>

       
  • Ethan Brown

    Ethan Brown - 2024-11-21

    Attached are the folder contents and a screenshot of the configuration tab

     

    Last edit: Ethan Brown 2024-11-21
    • Roland Baudin

      Roland Baudin - 2024-11-21

      OK thanks.

      I found the following issue in your tmpfile.dat:

      pre-processing DVI file (format version 2)
      processing of PostScript specials is disabled (Ghostscript not found)
      processing page 1
      WARNING: 152 PostScript specials ignored. The resulting SVG might look wrong.
      graphic size: 61.674644pt x 8.231855pt (21.676158mm x 2.893166mm)
      output written to tmpfile.svg
      1 of 1 page converted in 0.341416 seconds

      Mine is:

      pre-processing DVI file (format version 2)
      processing page 1
      graphic size: 72.014299pt x 8.231816pt (25.310131mm x 2.893152mm)
      output written to tmpfile.svg
      1 of 1 page converted in 0.46262 seconds

      So it seems that GhostScript is not installed in your machine. I think the problem is that GhostScript is not installed with MacTeX.

      In my MacOS VM (that I have set up a few years ago), it seems that I have installed GhostScript as a separate package. This is probably why the equation is well rendered in my case.

      You can install GhostScript from here: https://www.tug.org/mactex/morepackages.html

       
  • Roland Baudin

    Roland Baudin - 2024-11-21

    Another point: in your preamble, there is a line at the beginning:

    \documentclass[extrafontsizes, 60pt]{memoir} %makes fonts larger, so it is easier to see the glyphs

    The latex compiler complains about it. This is because TexMaths already adds an \documentclass[10pt,dvips]{article} at the beginning of the LaTeX file.

     
  • Ethan Brown

    Ethan Brown - 2024-11-21

    This is strange because GhostScript was indeed installed on my mac. I reinstalled it with brew, then downloaded the package and installed it directly. Neither affected the output.

    I did comment out the \documentclass line as well, also no change.

     
  • Ethan Brown

    Ethan Brown - 2024-11-25

    I followed the solution instructions listed above, and it is still not working.

    I first tried installing GhostscriptExtras, which didn't work. I also set the path directly, which also didn't work. I see in the texmaths confituration that it points to a different location for dvisvgm, namely /usr/local/texlive/2024/bin/universal-darwin/dvisvgm. I followed the same procedure in the link you shared to edit the dvisvgm file here, but without any change in the output. I'm fairly sure dvisvgm is being executed, because I had a typo in the work around that caused a runtime error. Now that I fixed that, TexMaths is rendering equations again, just not my tikz drawings.

     

    Last edit: Ethan Brown 2024-11-25
  • Roland Baudin

    Roland Baudin - 2024-11-25

    OK, normally dvisvgm should find the GhostScript shared library but for some reason, that's not the case. Even using the direct method by calling dvisvgm with the LIBGS environment variable or with the --libgs option doesn't work. There may be a compatibility issue between macTeX 2024 and your system (it works in a Monterey VM), or a bug somewhere.

    Note that typing in a terminal:
    dvisvgm -V1
    should show GhostScript among the results displayed. If not, then your tikz commands are not rendered when converting the DVI file to SVG.

    By the way, I tried to set up a VM with macOS Sonoma but for some reason I couldn't succeed. So I ended with a macOS Ventura VM. I installed macTeX 2024 (using the custom option from the install dialog that allows to add the GhostScript shared library) and alas I got the same situation as you: dvisvgm didn't work with tikz in that case.

    Then I completely removed macTeX from this Ventura system (by deleting the following directories: /Library/TeX, /Applications/TeX, /usr/local/lib and /usr/local/texlive).

    After that cleanup, I installed macports and texlive. This also installed dvisvgm and the GhostScript shared library and all the required LaTeX programs.

    Note that latex, xelatex, dvipng, lualatex, dvisvgm binaries are now installed in /opt/local/bin. So I changed the locations of these programs in TexMaths Config and tried to render your example and... bingo it worked!

    So there is a chance that installing texlive from macports could also work in your Sonoma system.

    Could you give it a try?

     
  • Ethan Brown

    Ethan Brown - 2024-11-26

    Oh this is amazing, it works now! It took some doing to get all the dependencies right, particularly for the SDK in Xcode, but with the macports installation of latex it now renders everything correctly.

    Thanks!

     
    • Roland Baudin

      Roland Baudin - 2024-11-27

      Ok, nice to see it works now.
      However, we don't know what the problem really is in macTeX. Maybe I should send a bug report to the macTeX team...

       
      • Ethan Brown

        Ethan Brown - 2024-12-02

        Yes, that would be great if you could send a bug report to them.

         

Log in to post a comment.