5

I am new to TeX and I want to add a .sty file. But when I tried all the ways described on this site. I could not do it, as it requires the permission of the folder to add the .sty file.I am a Linux user.

Update 1: I have tried: copying the .sty file in /usr/local/share/texmf but I did not find any file here. Again I have tried copying here: /usr/share/texmf/tex/latex but did not get any permission.

Again I have tried with the /home/username and I was shocked that I did not saw any folder texmf .

After these I have also tried the ways as advised in the comment section as well as the answer. But did not work.

Any further help will be appreciated.

5
  • 3
    If the *.sty file is in a path known to TeXLive, than \usepackage{*} would do. If that is not the case, copy the *.sty file into the directory your *.tex file is located and then use \usepackage{*}.
    – Skillmon
    Commented Dec 12, 2017 at 10:13
  • Sorry it is not working Commented Dec 12, 2017 at 10:39
  • 1
    If you do not have the permissions to write on the TeX file's folder you are lost. If you have them copy the sty file to that folder. If you want to install it for all documents look at the other posts about texmf-local and if you want to install it for all users and documents you are equally lost without permissions.
    – TeXnician
    Commented Dec 12, 2017 at 10:47
  • Please give me a detailed answer. I have tried the way as explained by @Skillmon but did not work. I would appreciate if anyone give me a detailed answer. Commented Dec 12, 2017 at 11:16
  • 1
    I guess that some people are confused because it is not clear how to interpret your question. Do you want to (i) include a standard style file to your document or (ii) add a .sty file to the system such that it can be used in your TeX documents? Your statement on the permissions suggests that it is the second possibility, but the fact that you tried @Skillmon's suggestion hints at the first. It would be great if you could rewrite your question such that it is clear what you mean, and specify what you tried.
    – user121799
    Commented Dec 12, 2017 at 12:24

2 Answers 2

9

If I understand correctly, you don't have the permissions to add the .sty file to your home TeX directory. If you can't do that, you can always put it in any other folder you have access to.

For example, if your .sty file is named file.sty, you can copy it to the same folder as the .tex file and write in the preamble:

\usepackage{file}

In general, if you don't want to or can't copy the .sty file to the .tex folder, you can write the relative path to where it is saved, like this:

\usepackage{../folder1/folder2/file}

The problem with this approach is that you will have to either copy the .sty file every time you use it or write the relative path to it.

5
  • 1
    The problem with the option "can't copy the .sty file to the .tex folder" is, that in general means he doesn't have write permission on that folder, in which case he can't use LaTeX in the first place, because he doesn't have permission to write the output nor .aux files.
    – Skillmon
    Commented Dec 12, 2017 at 16:32
  • What is the solution to it? Commented Dec 12, 2017 at 18:44
  • @ChandramauliChakraborty to not having write permission? Ask your sys-admin to grant them. If that's not an option but you have read permissions on the directory copy the files to a directory you have write privileges to and work in that folder.
    – Skillmon
    Commented Dec 12, 2017 at 19:03
  • How to do it? Elaborate it. Commented Dec 12, 2017 at 19:06
  • @ChandramauliChakraborty If the problem is write permission, there is NO "how to do it." It cannot be done, unless you are the system adminstrator. If you are, then changing permission is a system command, not a TeX command. If you are not, one possibility is to locate whoever is the system administrator, and ask for the change. You may or may not get it. BETTER: Does the computer have a USB port? Obtain your own USB stick, and put your files there, because you will have the necessary permission.
    – user139954
    Commented Dec 12, 2017 at 20:20
1

Add the .sty file in the folder where you have your .tex file (the source code). Then, in the preamble add

\usepackage{file}

For example, I wanted to add multicols.sty file. After having googled for multicols.sty and downloaded it, I pasted it in the folder containing my tex code. Then, in the preamble, I added

\usepackage{multicols}

Note: 'multicols' in 'usepackage' is written without the extension '.sty'.

1
  • It would probably be a better idea to install the package properly using a package manager.
    – Johannes_B
    Commented Aug 21, 2018 at 4:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .