94

I'm trying to convert Jupyter notebook to .pdf on Mac.

However, it tells me

nbconvert tailed: pdflatex not found on PATH

So, I went looking around and someone said, "Install mactex because this other way takes days to compile". So I did brew install Caskroom/cask/mactex and it finished without telling me there was a problem, but unfortunately it didn't install pdflatex that I can gather. And 'mac install pdflatex' doesn't bring anything useful up on Google for me maybe my bubble sucks.

How do I install pdflatex on my mac?

karel
  • 13,390
  • 26
  • 45
  • 52
Wayne Werner
  • 2,193
  • 2
  • 20
  • 29

4 Answers4

82

Install BasicTeX

To get pdflatex for Pandoc on macOS, install BasicTeX. Many people recommend MacTeX, which is a much bigger package than you need. BasicTex is produced by the same people who make MacTeX, but without, e.g., the GUI applications that make it so slow to download and install.

  1. $ brew install basictex
  2. Restart Terminal.
  3. Convert LaTeX to PDF.

Example

Say you want to convert LaTex to PDF with Pandoc. You'd write:

  1. $ pandoc sourcefile.tex -o output.pdf, which fails with error pdflatex not found. Please select a different --pdf-engine or install pdflatex.
  2. So you install BasicTex, $ brew install basictex.
  3. Then restart your Terminal, and
  4. Run $ pandoc sourcefile.tex -o output.pdf again. Success!
Honey
  • 105
  • 4
Merchako
  • 2,588
  • 3
  • 18
  • 17
  • 1
    Installing `basictex` this way did not seem to work for me for generating a PDF: `$ pandoc a.tex -o b.pdf [WARNING] Unusual conversion: to convert a .tex file to PDF, you get better results by using pdflatex (or lualatex or xelatex) directly, try \`pdflatex a.tex\` instead of \`pandoc a.tex -o b.pdf\`. pdflatex not found. Please select a different --pdf-engine or install pdflatex` – Taylor D. Edmiston Jan 15 '20 at 02:18
  • 2
    I get the same error as Taylor Edmiston. Additionally, `pdflatex` itself errors a lot of `could not find *.sty` and then doesn't generate a PDF at the end... – theonlygusti Feb 03 '20 at 02:09
  • 3
    You may need to install some latex packages: `sudo tlmgr update --self` then `sudo tlmgr install framed` – hamx0r May 24 '21 at 22:59
  • Agree with the others. The answer lead me down a painful path. I have no idea why it's voted so high. – Gerry Jul 02 '21 at 19:55
  • What's the next step if this isn't relevant anymore? Are there some straightforward changes that I can make, or do I need to take the answer down? – Merchako Jul 03 '21 at 20:35
  • Installing `mactex-no-gui` and opening a new shell should do the trick these days. – codehead Oct 31 '21 at 03:40
58

Yes, same story with my MacOS Sierra:

(1) installed mactex with homebrew cask, but no pdflatex found after that:

$ brew cask install mactex

$ which pdflatex

[no location]

(2) relaunched the terminal app

(3) pdflatex found:

$ which pdflatex

/Library/TeX/texbin/pdflatex

Elena Shebunyaeva
  • 681
  • 1
  • 5
  • 3
28

It appears that brew does not, technically speaking, install mactex. It just downloads it.

I had to use the quick launch and type in mactex which popped up an installer.

After it finished I pdflatex existed, though I did have to start up a new shell - I'm assuming it did something to my path.

Wayne Werner
  • 2,193
  • 2
  • 20
  • 29
  • 3
    I just tried and installing the cask did install MacTeX. But I had to start a new shell instance for `pdflatex` to be recognisable. This is because installing MacTeX modifies your PATH by including `/Library/TeX/texbin` which is where the `pdflatex` binary lives. – Dennis Feb 02 '17 at 18:42
  • I ran `brew cask install mactex` but `pdflatex` didn't show up in `/Library/TeX/texbin`. Instead it was in `/Library/Tex/Distributions/.DefaultTeX/Contents/Programs/x86_64/pdflatex`. – ijt Jan 18 '19 at 05:01
  • Now, in 2022, I had to use `brew install --cask mactex` to install it. – Matthias Bohlen May 15 '22 at 13:53
0

Sometime later and working on a mac I also could not get pdflatex to produce a PDF. What worked for me was firstly realising that my TEX file was expecting to be compiled with xelatex and then finding a suitable Docker image, such as https://github.com/jpbernius/docker-xelatex

This doesn't answer the second part about installation, but may help someone who just needs a PDF.

snow6oy
  • 101
  • 1