TeXShop auto-deletion of certain groups of pasted in characters

For my LaTeX equations I use Mathtype's excellent capability of copying equations as TeX code. My minor problem arises when I want numbered equations in LaTeX and also want to type the equation in Mathtype rather than directly in the TeX language.

When I copy/paste an equation from Mathtype it comes out as either:

${a^2} + {b^2} = {c^2}$


or

$${a^2} + {b^2} = {c^2}$$


depending on the copy settings in Mathtype.

However in my document I will wrap this equation in the equation environment (to get numbering) as follows:

$${a^2} + {b^2} = {c^2} \label{eq:abc}$$


I have to delete the  or  manually as these don't belong in the equation environment. Is it possible that TeXShop detects these symbols when pasted automatically and either deletes them or replaces them with and ?

So if I would just paste $ it would replace it with . I understand this question itself is (too) specific, but if a solution exists it could apply to other copy/paste rituals people may have. Edit: I have found a solution that almost fits my needs in Mountain Lion's Text Replacement tool. 1. First enable the symbol and text substitution in the System Preferences. 2. Configure it such that \[ is replaced by and $ is replaced by .
3. Copy/paste the formula from Mathtype into the TeXShop document.
4. Before compiling the code right click somewhere in the document and go to Substitutions -> Show Substitutions:
5. The following window opens: Check Text Replacements and click on Replace All.
6. Compile the document.

However, this does not substitute pasted in symbols automatically and requires an additional step. So I'm still looking for a "paste-time" method.

-
Well, if Mathtype gives you {a^2}+{b^2}={c^2} I wouldn't recommend using it. – egreg Apr 9 '13 at 15:18
Why not? It works flawlessly here... – Saaru Lindestøkke Apr 9 '13 at 15:20
If it adds those useless braces, I fear it adds others in places where they do evil. – egreg Apr 9 '13 at 15:25
I see. This might of course be the case, I haven't tested this systematically. But I've used the workflow now for 3 years in university and have not encountered any errors with it yet, so it suits my needs. Except for the inconvenience described in the question. – Saaru Lindestøkke Apr 9 '13 at 15:28

Easy, save the following file as "Latex (Texshop).tdl" into your "translator" folder.

MathType Output Translator 1.0: "Latex (Texshop)", "Daniel Wei 2013", language

include "LaTeX (base vars).tdl";
// redefinitions of base variables

var/"TranslatorName" = "Latex (Texshop)";
var/"TranslatorFileName" = "Latex (Texshop).tdl";

var/"BeginMathDisplay" = "$$\label{}@n"; var/"EndMathDisplay" = "@n$$";

include "LaTeX (base rules).tdl";


Then in the Mathtype preference, just select "Latex (Texshop)" as your copying style.

-
And if you're worried about extra braces (like egreg), then you can tweak the tdl file to eliminate them. But I wouldn't recommend it. – bubba Mar 28 '15 at 6:50