share
TeX - LaTeXWhere do I place my own .sty or .cls files, to make them available to all my .tex files?
[+651] [13] Tomas Aschan
[2010-08-05 13:50:43]
[ packages installing document-classes texmf ]
[ https://tex.stackexchange.com/questions/1137/where-do-i-place-my-own-sty-or-cls-files-to-make-them-available-to-all-my-te ]

I know how to define a package or a class, but how do I make it available (to myself) at all times?

Say I have the package file commonstuff.sty (or myprettyclass.cls), that I want to be able to include in any .tex file I create on my computer. Where do I put it? Do I need to run some installer on it, or is it enough to keep it in a certain folder?

Note: I know I can just place it in the same folder as the .tex file, but that's not what I'm after here. I'm looking for a way to "install" the package centrally on my computer.

(3) Is there a way to place it in an arbitrary directory and point to it? (for portability) - IljaBek
(4) @troyaner: If you want portability of your documents, you could ship your own packages with the file - *tex will find them if they're in the same folder as the document. If you want to be able to actually install to a custom directory, you can just run mktexlsr and point to that directory, e.g. sudo mktexlsr /path/to/your/texmf. - Tomas Aschan
the first solution is the one I was asking for. In case of beamer environment \usetheme{ABC} tries to expand to beamerthemeABC.sty and does not accept paths. This is my usage case for pointing to a directory... not sure if it's a completely different case compared to the OP's, but other posts redirect here - IljaBek
@troyaner: Have you tried putting beamerthemeABC.sty in the same folder as your document? - Tomas Aschan
yes, it works, but in my mindset it's something that belongs into an ./include directory and not into root of your document - IljaBek
(1) @troyaner: An alternative approach would be to use some kind of build system in which you can specify a source directory and a build directory. That way, you could have your *.tex and *.sty files in different places, and let the build system handle the finding of them for you. - Tomas Aschan
I think it would be really neat if there were a macro or package that lets you add any folder next to your main .tex file to make the compiler look for files before looking in the main distribution's dirs. This way you could (e.g.) use older version of packages (for compat. testing) or use packages that you don't want to install in the entire system (e.g. beta versions) or use web-based LaTeX systems (e.g. ShareLaTeX), where you can't update the distribution yourself, but things get very cluttered if you 'just' put it in the root of your document tree. Does such thing exist and is it possible? - Erik
A few years later, This was introduced in TeX Live 2017 see $TEXMFAUXTREES - user170109
[+411] [2010-08-05 13:58:55] Stefan Kottwitz [ACCEPTED]

You could create a folder below your TeX home directory and put your .sty file therein. Use this command at the command prompt to find out where:

kpsewhich -var-value=TEXMFHOME

On my computer it shows

C:/Users/stefan/texmf

but it might also be ~/texmf/ on a Linux or Unix computer.

Following the TeX directory structure, you should place your file in a subdirectory like ~/texmf/tex/latex/commonstuff/, according to Arthur's comment below. This has the advantage that it is not necessary to update the package database as TeX searches your personal texmf tree directly. If there is an ls-R file in your home texmf tree you can safely delete it as TeX will not use it anyway. (Note: this assumes your personal tree is on a local file system: users with remotely-mounted home folders may still need to hash.)

Regarding MiKTeX, have a look at the section "Installing sty or cls files" in the answer to the question How can I manually install a package on MikTex (Windows) [1].

You can then verify what file will be used with:

kpsewhich filename.sty

This will show the path to the file picked up by the TeX implementation.

[1] https://tex.stackexchange.com/questions/2063/how-can-i-manually-install-a-package-on-miktex-windows

(52) If he puts his .sty file directly in ~/texmf it just won't work! He needs to respect the TDS structure. - Arthur Reutenauer
(16) On Linux, so long as you've put the file within the TEXMFHOME tree (in a suitable place) then you simply run texhash on that directory. For example, if TEXMFHOME points to /home/astacey/texmf then texhash /home/astacey/texmf will do, no need for sudo. - Andrew Stacey
(23) Just for completeness: The default location of the home TEXMF tree on Mac OS X is ~/Library/texmf. - Philipp
(1) @Philip: Not if you use TeX Live. For TeX Live it's always ~/texmf. - Arthur Reutenauer
(1) @Arthur Reutenauer, Philipp: I was sure that I'd needed to run mktexlsr only a day ago, but now I test it then I find that you're right. Though, in my defence, I was reacting to the sudo in the answer: that certainly shouldn't be there. - Andrew Stacey
@Andrew: Sure enough, I just wanted to be as precise as possible. For what it's worth, I just check in an installation of TeX Live 2007 I have, and there TEXMF was already defined as ...,$TEXMFHOME,... without the leading !! in texmf.cnf; thus you didn't need mktexlsr at that time. I seem to remember from a recent discussion on the TeX Live list that they changed the behaviour around that time. - Arthur Reutenauer
(6) @Arthur: No. I have TeX Live 2009 on OS X 10.5 and the default location is, as Philipp has said, ~/Library/texmf. - Konrad Rudolph
@Konrad: It must depend on how you install it. I have TeX Live 2009 installed through macports, and mine reports ~/texmf - KeithB
I'm running MikTeX on Windows 7, and I'm unable to localize the textmf catalogue anywhere... =( - Tomas Aschan
Perhaps the folder is hidden in the explorer. It could be like C:\Documents and Settings\<username>\Application Data\MiKTeX\2.8 or type at the command prompt: kpsewhich -var-value=TEXMFHOME. - Stefan Kottwitz
This should be a comment on @Stefan Kottwitz's answer but not enough repo: also consider the path: kpsewhich -var-value=TEXMFLOCAL which on ubuntu 13.04 is: /usr/local/share/texmf/ if you want to install a .sty for all users. As mentioned in that answer, you still need to keep the correct subdir structure here. - Ciro Santilli OurBigBook.com
Xubuntu Linux 14.04, TeX Live plain vanilla install. Put Homework.sty in ~/texmf/tex/latex/local/Homework/Homework.sty. Ran sudo texhash on ~/texmf. Result of kpsewhich Homework.sty is ~/texmf/tex/latex/local/Homework/Homework.sty. However, if I define a new command in this style file, it is not seen when I compile. What's wrong? - Adrian Keister
(1) There is no explanation for why you're telling people to delete the ls-R file. Please elaborate. What does it have to do with the question the OP is asking? Why is this recommended? What goes wrong if you don't delete it? Etc. - Sverre
Just for completeness: the reason for such a sub-directory organization is stated at "3.4.6 Integrating local and personal macros" in tug.org/texmf-dist/doc/texlive/texlive-en/… - Mr. Ree
If you installed TeX Live with Homebrew then you will find that you need to drop your *.cls at: '/usr/local/texlive/texmf-local/tex/latex'. - Entalpi
Hi there. I'm a bit confused about all this material. I'm currently trying to install by hand the ebgaramond package since the new version of ctan only is compatible with latest ubuntu version. As said here, the ebgaramond documentation says I have to extract files it to my textmf tree and run texhash. I did it but "kpsewhich ebgaramond.sty" does not find anything (while it exists in the directory). Did I missed something? thanks in advance for help. - Julien Faure
(1) I think the answer was very confusing, and I only got it to work after reading the excellent wikibook page on this topic: en.wikibooks.org/wiki/LaTeX/Installing_Extra_Packages - Christian Herenz
Is there any way to update the packages installed this way? I installed texlive-scheme-full with dnf but it didn't have tabularray but I'm thinking if there's a way to update those packages rather than manually - Eduardo Jiménez
@ChristianHerenz it's not that confusing and for me works very well. tlgmr throws me this warning instead *** WARNING ***: Performing this action will likely destroy the Fedora TeXLive install on your system. But it's because it conflicts with dnf install; it's all about your needs - Eduardo Jiménez
(1) legendary status for this btw. saved my day. - Michael K Madison
(1) So helpful. Thank you so much for sharing your knowledge. - satoru kurita
Not just safe to delete it. You should delete it else it will be used and you must keep it current. - cfr
1
[+241] [2010-08-05 18:43:35] Joseph Wright

All of the other answers cover things quite well, but I thought a slightly different version might be helpful.

You have to put it in the 'right' place and second you need to update the database TeX uses to find files. The place to put the file depends on your operating system. Assuming you have a standard installation, this will probably be:

  • Windows 10 (and miktex)
    C:\Users\<user name>\Appdata\Local\MikTex\<number>\tex\latex\local\
  • Windows Vista/7 C:\Users\<user name>\texmf\tex\latex\local\
  • Windows XP C:\Documents and Settings\<user name>\texmf\tex\latex\local\
  • Linux ~/texmf/tex/latex/local/
  • Mac OS X /Users/<user name>/Library/texmf/tex/latex/local/

Note: the local/ folder might not exist; in this case, go ahead and create it.

A few of notes on that. First, on Windows the 'Users' part of the location is language dependent. Second, I've represented your home/user folder as '<user name>': this will obviously be dependent on your system. The folder I've indicated may well not exist: you may just have the texmf part, bits within that or nothing at all. The file location is important, and although you could just put your file inside texmf/tex/latex is is usual to keep things organised by package. The local folder is reserved for stuff installed on individual machines.


(2) @Juan. Depends on your TeX installation. For recent TeX Live's that is true, but as I understand it older ones do need texhash running. - Joseph Wright
I don't think you've ever needed a database for TeX Live with TEXMFHOME. I've never needed it on Mac, starting around 2002. Admittedly, that was before TL was available for Mac, so gwtex etc. I've never seen the point of using ~/texmf/tex/latex/local/ rather than ~/texmf/tex/latex/<package name>. - cfr
@cfr If you have ii on a network share under some circumstances it is, or at least was, necessary. - Joseph Wright
Ah. Thank you for the explanation. Is/was that true on Linux, too? - cfr
@cfr I got the information from some Linux users on an older 'big' system, where their ~ directories were an NFS mount :) - Joseph Wright
There is no tex after *C:\Users\<user name>\Appdata\Local\MikTex\<number>*. Please see here - Maifee Ul Asad
(2) For me, the Windows 10 + miktex path is C:\Users\<user name>\AppData\Local\Programs\MiKTeX 2.9\tex\latex\ - iago
(2) Thanks for the answer, why does kpsewhich -var-value=TEXMFHOME not give the trailing tex/latex/local/ part? - zyy
@cfr Well perhaps it's partly my personality, but the idea is that one knows from the .log if you are likely dealing with a one-off file or simply a personal install of a standard package (e.g. when one needs to force a particular version of a standard package). The creation of a local dir is something I saw in I think TLC2, and have used ever since. - Joseph Wright
@cfr TLC2 = The LaTeX Companion, 2nd Ed. - Joseph Wright
@cfr Well most users don't use system-wide 'local' files or similar: my answer's aimed at the 'typical' user I encounter. I see you've added an answer targetting more experienced users :) - Joseph Wright
@cfr I was thinking of reading the tex/latex/<whatever> parts of the log :) - Joseph Wright
Sorry ,,........ - cfr
2
[+65] [2011-06-06 21:58:21] Display Name

