[solved] Cannot get simple macro to center text

Hello,

I’m just starting with Texmacs which I discovered and it seems a really great typesetting software. I’m used to heavily use custom styles in word processors like Libreoffice and almost never do manual formatting (I rather prefer to create a new style), I’d like to replicate this with Texmacs.

I’m trying to add a simple macro that center text, but for some reason I cannot

My macro looks like:

<assign|title|<macro|body|<with|par-mode|center|body>>>

But when I use my macro, it does not center the body but is keeping it on the left. If I use <with|par-mode|center|my text here> inside the macro I get centered text, but when the macro does it I cannot.

I’d rather use a macro in case I want to change the styling from centering to something else later, all it one location.

Where am I going wrong here?

It feels as if the par-mode property does not pass through the macro to the inner body.

Thank you

I found the solution, but I do not understand it…

Rather than using <with|par-mode|center|...> I’m using <padded-center|...>. The paddced-center macro is defined by the texmacs UI it seems as <macro|body|<with|par-mode|center|<surround|<vspace*|padding-above><no-indent>|<vspace|padding-below>|body>>>

I don’t understand how the addition of vspace using surround makes the par-mode property leak through the body…

I found the issue…

I was editing my macro using the show prologue source mode (Super+Alt+p) and when I entered the <with|par-mode|center|body> I did not entered it correctly. This is because I think I haven’t understood yet how arguments works in full. To get arguments, you have to type <Tab> and not the | pipe character, and to enter the par-mode, if entered correctly within an argument introduced by <Tab> it will appear in italic directly.

What I did wrong is that I typed par-mode as a macro. I did something like \par-mode<Enter> to get the par-mode appear in italic, but it was probably understood as a macro instead and it didn’t work.

The difference in source code is (when looking at the .tm file with a text editor):

this one is correct:

<assign|title2|<macro|body|<with|par-mode|center|<arg|body>>>>

This one appears the same in the UI but is incorrect:

<assign|title3|<macro|body|<with|<value|par-mode>|center|<arg|body>>>>

Hi @mildred593 and welcome to the forum.

As the value of the environment variable par-mode I think.

The first experiences in editing in source mode in TeXmacs are very nasty IMHO, and there is no good guide. There are a few principles described in the manual at the beginning of Section 11.2; I wish there were a detailed guide on how to type.

After a few years of experience a part of editing in source mode feels natural for me, but not yet all of it :slight_smile: