How to typeset differential (math)?
Hello, how to typeset differential in math correctly? Here are my attempts: ---- \definemathcommand[dif][nolop]{\mfunction{d}} % Based on http://wiki.contextgarden.net/Math/functions \starttext \startformula \sin x {\tf d} x \stopformula \startformula \sin x \dif x \stopformula \stoptext ---- But: - case 1: there is no space between "d" and "x" (should be similar to that between "sin" and "x") - case 2: "d" in the formula is shifted down (?!) somehow. So - ? Other questions: I need to typeset some math text. - Variables should be typeset slanted, which is OK (see "x" in the example). - Functions (sin, log... "d" in df/dx) should be typeset non-slanted - I guess \definemathcommand is supposed for this (or is there a better way?). - Vector variables should be typeset bold slanted - is there a special command for this? (\vec adds arrow above the expression, so it is not supposed for this). Thank you in advance. Best regards, Lukas -- Ing. Lukáš Procházka | mailto:LPr@pontex.cz Pontex s. r. o. | mailto:pontex@pontex.cz | http://www.pontex.cz Bezová 1658 147 14 Praha 4 Tel: +420 241 096 751 Fax: +420 244 461 038
The most common definition is
\define\dif{\mathop{}\!\mfunction{d}}
(I don't know enough of ConTeXt, so may be {\tf d} is better than
\mfunction{d}).
The important part is \mathop{}\! which will add the space on the left
automatically when it's needed (for instance in \frac{\dif x}{\dif y}
no space is added).
2015-06-17 14:00 GMT+02:00 Procházka Lukáš Ing. - Pontex s. r. o.
Hello,
how to typeset differential in math correctly?
Here are my attempts:
---- \definemathcommand[dif][nolop]{\mfunction{d}} % Based on http://wiki.contextgarden.net/Math/functions
\starttext \startformula \sin x {\tf d} x \stopformula
\startformula \sin x \dif x \stopformula \stoptext ----
But:
- case 1: there is no space between "d" and "x" (should be similar to that between "sin" and "x")
- case 2: "d" in the formula is shifted down (?!) somehow.
So - ?
Other questions:
I need to typeset some math text.
- Variables should be typeset slanted, which is OK (see "x" in the example).
- Functions (sin, log... "d" in df/dx) should be typeset non-slanted - I guess \definemathcommand is supposed for this (or is there a better way?).
- Vector variables should be typeset bold slanted - is there a special command for this? (\vec adds arrow above the expression, so it is not supposed for this).
Thank you in advance.
Best regards,
Lukas
-- Ing. Lukáš Procházka | mailto:LPr@pontex.cz Pontex s. r. o. | mailto:pontex@pontex.cz | http://www.pontex.cz Bezová 1658 147 14 Praha 4
Tel: +420 241 096 751 Fax: +420 244 461 038 ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________
Hello, thanks for the solution: \define\dif{\mathop{}\!\mfunction{d}} Some explanation for \mathop and \mfunction would be appreciated, and also explanation why \definemathcommand[dif][nolop]{\mfunction{d}} didn't work... But it is not urgent, just for perfection... Best regards, Lukas -- Ing. Lukáš Procházka | mailto:LPr@pontex.cz Pontex s. r. o. | mailto:pontex@pontex.cz | http://www.pontex.cz Bezová 1658 147 14 Praha 4 Tel: +420 241 096 751 Fax: +420 244 461 038
The easy way to answer that: \definemathcommand[dif][nolop]{\mfunction{d}} didn't work because it's intended for log-like functions, and you don't want a log-like function, but a differential, which behaves differently (for instance, you *want* space between the function and the argument in `\sin x \cos y` but you *don't want* spaces between the “d” and the variable in `\dif x \dif y`). About `\mfunction` I don't know, I think what's in the wiki is enough, it's the command that sets the font used for other upright functions (notice that some people prefer italic differentials hence the definition would be \define\dif{\mathop{}\!d}). And about how does that work, well, basically what you want is a thin space added on the left, but not on the right, so \mathop{} gives a thin space on both sides, then with \! you remove the thin space on the right and you then leave the \mfunction{d} with normal spacing. That definition behaves correctly in every case (except if you use “physics-like” notation where the differential comes just after \int). I hope I don't leave anything relevant out (but I'm no expert).
Hello,
On Wed, 17 Jun 2015 16:23:01 +0200, Manuel Blanco
The easy way to answer that: \definemathcommand[dif][nolop]{\mfunction{d}} didn't work because it's intended for log-like functions, and you don't want a log-like function, but a differential, which behaves differently (for instance, you *want* space between the function and the argument in `\sin x \cos y` but you *don't want* spaces between the “d” and the variable in `\dif x \dif y`).
About `\mfunction` I don't know, I think what's in the wiki is enough, it's the command that sets the font used for other upright functions (notice that some people prefer italic differentials hence the definition would be \define\dif{\mathop{}\!d}).
And about how does that work, well, basically what you want is a thin space added on the left, but not on the right, so \mathop{} gives a thin space on both sides, then with \! you remove the thin space on the right and you then leave the \mfunction{d} with normal spacing.
That definition behaves correctly in every case (except if you use “physics-like” notation where the differential comes just after \int).
I hope I don't leave anything relevant out (but I'm no expert).
... thank you for deep explanation! Lukas -- Ing. Lukáš Procházka | mailto:LPr@pontex.cz Pontex s. r. o. | mailto:pontex@pontex.cz | http://www.pontex.cz Bezová 1658 147 14 Praha 4 Tel: +420 241 096 751 Fax: +420 244 461 038
On Wed, 17 Jun 2015, Procházka Lukáš Ing. - Pontex s. r. o. wrote:
Hello,
thanks for the solution: \define\dif{\mathop{}\!\mfunction{d}}
Another alternative is (untested) \definemathcommand[dif][nolop]{\mfunction{d}\kern\zeropoint}
Some explanation for \mathop and \mfunction would be appreciated, and also explanation why \definemathcommand[dif][nolop]{\mfunction{d}} didn't work...
Roughtly, the above exapnds to \define\dif{\mathop{\mfunction{d}}\nolimits} When the argument of \mathop is a single character (d, in this case), mathop centers the charater on the 'math-axis'. The rationale is that such a behavior is desirable when defining single letter math operators such as sum, int, bigcap, bigcup, etc. Adding \kern\zeropoint makes TeX think that the argument of \mathop is more than a single character, so it does not center d along the math-axis. Aditya
participants (3)
-
Aditya Mahajan
-
Manuel Blanco
-
Procházka Lukáš Ing. - Pontex s. r. o.