2

I have a table and its content is longer than one page. So I decided to use the longtable package. Unfortunately there are some issues with the caption and threeparttable/notes I can not sort out.

1st picture:

enter image description here

2nd picture:

enter image description here

  1. "Tab. 0.1: Caption" goes beyond the left margin. A possible solution to this problem ist using \setlength\LTleft{0pt}, but is there a more elegant way (package option?)?

  2. The caption is very close to the top of the table. Is there an option so that the distance between caption and table can be increased for all the tables in the document by 2ex?

  3. The Note (only this item) at the bottom should be aligned to the left margin and more space between the superscipt b and the "note" would be nice.

Additional question: Sometimes the page numbers do not change when I use longtables. The page following the first page is not page 2 but page 1 again!? Here in the MWE it works but in my large LaTeX document this problem occurs.

MWE:

\documentclass[
        a4paper,
        bibliography=totoc,
        toc=listof,
        chapterentrydots=on,
        listof=entryprefix
        ]{scrbook}

\usepackage[showframe]{geometry}
\usepackage{lipsum}

\usepackage{scrhack}                            

\usepackage[utf8]{inputenc}                     
\usepackage{textcomp}                           
\usepackage[T1]{fontenc}                        
\usepackage[english,german,ngerman]{babel}
\usepackage[babel,german=quotes,threshold=1]{csquotes} 
\usepackage[language=autobib,
        %backend=biber
            ]{biblatex}

\usepackage{lmodern}                            
\usepackage{scrlayer-scrpage}                   
\usepackage{microtype}


\usepackage{ragged2e}                           
\usepackage{everysel}                           
\usepackage{footmisc}                           

\usepackage{etoolbox}
\usepackage{booktabs}

\usepackage{tabularx}
\usepackage{tabulary}
\usepackage{longtable}
\usepackage{tabu}
\usepackage{array}                                          


\usepackage[
format=hang,
skip=2.5pt,                                     
justification=RaggedRight,                      
singlelinecheck=off,                            
labelfont=bf,                                   
font=footnotesize,
textfont=footnotesize,
twoside,
labelsep=colon
]
{caption}


\usepackage{enumerate}
\usepackage{enumitem}

\usepackage{graphicx}
\usepackage[normalem]{ulem}                 

\usepackage{threeparttable}
\usepackage{threeparttablex}
\usepackage{setspace} 


\renewcaptionname{ngerman}{\figurename}{Abb.}
\renewcaptionname{ngerman}{\tablename}{Tab.}




\begin{document}

\begin{ThreePartTable}
\begin{TableNotes}
\small
\item[a] xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
\item[b] yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
\item[]
\item[] \uline{Note}: \lipsum[1]
\end{TableNotes}

%\setlength\LTleft{0pt} %<============= How to remove?    
\footnotesize
\begin{longtable}[htb]{p{0.025\textwidth} p{0.63\textwidth} p{0.2575\textwidth}}
\caption[Caption]
{\textbf{Caption}}
\label{Caption}
\\%[2ex] %<======== How to remove 2ex? The space between tables and caption should always be the same!  

\toprule
& \textbf{aaaaaaaa}  & \textbf{bbbbbbb} \\
\midrule
\endfirsthead
%%%
\multicolumn{3}{l}{{cont.}} \\
\toprule
& \textbf{aaaaaaaa} & \textbf{bbbbbbb} \\
\midrule            
%%%
\endhead
\midrule
\multicolumn{3}{r}{{next page}} \\
\endfoot
\bottomrule
\insertTableNotes       
\endlastfoot
%%%
x & xxxxxxxxxxxxxxx\tnote{a} & xxx\\
%%%
y & yyyyyyyyyyyyyyy\tnote{b} & yyy\\
%%%
x & \lipsum[1-4] & xxx\tnote{a}\\
%%%
y & \lipsum[5] & yyy\tnote{b}\\
%%%
\end{longtable}
\end{ThreePartTable}
\end{document}
  • This problem is not specific to used document class nor to used caption package. It is present also at use of the article document class and caption when the width of caption in long table is defined by \setlength{\LTcapwidth}{\linewidth} and the caption text is longer than one line. this seems that can be considered as bug in longtable. this would be more evident, if you from your mwe remove all not used package in longtable. – Zarko Mar 11 at 7:21
0

Let's start with your first two questions:

i) There is a package option, e.g. margin=1em and the caption is moved to the right.

ii) the option skip controls indeed the skip between caption and tabular, but you need to tell KOMA-script not to touch it by using the global option origlongtable and the captionsetup position=above. Furthermore,, set skip to a greater value, e.g. skip=1em.

