sjelatex / derivative

Nice and easy derivatives for LaTeX
LaTeX Project Public License v1.3c
20 stars 3 forks source link

Request for an option to have upright partial derivatives and upright lowercase delta symbols #13

Open apoorvpotnis opened 11 months ago

apoorvpotnis commented 11 months ago

I understand that this might be difficult in pdflatex using the already existing fonts, but upright symbols are available in unicode fonts for use with xelatex/lualatex.

sjelatex commented 11 months ago

I had this feature in an early development version before I released the package as v0.9. I removed it because there isn't an upright partial in computer modern latin as far as I know. You can use packages to get it, but usually it doesn't fit the document font or it changes the font for all other characters as well.

There is actually a way to achieve it in pdflatex by Shear Transform and Improved shear transform which was what I had in the early dev versions. But I don't think it was within the scope of the package to define such tricks.

\documentclass{article}
\usepackage{derivative}
\usepackage{scalerel}

\newlength{\foodim}
\newsavebox{\foobox}
\newcommand{\slantbox}[2][0]{\mbox{%
    \sbox{\foobox}{#2}%
    \foodim=#1\wd\foobox%
    \hskip\wd\foobox%
    \hskip -0.5\foodim%
    \pdfsave%
    \pdfsetmatrix{1 0 #1 1}%
    \llap{\usebox{\foobox}}%
    \pdfrestore%
    \hskip 0.5\foodim%
}}
\newcommand\unslant[2][-0.25]{\ThisStyle{\slantbox[#1]{$\SavedStyle#2$}}}
\newcommand\uprightpartial{\unslant{\partial}}

\begin{document}
    $\partial \uprightpartial$

    $\unslant\alpha \unslant\beta \unslant\gamma \unslant\delta$

    $\pdv{f}{x}$

    \derivset{\pdv}[style-inf=\uprightpartial]

    $\pdv{f}{x}$
\end{document}

image

If you are using pdflatex, you can do the above but you should use \derivset{\pdv}[style-inf=\uprightpartial] in the preamble.

Likewise if you use lualatex or xelatex, you can use

\documentclass{article}
\usepackage{derivative}
\usepackage{unicode-math}
\begin{document}
    $\pdv{f}{x}$

    \derivset{\pdv}[style-inf=\symup{\partial}]

    $\pdv{f}{x}$
\end{document}