2

I'm making a small bundle of 'package-lets' for my classmates and need an easy way to register my package-lets with the local TeX installation.

Only the following distributions will be 'supported':

  • MikTeX (via mpm)
  • MacTeX/TeXLive (via tlmgr)

I cannot assume that they will keep their assignments all in the same directory (I can understand the desire to deeply organize things when graphical explorers would shove way too much information in your face), so I must register them with the system.

I have a way to install the packages once I have the path (something like …/texmf-local/tex/latex/), assuming texhash is cross-platform.

Sean Allred
  • 27,421
  • In TL, kpsewhich -var-value TEXMFHOME will give you the value of the user's texmf home. I would recommend installing there as it avoids the need for texhash and can be installed even by users who don't have admin rights on a system. Also, it is easy to tell people how to clean up later if they want to e.g. get rid of your install of pgf when their TeX installation gets the new version. (Exception: if you were installing fonts.) Better to use install than cp on unix-type systems and you can set the mode with -m. Plus install into a sub-directory of tex/latex for tidiness. – cfr Feb 16 '14 at 01:16
  • @cfr It seems that when I install package.sty `kpsewhich -var-value TEXMFHOME`, TeX cannot find package.sty when I \usepackage{package}. – Sean Allred Feb 16 '14 at 01:22
  • 1
    Well, it needs to be under tex/latex/pkgname within TEXMFHOME or latex won't find it. See my suggestion below. – cfr Feb 16 '14 at 01:42
  • MiKTeX has a different concept of local root directories. IT does know kpsewhich -var-value, but the variable TEXMFHOME is empty, and even worse, when upon installation one chose user mode install (as I did) TEXMFLOCAL points to the main installation path! Cf. Difference between administrative and user mode of MiKTeX and also Create a local texmf tree in MiKTeX. For adding a local root the right command would be initexmf --register-root (doubling the hyphen is important here, because -r is a different swi – Speravir Feb 16 '14 at 04:04
  • @Speravir This is looking more and more like MikTeX/Windows users are out of luck for now. Isn't there any tool up on CTAN that simplifies all of this? – Sean Allred Feb 16 '14 at 04:11
  • @SeanAllred: Not that I know, but perhaps others have more ideas/more clue. On the other hand installation should be possible with a batch script, when you pack this together with your sty files into one file and write a Readme "Extract everything into a temporary folder and execute the batch script …". Uninstallation with a batch script is quite probably harder/not possible unless the whole playtex folder could be deleted with included files. – Speravir Feb 16 '14 at 04:30
  • So you cannot rely on the value of kpsewhich -var-value TEXMFLOCAL with MiKTeX, even? (Because you could use that with TeX Live even though TEXMFHOME is more straightforward.) – cfr Feb 16 '14 at 04:40

1 Answers1

1

This solution should work for unix-like systems i.e. OS X, BSDs, GNU/Linux etc.

According to the comments, a variant might work for TeX Live on Windows but not, it seems, for MiKTeX. Being eminently unqualified to do otherwise, I pass over those matters in silence.

install -m 755 -d $(kpsewhich -var-value TEXMFHOME)/tex/latex/playtex
install -m 644 exam-extensions.sty smcm-danda.sty smcm-math.sty $(kpsewhich -var-value TEXMFHOME)/tex/latex/playtex
unzip -q pgf_3.0.0.tds.zip -d $(kpsewhich -var-value TEXMFHOME)

Setting the mode is less important if installing into TEXMFHOME rather than TEXMFLOCAL but still good practice.

Note that installing your files into a subdirectory of tex/latex keeps things tidy and reduces the chances you will inadvertently overwrite an existing file of the same name. To avoid that for certain, you could use cp -n and then use chmod 644 on the .sty files.

cfr
  • 198,882
  • This will certainly work wonderfully on UNIX systems, but is there an install analog for Windows? (I can't assume any sort of UNIX environment either; I'll be making a series of install.bat files for Windows users to double-click.) – Sean Allred Feb 16 '14 at 01:49
  • Sorry, I have no idea whatsoever about Windows. The only thing I know for sure is that Windows is not Linux/BSD/GNU etc. I also don't know if MiKTeX has kpsewhich. By the way, shouldn't smcm-danda.sty use \RequirePackage if it is a package? \ProvidesPackage is a useful command to include because the information can help in case of debugging etc. Also, I don't know what it does but \endinput seems a common finale. – cfr Feb 16 '14 at 01:57
  • 1
    MikTeX does have kpsewhich, thankfully. And it should, but I'm still far from any real release. When I'm ready to distribute my stuff to the class, I'll make them model files. If I can find an install analog for Windows, I'll accept your answer. Thanks! – Sean Allred Feb 16 '14 at 02:00
  • It might be that copy on Windows (whatever corresponds to cp) is also an analogue for install. As I understand it (please correct me), Windows doesn't have the same notion of file modes as Unix-type systems. (Certainly if you use a Fat 32 filesystem, everything becomes executable which I find terrifying. But I know Windows now uses more sophisticated filesystems.) Since the main feature of install as opposed to cp is that it can handle modes, owners, groups etc., I am not sure whether a Windows analogue would make sense? – cfr Feb 16 '14 at 02:45
  • You are correct in that Windows doesn't have a concept of file modes, necessarily, but rather more abstract and unnecessarily hard-to-get-at permissions. I am planning on using copy at the moment; right now I'm seeing if there is any sort of a 'target' concept in batch files: http://superuser.com/q/717458/160871 – Sean Allred Feb 16 '14 at 02:49
  • Rather you than me ;). When you solve it, perhaps you should answer your own question? For the Windows part, anyway... – cfr Feb 16 '14 at 03:02
  • Sorry, but I have to un-accept given new information in the comments above---apparently TEXMFHOME isn't a real thing under MikTeX, which throws a wrench in this general approach. – Sean Allred Feb 16 '14 at 04:12
  • @SeanAllred: I really think the true answer to your question is “No.” because of “cross-platform”. But you could provide a ZIP file with make and batch scripts (one for MiKTeX, one for Windows TeX Live), so it would be semi cross-platform. – Speravir Feb 16 '14 at 04:38