Somehow I crashed my TeX today and could not fix it. So, I decided to delete it and download the latest version. However, instead of downloading MacTeX (which could have saved me tons of trouble), I downloaded TeX Live 2020 (which cost 3.5 hours) and TeXShop separately. What a fool. To shake off the shame, I spent the next 3.5 hours to figure out how to make them work together, feeling like a smart fool now. Below are my notes.
rm -R /usr/local/texlive/2016
install-tl
GUI. Find out where is pdflatex and/or ptex2pdf.
which pdflatex
which ptex2pdf
PATH=/usr/local/texlive/2020/bin/x86_64-darwin:$PATH
pdflatex
should work in the terminal, which prints out a PDF file on your desktop.
cd ~/Desktop
pdflatex sample2e.tex
/usr/local/texlive/2020/bin/x86_64-darwin/
pdftex --file-line-error --synctex=1
and pdflatex --file-line-error --synctex=1
.
In the Typeset menu, select both LaTeX
and Pdftex
.
PATH
variable in R, so I can compile R Markdown to PDF files. In R console,
> Sys.getenv(“PATH”)
> Sys.setenv(PATH=paste(Sys.getenv(“PATH”),“/usr/local/texlive/2020/bin/x86_64-darwin”,sep=“:”))
Hoorey! Almost everything works again after I completely wiped out TeX Live 2020 and TeXShop, and reinstalled them from MacTeX-2020. Yes, I lost my patience in debugging. Before the wipe-out, TeX Live 2020 worked perfect in Terminal when the TeX files were run by pdflatex
. However, neither TeXShop nor RStudio compiled successfully. Ironically, the problems with TeXShop and RStudio did not go away for certain TeX files even after MacTeX-2020 was installed. So I guess I could have fixed those glitches had I known about the following few things.
LaTeX
to pdflatexmk
in certain cases.First try to locate them. Typically, it is in /usr/local/texlive/2020/texmf-dist/tex/latex/
.
kpsewhich PackageName.sty
If it is truly missing, then download it from CRAN.
Find out the TeX home directory:
kpsewhich -var-value=TEXMFHOME
For Mac, it is typically ~/Library/texmf/
. Next, add the missing sty file to the TeX home directory. For example, ~/Library/texmf/tex/latex/local/
. Create the local
folder if it does not exist.
The particular sty file that I had trouble with was mcexam.sty
. The trouble is solved based on this StackExchange thread.
Preferences...
menu, Engine
tab, the default path setting /Library/TeX/texbin
should be okay, thanks to MacTeX.