Edit Definition environment to have non-italic text

Hi All,
I’m adding some definitions to my work. Right now, all text within the Definition is italic by default. Is there a way to make it just “plain” text

I think that placing these two definitions in your preamble should get you what you want:

<assign|render-definition|<\macro|which|body>
  <render-enunciation|<theorem-name|<arg|which><theorem-sep>>|<arg|body>>
</macro>>

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

Paste using Paste from -> TeXmacs

If you want all “theorem-type” environments to be in “plain” text, it is best to redefine render-theorem instead.

In general for the modification of macros it is worth taking a look at the Macro editor, as it shows you the definition of a macro that you are using (when that definition is available). Here is a brief introduction: https://texmacs.github.io/notes/docs/macro-editor.html

2 Likes

Dear pireddag,
What do you mean by:

Paste using Paste from -> TeXmacs

Pasting this code in the Preamble (Document > Part > Show preamble), I get this wrong black text in my screenshot. Then, I get the correct colored code below when I paste it in my .tm file opened by a text editor.
<\hide-preamble> here </hide-preamble>

Texmacs is awesome but looks so tricky sometimes.

How to colorize all definition blocks in pastel green using a hex html code?
How to colorize all theorem blocks in pastel blue using a hex html code?
How to remove the italic format on all Enunciations blocks?

How to code those 3 points above inside the file mystyle.xxx linked to many .tm files?
file1.tm linked to mystyle.xxx
file2.tm linked to mystyle.xxx
mystyle.xxx and .tm files are located in the same Windows folder.

Thank you and regards


20230226-182822

One question at a time :slight_smile:

It is a menu item. You have first to go in the “Edit” menu, there select the menu item “Paste from”, and in the submenu that opens select “TeXmacs”.
Please let me know if this makes sense.

