1

In version 4, I used to be able to write the equivalent of \mathrm{d}^4 x as \dl^4 x. However in version 5 I get and error about a "Missing { inserted". Is there a way to fix the problem?

MWE:

\documentclass[letterpaper,12pt]{article} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage[english]{babel} \usepackage{diffcoeff} \begin{document} \begin{equation} \dl^4 x \end{equation} \end{document} 
2
  • 1
    What does "doesn't seem to work anymore" mean? You get an error? Unexpected output? Also, if you give a complete minimal example, nobody else has to type the extra other stuff in... Commented Jan 20, 2023 at 17:13
  • @mickep Thanks, I updated the question to make it more clear. Commented Jan 20, 2023 at 17:34

3 Answers 3

1

In v5 of diffcoeff the differential as a whole can be raised to a power, but to raise the operator symbol, the d, to a power you need to use the \difc (`c' for compact-form derivative) command. Thus \difc[4]x{{}} gives what you want, but I imagine uses more keystrokes than desired. To reduce the keystrokes, call a new macro (say) \dfl and write

\NewDocumentCommand \dfl { E{^}{1} m } { \difc[#1]{#2}{{}} } 

Then \dfl^4 x will give what you want (and \dfl x will give dx).

3
  • That's great, thank you! The only aspect missing is that the new \dfl doesn't inherit the horizontal space on the left from \dfl. What's the equivalent of, say, \difdef { l } {} { outer-Ldelim = \onemu }? Commented Jan 20, 2023 at 21:49
  • 1
    The simplest is to precede the \difc with the desired space in the definition of \dfl: Commented Jan 20, 2023 at 22:21
  • 1
    Alternatively, define a variant of \difc like \difdef { c } { dfl } { outer-Ldelim=\onemu, outer-Rdelim=\nilmu} and change the definition of \dfl slightly: \NewDocumentCommand \dfl { E{^}{1} m } { \difc[#1]{#2}{{}} [] where I've added empty square brackets at the end. Commented Jan 20, 2023 at 22:32
1

You can use the old version as [=v4] I couldn't see if there is a supported syntax in the new version

\documentclass[letterpaper,12pt]{article} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage[english]{babel} \usepackage{diffcoeff}[=v4] \begin{document} \begin{equation} \dl^4 x \end{equation} \end{document} 

enter image description here

1
  • Thanks, I indeed noticed that this was the case. Commented Jan 20, 2023 at 18:33
0

So, you need to use a completely different command, \difc, just to typeset this? And this package uses dots of all things as argument delimiters (yes, I know many people feel the same way about g-type arguments, but I respectfully disagree)? This is a classical example of why I prefer keyval syntax, such as the following (I used my own package to make this, but this should be taken as an encouragement to the authors of diffcoeff, derivative, and other packages to embrace keyval syntax):

\documentclass{article} \usepackage{semantex} \NewVariableClass\DifferentialOperator[ bool provide=in pars, define keys={ {in pars}{ use par=false, bool set true=in pars, set arg dots={\dotsc}, set arg sep={,}, }, {not in pars}{ use par=never, bool set false=in pars, set arg dots={\dotsm}, set arg sep={\,}, }, }, not in pars, define keys[1]={ {pow}{upper={#1}}, }, prepend keys[1]={ {arg}{ bool if TF={in pars} { define arg keys[1]={ {default}{ sep={####1}, } }, }{ return, define arg keys[1]={ {default}{ set arg keys x={ other sep={% \SemantexDataGetExpNot{arg sep}% \SemantexDataGetExpNot{symbol}% }{% \SemantexExpNot{####1}% } }, } }, }, } }, ] \NewObject\DifferentialOperator\dl{d} \NewObject\DifferentialOperator\dlpartial{\partial} \begin{document} \begin{gather*} \dl = \dl{x} = \dl[pow=4] = \dl{x,y,z} = \dl[pow=4]{x,y,z} = \dl[u]{x,y,z} = \dl[u,pow=4]{x,y,...,z} \\ \dlpartial = \dlpartial{x} = \dlpartial[pow=4] = \dlpartial{x,y,z} = \dlpartial[pow=4]{x,y,z} = \dlpartial[u]{x,y,z} = \dlpartial[u,pow=4]{x,y,...,z} \\ \dl[in pars] = \dl[in pars]{x} = \dl[in pars,pow=4] = \dl[in pars]{x,y,z} = \dl[in pars,pow=4]{x,y,z} = \dl[u,in pars]{x,y,z} = \dl[u,in pars,pow=4]{x,y,...,z} \\ \SetupObject\dl{in pars} \dl = \dl{x} = \dl[pow=4] = \dl{x,y,z} = \dl[pow=4]{x,y,z} = \dl[u]{x,y,z} = \dl[u,pow=4]{x,y,...,z} \end{gather*} \end{document} 

enter image description here

2
  • The derivative package already uses a keyval syntax :) Commented Feb 16, 2023 at 10:27
  • @Simon Only for setting it up, not this way. 😏 Commented Feb 16, 2023 at 11:16

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.