2

The Lyx wiki suggests that if I want to use tabularx when using gui-built tables, I can use the following preamble:

%% Hack by Heiko Oberdiek (on de.comp.text.tex)
\usepackage{tabularx}

%% Redefine the standard table
\let\ORIGtabular\tabular
\let\ORIGendtabular\endtabular
\let\ORIGtabularx\tabularx
\renewcommand*{\tabularx}{%
  \def\tabular{%
    \let\endtabular\ORIGendtabular
    \ORIGtabular
  }%
  \ORIGtabularx
}

\renewcommand{\tabular}{%
%% The width of the table. Adjust if needed
  \tabularx{\linewidth}%
}

\renewcommand{\endtabular}{\endtabularx} 

I'm fond of the tabulary package, and would like to reproduce the above substitution, except with tabulary instead. However, simply replacing tabularx with tabulary in the above doesn't work. Is there a way to make it work, or is the design of tabulary incompatible with this kind of substitution?

Sample:

 %% LyX 2.1.3 created this file.  For more info, see http://www.lyx.org/.
 %% Do not edit unless you really know what you are doing.
 \documentclass[english]{article}
 \usepackage[T1]{fontenc}
 \usepackage[latin9]{inputenc}

 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
 \usepackage{tabulary}

 \makeatother

 \usepackage{babel}
 \begin{document}

     %% Hack by Heiko Oberdiek (on de.comp.text.tex)


     %% Redefine the standard table
     \let\ORIGtabular\tabular
     \let\ORIGendtabular\endtabular
     \let\ORIGtabulary\tabulary
     \renewcommand*{\tabulary}{%
       \def\tabular{%
         \let\endtabular\ORIGendtabular
         \ORIGtabular
       }%
       \ORIGtabulary
     }

     \renewcommand{\tabular}{%
     %% The width of the table. Adjust if needed
       \tabulary{\linewidth}%
     }

     \renewcommand{\endtabular}{\endtabulary} 


 \begin{tabular}{|c|c|c|}

 j & fj & j\\

 \end{tabular}

 \end{document}

Errors: [Compile ~/nexo/techinal_notes/HFE_Study/hfe_study.tex]

E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Missing number, treated as zero \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Illegal unit of measure (pt inserted) \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Missing number, treated as zero \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Illegal unit of measure (pt inserted) \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Missing number, treated as zero \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Illegal unit of measure (pt inserted) \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 Extra alignment tab has been changed to \cr \end{tabular}
E: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 TeX capacity exceeded, sorry [grouping levels=255] \end{tabular}

W: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 No suitable columns!
W: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 tymin too large (10.0pt), resetting to 5.26984pt
W: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 tymin too large (5.26984pt), resetting to -5.48495pt
W: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 tymin too large (-5.48495pt), resetting to -17.75346pt
W: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 tymin too large (-17.75346pt), resetting to -31.53568pt
W: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 tymin too large (-31.53568pt), resetting to -46.83159pt
W: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 tymin too large (-46.83159pt), resetting to -63.6412pt
W: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 tymin too large (-63.6412pt), resetting to -81.96452pt
W: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 tymin too large (-81.96452pt), resetting to -101.80154pt
W: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 tymin too large (-101.80154pt), resetting to -123.15227pt
W: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 tymin too large (-123.15227pt), resetting to -146.0167pt
W: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 tymin too large (-146.0167pt), resetting to -170.39482pt
W: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 tymin too large (-170.39482pt), resetting to -196.28665pt
W: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 tymin too large (-196.28665pt), resetting to -223.69218pt
W: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 tymin too large (-223.69218pt), resetting to -252.61142pt
W: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 tymin too large (-252.61142pt), resetting to -283.04436pt
W: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 tymin too large (-283.04436pt), resetting to -314.991pt
W: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 tymin too large (-314.991pt), resetting to -348.45134pt
W: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 tymin too large (-348.45134pt), resetting to -383.42538pt
W: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 tymin too large (-383.42538pt), resetting to -419.91313pt
W: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 tymin too large (-419.91313pt), resetting to -457.91458pt
W: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 tymin too large (-457.91458pt), resetting to -497.42973pt
W: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 tymin too large (-497.42973pt), resetting to -538.45859pt
W: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 tymin too large (-538.45859pt), resetting to -581.00114pt
W: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 tymin too large (-581.00114pt), resetting to -625.0574pt
W: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 tymin too large (-625.0574pt), resetting to -670.62737pt
W: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 tymin too large (-670.62737pt), resetting to -717.71103pt
W: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 tymin too large (-717.71103pt), resetting to -766.3084pt
W: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 tymin too large (-766.3084pt), resetting to -816.41946pt
W: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 tymin too large (-816.41946pt), resetting to -868.04424pt
W: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 tymin too large (-868.04424pt), resetting to -921.18271pt
W: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 tymin too large (-921.18271pt), resetting to -975.83488pt
W: /home/brodsky3/nexo/techinal_notes/HFE_Study/hfe_study.tex:48 tymin too large (-975.83488pt), resetting to -1032.00076pt

77 errors, 33 warnings, 0 badboxes

[Finished in 0.25s]

Thank you!

jbrodsky
  • 21
  • 3
  • 1
    I know nothing about lyx (always seemed simpler just to type the latex commands directly) but you need somehow to use CCC not ccc as the preamble, how in the tabularx case do you get an X into the table preamble? – David Carlisle Oct 29 '15 at 22:53
  • The lyx table dialogue allows you to customize the column argument. Replacing the c's with C's or adding X's is very doable. – jbrodsky Oct 29 '15 at 23:12
  • 1
    tabulary seems to insist that everything is in one place. I had some success with custom insets ( http://tex.stackexchange.com/questions/114591/lyx-style-for-command-with-multiple-arguments/267347#267347 ). It might be possible to store the content of the tabular environment without expansion, then compose the complete tabulary environment at \endtabular. – user24582 Nov 03 '15 at 08:31

0 Answers0