2

I do physics and math, and so I have accumulated many different "\newcommand"s that make my life much easier that depend really only on the three packages amsmath, amsthm, and amsfonts.

My question is this:

What is the best way for me to carry them from document to document, other than merely copy and pasting all of the new commands into one huge, disgusting preamble? Ideally, I would like to be able to do something as simple as just having a single text file that I call, but it seems a bit more involved than that.

  • 2
    just put them in mypackage.sty and use \usepackage{mypackage} in all your documents – David Carlisle Jan 06 '17 at 22:01
  • What directory is mypackage.sty usually located in, or is it something I write? If the latter, what directory should I put it in? – InertialObserver Jan 06 '17 at 22:03
  • you can put it anywhere so long as tex finds it probably your tex installation already has a path set up for local additions, but check TEXINPUTS or set it to include wherever you put the file mypackage was a name I just made up in the comment, it does not have to be called that. – David Carlisle Jan 06 '17 at 22:05
  • 1
  • 1
    I've removed the tags amsmath and math-mode since they are irrelevant for the question itself. –  Jan 06 '17 at 22:30
  • The above comments already answered the question well. But: I believe (not sure) that MiKTeX will not let you place a non-distro .sty among the distro .sty files. You MUST use a "local" or "home" tree for that. Although it is bad practice, TeXlive doesn't care. If anyone knows more about this, ring in. In all cases, you have to update your file name database. –  Jan 06 '17 at 23:04
  • @RobtA: Placing personal input files into the distribution tree is, of course, awfully bad practice regardless of the distribution itself. With TeXLive, you should place them in the $TEXMFHOME/tex/latex/ directory (or a sub-…-subdirectory thereof). The correct value of TEXMFHOME for your system can be queried with kpsewhich --var-value TEXMFHOME. You do not need to rebuild the ls-R database. Finally (to the OP), you need not write a package (.sty) file: a normal TeX input (.tex) file should do, if your \newcommands stick to the ordinary syntax. – GuM Jan 07 '17 at 00:16
  • @GustavoMezzetti That is correct. Don't put personal stuff into the distro folders. Maybe my prior comment was not clear. Aside: In the USA, we have an expression "to 86 someone" meaning to kick them out of a bar, or otherwise get rid of them. It is not internationally understood. Unicode 0086 is a control character that is rarely used (and not in LaTeX). I have tried changing the catcode of % to 12, and the catcode of ^^^^0086 to 14, and it appears to work as expected (with utf-8). Easy for me, an American, to remember that code. Note that ^^^^0086 is a character, not a macro. –  Jan 07 '17 at 03:05
  • @RobtA: I’m afraid i don’t understand your pun (if a pun was intended). All sources I’ve looked up tell me the Unicode 0086 is “start of selected area”. How does this relate with TEXMFHOME? – GuM Jan 07 '17 at 03:16
  • a small recommendation ... if you are submitting your file(s) for publication, it is appreciated if you incorporate your definitions in the preamble of the main file, omitting definitions that aren't used in the submitted work. having spent hours untangling author definitions that happened to redefine "publisher" definitions, to the detriment of both, i do speak from experience. – barbara beeton Jan 07 '17 at 08:14
  • @GustavoMezzetti Not a pun. I wrote about two different things, which are not related. But I put both of them in the same comment. Sorry. Yes, 0086 is "start of selected area" but it is unused in TeX or plain text processors, as far as I know. I have tested this. Perhaps 0086 is used in word processors or other software, but then it would not be exported as plain text. –  Jan 07 '17 at 15:14
  • @RobtA: Oh, now I (probably) undeerstand! You must be referring to Percent signs - “comment” and “active” both at once? – GuM Jan 08 '17 at 02:14
  • @GustavoMezzetti Yes. I confused two different topics. –  Jan 08 '17 at 13:32

0 Answers0