Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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...

share|improve this question
2  
Are you perhaps looking for kpsewhich --var-value=TEXMFHOME, which will tell you where to 'local install' material? –  Joseph Wright Aug 25 '12 at 12:53
1  
And on a Mac, @JosephWright 's command returns /Users/<name>/Library/texmf not usr/local/texlive/texmf-local/ which is for system wide local additions. For that you need to use --var-value=TEXMFLOCAL (which on a current Mac installation returns /usr/local/texlive/2012/../texmf-local. –  Alan Munn Aug 25 '12 at 13:12
    
@AlanMunn Which of course you should not be adding anything to :-) –  Joseph Wright Aug 25 '12 at 13:17
2  
@projetmbc If you have a TeX distribution installed, you have kpsewhich; if you don't have one you won't have it. I don't think there's a surefire way to check that a distribution is 'complete' (if that's even a well formed idea), but just testing for the existence of the TeX binaries should be enough to verify that you have one. –  Alan Munn Aug 25 '12 at 14:09
1  
@projetmbc To check for a TeX system, I'd probably do which pdftex on Unix and use a path search on Windows (we have some code for this in the LaTeX3 build scripts to find Perl). However, this is more about shell scripting than TeX: the same approach applies to any executable you want to find. –  Joseph Wright Aug 25 '12 at 14:41
show 4 more comments

3 Answers

up vote 3 down vote accepted

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
share|improve this answer
add comment

I hope I did not missunderstand the question.

For Windows I simply would try with pdftex --version or pdflatex --version in the command line. If there is a (proper) installed version of TeX you get the Name of the distribution and the version.

You can also use path to see, if there is a directory for the binaries of TeX (MiKTex or TeXLive).

kpsewhich is running on windows, but has different parameters to the unix version (see comments of @Joseph Wright and @Alan Munn).

share|improve this answer
    
kpsewhich works on both Unix and Windows in the same way (see the LaTeX3 build scripts). I would avoid using pdftex --version as you get an error if it's not found, whereas a search can be done for the appropriate path without issuing an error if it fails. –  Joseph Wright Aug 25 '12 at 16:14
    
@Joseph: I just tried your kpsewhich --var-value=TEXMFHOME with Windows 7. No response because TEXMFHOME is not known. In an windwos batch you can check the returncode of pdftex and react without any stopping of the batch. –  Kurt Aug 26 '12 at 0:28
    
I only use kpsewhich to find a location if needed. If a value is not known, out scripts make the assumption on Windows to use %USERPROFILE%\texmf. –  Joseph Wright Aug 26 '12 at 6:07
add comment

If you just want the version of LaTex, pdfTex or packages you can check the log file in any project you've compiled on the system and there it is. There you'll also be able to see the path of the different packages and from there deduce the path of your executable TeX file

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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