9

I'm on Ubuntu 12.04 (not sure if it makes a difference) and I'm trying to change $TEXMFHOME to a custom directory. Currently it is $HOME/texmf, which I believe is the default, but even when I put .sty files in there the compilation of the .tex file cannot find it. And more so, when I change the directory of $TEXMFHOME to something else and move the .sty file there, it still can' find it. However, if I put the .sty file in the same directory as the .tex file it works perfectly (not what I want though). I am changing $TEXMFHOME in /etc/texmf/texmf.d/05TeXMF.cnf and using sudo update-texmf to generate the texmf.cnf file. Is this the correct way? What am I doing wrong?

If it's helpful, I am using emacs with auctex as my editor.

I have found other threads on here and other sites that are very similar, but none of the solutions for those worked for me.

Tyler
  • 2,541
nick
  • 123
  • 1
  • 8
  • 3
    (For the default personal tex tree.) You need to make you texmf home mimic the directory structure of your base install. For LaTeX stuff, you want to do mkdir -p ~/texmf/tex/latex/ and put your personal .sty files there. If, say, you want to put a biblatex.cfg file in your personal tree, then mkdir -p ~/texmf/tex/latex/biblatex/ and put the file there. Another good one: mkdir -p ~/texmf/bibtex/bib and put your .bib fiel there. – jon Sep 12 '12 at 13:28

2 Answers2

9

Why change it at all? I think what you're missing is that you should make your personal texmf-tree mimic that of the installed version. This is easily remedied.

In a terminal:

mkdir -p ~/texmf/{doc,tex}/{context,eplain,generic,latex,lualatex,plain,xelatex,xetex} # for example
mkdir -p ~/texmf/bibtex/bib # put your bib file in here

(You should / will need to make the appropriate sub-directories for bibtex and doc if you want to put things in there.)

Now you can test whether things are found:

touch ~/texmf/tex/latex/myfakefile.sty
kpsewhere myfakefile.sty

The last command should return:

/home/<user>/texmf/tex/latex/myfakefile.sty

Note also that the command

kpsewhich --var-value TEXMF

should return a list of places that will be searched in the order (I believe) they are searched. Your personal tree is probably listed first, which means that in a race between, e.g., the 'system' myfakefile.sty and your 'personal' myfakefile.sty, the personal one will win.

Finally, I should point out that your attempts at modifying texmf.cnf may have made this answer not work (I'm not sure what you did). I would revert your changes to the default set-up as it will be easier to maintain.

jon
  • 22,325
  • sweet, this worked. I have some questions though so I understand what this is doing....

    I looked up the -p option for mkdir, but I didn't quite understand what that option did.

    How did you know that ~/texmf/tex/latex is a directory that is seen when compiling latex? Is there a book on this sort of stuff for latex?

    Last question. There is a Ls-R file in '~/texmf/' What is that for?

    – nick Sep 13 '12 at 14:03
  • I'm glad to hear it. The -p switch allows you to make a subdirectory (or several) along with the parent one; otherwise mkdir will complain: 'No such file or directory'. Checking where *tex (et al.) will look can be done with kpsewhich --var-value <thing to check>; try checking for BIBINPUTS (which is good to know about for bibtex/biber. Try texdoc kpathsea for more information, but I suspect it'll be pretty overwhelming at first. (But it is good to know about texdoc as a means for looking up TeX-related manuals.) – jon Sep 13 '12 at 15:41
  • when I try "texdoc kpathsea" I get the following error "sh: 1: gnome-open: not found" – nick Sep 13 '12 at 20:31
  • @user18641 -- Really? If which gnome-open returns no result (I get /usr/bin/gnome-open), then there is something wrong with your system (not TeX Live related), which you should fix. In the meantime, you can do locate kpathsea.pdf to find the location of the document and then open in manually; or do (say): evince \locate kpathsea.pdf``. – jon Sep 13 '12 at 22:00
  • It returns no result. I'm afraid to ask what that means... – nick Sep 14 '12 at 02:51
  • See here; not sure what is going on with 12.04.... – jon Sep 14 '12 at 14:28
  • @jon sorry for the necro, but what should I do if I want to add 2 directory to the TEXMFHOME? The situation is that I have my master bib file on my Dropbox folder (in a properly structure mytexmf folder) that I share across computer, so I want texlive to search in there also. – Heisenberg Nov 10 '13 at 02:56
  • @Anh -- I'd symlink it with ln -s. – jon Nov 10 '13 at 03:33
  • @jon Can I not have 2 separate folders and add them both to the search path? I want to keep the default stuff in Home folder, only personal bib and sty file in the Dropbox folder. – Heisenberg Nov 10 '13 at 04:03
  • @Anh -- I suppose so; but you need to modify your local version of texmf.cnf (which changes every year) according to the model of the texmf.cnf found in the web2c folder. All of this is a lot more work, and error-prone, than simply adding two symlinks (the sizes of which will be so small as to be irrelevant to the overall TeX Live install). – jon Nov 10 '13 at 04:29
  • @jon I found a solution like you said. I modified TEXMFHOME in texmf.cnf. Apparently the syntax is onepath:anotherpath. I did not know that I had to use the colon. – Heisenberg Nov 10 '13 at 04:32
  • @Anh -- Yes, you should read the comments in /usr/local/texlive/2013/texmf-dist/web2c/texmf.cnf (assuming your install year is 2013). – jon Nov 10 '13 at 04:37
3

Assuming your shell is bash try to set the environment variable using export? In particular invoke export TEXMFHOME=/path/to/your/custom/location and then restart the shell.

If this works, you can add this export command to the .bashrc file and then you'll have it correct when ever you start your terminal.

Dror
  • 22,613