2

Background:

Currently, I have installed

/usr/local/texlive/2016
/usr/local/texlive/2017
/usr/local/texlive/2018

With TeXLive, I can use the TeX Live Utility.app to select which TeX distribution to use

enter image description here

Questions:

  1. How can I obtain the value of this setting in a bash variable?
  2. Is is possible to set this value via the command line?

Platform

  • MacOS High Sierra (Version 10.13.4)
  • 2
    kpsewhich -var-value=SELFAUTOPARENT returns /usr/local/texlive/2018 (or whatever year the installed distribution refers to). – egreg May 10 '18 at 8:00
  • Well that was easy. Woks great. – Peter Grill May 10 '18 at 8:05
  • @AndreasStorvikStrauman although better to set PATH than set SELFAUTOPARENT – David Carlisle May 10 '18 at 8:54
  • You shouldn't mess with the system $PATH variable though. Seems like kpsewhich uses the system one. – Andreas Storvik Strauman May 10 '18 at 8:55
  • @AndreasStorvikStrauman If I run env SELFAUTOPARENT='/usr/local/texlive/2017' kpsewhich -var-value=SELFAUTOPARENT, the terminal returns /usr/local/texlive/2018. Differently from other kpse variables, the SELF... ones are not looked at when program linked to libkpse are launched. – egreg May 10 '18 at 9:16
4

TeX Live relies on the kpse library and MacTeX is based on TeX Live.

Basically, all TeX related programs are linked to the library, whose primary job is to set up several environment variables starting from the location the program sits in.

So, for example, if you run pdflatex and the binary resides in /usr/local/texlive/2018/bin/x86_64-darwin/ (usually the location is determined via a soft link), the main variables that are set are (from texmf.cnf

% SELFAUTOLOC (directory of the binary=/usr/local/texlive/YYYY/bin/i386-linux),
% SELFAUTODIR (its parent = /usr/local/texlive/YYYY/bin), 
% SELFAUTOPARENT (its grandparent = /usr/local/texlive/YYYY), and
% SELFAUTOGRANDPARENT (its great-grandparent = /usr/local/texlive).

These four variables are set based on the location of the binary and used for locating the relevant texmf.cnf files (see the documentation of the library, texdoc kpathsea) which will set all the other necessary variables.

A program for querying the setup is kpsewhich; among other options, it can report the value of environment variables, including those that are set at program launch by kpse; so

kpsewhich -var-value=SELFAUTOPARENT

will return, on my machine,

/usr/local/texlive/2018

from which you can easily extract the year, if needed.

Just for information, when I want to test a document with different versions of TeX Live, instead of changing the distribution via the panel I just directly call the binary:

/usr/local/texlive/2017/bin/x86_64-darwin pdflatex

because the SELFAUTOLOC feature will set the environment to what results from reading the texmf.cnf files from the 2017 distribution.

  • This answer is correct as far as it goes, but the OP will end up with different TeX distributions being used on the command line vs. GUI programs (such as TeX Live Utility, BibDesk, or TeXShop) if they are configured to use /Library/TeX/texbin. – Adam Maxwell May 10 '18 at 13:52
  • @AdamMaxwell That’s a series of links pointing to the same place, the directory containing the binaries for the currently chosen TeX Live distribution. – egreg May 10 '18 at 14:24
  • Yeah, I know it's a series of links. This may meet the OP's needs by answering the spirit of his question, but it's not correctly answering the question of which distribution TeX Live Utility will show as selected, or how you would change that distribution from the command line. (Speaking here as the maintainer of TeX Live Utility). – Adam Maxwell May 10 '18 at 14:53
  • @AdamMaxwell: Do you want to post an answer? I would prefer that the GUI and command line tools use the same executables and packages. – Peter Grill May 10 '18 at 17:26
  • @PeterGrill The shell script that TeX Live Utility uses to change the distribution is here: github.com/amaxwell/tlutility/blob/master/texdist/… – Adam Maxwell May 10 '18 at 18:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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