I agree that the macros of TeXmacs are tricky. After a few years of steady use of TeXmacs I still don’t know how to use them.
To partially compensate for this, it is often possible to adapt TeXmacs macros to one’s own wishes without understanding the details of how they work (see e.g. https://texmacs.github.io/notes/docs/macro-editor.html).

Yes it makes sens.
But not the behaviour of TM. Pasting some code in the page is ‘invisible’, but you can find it behind, in the preamble.
Thanks and regards

I do think that it makes sense.
TeXmacs, in the default view, shows the typeset body of the document. An assign tag typesets to nothing, so it should not appear. It will appear in Source code view (but not in the preamble, if you have pasted it in the body of the document: could you please check that?).
The right place for that is in the preamble

For your other questions, starting with the first:

does

<assign|definition|<\macro|body>
  <with|color|#77dd77|<surround|<compound|next-definition>||<compound|render-theorem|<compound|definition-numbered|<compound|definition-text>|<compound|the-definition>>|<arg|body>>>>
</macro>>

do what you want? You would place it either in the preamble or in a style file, that you can place in the same directory as the document, and then load from the document. In the style file it is best to start by referring to one of the standard files (tag use-package) and then adding one’s own definition.
Please let me know if you need more detail. If you do, as a first step I will look into TeXmacs manual to see how much and where the topic is discussed, and we can start from there.

1 Like

Not exactly, because my question was un-precise, sorry. In fact, I thought:
How to colorize the background-color of all definition blocks …
Which argument(s) should I change in your code to colorize the background-color, and leave the text color in black?

To understand the next part of your answer, let me more time to study chapter 11 (Writing TEXMACS style files) of the English user manuel. Chapters 11 and following are missing in the French user manuel :frowning:

Thanks and regards

Weird result when copying/pasting code from the user manual, like this one in the page 79:

hassignjhellojhmacrojnamejHello hwithjfont-shapejsmall-capsjnamei!ii

I had hoped it was text color, which is easier :wink:
The only way I know of (but see below) of coloring the background of a document portion is through the ornament tag. I do not know whether ornament or ornamented is better, ornamented is based on ornament, but it might add something important of which I am not aware. Perhaps someone else knows.

I have seen a different environment than ornamented allowing for a colored background, but I cannot reconstruct it quickly. If I find out, I will post it. I also recall that it crashed TeXmacs sometimes, so I think ornament or ornamented are better.

here is an example, starting from the definition of definition and placing it in an ornament tag.

<assign|definition|<\macro|body>
  <\with|ornament-color|#77dd77|ornament-hpadding|0spc|ornament-border|0ln>
    <ornament|<surround|<compound|next-definition>||<compound|render-theorem|<compound|definition-numbered|<compound|definition-text>|<compound|the-definition>>|<arg|body>>>>
  </with>
</macro>>

I have also set ornament-hpadding to 0spc (the definition environment fills till the limit of the ornament, and I think in this way it occupies the space it occupies with its default definition) and ornament-border to0ln` (no border).

For copying, if you copy from the pdf, the copied text may be wrong here and there—I do not know the details but it is “sort of” intuitive. TeXMacs has an integrated manual, so you can copy from there; you can search the manual with a menu item (Help->Search->Documentation), which will tell you also the corresponding keyboard shortcut. If you insert a search term long enough you will find what you want. For example the title of the section: searching for “Writing a simple style package” finds it as sixth search result.

Nice theorem environment with background color can be created using tables.

I make use of the framed-theorems package to do something like this in a style package:

<use-package|framed-theorems>

<assign|theorem-ornament-border|0pt>

<assign|theorem-ornament-color|#aaf>

<assign|definition-ornament-border|0pt>

<assign|definition-ornament-color|#afa>

<assign|old-theorem|<value|theorem>>

<assign|old-definition|<value|definition>>

<assign|theorem|<macro|body|<with|ornament-border|<value|theorem-ornament-border>|ornament-color|<value|theorem-ornament-color>|<old-theorem|<arg|body>>>>>

<assign|definition|<macro|body|<with|ornament-border|<value|definition-ornament-border>|ornament-color|<value|definition-ornament-color>|<old-definition|<arg|body>>>>>

The neat thing is that TeXmacs is smart enough to recognise that theorem-ornament-color, definition-ornament-color, etc. are style parameters and lets you change them via menus in Focus->Preferences.

1 Like

This is very nice.
It is important, when writing up the style, to put <use-package|framed-theorems> after the use-package statement that states the “root” style of the document, e.g.

<use-package|generic|framed-theorems>
1 Like

Ah yes,thanks for pointing that out. I intended this as a style package, not a style file (as I wrote). I’ve edited the post accordingly.

Hi Jeroen,
Thank you for your code, it works fine for me. But, as you can sous-ensemble in my screenshots, there is a conflict with your first code in this post

Conflict:
Background color of Definitions are green after adding your code to colorize. Then, the Definitions background color is lost and a border appears when I add (before or after the other code) the code to remove italic format in Definitions.

My goals:

  • Colorize the background of all definitions, theorems, (and other enunciations blocks) with a different color for each type of enunciation.
  • Remove the italic text format on all enunciations block of any type.

How to fix the conflict between your 2 codes?
Thanks and regards


You have to use either one or the other, in case adapting one of the two to get what you want, not both, because the two definitions interact and it is easier to start from one than untangle the interaction :slight_smile:
I suggest to use @jeroen’s code. Mine can have defects of which I am not aware, while @jeroen’s uses code written for this purpose by Joris van der Hoeven.

After you have set this right, I think we can adapt @jeroen’s code to remove italic format, and colorize each type of enunciation block in its own color.

It seems only necessary to redefine render-theorem to remove italics

<assign|render-theorem|<\macro|which|body>
  <render-enunciation|<theorem-name|<arg|which><theorem-sep>>|<arg|body>>
</macro>>
1 Like

Therefore @sam could use your macros and add the redefinition of render-theorem.
I tried the redefinition of render-theorem down to “Axiom” :wink:

@sam For getting colorized environments, you have to repeat for each the procedure that @jeroen showed in his post. For example, for getting lemmas in green pastel

<assign|lemma-ornament-border|0pt>

<assign|lemma-ornament-color|#77dd77>

<assign|old-lemma|<value|lemma>>

<assign|lemma|<macro|body|<with|ornament-border|<value|lemma-ornament-border>|ornament-color|<value|lemma-ornament-color>|<old-lemma|<arg|body>>>>>

while the redefinition of render-theorem changes all enunciation environments in roman (removes italics), therefore lemma too.

2 Likes

Thank you Jeroen and Pireddag. Problem solved with your last message.

Then, to use the same code for other .TM files:

  • I duplicated/renamed the file packages\customize\theorem\framed-theorems.ts to mystyle.ts in the same folder of my .TM files.
  • added your code just before the closing tag </body> inside mystyle.ts
  • left only the line <use-package|mystyle> in the preamble of the .TM files using this style/code.

Regards, Happy coding :slight_smile:

1 Like

It is also possible to put your mystyle.ts in the styles subfolder of you personal configuration directory (~/.texmacs if you are on Linux); that way the style files is available to all TeXmacs documents. The styles subfolder can be also organized into further subfolders (I tried one level of subfolders only, I guess nested subfolders work as well).

Happy that it works :slight_smile: