tabularray icon indicating copy to clipboard operation
tabularray copied to clipboard

Inheritance for environments

Open lvjr opened this issue 3 years ago • 7 comments

Discussed in https://github.com/lvjr/tabularray/discussions/35

Originally posted by zandivx July 13, 2021 When defining new tabularray environments with \NewTblrEnviron I often find myself copying and pasting existing definitions of other environments I've created earlier. I think it would be a great option to be able to refer to existing environments and inherit their options (something like \UseTblrTemplate but for environments).

lvjr avatar Jul 16 '21 08:07 lvjr

It is easy to inherit options of an existring environment when defining a new environment. But if we want to go further, making \SetTblrInner and \SetTblrOuter obey environment inheritance, we need to carefully design some proper interfaces for this.

For example, if we define longtblr as an inheritance of tblr environment, then users should be able to control whether or not \SetTblrInner[tblr]{rowsep=0pt} also applies to longtblr environment.

lvjr avatar Sep 24 '21 08:09 lvjr

Maybe it is easier to just provide an interface to make common settings for all tabularray environments with

\SetTblrInner[*]{<settings>}
\SetTblrOuter[*]{<settings>}

or

\SetTblrInner*{<settings>}
\SetTblrOuter*{<settings>}

or

\SetTblrInner[tabularray]{<settings>}
\SetTblrOuter[tabularray]{<settings>}

lvjr avatar May 18 '22 08:05 lvjr

It is easy to inherit options of an existring environment when defining a new environment. But if we want to go further, making \SetTblrInner and \SetTblrOuter obey environment inheritance, we need to carefully design some proper interfaces for this.

For example, if we define longtblr as an inheritance of tblr environment, then users should be able to control whether or not \SetTblrInner[tblr]{rowsep=0pt} also applies to longtblr environment.

I think it is better to change all the setting of tblr, talltblr and longtblr when nothing is input in [ ].

earthmoon avatar May 18 '22 10:05 earthmoon

I think it is better to change all the setting of tblr, talltblr and longtblr when nothing is input in [ ].

@earthmoon I agree with you. But then this will be a breaking change (it will affect some existing documents). And I can not make breaking changes every year.

As the first step, maybe I will throw a warning if the optional argument is empty in the next release.

lvjr avatar May 18 '22 10:05 lvjr

There is a potential problem if we change settings for all tabularray environments by default. In amsmath library, some environments +array, +pmatrix, etc are defined. These environments should not be affected.

lvjr avatar May 25 '22 08:05 lvjr

By default, exclude them and leave a choice to user to change them.

earthmoon avatar May 25 '22 09:05 earthmoon

Or we can make \SetTblrInner and \SetTblrOuter accept keyval options:

  • env={env1,env2,…,envN} or env=*
  • mode=text or mode=math

lvjr avatar Jun 06 '22 09:06 lvjr

To make my life easier, I decide to only extend the interface a little, allowing the setting for multiple tabularray environments at the same time:

\SetTblrInner[enva,envb,envc]{<settings>}
\SetTblrOuter[enva,envb,envc]{<settings>}

lvjr avatar Aug 22 '22 12:08 lvjr