Different colors for definitions and theorem/proposition

Hello to all!

I’ve been trying to find a solution for a while now without much success. Here is my problem: I would like to put in light green the definitions and in light blue the theorems/propositions. In the customization menu of the style option, I am able to modify the rendering as I wish. The only problem is that if I change something, it applies to everyone! How can I make sure that only the definitions are modified when I modify the style?

To summarize, I would like to put the definitions in one colour and the theorems/propositions in another.

Thank you in advance!

1 Like

You could redefine theorems and defintions in your preamble:

<assign|definition|
  <macro|body|<with|ornament-color|#FFE6E6|
    <surround|<compound|next-definition>||<compound|render-theorem|<compound|definition-numbered|<compound|definition-text>|<compound|the-definition>>|<arg|body>>>>>>`

Or, perhaps more elegantly, store the old definition and redefine:

<provide|plain-definition|<value|definition>>
<assign|definition-ornament-color|#ffe6e6>
<assign|definition|
  <macro|body|<style-with|src-compact|none|
    <with|ornament-color|<value|definition-ornament-color>|<compound|plain-definition|<arg|body>>>>>>

Hey, thanks for the fast reply, I appreciate it.

However, I’m lacking knowledges for using the source menu, how do I modify such things in the preamble? I’m kinda new to TeXmacs so shortcuts aren’t my cup of tea. So far, I can access it and watch it, but modifying it doesn’t really seems to work…

Thanks you in advance. :slight_smile:

You can access the preamble from Document->Part->Create preamble. Then you can copy code from here and paste it in by doing Edit -> Copy from -> TeXmacs.

Thanks you! Still having some troubles, I have followed the steps you told me and added the second code to the end of the preamble, but now, this appears in my document:

The first code doesn’t work either, and gives me the same result as I linked above. Am I doing something wrong? I’m sorry to bother you that much :frowning:

Maybe that will help you visualize what I’m working to achieve.

This is basically how I want the definitions to looks like:

And how the the theorems/lemmas/propositions to looks like:

Hope it’ll clarify my goal to some of you! Thanks in advance. :slight_smile:

I seem to have mangled the code up a bit when copying to the forum. Let’s try again:

<provide|plain-definition|<value|definition>>

<assign|definition-ornament-color|#ffe6e6>\ 

<assign|definition|<macro|body|<style-with|src-compact|none|<with|ornament-color|<value|definition-ornament-color>|<compound|plain-definition|<arg|body>>>>>>

When this is in the preamble, select “Framed theorems” in the settings for the definition.

Thank you so much! It’s working just fine now as expected. One last question, what should I add in this code to add the green border? This is the only thing which I’m looking forward, and I’ll be done asking questions. :stuck_out_tongue:

No problem asking questions, that’s what the forum’s for :slight_smile:
The border can be controlled by ornament-shadow-color and ornament-sunny-color:

<provide|plain-definition|<value|definition>>

<assign|definition-ornament-color|#ffe6e6>\ 

<assign|definition-ornament-shadow-color|red>

<assign|definition-ornament-sunny-color|red>

<assign|definition|<macro|body|<style-with|src-compact|none|<with|ornament-sunny-color|<value|definition-ornament-sunny-color>|ornament-shadow-color|<value|definition-ornament-shadow-color>|ornament-color|<value|definition-ornament-color>|<compound|plain-definition|<arg|body>>>>>>
3 Likes

That’s perfect! Thank you for your help and have a nice week-end man! :smiley:

2 Likes

Another remark: when you are in a tag like theorem the focus bar shows you two icons: the wrench and the eye. The wrench is to modify the tag globally, while the eye sets parameter only locally.

1 Like

I haven’t managed to have integrated environments, say theorems colored in green. What I did is to define separate “coloring” environments eg

<assign|thr|<macro|body|<inactive|<framed|white|pastel green|<arg|body>>>>>
<assign|dff|<macro|body|<inactive|<framed|white|OldLace|<arg|body>>>>>
<assign|exr|<macro|body|<inactive|<framed|white|LightCyan|<arg|body>>>>>

The downside is I need to perform those first and then the enunciation, eg thr and then lemma give the texmacs lemma environment but on pastel green background. In practice it’s not such a hassle as it sounds. I use it for lecture notes.

Those hacks are based on comments in this forum yet I don’t remember the thread

Best

Krzysztof

It would be helpful to understand what you did, what it came out and what you were expecting, so we can help you to obtain what you wanted in the first place instead going for a “plan B”.
My solution for the kind of effects you want is simply to define a macro \mytheorem which introduces an ornament tag and a theorem tag inside it. This is not perfect but good enough for me. Since you define a macro anyway, instead of putting the body right away you can put a theorem tag inside, you do not have to type it independently.

Well, I haven’t been precise enough I guess, sorry for that. The code

    <\body>
  <\thr>
    <\lemma>
      \;
    </lemma>
  </thr>
</body>

with “/thr” being

<assign|thr|<macro|body|<inactive|<framed|white|pastel green|<arg|body>>>>>

has as effect

ba

It’s very rough obviously, for instance I would need to manually hardcode a frame of a different colour if I wished so. What I haven’t managed is to get this effect with one macro or as you say “to define a macro \mytheorem (or \mylemma in this case) which introduces an ornament tag and a theorem tag inside it”. It was of course my goal, yet nothing I tried in TeXmacs with source mode worked, so I probably don’t master all its subtleties. As I was kind of in a hurry I settled for the method you see. Of course I would be happy for any suggestion.

Cheers,

Krzysztof

I’ve just tried with the macro

<assign|mytheorem|<\macro|body>
  <with|framed-color|pastel blue|<\framed>
    <\theorem>
      <arg|body>
    </theorem>
  </framed>>
</macro>>

and the document

<\mytheorem>
  dkjskdjsadjsadjsad
</mytheorem>

produces


Wouldn’t this be ok?

Absolutely! I also realise what was wrong with my approach: I tried (and failed) to tweak the existing theorem environment instead of setting up a new one like you are suggesting.

I wouldn’t call the approach of customizing the existing tags wrong. In fact, even though it is a bit more complicated to implement, I would say it is semantically more meaningful. A theorem remains a theorem, you just change the look. Also, if you want to use someone else’s style file, you may have to change it or your document if they happen to use a different name for theorems (eg. myawesometheorem instead of mytheorem)

I agree with @jeroen, there are two different situation: one in which you want to change the appearance of all theorems, and another in which you want to be able to have special theorems (but also normal ones). Having a new macro is appropriate in the second situation. For the first it is certainly possible to achieve the same result, just I didn’t had time to delve into the mechanism of how the theorem appeareance is currently implemented in the macro system. If I remember correctly there should be a render-theorem environment, and then one should be able to redefine it if one really wants the first kind of customisation. For my use case (lecture notes) I wanted the second, to hightlight some fundamental theorems to the students while leaving other secondary theorems typeset in the normal way.