0

Is it possible to have longtable and tabulary together in a table for autofit and Auto continuation of table in next page

Below is my code

 \documentclass{article}
\usepackage{longtable,tabulary,capt-of,dcolumn}
\usepackage{booktabs}
\usepackage{showframe}


\makeatletter

\def\ltabulary{%
\def\endfirsthead{\\}%
\def\endhead{\\}%
\def\endfoot{\\}%
\def\endlastfoot{\\}%
\def\tabulary{%
  \def\TY@final{%
\def\endfirsthead{\LT@end@hd@ft\LT@firsthead}%
\def\endhead{\LT@end@hd@ft\LT@head}%
\def\endfoot{\LT@end@hd@ft\LT@foot}%
\def\endlastfoot{\LT@end@hd@ft\LT@lastfoot}%
\longtable}%
  \let\endTY@final\endlongtable
  \TY@tabular}%
\dimen@\columnwidth
\advance\dimen@-\LTleft
\advance\dimen@-\LTright
\tabulary\dimen@}

\def\endltabulary{\endtabulary}

\makeatother

\begin{document}


\begin{table}
\captionof{table}{Sample Table 1 }\label{table_specrot}
\begin{ltabulary}{LLD..{1.3}}
x&y&1.1\\
x&y&1.244\\
x&y&1.3\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&y&1.2\\
x&yaaaa&1.2\\
\end{ltabulary}
\end{table}

\end{document}
user52124
  • 413
  • @David Carlisle, But that table doesn't have any Table Caption in it, how to enable Table Caption, all 3 table functions in a single Table, for example, decimal align using dcolumn, Autofit using tabulary and table continuation – user52124 Jul 14 '16 at 10:08
  • you can use \captionof{table}{xxxx} from the caption (or capt-of) packages to do the caption before the table. dcolumn in tabulary should work with no problems. – David Carlisle Jul 14 '16 at 10:16
  • @DavidCarlisle sorry for bugging you :-), could you please add that caption in the above table coding and re post it to me, i am kind of having trouble compiling itabulary in this table – user52124 Jul 14 '16 at 10:24
  • just put \captionof{table}{Sample Table 1 }\label{table_specrot} before (not inside) the \begin{ltabulary} (and use the capt-of package) – David Carlisle Jul 14 '16 at 10:35
  • @DavidCarlisle, Thanks for that, the caption is working fine, but i can't see the table splitting to the next page, Please guide, Do I need to introduce any other things to see the table splitting automatically? you can see my updated code above – user52124 Jul 14 '16 at 10:57
  • you have it in a table environment they never split see the linked question. Just remove the begin{table} end{table} – David Carlisle Jul 14 '16 at 11:07
  • @DavidCarlisle, thanks for that :-), it's working fine, now one more issue, the caption should be displayed in the next page too with the Caption (Table 1 Continued) – user52124 Jul 14 '16 at 11:14
  • no, you don't get that, sorry. – David Carlisle Jul 14 '16 at 11:17

0 Answers0