16

I've seen somebody asked this question a year ago, but no answers given so I'm hoping this might attract some more/new/different attention.

Simple question. I want to use LaTeX with Inkscape on mac. I already use a tex editor so I should have most of the LaTeX stuff I need. However when I go to "Extensions>Render>", there's not a LaTeX option there as other online sources suggest.

As a fudge I tried using the application Latexit to generate SVG/EPS images to import but I can't seem to get import of those to work either.

Tom
  • 483
  • 1
    Welcome to TeX.SX! You should know that this site is considered a Q&A, not a discussion forum, which (somehow) implies that duplicates aren't allowed. I will start a poll to close this question, though I hope that the original question will get enough attention now. You should also know that you can share questions on other places to draw more attention to it. – Ruben Jul 26 '15 at 21:36
  • Fair enough, I looked to meta first. The jury seems to be out but some people seem to suggest just re-asking an old unanswered question. – Tom Jul 26 '15 at 21:41
  • Ok, I looked meta afterwards... Let's leave your question open then and link the other question as a dupe to yours if you get an answer. – Ruben Jul 26 '15 at 21:45
  • Sure, whatever is best. It just seems like the question could do with more attention. It has 1000 views but no real answers. – Tom Jul 26 '15 at 21:47
  • What version of Inkscape do you have? How did you install it? This question can't be closed as a dupe anyway because the other has no answers. However, right now, I don't really see this as being on topic. It sounds like a feature request for the folks who supply you with Inkscape (or for you if you compile yourself) or, maybe, the developers (less likely). I don't really see what kind of answer could be provided here: the extension is not included in your copy of Inkscape, whereas it is enabled by default for most. Too bad you're on a Mac, I guess :(. – cfr Jul 27 '15 at 02:25
  • Interesting. The FAQ suggests the extensions for this are not included in the main package. Yet I have the Render option even though my distro does not seem to do anything special to enable or add the code for the extensions. Maybe I'm misreading the FAQ. – cfr Jul 27 '15 at 02:41
  • I export Inkscape drawings as PDFs and then include them in LaTeX files using \includegraphics from the graphicx package. – musarithmia Jul 27 '15 at 05:24
  • Ok well in any case, surely this is going to be a question almost every single mac user wanting to use Inkscape for scientific figures (and other applications) is going to have? The answer may not be a happy one, but it would be helpful for myself and future viewers to have a definitive one. – Tom Jul 27 '15 at 10:54
  • @AndrewCashner I found that I was able to drag and drop PDF SVG latex images from "Latexit" into Inkscape and it would open up a new document "latex.pdf" which I could edit. However when I copied and pasted it from there into the document that is my poster it appears a blank square with nothing in it. I also tried saving the "latex.pdf" which would automatically change it to "latex.svg", then importing from the poster document (also svg) but this presents me with an error. Any simple fix to this issue? – Tom Jul 27 '15 at 10:58
  • I spent the whole weekend learning Inkscape because I thought it was a standard application for scientific figure creation, but without Latex it's a bit useless :'( – Tom Jul 27 '15 at 10:59
  • 3
    Inkscape works fine on mac: all you do is write latex inside $ $ in text boxes in your image, and then export to pdf with the latex option as explained in this answer. When you export you get a pdf (with no latex in it) and .pdf_tex file which you can open and copy the contents of inside your main latex file. Making sure directories match, you will get your image with the overlaid math text. There is no need for a "Extensions>Render>" option, as explained here at the very bottom – Emilio Ferrucci Sep 29 '15 at 21:43
  • https://gitlab.com/inkscape/inbox/-/issues/1221 This link helped do the job of producing latex vectors in inkscape. – Amsterdam6483 Mar 03 '21 at 10:38

6 Answers6

20

I encountered this problem coming from linux, where you could just easily go to Extension->Render->LaTex and type your latex formula. This is what I did (finding every piece from different sources) to fix this problem.

The general solution is that you have to add the PATH for latex, dvips, and pstoedit to the paths in the app. To do this follow the instructions below:

  1. Find the PATH to latex and dvips by typing the following in a terminal: which <app.name>, and the write down the paths. These two apps are usually installed with the MacTex installation, so there shouldn't be any need for installation here.
    For example here I get for both of them: /Library/TeX/texbin.
  2. pstoedit does not exist by default in the MacTex, so you have to install it. However, I tried installing it from a tar ball and it didn't work (probably cause I didn't have all the dependencies).
    I used macports here to to install this, and it worked for me. Now similarly find the PATH for pstoedit. For example I had: /opt/local/bin/.
  3. With your desired editor, open (with sudo) the following file: /Applications/Inkscape.app/Contents/Resources/script. Now at the end of this file, right above the last line exec "$CWD/bin/inkscape" "$@" add the paths that you extracted from step 1 and 2.
    For example I should add the line: PATH=$PATH:/Library/TeX/texbin:/opt/local/bin

Alternatively - especially if your installation doesn't have the script file - simply open Inkscape from the terminal: open -a /Applications/Inkscape.app/. Assuming the required LaTeX programs are already in your terminal's path (check with echo $PATH), this should work.

You should then be able to open Inkscape and type latex formulas by going to Extension->Render->Mathematics->LaTex.

Mostafa
  • 301
  • 2
    This worked for me. I had to add the PATH command before the line that starts exec. – borticus Sep 27 '16 at 17:00
  • 2
    On my installation, the /Applications/Inkscape.app/Contents/Resources/script does not exist, nor does any other file called script. I am on a Apple Silicon MacBook Air. Do you know what changed here or what the problem might be? – McLawrence Feb 25 '21 at 20:07
  • 1
    Opening Inkscape from the terminal with open -a /Applications/Inkscape.app/ worked on a Silicon Macbook. – Saurabh Shringarpure Dec 17 '23 at 10:14
  • Inkscape 1.3.2 on Mac 14.3.1 (M1): the path in my case is Extensions -> Text -> Formula (pdflatex) – Carlos H. Mendoza-Cardenas Feb 25 '24 at 23:28
  • My installation also appears not to have a script file, although opening the program with open -a /Applications/Inkscape.app does work for me. Another thing that seemed to work was symlinking pdflatex, dvips, and pstoedit within the bin folder. Concretely, I went into /Applications/Inkscape.app/Contents/Resources/bin and executed {ln -s $(which pdflatex) .}, and similarly dvips an pstoedit. Now latex rendering seems to work however I open inkscape. – Evan Feb 28 '24 at 23:59
7

I have a solution that I hope future viewers will find useful. It's not perfect but it's a quick and easy enough workflow for me.

I use the application Latexit to generate the Latex image. It's really easy to install and use.

Then I save as PDF vector format

enter image description here

Then from Inkscape select File>Import, select the PDF file, hit open and you're presented with this option box

For some reason it doesn't seem to work unless you tick "Clip to media box" and "Import via Poppler". Voila it's in Inkscape.

Remark: I think you can also save as SVG format from Latexit which might be better, but you need something extra called PDF2SVG which I'm not sure how to install.

Ruben
  • 13,448
Tom
  • 483
  • 3
    For anyone that missed it: "Clip to media box" and "Import via Poppler" is crucial part of the answer! Thanks so much. :) – Charlie Parker Oct 19 '16 at 23:30
