Any instructions to customize fancy and colorful environment in TeXmacs?

I think TeXmacs is the best for taking notes because of its professional formula display and WYSIWYG feature. And we always hope to have our own fancy styles in typesetting.

In LaTeX some fancy (and professional) theorem environments attract me and I dream to have them in TeXmacs, such as:

  1. From https://github.com/Adhumunt/NotesTeX

In LaTeX we know package tcolorbox is a powerful tool to realize them. But how can we do in TeXmacs?

I believe try customizing environment is a very good way to learn TeXmacs macro systems as well. So, do you have any suggestions?

Thanks a lot!

3 Likes

Hi @kaihuang, I think you can do a part of what you want, but not a crucial thing, that is choosing where to have colored lines (e.g. only on one side, or on top and bottom).

Using the “ornamented” environment one can insert another environment in a colored frame (with a colored background as well) but as far as I know all of the lines appear; one can have some customization but not enough to reproduce your examples with the lines on top and bottom or the line only on the left.

Using a table with a single cell one can control which side have borders, but the borders are only black.

Perhaps something more sophisticated is possible, but I need time to think about it.

For writing up the environments as macros, please take a look at http://www.texmacs.org/tmdoc/devel/style/design/style-example.en.html, at the end, sentences starting with “An interesting technique for writing macros” (please ask if you cannot make it work).

G.

For 2. you could try a table where the first cell has a fixed width (e.g. 2pt), put a theorem, definition,… in the second cell, then set the background colours:

When you have something you like, you can redefine the macros for theorem, definition etc. to look like the thing you want.

1 Like

It seems you can switch the text colour outside of the table and reset the text colour to black inside the cell to colour the borders only.

1 Like

A concrete example: to obtain something like
image
just add the following to the preamble of your document (or create a new style file)

<assign|render-enunciation|<\macro|which|body>
  <\padded*>
    <\with|color|orange>
      <\wide-tabular>
        <tformat|<cwith|1|1|1|1|cell-tborder|1ln>|<cwith|1|1|1|1|cell-bborder|1ln>|<cwith|1|1|1|1|cell-lborder|0ln>|<cwith|1|1|1|1|cell-rborder|0ln>|<cwith|1|1|1|1|cell-background|#f0f0f0>|<cwith|1|1|1|1|cell-lsep|0.2em>|<cwith|1|1|1|1|cell-rsep|0.2em>|<cwith|1|1|1|1|cell-bsep|0.3em>|<cwith|1|1|1|1|cell-tsep|0.3em>|<table|<row|<\cell>
          <\surround|<arg|which>|<yes-indent*>>
            <with|color|black|<arg|body>>
          </surround>
        </cell>>>>
      </wide-tabular>
    </with>
  </padded*>
</macro>>

<assign|render-theorem|<\macro|which|body>
  <render-enunciation|<theorem-name|<arg|which><theorem-sep>>|<with|font-shape|italic|<arg|body>>>
</macro>>
2 Likes