This semester I’ve been adamant in writing up all my homework in LaTeX. While time consuming, I’ve become far more proficient with the language. Frankly, I also think it helps you get better grades. Rewriting handwritten work onto a computer forces you to be explicit in what you did, and your submission looks far more professional.

So much nicer than handwritten

With that said, it’s a sometimes a pain because of how tedious certain aspects are. For example, consider a partial differential equation with constants:

\left( \frac{\partial U}{\partial S} \right)_{V, n_i} = T

\left( \frac{\partial U}{\partial S} \right)_{V, n_i} = T

We can improve our experience by using the predefined partial derivative function from the physics package, but that still requires left and right parenthesis as well as manually subscripting the variables held constant.

%included in your document header
%included in your document body
\left( \pdv{U}{S} \right)_{V, n_i} = T

Let’s not forget LaTeX is a programming language! We can be smart about this and automate it by defining our own function, \pdvc, (partial derivative with constants) and build off of \pdv from physics.

%include this in your document header
%#1 is the numerator term, #2 is the denominator term,
%and #3 are the variables held constant
\newcommand{\pdvc}[3]{\left( {\pdv{#1}{#2}} \right)_{#3}}
%To use in your document
\pdvc{U}{S}{V, n_i} = T

With a little forethought, we went from writing 57 characters for this partial derivative to 22, and the code is far more readable and debug-able. Hope this helps in your LaTeX-ing endeavors, and let me know of any suggestions you have!

Edit 10/28/2019: Previous version had a typo in the code for the command, moved the parenthesis so that the constant of derivation is outside the parenthesis and not inside.