Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Special case differentiation operator #53

Closed
runarberg opened this issue May 24, 2022 · 4 comments · Fixed by #108
Closed

Special case differentiation operator #53

runarberg opened this issue May 24, 2022 · 4 comments · Fixed by #108
Labels
enhancement New feature or request

Comments

@runarberg
Copy link
Owner

Add \d as a special case differentiation $\rm{d}$ operator.

Input: \d
output: <mo rspace="0">d</mo> with lspace="0" if first in a row.

This will make it far simpler to write differentiation such as:

\df / \dx f(x)

and integrations such as

int f(x) \dx

Where the spacing around the roman $\rm{d}$ is accurate.

@runarberg runarberg added enhancement New feature or request good first issue Good for newcomers labels Nov 3, 2023
@runarberg
Copy link
Owner Author

Additionally int f(x) dx could provide the d as an operator text-transformed to italic with rspace="0":

<mo rspace="0">𝑑</mo>

@runarberg
Copy link
Owner Author

Arguably roman d as the differential operator—though common—is not standard notation. Perhaps we should value simplicity and cater to standard notation. Users that want to use the roman d can use a font command and space literals for the same effect.

@cben
Copy link

cben commented Dec 1, 2023

Would this preclude using a backslash on any word starting with d?

screenshot div vec E
looks bad because "div" is in regular math font and is ambiguous with "d i v" product;
currently, a backslash helps render it upright as an <mo>div</mo> operator:
bildo

But if you special-case \dx etc., would that still work for e.g. \curl but no longer for \div?

P.S. what about partial differential — ∂𝑓/∂𝑥 vs. d𝑓/d𝑥?

[I'm not an active mathup user, just came accross your repo today and am curious about the space of possible syntactic choices, feel free to ignore me]

@runarberg
Copy link
Owner Author

@cben Not anymore. I’ve abandoned the special case \d in favor of just trying to be smart about when people write the differential the normal way (i.e. dx). As you’ve demonstrated here a special case \d has pretty bad implications.

The attached PR puts d as an operator if it is a part of a longer term (meaning followed by another alphabetic character), and never if it is preceded with a backslash. If people want the roman d as their differential operator they can actually write rm dx which will yield something like <mo rspace="0">d<mo><mi>x</mi>.

Finally as for writing differentiations (df / dx) the attached PR also puts an lspace="0" if the d is the first letter of a fraction. So df / dx, (del f)/(del x), and rm df / rm dx will all yield the correct spacing. We actually put an lspace="0" to any operator (including ∂) if it is the first element in a fraction or a group. (aside: (\d f) / (\d x) actually puts a space between the d and the operant while del x won’t. This is because—unlike d—the ∂ operator is defined in the MathML operator dictionary to not have any rspace by default).

Thanks for your interest in this repo. I’ve actually been doing a lot of this on my own and it is very nice to get a second pair of eyes and provide some feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants