2

I want to add the longtabu caption bottom of the table. I know this is not good. But I was told to do so. When I do it as in the code sample, the caption comes too close to the table. But after the caption there is a big vertical space.

I have used \captionsetup[longtable]{skip=10pt} as well. It doesn't help.

\documentclass[a4paper,12pt, oneside]{book}

%tweek font spacing for better look
\usepackage{microtype}

%enable linespacing commands%
\usepackage{setspace}

%enable H option that prevent figure floats
\usepackage{float}

%used to import graphics%
\usepackage{graphicx}

%used for referencing%
\usepackage{harvard}

%customise chapter styles%
\usepackage{titlesec}

%set margins%
\usepackage[left=2.8cm,right=2.8cm,top=2.8cm,bottom=2.8cm]{geometry}

%allows to create tables with different column widths%
\usepackage{tabularx}

%allows to create tables that can span across pages%
\usepackage{longtable}%dependency of longtabu (bug fix patch applied)
\usepackage{tabu}%contains longtabu

%enable table row colors
\usepackage{color, colortbl}
%\usepackage[table]{xcolor}

%enable listing customizations
\usepackage{listings}

%enable pyglist code blocks
\usepackage{verbments}

%enables itemize space customization options
\usepackage{enumitem}

%enable caption customizations ie:\captionsetup
\usepackage{caption}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newenvironment{stablecell}{
\begin{minipage}{\linewidth-1pt}
\vspace{2mm}
}{
\vspace{1mm}
\end{minipage}
}

\newenvironment{spackenum}{
\begin{enumerate}[noitemsep,topsep=0pt,parsep=0pt,partopsep=0pt,leftmargin=*]
}{
\end{enumerate} 
}

\newenvironment{spackitems}{
\begin{itemize}[noitemsep,topsep=0pt,parsep=0pt,partopsep=0pt,leftmargin=*]
}{
\end{itemize} 
}

\newenvironment{snomargitems}{
\begin{itemize}[leftmargin=*]
}{
\end{itemize}
}

\newenvironment{scode}{\captionsetup{type=listing}}{}

\newcommand{\shrule}{\vspace{1mm}\hrule\vspace{2mm}}

%========================================

\newcommand{\cgui}{\textit{CGui}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\definecolor{gray}{gray}{0.9}

%keep only the page number%
\pagestyle{plain}

%set onehalf line spacing
\onehalfspacing

%customise chapter styles from titlesec%
\titleformat{\chapter}{}{}{0em}{\bf\LARGE}

%set bibliography listing style to agsm%
\bibliographystyle{agsm}

%monospace font in listing
\lstset{basicstyle=\ttfamily\small,
captionpos=b,tabsize=4}

\captionsetup[longtable]{skip=10pt}

\begin{document}




%%%%%%%%%%%%%%%% Table Start %%%%%%%%%%%%%%%%%%%%
\begin{longtabu} to \textwidth { |>{\columncolor{gray}}X[1, l] | X[4 , l ]| }
%%%%%%%%%%%%%%%% Heading Start %%%%%%%%%%%%%%%%%%
\hline
\endfirsthead
%==============================================
%Next page headings
\hline
\endhead
%==============================================
%Before page break text
%\multicolumn{2}{r}{Continued on next page} \\
\endfoot
%==============================================
\hline
\caption[xxxx xxx xxx xxx xxxx xxxxxxx xxxxx xxxx xxxxx]
{xxxx xxx xxx xxx xxxx xxxxxxx xxxxx xxxx xxxxx}
\label{table:xxxx_xxx_xxxx}\\
\endlastfoot
%%%%%%%%%%%%%%%% Heading End %%%%%%%%%%%%%%%%%%
%\hline
\textbf{xxxxxxxxx}
& xxxx xxx xxx xxx xxxx xxxxxxx x xxx xxxx xxxxxxx xxxxx xxxx xxx xxxxx xxxx xxxxx \\
%==============================================
\hline
\textbf{xxxxxxxxx}
& xxxx xxx xxx xxx xxxx xxxxxxx x xxx xxxx xxxxxxx xxxxx xxxx xxx xxxxx xxxx xxxxx \\
%%%%%%%%%%%%%%%%% Body End %%%%%%%%%%%%%%%%%%%%
\end{longtabu}
%%%%%%%%%%%%%%%% Table End %%%%%%%%%%%%%%%%%%%%
\paragraph{}
xxxxx xxxx xxxx xxxxx xxxx xxxxx xxxx xxxx


\end{document}
  • 1
    I strongly recommend not using tabu. Its author has promised backwards-incompatible changes and refuses to fix serious bugs in the current version in the meantime. – cfr Apr 21 '15 at 1:29
  • @cfr what alternative do you suggest to achieve the same longtabu behaviour? – Makmeksam Apr 21 '15 at 8:37
  • 2
    If you want a table that breaks across pages, you should try ltablex, which combines longtable and tabularx. – Bernard Apr 21 '15 at 9:25
  • @Bernard longtabu had even more issues such as tex.stackexchange.com/questions/235418/…. Will ltablex fix them too? – Makmeksam Apr 21 '15 at 10:57
  • 1
    If the problem is going under the bottom margin, any table environment will brea cells across pages, as far as I know, so it's up to you to adapt the contents of rows. For instance, you can replace a multined row with two row without an \hline in between. – Bernard Apr 21 '15 at 11:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.