Help modifying the book chapter macro

I am trying to achieve this look for my book chapters.
01%20AM

I tried to start with modifying chapter-text and chapter-header macro which I believe are responsible for printing “chapter 1” on the page, but doesn’t seem to do anything.

12%20AM

Any help with this is appreciated.

You can maybe make progress with the help of the Macro editor; see https://texmacs.github.io/notes/docs/macro-editor.html for an introduction

I have done the following very quickly; it is yet very far away from what you want, it might help you to get started:

<assign|chapter-title|<\macro|name>
  <new-dpage*><no-indent><new-line><no-indent><vspace*|5fn>

  <\bothlined>
    <with|math-font-series|bold|font-series|bold|<really-huge|<arg|name>>>
  </bothlined>

  <vspace|2fn><no-page-break><no-indent*>
</macro>>

G.

P.S. Using Edit -> Copy to -> TeXmacs you can copy your macros in source format and paste them here as code. For pasting a macro to TeXmacs, use Edit->Paste from->TeXmacs.

1 Like

Good start, thank you. But I still can’t figure out how to right align the text.

Small suggestion: using the macro editor, keep expanding the definitions of the macros (for example the definition of bothlined, the definition of the macro bothlined is based on and so on).

Using bothlined as an example, after a few expansion you arrive at a macro which is based on tables. I expect there you will be able to change the text alignment. I think it is worth investigating a bit.

Is it possible to copy a macro from the preamble to the macro editor?

After playing around with your example, this is what I ended up with.

<assign|chapter-numbered-title|<style-with|src-compact|none|<\macro|name>
  <new-dpage*><no-indent><new-line><no-indent><vspace*|5fn>

  <with|font-series|bold|<really-huge|Chapter <the-chapter>>><new-line>
  \;
  <vspace|2fn>
  \;
  <\bothlined>
    \;
    <no-indent><with|font-series|bold|font-family|ss|<really-huge| <arg|name>
    >>
    \;
  </bothlined>

  <vspace|2fn><no-page-break><no-indent*>
</macro>>>

Which is close. What I would like to right-align is <with|font-series|bold|<really-huge|Chapter <the-chapter>>>

Not sure what can be further expanded in that section of the macro…

Place your cursor within bothlined and use the macro editor to expand that, then expand further in the same way :slight_smile:

I understand, but that’s not the part I want to modify. The text I want to modify is above that.

<with|font-series|bold|<really-huge|Chapter <the-chapter>>>

Another thing. Even though <no-indent> is there, the text appears to be indented.

This seems to work (use Paste from -> TeXmacs scheme)

(assign "chapter-numbered-title" 
  (macro "title" 
     (document (with "color" "gray" 
          (with "font-family" "ss" (with "text-color" "grey" 
           (document 
              (wide-tabular (document (tformat (cwith "2" "2" "1" "1" "cell-tborder" "1ln") 
                      (cwith "1" "1" "1" "1" "cell-bborder" "1ln") (cwith "2" "2" "1" "1" "cell-bborder" "1ln") (cwith "2" "2" "1" "1" "cell-lborder" "0ln") (cwith "2" "2" "1" "1" "cell-rborder" "0ln") (cwith "1" "1" "1" "1" "cell-halign" "r") (cwith "1" "-1" "1" "1" "cell-lsep" "0.5em") (cwith "1" "-1" "1" "1" "cell-rsep" "0.5em") (cwith "1" "-1" "1" "1" "cell-bsep" "0.5em") (cwith "1" "-1" "1" "1" "cell-tsep" "0.5em") 
   (table (row (cell (document (with "font-series" "bold" (concat "Chapter " (the-chapter)))))) 
        (row (cell (document (with "font-series" "bold" (very-large  
               (with "color" "black" (arg "title"))))))))))))))))))

and the use \chapter as usual.

Sorry, I had not understood it. I did not manage to align the chapter header on the right, but I did with something else which looked pretty close. This means that I do not know how alignment works :wink:
But you have a chapter macro by @mgubi now.

Thanks, your example looks great. I was also able to make my example work using a wide tabular:

<\wide-tabular>
  <tformat|<cwith|1|1|2|2|cell-halign|r>|<table|<row|<\cell>
    \;
  </cell>|<\cell>
    <with|font-series|bold|font-shape|small-caps|color|grey|font-family|ss|<really-huge|Chapter
    <the-chapter>>><new-line>
  </cell>>>>
</wide-tabular>

However, I still can’t seem to figure out why <no-indent> doesn’t seem to work. It doesn’t seem to work in your example as well. Not sure if I’m using it wrong, but I’m inserting it right before <wide-tabular>.

Another command that doesn’t seem to do anything is <new-dpage> New chapter will start on the same page.

It works for me with \no-indent:

A start for that might be the following:

<assign|chapter-test|<\macro|name>
  <with|font-series|bold|par-mode|right|<no-indent><really-huge|Chapter
  <the-chapter>>>

  <with|font-series|bold|<no-indent><really-huge|<arg|name>>>

  \;
</macro>>

hmm, it doesn’t seem to work for me with your example…

OK, I was able to fix the indentation issue by placing a <no-indent> inside chapter macro, rather than chapter-numbered-title.

I would still like the to be flush with the edge of the horizontal line, but I could probably play around with the tabular environment to figure that out.

Indeed, I’m not sure why this is not working anywhere the \no-indent is placed.

yeah, not sure, something to do with scoping.

In case anyone is interested, here’s the full code for accomplishing what I want to do (more or less):

<assign|chapter-numbered-title|<\macro|title>
  <new-dpage*><no-indent>\ 

  <with|color|gray|<with|font-family|ss|<\with|text-color|grey>
    <no-indent>

    <\wide-tabular>
      <tformat|<cwith|2|2|1|1|cell-tborder|4ln>|<cwith|1|1|1|1|cell-bborder|4ln>|<cwith|2|2|1|1|cell-bborder|4ln>|<cwith|2|2|1|1|cell-lborder|0ln>|<cwith|2|2|1|1|cell-rborder|0ln>|<cwith|1|1|1|1|cell-halign|r>|<cwith|1|-1|1|1|cell-lsep|0.0em>|<cwith|1|-1|1|1|cell-rsep|0.0em>|<cwith|1|-1|1|1|cell-bsep|1.5em>|<cwith|1|-1|1|1|cell-tsep|1.5em>|<table|<row|<\cell>
        <with|font-series|bold|font-family|ss|font-shape|small-caps|<large|
        Chapter <with|font-base-size|38| <the-chapter>>>>
      </cell>>|<row|<\cell>
        <no-indent><with|font-series|bold|font-shape|small-caps|font-family|ss|<very-large|<with|color|black|<arg|title>>>>
      </cell>>>>
    </wide-tabular>
  </with>>>
</macro>>


<style-with|src-compact|none|<assign|chapter|<macro|title|<assign|chapter-numbered|<compound|chapter-display-numbers>><assign|chapter-prefix|
<macro|<compound|the-chapter>.>>
<new-dpage*><compound|next-chapter><compound|chapter-clean><no-indent>
<compound|chapter-header|<arg|title>><compound|chapter-toc|<arg|title>><if|<value|chapter-numbered>|<compound|chapter-numbered-title|<arg|title>>|<compound|chapter-unnumbered-title|<arg|title>>>>>>
2 Likes

Maybe you are in the Papyrus modus? In that modus there are no pages so <new-dpage> does not work. In this case try switching to the Paper modus.

No, I was in the paper mode.

In my above final macro it works. For some reason I have to put it inside the chapter macro instead of the chapter-numbered-title macro