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
Best Answer
You should install TeXlive.
Note some distributions like Debian derived ones (e.g. ubuntu) have a version of TeXlive in the package manager. This isn't a great option: it is old and it doesn't have all the packages you might need. Installing the one via the TUG website is much better. See this blog discussion for arguments.
TeXlive comes with a variety of useful things like
tlmgr
for updating packages from CTAN and so on. This way you always have the most up to date packages.