LyX: Installing unknown document classes

If you either received a LyX file that uses a document class unknown to your LyX installation or you would like to create a document using one of the options in the settings dialog, you need to install that document class.

This description is for Mac OS based on the latest version of MacTeX (as of May 28th 2012 this is MacTeX-2011), but should work with any version.

First, you should find out where the document class package should be put. In a previous version, I mentioned to put it in /usr/local/texlive//texmf-dist/tex/latex/ but this approach is not recommended, because it makes it only available for the current version. There are two better options that allow you to install a new version and keep all your custom packages: You can either make it available to all users or just your user.

Now that you know where to put it, follow these steps:

  1. Download the desired document class package.
  2. Put the folder with the downloaded document class package into the path retrieved above. You can use Finder to do that. In Finder go to Go > Go to Folder and type in the path. You need to authenticate yourself in order to do that.
  3. In Terminal execute the following command: sudo texhash
    You will be required to enter your password.
    In case texhash cannot be found you have to go to /usr/local/texlive//texmf-dist/bin/ and execute sudo ./texhash
    Note: You can make sure it worked by executing kpsewhich classname.cls which will give you the path to that package class.
  4. In LyX do Reconfigure (in the menu bar LyX > Reconfigure)
  5. Restart LyX and the document class should be available now

On Windows (using MikTeX) this should work quite easy using the MikTeX Package Manager.

Update 28.03.2013: Fixed path to LaTeX packages (Thanks, Mathias!)
Update 05.04.2013: Updated description with better location for custom document classes.

8 Comments

Mathias March 24, 2013 at 14:40

Thanks for guide! I just successfully followed the recipe. However, note with some versions of LaTeX, the relevant directory is /usr/local/texlive/2011/texmf-dist/tex/latex, not /usr/local/texlive/2011/texmf-dist/latex.

Matthias Schoettle (Post author) March 28, 2013 at 20:54

Thank you, Mathias! I just realized, that there is only one correct path, which is the one you mention. But I found out a better solution and will update the post.

kumar May 24, 2013 at 05:38 where can i fund this “/usr/local/texlive/2011/texmf-dist/tex/latex” path. Can you suggest me clear. Matthias Schoettle (Post author) May 25, 2013 at 11:32

You need to access it via the “Go to folder” in the “Go” menu in Finder. Or press Shift + Command + G. In the popup window you type in the path and hit enter.

Roberto June 16, 2014 at 19:08

Thanks for this awesome description! I just have a question: in the third step, I cannot execute the sudo texhash command because the bin file in /usr/local/texlive//texmf-dist/bin/ does not exit. What should I do?

Matthias Schoettle (Post author) June 18, 2014 at 14:56

Thanks, Roberto. So texhash was found? You have to wait until it returns/exits, which may take a while. So just let it run 🙂 Hope that helps.

Mohammadyar August 14, 2020 at 08:05

Hi, in windows I use MikTeX and I install package but when I click reconfigure in lyx and restart it, nothing happens and still I get unavailable for that package in the document settings! I would really appreciate If you could guide me through this.