Possibility of having a default end of environment tag

Is it possible to have a small triangle say that would indicate the end of a remark/theorem statement. One similar to the QED symbol put at the end of a proof environment?

Perhaps this has been already answered on the forum but I did not look for a thread on the topic. The way to do what you want is to modify the theorem macro, exempli gratia

<assign|theorem|<\macro|body>
  <surround|<compound|next-theorem>||<compound|render-theorem|<compound|theorem-numbered|<compound|theorem-text>|<compound|the-theorem>>|<arg|body>
  <qed>>>
</macro>>

where I got the macro definition from the macro editor (I recommend you to read https://texmacs.github.io/notes/docs/macro-editor.html to see with examples how to use it) and added the <qed> symbol at the end.

1 Like

This does not produce the desired result.

I guess you would want the square to appear below the proof’s body. For this, one needs to stack them vertically in a document tag. However that tag is normally implicitly defined/inserted through formatting, and it is easy to get it wrong. This should work

<assign|mytheorem|<\macro|body>
  <surround|<compound|next-theorem>||<\render-theorem|<compound|theorem-numbered|<compound|theorem-text>|<compound|the-theorem>>>
    <arg|body>

    <qed>
  </render-theorem>>
</macro>>

You can check the full tag structure by setting the preference “Tags with special rendering” to “raw”, in the Document>Source>Preferences…

1 Like

The remark of @pjoyez is correct, however I would go to redefine the render-theorem macro, or create a new one which inserts the symbol. Conceptually is this macro which is responsible for the rendering, as the name suggests.

I don’t have access to the computer to test, so I ask. Does render-theorem format all enunciation environments? In this case one needs to also assign a new name to the "new render-theorem".

Ok, re-read your post, you also say it :slight_smile:

How would you set it to the right of the last word of the proof, as I wanted it to be?

I can’t get the full structure after changing the preference. Nevertheless I get the same effect by inserting a new-line tag before qed. However, the qed sign appears to the left. Then I replace qed by tab-qed as in render-proof, but the sign appears in the middle. In plain text tab-qed renders the sign to the right. It looks the render-proof has something more in its definition, which I don’t understand now.

The following works: insert htab then qed. But putting these directly in the macro yield some undesired results.

2 Likes

I think I have understood something. If a macro accepts a multi-paragraph input which it combines with an implicit concat, like

<assign|test-concat|<macro|body|<arg|body> <qed>>>

and the argument body is multi-paragraph, then TeXmacs inserts an implicit surround tag.

What I want—setting qed to the right of the last word of the proof—IMO is achieved with some Scheme programming, id est detecting if the argument is a document and if it is adding qed to its last child.

I wrote a Scheme function which uses tree-child-ref. It works if I use it within a Scheme session; it crashes TeXmacs if I use it within an extern tag. Could it be a bug?

The function is

(define (test-tcr body) (stree->tree `(concat ,(tree->stree (tree-child-ref body 0)) ,(tree->stree (tree-child-ref body 0)))))

Maybe the tree manipulation functions are not meant to be used with macros. I am re-writing the macro with Scheme list manipulation functions. Probably I’ll have more questions, I’ll write in case.