# Macros, strange behavior

In tex file I have two very similar macros
\newcommand{\te}{\textsf{te}}
\newcommand{\tm}{\textsf{tm}}

I take tex file by texmacs. In the corresponding tm file there are two macros
<assign|te|<macro|<with|font-family|ss|te>>>
<assign|tm|<macro|<with|font-family|ss|tm>>>
The first macros works right and in the text appears te in corresponding font, but second does not work! In the tm file first macros appears as <te> but second as <value|tm> and in the text it looks like <macro|tm>. Could somebody explain this situation?

More surprise. I changed the name of macros \tm -> \tmm :
\newcommand{\tmm}{\textsf{tm}}. In this case it works correctly and appears tm in corresponding fonts.
The magic

It did not work for me as well, but then I typed it in again, pressed return to activate it and it started working.
So—I do not know the reason for not working (for that we have to wait for someone that know TeXmacs better), but try typing it in (rather than using the version that TeXmacs converts from LaTeX) with the hope that it succeeds.

I do not understand what you did. Could you explain on more details.

Document->Part->Create preamble

and I start typing int he preamble

Then I typed:

• \assign Return
• the just typed \assign becomes <assign||>, cursor is between the two vertical bars)
• tm
• tm should be set in green cursive automatically by TeXmacs, this is the sign that you are typing in the right field
• I moved the cursor with right arrow to the part between the second vertical bar and the > sign
\macro Return
• the just typed \macro becomes <macro|>, with just one vertical bar, so that the whole expression is now <assign|tm|<macro|>, and the cursor is in the empty field between | and >, after macro)
• typed \with Return
• the just typed \with becomes <with|>, the cursor is between | and >
• tab
• the expression becomes <with|||> (two more vertical bars), cursor is between the first two bars
• font-family
• which should also be green cursive automatically
• go to the field between the second and the third bar
• type ss
• go to the field between | and >
• type tm

The macro is ready (we do not need to press return once more).

With menu: Document->Part->Show preamble should remove the tick before the menu entry “Show preamble”, now you are in the main body of the document.

Type

\tm return

it should work

There is a tutorial that shows a macro at http://www.texmacs.org/Tutorial/Editing/Chapter4.html, but it uses keyboard shortcuts and puts the macro in a style file. In the instructions above you are putting the macro in the preamble of your document (you can check where it is by opening the .tm field with a text editor) and using LaTeX-style commands to enter the names of the primitives and turn them into activated primitives (\assign, \macro, \with, all followed by return).

Let me know.

Thank you for detailed explanation and reference. But I have verified that command \tm works well without redefining it in preamble as you suggest, and it works well for new typing, only, but redefining does not change already used \tm command. The <macros|tm> in the text has the same form because in tm file appears <value|tm> instead of <tm> . If I change <value|tm> to <tm> then in the text appears correct tm instead of <macros|tm>. That is why the question is following: Why in the tm file the \te macros has form <te> but \tm macros has form <value|tm>?

I cannot reproduce the problem. Can you copy and past a minimal example? There could be something else interfering with that. If I do like Giovanni and copy your two macros in the preamble of a new document, then the macros works normally.

This time it is I who did not understand.

What happens if you create a new file and type \tm return?

Or also like Max said, could you copy/paste the whole file, keeping only the smallest part that shows the problem (or at least deleting most of the parts which are not related to the problem )

The tex file mix.tex:
\documentclass{revtex4-1}
\newcommand{\te}{\mathsf{te}}
\newcommand{\tm}{\mathsf{tm}}
\begin{document}

E_{\te} = k,\ E_{\tm} = k^2

\end{document}

The file mix.tm:
<TeXmacs|1.99.15>
<style|<tuple|generic|std-latex>>
<\body>
<\hide-preamble>
<assign|te|<macro|<math-ss|te>>>
<assign|tm|<macro|<math-ss|tm>>>
</hide-preamble>
Solutions read
<\equation>
E<rsub|<te>>=k,E<rsub|<value|tm>>=k<rsup|2>
</equation>
</body>
<initial|<\collection>
</collection>>

You see <value|tm> instead of <tm>. In the text we have <macros|tm>. But if I print\tm with enter this macros works well.

If I change \tm to \tmm, the file mix-1.tex
\documentclass{revtex4-1}
\newcommand{\te}{\mathsf{te}}
\newcommand{\tmm}{\mathsf{tm}}
\begin{document}

E_{\te} = k,\ E_{\tmm} = k^2

\end{document}

<TeXmacs|1.99.15>
<style|<tuple|generic|std-latex>>
<\body>
<\hide-preamble>
<assign|te|<macro|<math-ss|te>>>
<assign|tmm|<macro|<math-ss|tm>>>
</hide-preamble>
Solutions read
<\equation>
E<rsub|<te>>=k,E<rsub|<tmm>>=k<rsup|2>
</equation>
</body>
<initial|<\collection>
</collection>>

Here everything ok. If I print \tmm with enter this macros works well.

I did not make new file. In my mix.tm file (see my post above) appears <value|tm> instead of <tm> and for this reason in text we we have <macros|tm> instead of tm in corresponding font.

I tried it now, I see the same. The macros work, but the instances of \tm macros in the .tex file are imported to <value|tm>. I do not know what happens, I hope Max does

It seems a bug in the LateX->TeXMacs conversion. Note that “tm” is the acronym for TeXMacs, I guess it was used internally in the code to do some magic stuff around and it generated a but. I think it need to be reported to the bug tracker so that we do not loose track of it.

I add the link to the bug tracker, which someone might find useful: https://savannah.gnu.org/bugs/?group=texmacs
Also: accounts at Savannah can be registered at https://savannah.gnu.org/account/register.php