# Re: How to insert a tabular array to LyX

‫

> >
> > I want to insert a tblr environment (from the tabularray package) into
> my lyx document.
> >
> > I read that currently LyX supports only tabular environments for tables,
> and not even tabularx.
> >
> > But still I would like to get some thoughts or ideas from the members
> how to insert (graphically, not through ERT) something like the following
> environment:
> >
> > >\begin{tblr}[t]{width=10cm,colspec={X[c]},rows={ht=2cm},hlines,vlines}
> > >item 1
> > >\\
> > >item 2
> > >\\
> > >item 3
> > >\end{tblr}
> >
> > Thanks very much.
>
> You could redefine the tabular environment used by LyX. However, you
> cannot use the GUI for setting tabular properties. Another difficulty is
> the fact that LyX uses \tabularnewline instead of \\ to end a line and,
> seemingly, the tabularray package does not understand it. So you have
> also to redefine \tabularnewline and remember to add \\ in ERT at the
> end of each table line.
>
> Arguments such as "width=10cm,colspec={X[c]},rows={ht=2cm},hlines,vlines"
> can be passed through the "LaTeX argument" in the "Tabular Settings"
> paying attention to avoid any space character.
>
> See the attached example containing two examples in both ERT and a
> somewhat LyXfied form as explained above. This last form is marginally
> better than the ERT one.
>
> --
> Enrico
>


Hello Enrico,

You can overcome the \tabularnewline problem more easily if you will
replace "\renewenvironment{tabular}{\begin{tblr}[t]}{\end{tblr}}"  in the
preamble with
"\renewenvironment{tabular}{\begin{tblr}[t,expand=\tabularnewline]}{\end{tblr}}",
this way you won't have to add "\\'' manually at the end of a line.  See
the attached file.

Regards,
Udi


newfile1.lyx
Description: application/lyx

--
lyx-users mailing list
lyx-users@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-users