Skip to content

Commit

Permalink
m
Browse files Browse the repository at this point in the history
  • Loading branch information
Willie169 committed Feb 13, 2025
1 parent 14d2c19 commit 87c5e56
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 55 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Features of the template:
* Default fonts settings with TeX Gyre, Noto CJK, and XITS Math.
* Utilizes a broad range of packages such as `etoolbox`, `xparse`, `titlesec`, `titling`, `setspace`, `needspace`, `titletoc`, `amsmath`, `float`, `chemfig`, `listings`, `physics`, `siunitx`, `tikz`, `circuitikz`, `mhchem`, `hyperref`, `tcolorbox`, `unicode-math`, and `markdown`.
* Defines a lot of useful commands and shorthands.
* Patches for [`physics`](https://ctan.org/pkg/physics) package. See my [physics-patch](https://github.com/Willie169/physics-patch) repository for more information.
* Use code from my [physics-patch](https://github.com/Willie169/physics-patch) package for patches for [`physics`](https://ctan.org/pkg/physics) package.

You can use your own fonts by setting `Fonts`, `CJKFonts`, and `NotoCJKFamily` to `0` and changing the definition of `\SetMathFont`. To use the default fonts settings in the template, you'll need TeX Gyre, Noto CJK, and XITS Math fonts, which can installed with the Shell script below (`wget` required):

Expand Down
145 changes: 91 additions & 54 deletions template.tex
Original file line number Diff line number Diff line change
Expand Up @@ -59,31 +59,67 @@
\tcbuselibrary{breakable,documentation,fitting,hooks,listings,listingsutf8,poster,raster,skins,theorems}
% \usepackage{physics-patch}
% begin physics-patch
\IfPackageLoadedTF{siunitx}
{
\DeclareDocumentCommand\siqty{o m m}{
\IfValueTF{#1}{\SI[#1]{#2}{#3}}{\SI{#2}{#3}}
\DeclareDocumentCommand{\patchedphysicsquantity}{ t\big t\Big t\bigg t\Bigg o d() d|| g }
{ % Flexible automatic bracketing of an expression in () or [] or {} or ||
% Handles manual override of sizing
\IfBooleanTF{#1}{\let\ltag\bigl \let\rtag\bigr}{
\IfBooleanTF{#2}{\let\ltag\Bigl \let\rtag\Bigr}{
\IfBooleanTF{#3}{\let\ltag\biggl \let\rtag\biggr}{
\IfBooleanTF{#4}{\let\ltag\Biggl \let\rtag\Biggr}{\let\ltag\left \let\rtag\right}
}
}
}
% Handles actual bracketing
\IfNoValueTF{#5}{
\IfNoValueTF{#6}{
\IfNoValueTF{#7}{
\IfNoValueTF{#8}{
\IfBooleanTF{#1}{\big}{
\IfBooleanTF{#2}{\Big}{
\IfBooleanTF{#3}{\bigg}{
\IfBooleanTF{#4}{\Bigg}{}
}
}
}
}
{\ltag\lbrace#8\rtag\rbrace}
}{
\ltag\lvert{#7}\rtag\rvert
\IfNoValueTF{#8}{}{#8}
}
}{
\ltag(#6\rtag)
\IfNoValueTF{#7}{}{|#7|}
\IfNoValueTF{#8}{}{#8}
}
}{
\ltag[#5\rtag]
\IfNoValueTF{#6}{}{(#6)}
\IfNoValueTF{#7}{}{|#7|}
\IfNoValueTF{#8}{}{#8}
}
}{
\let\siqty\relax
}
\makeatletter
\DeclareDocumentCommand{\@patchedquantity}{ t\big t\Big t\bigg t\Bigg o d() d|| g g }
{
\let\ppqty\patchedphysicsquantity
\DeclareDocumentCommand\siqty{o m m}{
\IfValueTF{#1}{\SI[#1]{#2}{#3}}{\SI{#2}{#3}}
}
\DeclareDocumentCommand{\integratedquantity}{ t\big t\Big t\bigg t\Bigg o d() d|| g g }
{ % integrate \qty from physics and \qty from siunitx
\IfValueTF{#9}
{
{ % \qty from siunitx
\IfValueTF{#5}
{\siqty[#5]{#8}{#9}}
{\siqty{#8}{#9}}
}
{
}{ % \qty from physics
% Handles manual override of sizing
\IfBooleanTF{#1}{\let\ltag\bigl \let\rtag\bigr}{
\IfBooleanTF{#2}{\let\ltag\Bigl \let\rtag\Bigr}{
\IfBooleanTF{#3}{\let\ltag\biggl \let\rtag\biggr}{
\IfBooleanTF{#4}{\let\ltag\Biggl \let\rtag\Biggr}{\let\ltag\left \let\rtag\right}
}
}
}
% Handles actual bracketing
\IfNoValueTF{#5}{
\IfNoValueTF{#6}{
\IfNoValueTF{#7}{
Expand Down Expand Up @@ -114,54 +150,55 @@
}
}
}
\DeclareDocumentCommand\patchedquantity{}{\@patchedquantity}
\makeatother
\DeclareDocumentCommand\patchedqty{}{\patchedquantity}
\DeclareDocumentCommand\ptqty{}{\patchedquantity}
\DeclareDocumentCommand\qty{}{\patchedquantity}
\let\patchedquantity\integratedquantity
\let\iqty\integratedquantity
\let\ptqty\patchedquantity
\ifoverride\let\qty\patchedquantity\fi
\DeclareDocumentCommand\derivative{ s o m g d() }
{ % Total derivative
% s: star for \flatfrac flat derivative
% o: optional n for nth derivative
% m: mandatory (x in df/dx)
% g: optional (f in df/dx)
% d: long-form d/dx(...)
\IfBooleanTF{#1}
{\let\fractype\flatfrac}
{\let\fractype\frac}
\IfNoValueTF{#4}
{
\IfNoValueTF{#5}
{\fractype{\diffd \IfNoValueTF{#2}{}{^{#2}}}{\diffd #3\IfNoValueTF{#2}{}{^{#2}}}}
{\fractype{\diffd \IfNoValueTF{#2}{}{^{#2}}}{\diffd #3\IfNoValueTF{#2}{}{^{#2}}} \argopen(#5\argclose)}
}
{\fractype{\diffd \IfNoValueTF{#2}{}{^{#2}} #3}{\diffd #4\IfNoValueTF{#2}{}{^{#2}}}}
\IfNoValueTF{#5}{}{\argopen(#5\argclose)}
% s: star for \flatfrac flat derivative
% o: optional n for nth derivative
% m: mandatory (x in df/dx)
% g: optional (f in df/dx)
% d: long-form d/dx(...)
\IfBooleanTF{#1}
{\let\fractype\flatfrac}
{\let\fractype\frac}
\IfNoValueTF{#4}
{
\IfNoValueTF{#5}
{\fractype{\diffd \IfNoValueTF{#2}{}{^{#2}}}{\diffd #3\IfNoValueTF{#2}{}{^{#2}}}}
{\fractype{\diffd \IfNoValueTF{#2}{}{^{#2}}}{\diffd #3\IfNoValueTF{#2}{}{^{#2}}} \argopen(#5\argclose)}
}
{\fractype{\diffd \IfNoValueTF{#2}{}{^{#2}} #3}{\diffd #4\IfNoValueTF{#2}{}{^{#2}}}}
\IfNoValueTF{#5}{}{\argopen(#5\argclose)}
}
\let\dv\derivative
\DeclareDocumentCommand\partialderivative{ s o m g g d() }
{ % Partial derivative
% s: star for \flatfrac flat derivative
% o: optional n for nth derivative
% m: mandatory (x in df/dx)
% g: optional (f in df/dx)
% g: optional (y in d^2f/dxdy)
% d: long-form d/dx(...)
\IfBooleanTF{#1}
{\let\fractype\flatfrac}
{\let\fractype\frac}
\IfNoValueTF{#4}
{
\IfNoValueTF{#6}
{\fractype{\partial \IfNoValueTF{#2}{}{^{#2}}}{\partial #3\IfNoValueTF{#2}{}{^{#2}}}}
{\fractype{\partial \IfNoValueTF{#2}{}{^{#2}}}{\partial #3\IfNoValueTF{#2}{}{^{#2}}} \argopen(#6\argclose)}
}
{
\IfNoValueTF{#5}
{\fractype{\partial \IfNoValueTF{#2}{}{^{#2}} #3}{\partial #4\IfNoValueTF{#2}{}{^{#2}}}}
{\fractype{\partial^2 #3}{\partial #4 \partial #5}}
\IfNoValueTF{#6}{}{\argopen(#6\argclose)}
}
% s: star for \flatfrac flat derivative
% o: optional n for nth derivative
% m: mandatory (x in df/dx)
% g: optional (f in df/dx)
% g: optional (y in d^2f/dxdy)
% d: long-form d/dx(...)
\IfBooleanTF{#1}
{\let\fractype\flatfrac}
{\let\fractype\frac}
\IfNoValueTF{#4}
{
\IfNoValueTF{#6}
{\fractype{\partial \IfNoValueTF{#2}{}{^{#2}}}{\partial #3\IfNoValueTF{#2}{}{^{#2}}}}
{\fractype{\partial \IfNoValueTF{#2}{}{^{#2}}}{\partial #3\IfNoValueTF{#2}{}{^{#2}}} \argopen(#6\argclose)}
}
{
\IfNoValueTF{#5}
{\fractype{\partial \IfNoValueTF{#2}{}{^{#2}} #3}{\partial #4\IfNoValueTF{#2}{}{^{#2}}}}
{\fractype{\partial^2 #3}{\partial #4 \partial #5}}
\IfNoValueTF{#6}{}{\argopen(#6\argclose)}
}
}
\let\pdv\partialderivative
% end physics-patch
\usepackage{unicode-math}
\SetMathFont
Expand Down

0 comments on commit 87c5e56

Please sign in to comment.