MATLAB environment variables issue with MacTeX 2020

2 Ansichten (letzte 30 Tage)
Yuanqing Xue
Yuanqing Xue am 29 Okt. 2020
Beantwortet: Walter Roberson am 31 Okt. 2020
Hello
I'm running several matlab script include using xelatex to compile LaTex code and export to pdf. I downloaded c from the official website and installed successfully, but I keep having this error when I run my script. I use Mac system in MacOS High Sierra and the code was run locally using matlab2020
/bin/bash: xelatex: command not found
...
LaTeX compilation failed.
I searched for lots of answers, the one I found the most useful is this one: https://www.mathworks.com/matlabcentral/answers/850-matlab-environment-variables
I used the suggestion from the answer to set :
setenv([getenv('PATH') ':/usr/texbin']);
setenv([getenv('PATH') ':/usr/local/bin']);
also
setenv('PATH', [getenv('PATH') '::/usr/local/bin']);
then I thought the installation path for MacTeX 2020 might changed, I found this: "The default installation directory is /usr/local/texlive/2020 on Unix"
after change the path and run this
setenv('PATH', [getenv('PATH') ':/usr/local/texlive/2020/']);
Still does not work and the same error showed up
Does anyone know how to fix this? Thanks!
  4 Kommentare
Walter Roberson
Walter Roberson am 30 Okt. 2020
/Library/TeX/texbin/xelatex is the fully qualified path of the executable, not just the directory name. So you should be using
setenv('PATH', [getenv('PATH') '/Library/TeX/texbin']);
Yuanqing Xue
Yuanqing Xue am 30 Okt. 2020
Thanks! With this combination it worked!
setenv('PATH', [getenv('PATH') '/Library/TeX/texbin']);
switch latex_compiler
case 'pdflatex'
cmd = ['/Library/TeX/texbin/pdflatex --interaction=nonstopmode ', fname, '.tex'];
case 'xelatex'
%cmd = ['/Library/TeX/texbin/xelatex --shell-escape ', fname, '.tex'];
cmd = ['/Library/TeX/texbin/xelatex --interaction=nonstopmode ', fname, '.tex'];
otherwise
error('latex:compiler', 'Unknown LaTeX compiler.')
end
status = system(cmd);
if status ~= 0
error('latex:compile', 'LaTeX compilation failed.')
end

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 31 Okt. 2020
(summarizing)
The one from http://www.texts.io/support/0001/ installs into /Library/TeX/texbin/xelatex
setenv('PATH', [getenv('PATH') '/Library/TeX/texbin']);

Weitere Antworten (0)

Kategorien

Mehr zu Adding custom doc finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by