As already mentioned by Arthur, .sty or .cls files must be in some subdirectory of tex\latex which can be in any directory of any drive.

See the following screenshot, it shows how the path to my packages and classes is.

enter image description here

I will explain two cases, registering to MikTeX and registering to TeX Live.

Registering to MikTeX

Open Settings (Admin), select Roots tab, and add my path E:\A\My LaTeX\MyLibrary.

Note that the trailing \tex\latex\misc must not be included !

enter image description here

Afterwards, select General tab and press Refresh FNDB button.

enter image description here

If you cant find MiKTeX Options (Admin) you may have a newer installation that instead uses MiKTex Console. For this version, simply go to the Packages tab and click the database icon.

Registering to TeX Live

See How to register my own packages or classes in a separate drive to TeX Live installation? [1]

[1] https://tex.stackexchange.com/q/20160/2099

(3) I would like to inform that in the versions of MikTeX that includes the "MikTeX Console" (after 2018-02-26) the refresh has been replaced to Menu Tasks -> Refresh file name database. - FHZ
3
[+50] [2010-08-05 14:09:55] Arthur Reutenauer

The .sty files need to be put it some subdirectory of tex/latex in a texmf tree. Those trees have a rather fixed structure, but their location may vary according to your OS and TeX distribution. If you use Unix (including Mac OS) and TeX Live, there's by default a hierarchy

