I just downloaded the elsarticle document class. In the unzipped directory, there are .bst files, .tex files, a .sty file, a .pdf file, and a very unhelpful README.

Where should I put these files in order to use them system-wide in my documents?

In reading a very similar post, I've realized that which version of LaTeX I'm using (one of which is apparently MiKTeX) is relevant here. How do I figure out what I'm using? I create LaTeX documents in Emacs, and use C-c c to generate PDFs from my .tex files.

In reading an answer to another similar post, I see that I should put my files in the directory returned by

kpsewhich -var-value=TEXMFHOME

For me, this returns


a directory which does not exist on my computer. What's the deal?

  • This applies for personal files in the very same way as it does for downloaded files: tex.stackexchange.com/questions/1137/… However, wasn't elsarticle part of the distros? – yo' Aug 19 '15 at 22:40
  • i don't have elsarticle already in my distro. – dbliss Aug 19 '15 at 22:41
  • It is indeed part of MiKTeX. Us e MPM for ths distribution. – Bernard Aug 19 '15 at 22:44
  • It is also part of TeX Live. @dbliss How did you install TeX on your system? Emacs is just the editor: it doesn't tell us what distribution of TeX you are using. What OS are you on? If you are using a Mac or GNU/Linux, you are almost certainly using some form of TeX Live. If on Windows, probably either MikTeX or TeX Live. – cfr Aug 19 '15 at 22:49
  • 1
    @dbliss A GNU/Linux system rules out MikTeX. That basically means TeX Live. But it leaves open the question of whether you are using your Linux distro's packages or an upstream installation. But I think we've figured that out in comments further down, right? – cfr Aug 19 '15 at 23:23

Best option: Recommended

Your first option should be to install the package which is part of TeX Live itself. If you installed TeX Live from upstream (recommended), you should already have it if you installed a full distribution. If not, you can use tlmgr to install it.

If you installed TeX Live through your distro's package manager (e.g. apt or yum or pacman or...), then you have to find out which package your distro's packagers put elsarticle in. Install that.

If none of that is an option or if, for some reason, your distro packages only part of TeX Live, you can install the package manually.

Manual option

For a manual install, choose one of two places:

  • your local TEXMF tree, TEXMFLOCAL: this will make them available system-wide;
  • your personal TEXMF tree, TEXMFHOME: they will be available only to you.

To find out where these trees are, use

kpsewhich -var TEXMFLOCAL


kpsewhich -var TEXMFHOME

The easiest option is to put the files in your personal tree, TEXMFHOME.

You will need to create a suitable structure. For example:

mkdir -p $(kpsewhich TEXMFHOME)/tex/latex/elsarticle
mkdir -p $(kpsewhich TEXMFHOME)/bibtex/bst/elsarticle
mkdir -p $(kpsewhich TEXMFHOME)/doc/latex/elsarticle

Now unpack the archive you downloaded from CTAN and move all the .bst files into $(kpsewhich TEXMFHOME)/bibtex/bst/elsarticle, the .cls into $(kpsewhich TEXMFHOME)/tex/latex/elsarticle and the documentation into $(kpsewhich TEXMFHOME)/doc/latex/elsarticle.

Then you are done. It is perfectly normal for TEXMFHOME not to exist if you've never used it before.

If you prefer to install into your local TEXMF tree, replace TEXMFHOME with TEXMFLOCAL, run the commands above with root privileges, if necessary, and then run

mktexlsr $(kpsewhich TEXMFLOCAL)

No equivalent step is required if you use your personal TEXMF tree, which is why that is a lot easier.

  • nice answer. but i'm still wondering what i need to do to figure out what i'm using now. is there not an easy way to tell which distro i'm using, and then which version of it i'm using? i can't remember what i installed or how, but i'm sure i used a standard means, like apt-get or tlmgr. – dbliss Aug 19 '15 at 23:12
  • @dbliss Can you use apt to test whether apt knows about a file? For example, on my distro, I could say pacman -Qo $(which latex) and pacman will tell me which package latex belongs to or if it doesn't belong to a known package at all. I can't tell you what the exact command for apt is, though, as I have not used a Debian-based system for a few years. – cfr Aug 19 '15 at 23:16
  • @dbliss Failing that, it is impossible to know for certain. However, if which latex gives you something like /usr/bin/latex, you probably used apt. The fact that you do not have /usr/local/texlive makes it extremely likely that you used apt as that is the standard installation directory for TeX Live, if you use upstream's installer. – cfr Aug 19 '15 at 23:18
  • indeed, which latex returns /usr/bin/latex. so it sounds like i should use apt to uninstall whatever it is i have, and then follow your instructions to re-install. hopefully emacs knows how to interface with the new installation. – dbliss Aug 19 '15 at 23:19
  • @dbliss So try to figure out if elsarticle is included in a package provided by your distro. If so, install that using apt. That is the best option because it is guaranteed to match the rest of your installation and will get updated, if appropriate, automatically when you update your system. If not, use the manual installation option from my answer. At some point, you might want to consider switching to upstream's TeX Live as it makes life simpler. But only do that when you have the time to sort out any problems that may occur. (Search for vanilla to find extensive instructions.) – cfr Aug 19 '15 at 23:22

Each distribution should have a local texmf directory. Within that, use the TeX Directory Structure:

  • .cls files go in tex/latex/elsarticle
  • .bst files go in bibtex/bst/elsarticle
  • the README and .pdf go in doc/elsarticle

Templates aren't a special kind of file; they are just sample documents to fill in. Some TeX IDE's have a place to put them. For instance in TeXShop they can be put in /Library/TeXShop/Templates. The TDS specifications suggest they can go in /doc/elsarticle.

  • @MatthewLeingang thanks. i'm going to hold off on following this advice, however, because the comments above make me think i should already have elsarticle on my system. do you have any thoughts on the comments under my OP? – dbliss Aug 19 '15 at 22:56
  • @cfr: What I meant was, each TeX distribution has a local system-wide texmf. Isn't that true? For instance, with texlive it's /usr/local/texlive/texmf-local/. – Matthew Leingang Aug 19 '15 at 23:04
  • for what it's worth, i do not have the directory /usr/local/texlive/. – dbliss Aug 19 '15 at 23:10
  • 1
    What you meant is right, but what you said wasn't ;). Now you've said what you meant, I've deleted my comment. – cfr Aug 19 '15 at 23:10
  • @dbliss That's because you probably used your distro's TL packages. The answer I've given should work regardless of the actually directories your distro's packagers have decided to use. However, as I explain there, the best option is to install the TeX Live package rather than manually installing it yourself from CTAN. – cfr Aug 19 '15 at 23:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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