I created a new class file to use.

I have put the .cls file in the same directory as the original cls files (report, book etc) and im 100% sure the names match.

The directory for me is:

C:\Program Files\MiKTeX 2.8\tex\latex\base

But still, when compiling it says:

! LaTeX Error: File `myclass.cls' not found.

What am i doing wrong here? (sorry for being such a noob)

In my texteditor i use:


This is a duplicate of the following questions:

The basic answer is you should never put your own packages or classes in the main directories of your TeX distribution. You should always put them into a local directory. Consult the accepted answers to these questions for more details of how to do this.

| improve this answer | |

Every own created package and class should go into a local tree, which is supported by all TeX distributions. For MiKTeX read the MiKTeX documentation, section "Register a user-managed TEXMF directory". It shows how a local tree can be created, if not already present.

| improve this answer | |
  • 1
    In Miktex, we can easily register our own packages/classes that are saved in any sub directory of tex\latex (no matter where we put the tex\latex directory) to the LaTeX system as explained in your link above. How to do the same thing in TeX Live? – xport Jun 7 '11 at 8:13
  • I recommend to put your class file into a dedicated directory.

  • After copying the class into your texmf directory structure, refresh TeX's file name database. In MiKTeX, open MiKTeX Options/ Settings and click the button "Refresh FNDB", or run mktexlsr (or texhash in some distributions) at the command prompt.

| improve this answer | |
  • I put it in the directory with the other classes. What u mean with a dedicated directory? I did refresh the database but didnt help. – Toroo Feb 7 '11 at 18:57
  • @Toroo: I mean: don't mix your own files with distribution files. What if you update to MiKTeX 2.9 but your class remains in C:\Program Files\MiKTeX 2.8\tex\latex\base? – Stefan Kottwitz Feb 7 '11 at 19:03

A quick fix is to just put the .cls file next to the .tex file you're compiling (ie. in the same directory).

Perhaps this is not a permanent enough solution for you (eg. if you're going to use this class file in many documents), but this is how I use IEEE's & OSA's journal class files (where once every few years at most I need to use a particular class file). This has the added benefit of your LaTeX document's directory being self-contained - it should compile on any other LaTeX system without needing any additional installation - important for submitting a journal paper - not sure about your case.

| improve this answer | |
  • Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. – Paul Gessler Aug 19 '14 at 18:29
  • Thank you for the help. For complete newbies like me, here is a short tutorial on what is a class file and how to actually use one. – Vorac Nov 19 '15 at 17:15

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.