The physics package is useful

A lot of my LaTeX documents make heavy use of the physics package. Aside from it overloading several standard commands (e.g. \sin, \abs, etc.), it also makes a few abbreviations very convenient (e.g. \order). It also makes typesetting vector calculus, ordinary/partial/variational derivatives, linear algebra (bra-ket notation and matrices), and other areas much less painful. I think it's safe to say it fills a gap in the market.

The physics package is unpopular

Despite the advantages I've listed from using the package, there are some short comings. It makes use of \xparse which can give several spacing issues (these are usually edge cases but aren't too uncommon), and the syntax can be counter-intuitive. Because of this, whenever I (or others) post a problem that involves the package, a frequent theme is to give physics a wide berth:

(I am sure there are likely more unfavourable reviews of the package out there).

What alternatives are there?

I am curious to know what people think good alternatives are? Off the top of my head:

  • Keep on using physics and hope the macros are improved (unlikely?).
  • Try to re-write the few macros I use most often, but better (I doubt my implementation would be great).
  • There is another equivalent package already which addresses these issues which I haven't found yet.
  • Type it all out in full and abandon all hope of convenient math macros.

While the last option is a bit melodramatic, I think the overarching question of: "Is it preferable to use a supported package which is not ideal/buggy, or should I try and re-invent the wheel?" is one I encounter a fair bit when considering packages. My current ethos is to always use a package/module, and never re-invent the wheel. What would more proficient/experienced users recommend?

  • 13
    You have a very good point. I for myself have decided to write a few macros on my own, and not to use the physics package. Yet I would love to see a package that really does what physics promises to do.
    – user121799
    Jan 23, 2019 at 17:12
  • 4
    I've never looked at the code or used it, but the documentation left me feeling this was more "a collection of stuff that seemed like a good idea when we wrote it" rather than a coherent solution to a well defined problem. When I have produced "physics-like" documents, I've just defined a few simple macros to save repetition, and never really felt the need for more than that.
    – alephzero
    Jan 23, 2019 at 17:26
  • 3
    For everybody interested in a (hopefully eventually) viable alternative to physics: You are welcome to contribute to physics replacement effort. Also it was brought to my attention that the diffcoeff package might fill the gap partly.
    – Skillmon
    Jan 24, 2019 at 8:33
  • 3
    Additionally to the diffcoeff package, there is also the braket package, which provides macros for Dirac bra-ket notation.
    – Skillmon
    Jan 24, 2019 at 18:05
  • 3
    In addition, for (partial or univariate) derivatives, you have the long-established package esdiff and the recent derivative package. For the Dirac braket, inner products, norms, &c., you can easily make your own macros with powerful commands DeclarePairedDelimiter,\DeclarePairedDelimiterX and DeclarePairedDelimiterXPP commands in mathtools. I used them to help a friend of mine typing an introductory book on Quantum Mechanics.
    – Bernard
    Sep 2, 2019 at 22:45

1 Answer 1


This most likely won't help you and I even don't know if it's 'a good' solution, but I just copied the code I need from physics as a first entry point (mostly \bra, \ket for quantum physics) and then looked at it. The problem(s) with physics are the white spaces caused by \vphantom that is in the code for no reasons whatsoever. Take \ket as example:

\DeclareDocumentCommand\ket{ s m }
{ % Ket
    {\vphantom{#2}\left\lvert\smash{#2}\right\rangle} % No resize
    {\left\lvert{#2}\right\rangle} % Auto sizing

just delete that \vphantom and it works perfectly. Same with other definitions of this package.

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.