Bug introduced in 9.0, persisting through 12.2.

I use the pdconv function below, in order to show partial derivatives in a much more intuitive way:

pdConv[expr_] := 
  fns = DeleteDuplicates[
    Cases[expr, Derivative[__][g__][__] :> g, Infinity]];
   expr /. {Derivative[inds__][g_][vars__] :> 
      Apply[Defer[D[g, ##]] &, 
       Transpose[{{vars}, {inds}}] /. {{var_, 0} :> 
          Sequence[], {var_, 1} :> {var}}], 
     a_[__] :> a /; MemberQ[fns, a]}]]
$PrePrint = pdConv;

For example:

enter image description here

However, if I try to copy this as LaTeX, and paste it into LyX (a WYSIWYG LaTeX compiler), I get

enter image description here

This is a trivial example, but the equations I am using for my work are much more complicated than this (e.g. a PDE boundary condition with over 100 terms!) However, if I convert into StandardForm and then do the same, the "Null" doesn't appear. The number of instances of "Nulls" that appear in LyX seems to be higher for expressions that have more brackets.

My questions:

  • How can I copy and paste successfully without the Nulls appearing?
  • Is there a way to avoid converting the result into StandardForm before copying as LaTeX and pasting?

A comment rather than an answer, just so I can show it the formatted results from $\TeX$. I did exactly what you described, i.e. selected the output cell, right click, copy as, LaTeX, then pasted the results below between \$\$ \$\$ to get it interpreted. As you can see, the output from Mathematica seems to work fine, at least with SSE's $\TeX$ interpreter:

$$ \left(\frac{\partial ^2u}{\partial x^2}+\frac{\partial ^2u}{\partial y^2}\right) \left(\frac{\partial ^2v}{\partial x^2}+\frac{\partial ^2v}{\partial y^2}\right) $$

  • 2
    $\begingroup$ Thanks for checking. I tried what you did and it works absolutely fine - previously I was dragging my mouse over the resulting expression and then right-clicking and copying as LaTeX. Turns out clicking on the cell at the right works perfectly. However, what if I want to copy only a selection of the output? $\endgroup$ Mar 12 at 17:53

This is a bug introduced in v9 and persisting through v12.2. The followings are 2 GIFs showing the behavior of v9 and v8:

enter image description here

enter image description here

I've used the code here to shorten u[x, y] and v[x, y] to u and v.

Please report it to WRI.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.