[Tex/LaTex] Windows-Terminal commands to have information about LaTeX distribution

distributionsinstalling

I'm looking for command to use in one terminal so as to know the following facts.

  1. Is there one LaTeX distribution installed ?
  2. What is the path where to put local classes or packages ? In my Mac, I know that it is '/usr/local/texlive/texmf-local/tex/latex'.

The command will be used by one Python script so as to automate the installation of my personnal little classes or packages.

The solutions given in the following comments work well on Mac, and I think that this works also under Linux, but I don't know how to do under Windows

Best Answer

In terms of finding the correct location for a local installation, we do this in the make.bat files for LaTeX3. There, we have

if not defined TEXMFHOME (
  for /f "delims=" %%I in ('kpsewhich --var-value=TEXMFHOME') do @set TEXMFHOME=%%I
  if [%TEXMFHOME%] == [] (
    set TEXMFHOME=%USERPROFILE%\texmf
  )

which means that if the variable TEXMFHOME exists then it is used, otherwise we try kpsewhich to get a value, and if that returns nothing fall-back on the default location.


For finding 'some program', I use another bit of batch file programming culled from elsewhere. Here, the example is to find Perl, but the same approach would apply to finding pdfTeX

:perl

  set PATHCOPY=%PATH%

:perl-loop

  if defined PERLEXE goto :end

  for /f "delims=; tokens=1,2*" %%I in ("%PATHCOPY%") do (
    if exist %%I\perl.exe set PERLEXE=perl
    set PATHCOPY=%%J;%%K
  )

  if defined PERLEXE goto :end

  if not "%PATHCOPY%"==";" goto :perl-loop

  echo.
  echo  This procedure requires Perl, but it could not be found.

  exit /b 1

  goto :EOF