Inheritance for environments
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).
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.
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>}
It is easy to inherit options of an existring environment when defining a new environment. But if we want to go further, making
\SetTblrInnerand\SetTblrOuterobey environment inheritance, we need to carefully design some proper interfaces for this.For example, if we define
longtblras an inheritance oftblrenvironment, then users should be able to control whether or not\SetTblrInner[tblr]{rowsep=0pt}also applies tolongtblrenvironment.
I think it is better to change all the setting of tblr, talltblr and longtblr when nothing is input in [ ].
I think it is better to change all the setting of
tblr,talltblrandlongtblrwhen 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.
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.
By default, exclude them and leave a choice to user to change them.
Or we can make \SetTblrInner and \SetTblrOuter accept keyval options:
env={env1,env2,…,envN}orenv=*mode=textormode=math
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>}