4

I stumbled upon this in Jan 2022. The current version of Inkscape for Mac has an option for LaTeX rendering but it is disabled by default. But, if you run

alias inkscape="/Applications/Inkscape.app/Contents/MacOS/Inkscape"

in a terminal and then launch

inkscape

the option magically starts working! There is some issue with how paths are handled when the app is launched using the GUI.

Source: https://gitlab.com/inkscape/inbox/-/issues/1221

The menu

Options

The LaTeX

  • In my case the path was /Applications/Inkscape.app/Contents/MacOS/inkscape (The i in inkscape was lower case). However, you can also launch this without the terminal involved just by right clicking on the 'Inkscape' app in the Application folder and select Show Package Content and then look for /MacOS/inkscape and launch it (double click). – Nathanael Skrepek Nov 26 '22 at 23:22
2

Sad to see Inkscape on mac OS is lagging behind and we yet to see a stable native implementation. Many features present on Windows and Linux, including the LaTeX equation import, is missing. But even if it was there, there is other solution which IMHO is better. textext extension has been around for a while, and now other people have taken over the development. how to install it on mac OS?

  1. go to this repository and download the latest stable version and unzip
  2. go to this address:

~/.config/inkscape/extensions/

  1. copy the contents of extension folder from the download into this folder
  2. as this page has explained:

    • find the address of pdflatex

which pdflatex

  • open the file below in an editor:

~/.config/inkscape/extensions/textext.py

  • change the line

out = exec_command(['pdflatex', self.tmp('tex')] + latex_opts)

to

out = exec_command(['/Library/TeX/texbin/pdflatex', self.tmp('tex')] + latex_opts)

do not forget to install other dependencies mentioned in the readme of the mentioned repository. I know it it is not that straight forwards but it works at the end.

Foad
  • 893
0

If you install inkscape from the dmg file offered by inkscape.org you won't have latex rendering.

You can have latex rendering similar to the linux version by building it via macports:

1- install macports

2- install pstoedit from the terminal

sudo port install pstoedit

3- install inkscape from the terminal

sudo port install inkscape

note: I am not sure if step 2 is necessary, but that is how I did it and it worked.

M.A
  • 255
  • 2
  • 7
0

I just tested to run the following code in terminal on Mac OS Ventura using inkscape version 1.3.

open -a /Applications/inkscape.app/

The LaTeX rendering and function plot rendering all worked as intended.

If you use inkscape frequently, you can save time by creating the alias for the command above in terminal.


Step 1: Determine which shell you are using. Common ones are bash and zsh. You can check by running:

echo $SHELL

Step 2: Open appropriate shell configuration.

For bash, enter nano ~/.bashrc.

For zsh, enter nano ~/.zshrc.


Step 3: Create the alias.

alias inkscape="open -a /Applications/inkscape.app"

To save the alias, you can press Ctrl + X, then Y to save the changes.


Step 4: To apply the changes to your current terminal session, run the following command.

For bash, source ~/.bashrc.

For zsh, source ~/.zshrc.


Finally, you can open the inkscape with pdflatex and function plotting functioning well in terminal by just type the key word alias inkscape to open the inkscape application.