[Tex/LaTex] Finding directory path for .sty files

packagespaths

I am attempting to add the subfloat.sty file to my LaTeX search path. In order to find that path, I executed:

kpsewhich -var-value=TEXMFHOME

which, as expected, gave

/home/max/texmf

However, there are no subdirectories associated with that (seemingly empty) path, and I cannot even cd to ~/texmf nor copy files to this directory (consequently, I cannot move the .sty file into any subdirectory). However, I can run LaTeX successfully, including various other packages without error, so obviously it's looking for and finding them in some directory path, just not the one indicated.

Does anyone have any suggestions for how to trouble-shoot this problem?

Best Answer

The package subfloat.sty should be added to the LaTeX search path, i.e., if you have an openSUSE Linux machine, generally it is found to be in:

/usr/share/texmf/tex/latex/subfloat/

and/or

$HOME/texmf/tex/latex/subfloat/.

If you have never added manually to your LaTeX distribution a package for the only user max, the directory ~/texmf shouldn't exist. Furthermore, if you haven't added any other path to your TEXMFHOME, all the folders containing your LaTeX packages should be grouped in /usr/share/texmf/tex/latex.

The variables TEXMFHOME and your TEXMFDIST are defined in:

max@hostname ~: $ echo `kpsewhich texmf.cnf`

which should give as a result /etc/texmf/web2c/texmf.cnf.

Now, if the result of the following bash script is a message showing the word Yes or the word Nes (to execute a bash script: save it to a file named compare.sh, give it the proper permissions via chmod +x compare.sh and execute it via ./compare.sh):

if grep -q "TEXMFDIST = /usr/share/texmf" `kpsewhich texmf.cnf`; then
    if grep -q "TEXMFHOME = {~/texmf" `kpsewhich texmf.cnf`; then
        echo "Yes"
    else
        echo "Nes"
    fi
else 
    echo "No"
fi

then you could try to follow this procedure:

  1. Download the package subfloat from CTAN: Direc­tory macros/latex/contrib/subfloat (wget is needed)
  2. unpack the package subfloat.zip;
  3. Run the script subfloat.ins;
  4. Copy subfloat.sty to your LaTeX search path;
  5. Optionally, copy the documentation in the documentation directory;
  6. Update your LaTeX distribution.
max@hostname ~: $ wget mirrors.ctan.org/macros/latex/contrib/subfloat.zip # download link for subfloat, if you don't trust this, you can download it manually
max@hostname ~: $ unzip subfloat.zip
max@hostname ~: $ cd subfloat
max@hostname ~/subfloat: $ latex subfloat.ins
max@hostname ~/subfloat: $ sudo mkdir /usr/share/texmf/tex/latex/subfloat
max@hostname ~/subfloat: $ sudo mkdir -p /usr/share/texmf/doc/subfloat
max@hostname ~/subfloat: $ sudo cp subfloat.sty /usr/share/texmf/tex/latex/subfloat/
max@hostname ~/subfloat: $ sudo cp subfloat.pdf /usr/share/texmf/doc/subfloat
max@hostname ~/subfloat: $ sudo texhash # update your LaTeX distribution
Related Question