How do I add a custom .sty file to MiKTeX Portable?

Adding it to .\tex\latex\misc and then refreshing the database doesn't work -- Xetex still avoids searching for the file altogether, outside of the current .tex file directory.

  • Put the .sty file in the same directory as your .tex document. XeTeX (or LaTeX) searches in the current directory, but does not go into subdirectories. – LianTze Lim Mar 22 '12 at 7:34
  • @LianTzeLim: I don't want to do that for every single document I use the file in. It needs to become part of MiKTeX Portable itself. – user541686 Mar 22 '12 at 7:42
  • You are not giving enough precise informations. It is unclear in which tree (if any) .\tex\latex\misc is and how exactly you refreshed the database. – Ulrike Fischer Mar 22 '12 at 7:44
  • 1
    @UlrikeFischer: I'm at the root MiKTeX Portable directory, so the folder is <miktex-root>\tex\latex\misc. I refreshed the database by clicking on Refresh FNDB in MiKTeX Options. – user541686 Mar 22 '12 at 7:54
  • Did you try another tree mentioned in the miktex settings, e.g. UserConfig? Or can you create your own local tree? (I never used the portable version, so I don't know how it manages its tree). – Ulrike Fischer Mar 22 '12 at 8:08

Apparently MikTeX Portable doesn't like custom additions to its own TEXMF tree. You'll have to create your own tree, say in E:\own-texmf (let's assume E: is the thumb drive containing your MikTeX Portable installation.

Put your custom .sty in, say, E:\own-texmf\tex\latex\misc.

Then in the MikTeX Options dialog, switch to the Roots pane, and add E:\own-texmf to the list of registered root directories.

Now go back to the General pane, and Refresh FNDB. MikTeX Portable should now be able to see your custom .sty file.

  • Oh huh... so there's no "correct" way to embed it inside MiKTeX Portable? +1 thanks for the info. – user541686 Mar 22 '12 at 9:14
  • @Mehrdad Guess not for the present. I'm not sure if the MikTeX maintainer has a reason for making it this way; you could try contacting him and ask if it's possible to rectify this in future versions. Also, if you think this answer is satisfactory enough, appreciate it if you could "accept" it (by clicking the green tick symbol), so as to have as few "unanswered" questions as possible on the site. :-) – LianTze Lim Mar 22 '12 at 14:06
  • @Mehrdad: It wouldn’t work with not portable MiKTeX, too. If you have MiKTeX portable on a removable drive, you should of course put your local TeXMF onto the same drive. Inside of MiKTeX the relative path will be saved. See also Setting TEXMFHOME variable when using Miktex portable. – Speravir Mar 22 '12 at 19:16
  • 1
    “I'm not sure if the MikTeX maintainer has a reason for making it this way; you could try contacting him and ask if it's possible to rectify this in future versions.” Setting a local TeXMF tree inside of MiKTex worked in earlier versions (I had managed it this way), but was changed with version 2.8 or 2.9 for security reasons, don’t know exactly anymore. So, I guess it will not reversed by Christian Schenk (the MiKTeX maintainer). – Speravir Mar 22 '12 at 19:23
  • I was going to wait a little and see if maybe someone else will have another idea, before I accept this answer. :) But thanks for the reminder, I went back and accepted the ones I'd forgotten to. – user541686 Mar 22 '12 at 19:40

That's a pretty old thread but just for documentation... I could install a custom package into a portable miktex installation. It appears that miktex portable doesn't like you adding packages into texmfs\install directory. You should create your own install folder and drag'n'drop packages from tds.zip files to there. Add this folder to path list in MikTex Options > Root, so Update FNDB normally. It have to work now.

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.