Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

Originally I was going to ask a question about how to get LaTeX working in Anki, but as I was writing the question, I was trying to solve the problem myself. I thought others may benefit from my findings, so I decided to post them here. If you notice that any of my steps are wrong, please let me know. And I was still unable to get it to work, so if you scroll down to the end, you can see where I'm stuck and still need help.

The current issue is: How can I install libgd?


I'm trying to make Anki work with LaTeX. The only information I could find about how to do this is from this page:

  • [...] to use LaTeX, you have to install it separately - it is not bundled with Anki
  • [...] on OSX use MacTex
  • Dvipng must also be installed.
  • On OSX, if you use MacPorts or similar to install LaTeX, make sure latex and dvipng are linked in /usr/bin.

The standard installation of MacTex takes up 3GB, far more than I believe is necessary, since I am not going to use its GUI application. I just need the LaTeX library, if I understand it correctly, which should be way less than 3GB. Therefore, I'm installing the BasicTeX version instead, which only takes up about 100MB.

I'm not sure if I already have Dvipng installed or not, so I'm restarting Anki to see if it works or not. I got the following error:

Error executing dvipng. [...] Output written on tmp.dvi [...]

So I probably need to install dvipng... The Install readme has the following information:

Installing dvipng should be simple: merely ./configure',make', and `make install'.

Prerequisites:

  • The GD Graphics Draw library, libgd
  • The path-searching library kpathsea
  • libpng and libz

Again, I'm not sure which, if any, of these prerequisites I already have installed, so I'm just going ahead with the installation in hopes of error messages guiding me to the right path.

After executing ./config, it gives the error:

configure: error: cannot find/use libpng

... which I think is weird since the readme states:

 To be able to compress and write PNG files to disk, dvipng (or
 really libgd) uses libpng which in turn uses libz. These should be
 available on any modern system, if not, download them and install
 them.

I went to the libpng website, and tried finding a "current binary" that works with my OS (10.6/i386), but it seems that none of the latest 3 versions have a binary that is available to download. So I went to the "old binaries" section, which took me to this website, which has libpng v1.4.5. I installed the "Individual Installer package" for libpng.

Now that it's installed, I tried installing Dvipng again, and it now gives the following error:

cannot find/use libgd
This drawing library can be downloaded at http://www.boutell.com/gd

When I go to that website, I see it says that the page moved and that it is currently down. There is only a link to the source files and no binary distribution. I'm not sure where I should go from here... should I download the source and compile it somehow? Once it's complied what do I do with it? Do I run some file it generates? Would I move files it generates to specific folders? How would Dvipng know how to access it? I'm unfamiliar with how to do something like this, so any help would be appreciated.


Here's a summary (so far) of the dependency hierarchy which must be installed in order to get LaTeX to work with Anki:

  • MacTeX: Installed (got the BasicTeX version to save a lot of disk space).
  • Dvipng: Not installed (can't install without libgd).
    • libpng: Installed (got the Individual Installer package).
    • libgd: Not installed (not sure how to install this).
    • ???

Other questions:

  • Is there a better, reliable method to know if any of these dependencies are installed rather than running an installer which depends on them and hoping for a meaningful error message?
share|improve this question

2 Answers 2

Your question was very helpful to me in getting LaTeX working with Anki, but I've found there's an easier way to get dvipng:

  1. Install MacTeX. I installed BasicTeX-2011.pkg (MacTeX-Additions-2011.mpkg is NOT required).
  2. Open the terminal, type "tlmgr update --self && tlmgr install dvipng" and press enter. It will update TeX Live Manager and install the latest dvipng.

Once you do that, you should be all set.

share|improve this answer
    
I agree. It is much better to install packages in MacTex via Tex Live Utility than the command line. This suggestion should work. –  dan8394 Aug 14 '11 at 3:46
    
Question: I am the only admin on my system but when I try and run the terminal command "tlmgr update --self && tlmgr install dvipng" I get an error saying I need to run the program as an admin. I am the admin! How do I run this program? I need it to properly configure latex on OSX10.6 (Snow Leopard) because I am having pdflatex/ dvipng errors after a new install of BasicTex. Thanks! –  user21373 Apr 8 '12 at 19:01

I was having this exact problem but the command "tlmgr update --self && tlmgr install dvipng" did not work and I got the error I need to run the program as an admin.

The user account I was using was an admin account. What I did instead is run each command separately as sudo: At the Mac OS X Terminal prompt:

$ sudo tlmgr update --self

(wait for this command to grab updates and compete)

$ sudo tlmgr install dvipng

This worked and installed tlmgr updates as well as dvipng, causing Anki to display LaTeX output!

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.