Customizing the section type with color blocks

Many of us want to customizing our own style. As still a beginner, I hope to see more examples of customizing the TeXmacs. Recently, I find this style of section and subsection in LaTeX forum:



In LaTeX we can use \box or similar box commands to generate those colored blocks, but how should we make those in TeXmacs? Could anybody show me the approach?

I made a rapid try and came up with something like:

<assign|section-numbered-title|
  <macro|title|<compound|section-title|<sectional-prefixed|
     <tabular|<tformat|<cwith|1|1|1|1|cell-background|blue>|
           <table|<row|<cell|<with|color|#f0f0f0|<compound|the-section>>>>>>>
     <compound|section-sep>|<arg|title><compound|section-post-sep>>>>>

to be added to the preamble. I used a table to make the colored box, maybe one will have to adjust paddings and centering but does not seems impossible. I suggest you experiment with the formatting on a text and then when you are satisfyed with the paddings, color and centering copy the TeXmacs code into the above macro.

1 Like

I see. But do you have any suggestions for the colored underline? It seems both wide-underlined and wide-std-underlined have no color or thickness options.
p.s. Box seems to be more flexible than table. Isn’t it? Do think TeXmacs should have box like in LaTeX?

What features you cannot implement with tables? In my experience tables are really useful to obtain graphic effects and organize text on the page. There is also the ornamented environment if you need some decoration.
Again for underline you can use a table and the associated borders I think.

Example:

<assign|section-numbered-title|<\macro|title>
  <\section-title>
    <with|color|pastel blue|<\wide-tabular>
      <tformat|<cwith|1|1|1|1|cell-tborder|0ln>|<cwith|1|1|1|1|cell-bborder|2ln>|<cwith|1|1|1|1|cell-lborder|0ln>|<cwith|1|1|1|1|cell-rborder|0ln>|<table|<row|<\cell>
        <sectional-prefixed|<tabular|<tformat|<cwith|1|1|1|1|cell-background|blue>|<table|<row|<cell|<with|color|#f0f0f0|<compound|the-section>>>>>>><compound|section-sep>|<with|color|black|<arg|title>><compound|section-post-sep>>
      </cell>>>>
    </wide-tabular>>
  </section-title>
</macro>>

gives

Would it be sensible to turn your solution into a small package?

I think this should need a nice interface, I still do not know how to create macros which allow to customize parameters via the focus bar. Some suggestions?