Partial derivatives

I’m trying texmacs for the first time and already am running into difficulties creating my own macros. I tried creating macros for the first-order partial derivative, the nth-order partial derivative, and the second-order mixed derivative. The first-order derivative works fine, but the nth-order and second-order mixed derivatives are not coming out as expected. The problem seems to be the inclusion of the third argument in the respective macros; instead of the third argument being displayed, the text ‘third’ is displayed. Some help would be appreciated. Here are my macros:

  1. <assign|pdv|<macro|first|second|<frac|\partial first|\partial second>>>

  2. <assign|pdvn|<macro|first|second|third|<frac|<math|\partial <rsup|third> first>|<math|\partial second<rsup|third>>>>>

  3. <assign|pdvmix|<macro|first|second|third|<frac|<math|\partial <rsup|2>first>|\partial second \partial third>>>

Note: I wasn’t sure if the symbol ∂ would show on this page, so I simply wrote \partial above, and the space between ‘\partial’ and ‘first’ or ‘second’ or ‘third’ is absent in my actual macro.

And here are some sample outputs (I wrote them in LaTeX for easy copying and pasting into a LaTeX editor):

\frac{\partial y}{\partial x}

\frac{\partial^{\text{third}}y}{\partial x\partial \text{third}}

\frac{\partial^2 f}{\partial x\partial\text{third}}

Hi @jf_123 and welcome to the forum.

I think the arguments in the body of your macro need to be inside arg tags, like in

<rsup|<arg|third>> <arg|first>>|<math|\<partial\>

copy and paste into TeXmacs preamble with Edit->Paste from->TeXmacs (you may have to adjust the spaces because I copied from your macro definition where you say there are spaces you do not have in the macros in TeXmacs).

You obtain the arg tag by writing the argument name as if it were a macro name, exempli gratia \third; as you press the slash you enter the hybrid mode:


after pressing return, TeXmacs shows the argument like the ones in the list of macro arguments:



Copy by means of the menu item Edit->Copy to->TeXmacs

1 Like

Thanks for responding, Giovanni.

Unfortunately, the problem persists. After a bit of a struggle, I was able to get this macro:

The ‘third’ in <arg|third> was initially coming up ‘’ and color blue, so I had to copy and paste <arg|first>, which had the proper color for ‘first’, then change ‘first’ to ‘third’.

I’m curious to know if you actually got it to work yourself. Most likely, I’m doing something wrong, but I can not pinpoint where.

Please try the following macros, which have been effective for me. Simply copy and paste them into the preamble of your TeXmacs file using menu item Edit → Paste from → TeXmacs, as @pireddag suggested.



It’s challenging for me to identify the error just from the screenshot provided. The fact that first, second, and third are already highlighted in dark red suggests they might be tagged by \arg twice, though I’m uncertain if this is causing any issues. Additionally, a simpler approach for such a macro would wrap all formulas with just one \math.