Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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:

\begin{equation}
{a^2} + {b^2} = {c^2}
\label{eq:abc}
\end{equation}

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 \begin{equation} and \end{equation}?

So if I would just paste \[ it would replace it with \begin{equation}.

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 \begin{equation} and \] is replaced by \end{equation}. enter image description here
  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:
    enter image description here
  5. The following window opens: enter image description here 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.

share|improve this question
    
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... –  Bart Arondson 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. –  Bart Arondson Apr 9 '13 at 15:28
add comment

1 Answer

up vote 1 down vote accepted

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" = "\begin{equation}\label{}@n";
var/"EndMathDisplay" = "@n\end{equation}";

include "LaTeX (base rules).tdl";

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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