Besides that, don't load tabu, tabularx and tabulary, if you don't need them.

\documentclass[
        a4paper,
        bibliography=totoc,
        toc=listof,
        chapterentrydots=on,
        listof=entryprefix,
        origlongtable
        ]{scrbook}

%\usepackage[showframe]{geometry}
\usepackage{lipsum}

%\usepackage{scrhack}                            

\usepackage[utf8]{inputenc}                     
\usepackage{textcomp}                           
\usepackage[T1]{fontenc}                        
\usepackage[english,ngerman]{babel}
\usepackage[babel,german=quotes,threshold=1]{csquotes} 
\usepackage[language=autobib,
        %backend=biber
            ]{biblatex}

\usepackage{lmodern}                            
\usepackage{scrlayer-scrpage}                   
%\usepackage{microtype}


\usepackage{ragged2e}                           
\usepackage{everysel}                           
\usepackage{footmisc}                           

\usepackage{etoolbox}
\usepackage{booktabs}

%\usepackage{tabularx}
%\usepackage{tabulary}
\usepackage{longtable}
%\usepackage{tabu}
\usepackage{array}                                          

\usepackage{caption}
\captionsetup[longtable]{
format=hang,
skip=1em,                                     
justification=raggedright,                      
 singlelinecheck=off,                            
 labelfont=bf,                                   
 font=footnotesize,
 textfont=footnotesize,
 twoside,
 labelsep=colon,
 margin=1em,
 position=above,
}


\usepackage{enumerate}
\usepackage{enumitem}

\usepackage{graphicx}
\usepackage[normalem]{ulem}                 

%\usepackage{threeparttable}
\usepackage{threeparttablex}
\usepackage{setspace} 


\renewcaptionname{ngerman}{\figurename}{Abb.}
%\renewcaptionname{ngerman}{\tablename}{Tab.}




\begin{document}

\begin{ThreePartTable}
\begin{TableNotes}
\small
\item[a] xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
\item[b] yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
\item[]
\item[] \uline{Note}: \lipsum[1]
\end{TableNotes}

%\setlength\LTleft{0pt} %<============= How to remove?    
\footnotesize
\begin{longtable}[htb]{p{0.025\textwidth} p{0.63\textwidth} p{0.2575\textwidth}}
\caption[Caption1]
{\textbf{Caption}}
\label{tab:caaaption}
\\%[2ex] %<======== How to remove 2ex? The space between tables and caption should always be the same!  

\toprule
& \textbf{aaaaaaaa}  & \textbf{bbbbbbb} \\
\midrule
\endfirsthead
%%%
\multicolumn{3}{l}{{cont.}} \\
\toprule
& \textbf{aaaaaaaa} & \textbf{bbbbbbb} \\
\midrule            
%%%
\endhead
\midrule
\multicolumn{3}{r}{{next page}} \\
\endfoot
\bottomrule
\insertTableNotes       
\endlastfoot
%%%
x & xxxxxxxxxxxxxxx\tnote{a} & xxx\\
%%%
y & yyyyyyyyyyyyyyy\tnote{b} & yyy\\
%%%
x & \lipsum[1-4] & xxx\tnote{a}\\
%%%
y & \lipsum[5] & yyy\tnote{b}\\
%%%
\end{longtable}
\end{ThreePartTable}
\end{document}
  • Thank you for your answer. What you suggest is unfortunately not really a solution to my issue. Now the caption goes beyond the upper margin. Furthermore: Using margin=1em does not align the caption to the left margin and influences other tables, where the caption is already aligned to the left margin. – TRJW Aug 27 '18 at 11:54
  • No, the caption does not go up "beyond" the top margin, only to the margin. And you are free to set margin= to any value. And if it influences other tables, set it at the first one back to whatever you like. What are you afraid of? – Keks Dose Aug 27 '18 at 12:11
  • The headline goes beyond the upper limit. (showframe --> enable) In my opinion, it makes sense to set the appearance of graphics and tables in general and not to customize each object individually. – TRJW Aug 28 '18 at 7:09
  • Yes, in a perfect world you were right. But as I usually tend to get my work done, I'll leave it to you to avoid the realms of reality. – Keks Dose Aug 28 '18 at 7:28
  • @TRJW Welcome to the realms of reality: the only guy who invested time and effort into your questions is incompetent, delivers botch and tends to condescending comments. Are you going to demand your money back, now? – Keks Dose Aug 28 '18 at 16:16

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.