1

I tried to redefine the tabular that is used as default for tables in Lyx. The reason is, I want to have an option for 'auto line break in cells'. That you can do with tabularx with the argument 'X'. Example:

\usepackage{tabularx}
...
\begin{tabularx}{\linewidth}{ r X }
    right-aligned foo & long long line of blah blah that will wrap when the table fills the column width\\
\end{tabularx}

The redefinition of tabular I use in Lyx looks like this:

\let\ORIGtabular\tabular
\let\ORIGendtabular\endtabular
\let\ORIGtabularx\tabularx
\renewcommand*{\tabularx}{%
  \def\tabular{%
    \let\endtabular\ORIGendtabular
    \ORIGtabular
  }%
  \ORIGtabularx
}
\renewcommand{\tabular}{  \tabularx{\textwidth}}
\renewcommand{\endtabular}{\endtabularx} 

As result I get the following tables (sample lyx file is attached at the end of the post):

enter image description here

Questions & Problems:

  • Why are the tables 0.1 and 0.2 wider than it's content? How do I prevent this?
  • How do I set 'X' argument for each cell as default?

>Minimal Lyx Sample File<

  • Don't do that:-) tabularx works out how wide X needs to be then uses a tabular* with X replaced by p{2cm} or whatever, so you get lucky that tabular* doesn't call tabular which would make you loop. Also you are inserting an unwanted space here \renewcommand{\tabular}{ \ – David Carlisle Mar 07 '14 at 13:19
  • 1
    Well is there a way in Lyx to make auto line breaks in corresponding table cells? I don't want to use manual line breaks. – user41490 Mar 07 '14 at 13:45
  • 2
    Go into the table settings and define a width for a column, then text will break. – Torbjørn T. Mar 07 '14 at 15:23
  • I guess this is the best and fastest way to do this. Thanks @Torbjørn – user41490 Mar 10 '14 at 08:29

0 Answers0