/usr/local/texlive/2009/texmf
/usr/local/texlive/2009/texmf-dist
/usr/local/texlive/texmf-local

as well as other directories. You want to put it in the texmf-local directory, not in the other directories that are managed by the TeX Live installer; when you upgrade TeX Live, your package may be overwritten. The texmf-local hierarchy, as the names hints, is for local packages managed by you; it won't be touched by updates (which is also why it's directly under the texlive directory, and not texlive/2009, for instance).

You may also choose to create a directory called texmf in your home directory, and the package will be visible only to you, not the other users on your computer.

On Windows with MiKTeX, I believe the directory for local installs is C:\Localtexmf by default.

In any case and whatever your distribution, you have to place the .sty file inside .../texmf-local/tex/latex and not directly in the root directory; it's just won't work otherwise.

Then, if you've installed the package in your home directory, you have nothing to do. If you've put in texmf-local, on the other hand, you need to run the utility mktexlsr (or texhash, it's an alias).


(7) I second Arthur's recommendation to use /usr/local/texlive/texmf-local/tex/latex/, if on a Unix system. - András Salamon
(1) For me it was /usr/share/texmf/ on ubuntu 20.04 - Exceptional NullPointer
Last two paragraphs worked perfectly on Windows 10. - Mew
4
[+50] [2010-08-05 14:10:25] Neil Olver

On Linux, you can pick any directory you like, and then add a line like

export TEXINPUTS=".:~/latex:"

to your .bashrc file (you can add multiple directories, separated by colons. I think you do need the '.' in the beginning). There may be something similar in Windows. I find this easier, since it separates "my" stuff from the texmf tree. Probably not great if you're writing a big package, but handy for some small things you just want to share between all your projects.


(6) @Neil: No, you don't need the dot in the variable, it's there by default. You do need the trailing colon, though, or the system directories won't be searched at all. - Arthur Reutenauer
(7) This is not the best solution. There is already a standard user-specific TEXMF tree (~/texmf on Linux), see Stefan Kottwitz's answer. - Philipp
(12) @Philipp: On my Mac OS X system, the user-specific TEXMF tree is inside ~/Library, which contains random applications' preferences, and other stuff that I haven't put there. It doesn't feel like "my" directory, and I won't remember to look there when I'm (say) copying my preferences to another computer. I really do prefer having my own .sty files in a directory I remember and regularly backup, and using TEXINPUTS. So I will repeat my opinion from the comment I hastily deleted: this is the best solution as far as I can see. - ShreevatsaR
(2) Note that the question is about a .sty file with common preamble stuff and definitions you wrote yourself (and will frequently edit as you think of new useful definitions and macros, presumably), not a package you downloaded and were trying to install on the system. For the latter, I agree it's better to place in the texmf tree and forget about it. - ShreevatsaR
Library resides in your home directory and is not hidden (doesn't start with a dot), so its a perfectly valid place to put user-created files. Plus, on OS X, environment changes in the shell initialization files aren't read by graphical applications. - Philipp
(12) @Philipp: If you have a good memory or use only one computer, I'm sure ~/Library is fine. But I for instance have all my config files (bash, emacs, etc.) and some other stuff in one directory that I keep synced between several computers running Mac OS X, Linux, and Solaris. Obviously, having to update files at several different paths separately on the different computers each time is impractical—and as I said, when I reinstall OS or copy preferences, I'm very likely to forget ~/Library. Nothing I've seen here convinces me this answer is not the best solution… but whatever works for you. :-) - ShreevatsaR
(1) @neil-olver thanks for that advice. I want to use a theme that I'm distributing with a software package. I don't want to require users to copy it to ~/texmf to use it. Setting an environment variable is exactly what I need. - qris
(9) +1 on this answer for project-specific sty directories export TEXINPUTS=".:./sty:. So, in /home/me/my_thesis folder, it will search for custom stys in /home/me/my_thesis/sty. (Put that TEXINPUTS binding just inside your per-project makefile). - Rudy Matela
(3) @Philipp, while Library does not start with a dot, it is partly hidden on MacOS since you need to press the option key to find it under the 'Go' menu, and doesn't show at all in the Finder. I agree that putting personal things in the Library does not feel right. - PatrickT
Wish I could upvote this one more. - esmit
5
[+16] [2013-11-08 09:07:25] user39700

Using texlive on Ubuntu, the *.sty files are located at

/usr/share/texmf-texlive/tex/latex/

or

/usr/share/texmf-dist/tex/latex/

Adding a new style foo.sty usually means

  1. create folder foo

    sudo mkdir /usr/share/texmf-texlive/tex/latex/foo

  2. copy the file foo.sty there

    sudo cp foo.sty /usr/share/texmf-texlive/tex/latex/foo/

  3. run texhash

    sudo texhash

Works for me with texlive 2009-15 on Xubuntu 12.04LTS


(6) Note that Stefan's answer (the one with the most upvotes) describes a much easier way to do this on Linux. For LaTeX: create a folder structure that mimics your TeX-tree: mkdir -p ~/texmf/tex/latex/foo; and for bibtex: mkdir -p ~/texmf/bib/{bib,bst}. Put foo.sty in foo, and put custom bst files in bst. Note that this is not a 'system-wide' location, but one personal to you; but it is easier to deal with (no su needed), and doesn't need texhash because it is always searched automatically. - jon
(6) Note that user39700's answer is wrong even for system wide installation. The files should be installing into the local tree, not the system one managed by the package manager. That is not to say it will not work. It will. But it is not the way it should be done for a Linux distro. - cfr
(2) Note that for bibtex, you need to have the following: mkdir -p ~/texmf/bibtex/{bib,bst} and NOT mkdir -p ~/texmf/bib/{bib,bst} as mentioned by jon. - aatishk
Using Ubuntu 20.04 I had to sudo mkdir /usr/share/texmf/tex/latex/foo/ and the rest was the same (with the said directory, obviously) - Yair Daon
6
[+12] [2013-04-30 20:21:36] Sverre

The other answers provided to this question all suggest to put your .sty files in the folder /texmf/ in your user profile folder (although there doesn't seem to be any agreement on what exactly you need to do after that).

This will, however, not work if you (like me) are using a portable LaTeX program, because then there won't be any such /texmf/ folder on your computer.

An alternative solution is therefore to put your .sty files (e.g. foo.sty) in any folder you'd like (e.g. C:/foo/), and then simply specify the path where you keep your .sty file when you load it in the preamble:

\usepackage{C:/foo/foo}

To avoid errors or warning messages, be sure to give the path also in your .sty file:

\ProvidesPackage{C:/foo/foo}

To maintain full portability of your LaTeX program, you can put your .sty files in a LaTeX subfolder, e.g. C:/texlive/foo/.

This way you can keep all your .sty files in one single place on your computer, and include the same path with \usepackage in all your .tex documents.


(3) But this is not at all portable. Already another Windows user can have put the individual package in another folder, other operating systems do not even know paths starting with C:. - Speravir
But the OP didn't ask for a portable solution. He wanted to know where he could put the file on his own computer so that it is available to himself whenever he's using that computer. (I'm aware that C: is a Windows thing, I didn't mean it that literally when asking if "this" would work on MacOS and Linux - I only meant specifying a path in \usepackage). - Sverre
(2) The way you apparently understand and answer the question it had to be closed as “too localized”. Happily other users answered for general use. This said if you would add some strong warning in your answer it would be a lot better. - Speravir
I think it would be "too localized" only under the assumption that the OP's computer operates in a unique fashion, which I think is fair to assume is not the case. I don't see why it's necessary to add a strong warning to my answer that the suggested solution is not portable, since the OP explicitly asks for a non-portable solution: "I'm looking for a way to "install" the package centrally on my computer". But we're repeating ourselves here now, so I'll end this discussion here. - Sverre
(9) The argument to \usepackage is a pagckage name not a file path. If the packages that you include this way have a\ProvidesPackage line (as packages should have) then the use described here will produce a warning that the name used is incorrect. Unfortunately (due to compatibility with LaTeX2.09) ProvidesPackage is not mandatory and supplying a path does not give an error or warning in that case, however that is a lack of error checking by the system, it does not mean that this is supported syntax. - David Carlisle
@DavidCarlisle: I load my packages with a path in \usepackage, and my packages have a line \ProvidesPackage. I get no error or warning messages, and everything works the way it should. - Sverre
@Sverre you should get a warning like : LaTeX Warning: You have requested package /c/tmp/longtable', but the package provides longtable'. - David Carlisle
(1) @DavidCarlisle: I don't :) Probably because I also specify the path as the name of the package in \ProvidesPackage? - Sverre
(4) @Sverre oh yes exactly, but that means your package can not be installed in any other location, which makes it a rather odd package. the name in the ProvidesPackage and the name in the usepackage should be the same. any relationship to any path on the file system is an accident of the implementation. - David Carlisle
(1) @DavidCarlisle: True, but why would I want to move my packages around on my computer? The standard procedure of keeping your custom .sty files in the same folder as your .tex file always bugged me, so it's precisely to avoid moving them around that I put a path in \usepackage, so that I can keep them in the same folder all the time. - Sverre
(3) the standard way to do that is to put your local files in ~/texmf so they are in the standard search path or any other directory of your choice so long as you add it to the TEXINPUTS path. - David Carlisle
(1) Sure, that's what the other answers here suggest (but notice that there seems to be a dozen opinions on what exactly to do after you've put your packages files in ~/texmf). I merely suggested an alternative solution that doesn't require you to add, remove, or change anything in your TeX program files. - Sverre
@Speravir: Actually, the solution you presumably(?) suggest will only work if your LaTeX program is not portable. I believe needing to put files in your user profile folder centrally on your computer is by definition not portable. My LaTeX is fully portable, so I need an alternative solution. I've updated my answer accordingly. - Sverre
I did not suggest anything until now. But let me say, you can believe me, that you are wrong: I used both MiKTeX and TeX Live in their portable versions, and everything works fine. The only thing you must do is updating the fontname database, if you’ve installed or removed a package. - Speravir
(1) That's great to hear. Could you please add an answer to the OP where you explain your procedure for portable LaTeX versions - since none of the other answers here mention the "fontname database"? I really do not have any folder of the type C:\Users\<user name>\texmf\ mentioned by others here, and I believed this was the result of using portable LaTeX. You might be right that I am wrong about that, so I would love to see how I should do it. - Sverre
7
[+12] [2013-08-09 02:21:23] user34845

I've just found this in the MiKTeX documentation [1]. Just FYI:

6.2. Which is the best directory to keep .sty files where MiKTeX can find them? MiKTeX Package Manager takes care of the proper installation of well known LaTeX packages.

If (for some reason) you have to install a package by hand, then you should copy the input files into the directory tex\latex\misc relative to a registered root directory. For example:

Create the root directory C:\Local TeX Files.

Create the sub-directory tex\latex\misc and copy your input files (*.sty, *.cls) here.

Register the root directory (C:\Local TeX Files) in MiKTeX Options.

For more information, read the section Integrating Local Additions in the MiKTeX manual.

[1] http://mirrors.ctan.org/systems/win32/miktex/doc/2.9/miktex.pdf

(2) Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format - texenthusiast
8
[+8] [2011-01-26 08:28:04] Dror

For me, using MAC OS X with standard MacTeX, the above answer were only partially helpful. I couldn't find the directory ~/Library/texmf.

I did the following. Assume that you want to add mystyle.sty to your TeX. Create the directory ~/Library/texmf/tex/latex and place mystyle.sty in it. Afterwards invoke texhash ~/Library/texmf/.

This worked for me.


(3) You don't need to run texhash for files added in ~/Library/texmf, they will be automatically found. - Juan A. Navarro
(1) @Juan: will they be found without any action from my side? - Dror
(1) yes, see the comments on the accepted answer about TeX Live (which is what MacTeX installs). - Juan A. Navarro
(2) Your suggestions were not working until I changed my class name from something-else.cls to somethingelse.cls. Apparently the hyphen was causing a problem. No such problem with my style file with or without a hyphen... Having fixed the name, your suggestions work. - PatrickT
9
[+7] [2014-05-01 20:31:42] Peeter Joot

To avoid tex distribution or operating system specific requirements on where to put stuff and what to run to get it to be found I use a GNUmakefile rule of the following form:

%.sty : ../%.sty
  cp $^ $@

Each subdirectory for which I build latex code references this rule, resulting in the .sty file to be copied locally to that directory before pdflatex is invoked (using suitable dependency rules). See for example, notes/make.rules and notes/phy452/GNUmakefile in my physicsplay github repo [1].

This works well for me on Linux (ubuntu + TexLive) and Windows (cygwin + MikTex).

[1] https://github.com/peeterjoot/physicsplay/tree/master/

(1) And what if I compile TeX files all around my disk space, and not in any nicely organized structure? Like: papers in Dropbox, talks here, Copy-editor job there, etc. Am I supposed to create a makefile for all my >100 projects a year? - yo'
(1) Would you really be using personal .sty files in so many ad-hoc locations? Even so, there isn't anything that would prevent such a method from being used even from many locations (since the makefiles in each location can be trivial, including just an include of the make rules). - Peeter Joot
(2) For one, I use my own beamer style, and the class of the journal I work for. That already makes the process way to complicated. Especially since TEXINPUTS, ~/texmf and texmf-local exist... - yo'
10
[+7] [2014-11-26 13:11:26] ClementWalter

I am using a quick fix to this issue since I work mainly on a USB stick and don't want to touch to the tex folders the computers I am using.

Indeed, you can specify backward directories to \usepackage, then you don't have to know the exact full path but only the relative path from your .tex to your .sty file.

An example: given a portable hard disk D, I have in D:/latex/files/ my .tex files and in D:/latex/packages/ some packages I want to use, then you can write \usepackage{../packages/mypack.sty}

Not sure if this works on windows however


(3) Hi and welcome, i did some additional code markup. You can have a look at our starter guide to familiarize yourself further with our format. - Johannes_B
(1) This (using ../) will most likely not work because of security restrictions. And it's much better to move these files in a separate texmf tree. - Martin Schröder
(2) Welcome to TeX.SX! Sure, this approach works to some extent, but I don't see any addition with respect to Sverre's answer. - Claudio Fiandrino
(1) @ClaudioFiandrino the main point was that you don't need the full path, meaning you can copy and paste your folder everywhere and it still works - ClementWalter
(1) How do you handle .cls files? - PatrickT
11
[+4] [2021-05-14 18:01:28] John Bentley

For Windows (10) users on Miktex (Console 4.2):

  1. Open Miktex Console (4.2) > Settings > Directories and observe the informational links FAQ: Which is the best directory to keep my .sty files? [1] and KB: TEXMF root directories [2]. We'll follow the advice in those links.

     MikTex (Console 4.2) > Settings > Directories

  2. Anywhere you like: create a TEXMF root directory, with a structure suitable for your custom latex packages (.sty files). Add your package. E.g. C:\Users\John\Documents\Sda\Code\WritingReadingTech\Markup\Latex\Libraries\texmf\tex\latex\MyPackage\MyPackage.sty

  3. Miktex Console (4.2) > Settings > Directories > [+]. Select the TEXMF root directory. E.g. C:\Users\John\Documents\Sda\Code\WritingReadingTech\Markup\Latex\Libraries\texmf. Click [Select Folder]. Observe this folder as in the picture above with "Purposes: Generic", "Attributes: User"

  4. In your latex (.tex) source files, existing anywhere on your computer, add a reference to your custom package with \usepackage{MyPackage}. Build/compile your latex source file. Everything should be as desired.

I found it unnecessary to run Miktex Console (4.2) > Tasks > Refresh File Name Database.

[1] https://miktex.org/faq/local-additions
[2] https://miktex.org/kb/texmf-roots

12
[+1] [2019-12-22 21:35:23] Lance Pollard

This worked for me (Makefile):

KEY := myrepo
TEX := $(shell kpsewhich -var-value=TEXMFHOME)
PWD := $(shell pwd)

link:
  ln -s "$(PWD)" "$(TEX)/$(KEY)"
.PHONY: link

Then:

make link

13