0

I use TeX Live with TeXSchop on Mac OS High Sierra, and would like to create a “package" folder containing a macros file I named “CSTmacros.sty" so that it’s available to any working TeX file with the preamble \usepackag{CSTmacros}. I was told to add the following path to my home Library:

~/Library/tex/latex/CSTmacros/CSTmacros.sty

Unfortunately that's not working. Also, the System modified the path by adding a texmf folder, thus:

~/Library/texmf/tex/latex/CSTmacros/CSTmacros.sty

The other TeX-related folders are ~/Library/texlive/2020\texmf-var and ~/Library/TeXShop. Do I need to move the texmf folder and its contents into the 2020 folder?

Thanks in advance!

Mensch
  • 65,388
  • The second version is the correct place for your local macros. I'm not sure what you mean by "the system modified the path". The texlive folders should be left alone. So just create ~/Library/texmf/tex/latex and then put your CSTmacros folder containing CSTmacros.sty there and it should be found properly. – Alan Munn May 07 '20 at 00:25
  • Thanks, Alan Munn, but this is exactly the configuration I have now, which does not work. I said "System modified the path" because I don't think I created the texmf file in the sequence, though I may be wrong. I think I created the path – Gerald Kaiser May 07 '20 at 06:37
  • Open a terminal window and type: mkdir -p ~/Library/texmf/tex/latex/CSTmacros This will create the directory. Then assuming you reported what did correctly, type mv ~/Library/tex/latex/CSTmacros/CSTmacros.sty ~/Library/texmf/tex/latex/CSTmacros This should move your style file to the correct place. To test if you've done it correctly, type kpsewhich CSTmacros.sty What does that show? – Alan Munn May 07 '20 at 10:19
  • Thanks, Alan. I did what you wrote, and the final Terminal message is: /Users/kaiser/Library/texmf/tex/latex/CSTmacros/CSTmacros.sty gerrysmbpretina:~ kaiser$ – Gerald Kaiser May 07 '20 at 22:42
  • PS: I just rebooted the Mac after the Terminal commands, and it still doesn't work. Is it possible on this forum to send a small screenshot of the TeX-related parts of my Library? – Gerald Kaiser May 07 '20 at 23:23
  • What you have done is correct. So now the problem is that I have no idea what "it doesn't work" actually means. Can you edit your question to show a sample document, and the error that you get when you try to compile it? – Alan Munn May 08 '20 at 03:36
  • I don't think attachments are possible here, so how shall I send a sample document? In addition to the source file it would also have the text of the macros file and the console file, and I'm afraid that would exceed the parameters. The best solution would be to attach the above 3 files. – Gerald Kaiser May 08 '20 at 03:44
  • You can edit your question to show what happens with the following document: \listfiles\documentclass{article}\usepackage{CSTmacros}\begin{document}\end{document} and copy the console output from compiling that into your question. – Alan Munn May 08 '20 at 03:51
  • Thank you so much Allen! I finally got everything to work, with some warnings in the console. These warnings are for using macros like \a for \alpha, which is not allowed in Latex but I manage to use it by adding \def\a{\alpha} to the macros file. I also have some very useful shortcuts like \newcommand{\3}[1]{{\boldsymbol #1}}. These commands get warnings but typeset anyway. To be continued below. – Gerald Kaiser May 08 '20 at 20:05
  • But the main problem seems to have been with the following preamble: \usepackage[colorlinks=true, pdfstartview=FitV, linkcolor=blue, citecolor=blue, urlcolor=blue]{hyperref}. The console said "Package hyperref Warning: old toc file detected, not used; run LaTeX again." Once I commented out the above preamble, it ran. The console message refers to a "toc file" which must be my \tableofcontents command. So now the TOC is not linked to the contents. Can you recommend a fix or a substitute? – Gerald Kaiser May 08 '20 at 20:06
  • You simply need to delete the .aux files and compile again. If you read the warning, it simply says to run LaTeX again. And it's a really bad idea to use one letter shorthands, since these often overlap with existing macros or primitives, and you can get results you don't like. And you should never use \def in a user level document (or even in a package or class file) unless you are really sure of what you're doing ; you should use \newcommand. This way if something is already defined, you will not zap like you did. \a is defined in the LaTeX kernel and you should not redefine it. – Alan Munn May 08 '20 at 20:17
  • See How to redefine one-letter commands? for some discussion about NOT redefining one letter macros. – Alan Munn May 08 '20 at 20:20
  • I tried trashing the aux files, aborting and re-running LaTeX, but the error message persists. I suspect one or more of my illegal one-letter commands is somehow interfering with the hyperref package. This does NOT happen when I comment out \usepackage{CSTmacros}, add the macros file to the folder as a .tex file, and use \input CSTmacros.tex instead. Continued below. – Gerald Kaiser May 08 '20 at 21:05
  • The problem of getting rid of all my one-letter commands is that I'd have to completely rewrite reams of files which have worked well with the \input CSTmacros.tex method. So I may bite the bullet and just include the macros file in each folder, as I've been doing. Thanks for your help and patience! – Gerald Kaiser May 08 '20 at 21:05
  • There's not need do do that, where the macros are defined is neither here or there, and it's more convenient to have them as a package. But you should be aware that you are likely to mess things up, depending on what one letter macros you have defined. What I would recommend is define everything with \newcommand (not \def) and see which ones cause problems, and change the names of only those macros. – Alan Munn May 08 '20 at 21:08
  • It's not that all one letter macros are bad, it's just that many are used as part of the kernel and shouldn't be redefined, since other packages will depend on their being defined in their original way. – Alan Munn May 08 '20 at 21:12
  • Only the Greek letters (including capitals) use \def since they don't work at all with \newcommand. The numbered macros like \newcommand{\3}[1]{{\boldsymbol #1}} work fine but get console warnings. I'm writing a book, and would lose all my momentum if I stopped to change all the greek-letter macros. Using \input instead of \usepackage is a small price to pay. The publisher will straighten everything out in the end. Thanks again. – Gerald Kaiser May 08 '20 at 21:32
  • As I said, the use of a package vs. \input shouldn't make a difference at all. And your \3 macro as defined shouldn't give any warning. – Alan Munn May 08 '20 at 21:34
  • I'm afraid you are right. The \input method worked fine just a while ago, but no longer. I seem to have awakened a sleeping dog in the LaTeX kernel. No idea what's going on. And yes, the only warnings I seem to get are regarding Greek letters. – Gerald Kaiser May 08 '20 at 21:44
  • Your comment that package vs. \input shouldn't make a difference proves correct. I isolated the real problem: \usepackage[colorlinks=true, pdfstartview=FitV, linkcolor=blue, citecolor=blue, urlcolor=blue]{hyperref} screws up the whole works for some reason. Replacing it with \usepackage{hyperref} works now, though I miss the colors. "Breaking News:" I cut and repasted \usepackage[colorlinks=true, pdfstartview=FitV, linkcolor=blue, citecolor=blue, urlcolor=blue]{hyperref}, and everything works now! The ways of LaTeX are truly mysterious. – Gerald Kaiser May 08 '20 at 21:55

0 Answers0