Graphics, Figures & Tablesproblems with the legend of a long table

Information and discussion about graphics, figures & tables in LaTeX documents.
marie2011
Posts: 138
Joined: Mon Feb 06, 2012 4:58 pm

problems with the legend of a long table

Post by marie2011 »

Dear forum members,

Many thanks for the prompt answer.

I can compile the table now. I have two further questions:

1. Is it possible to have "continuación" not in the middle, but on the right side. This is the way my other tables look like.

2. Is it possible to delete the line above the legend which appears in the table on the next page? Attached you will find a picture so that you can see what I mean.

Many thanks in advance.

Best regards,

Marie
Attachments
line.png
line.png (4.92 KiB) Viewed 5320 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

problems with the legend of a long table

Post by cgnieder »

The line is a mistake on my part:

Code: Select all

...
 \endfirsthead
  \toprule% <= this needs to be removed
  \multicolumn{2}{c}
    {\parbox{\LTcapwidth}{\tablename\ \thetable{}: Respuestas a la pregunta 10 del
    cuestionario final de evaluación: incluir pregunta/ incluir pregunta / incluir
    pregunta}} \\
  \toprule
   \textbf{Participante} & \textbf{Respuesta} \\
  \midrule
 \endhead
...
However, if you're actually going to follow my proposal and use booktabs you should adapt all your tables. If you don't want to use that then leave the lines you used as they were. Consistency is more important than booktabs.

As for the continuation remark: change the \hfil in my code to \hfill.

Here's the adapted example using your original settings:

Code: Select all

\documentclass{scrbook}

\usepackage{longtable}
\newcommand\exampleentry{%
1 & Einst war Großbritannien die vorherrschende Weltmacht. Im Kampf mit
    Portugal, Spanien, Frankreich und den Niederlanden eroberte das
    British Empire Gebiete, die zu Hochzeiten fast ein Viertel der Erde
    bedeckten. Heute erinnern nur noch 14 kleine Außenposten an die
    koloniale Vergangenheit. Der Fotograf Jon Tonks hat sie besucht: Oft
    Tausende Meilen vom Festland entfernt, sind die Insulaner britisch --
    immer noch und mit Leidenschaft. \\}
\begin{document}

\begin{longtable}{lp{.7\linewidth}}
  \caption{Respuestas a la pregunta 10 del cuestionario final de
    evaluación: incluir pregunta / incluir pregunta / incluir pregunta} \label{tab:longtable} \\
  \hline
  \textbf{Participante} & \textbf{Respuesta} \\
  \hline
 \endfirsthead
  \multicolumn{2}{c}%
    {\parbox{\LTcapwidth}{\tablename\ \thetable{}: Respuestas a la pregunta 10 del cuestionario final de
    evaluación: incluir pregunta/ incluir pregunta / incluir pregunta  }} \\
  \hline
   \textbf{Participante} & \textbf{Respuesta} \\
  \hline
 \endhead
  \hline
  & \hfill \emph{continuación} \\ \hline
 \endfoot
  \hline \hline
 \endlastfoot
  % fill the table with stuff:
  \exampleentry
  \exampleentry
  \exampleentry
  \exampleentry
  \exampleentry
  \exampleentry
  \exampleentry
\end{longtable}

\end{document}
Regards
site moderator & package author
marie2011
Posts: 138
Joined: Mon Feb 06, 2012 4:58 pm

problems with the legend of a long table

Post by marie2011 »

Hi Clemens,

Many thanks for your prompt answer. Everything works fine now and a new question arose:

Is it possible to expand the legend of "change.png" so that it looks like the legend in "right.png"?

Thanks for your hint (bookmarks). The problem I have is that I have many tables in my work and I would have to make changes in all of them. I have to submit it quite soon, but perhaps I can manage to change things.

Many thanks in advance.

Best regards,

Marie
Attachments
change.png
change.png (21.69 KiB) Viewed 5308 times
right.png
right.png (16 KiB) Viewed 5308 times
Last edited by cgnieder on Thu Nov 08, 2012 6:56 pm, edited 1 time in total.
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

problems with the legend of a long table

Post by cgnieder »

Have you changed the document class? The caption in »change« looks like standard LaTeX and the one in »right« like the standard KOMA one...

Anyway, you should not just blindly (?) copy and paste my code but only change the parts in your original document that need to be changed. Basically that are the column specifications and the various \multicolumns. Just compare your code with mine to see where the differences are and exchange them. Maybe don't change everything at once but gradually and compile in between so you can see what each code part does.

Regards
site moderator & package author
marie2011
Posts: 138
Joined: Mon Feb 06, 2012 4:58 pm

problems with the legend of a long table

Post by marie2011 »

Hi Clemens,

you are right. I just copied your code and did not compare it with mine. I compared it with mine this time and unfortunately I am still having problems. I am adding my current code:

Code: Select all

\documentclass[12pt%
%,draft%
,twoside%
,BCOR10mm%
,bibtotocnumbered,
,toc=listof,
numbers=noenddot
]{scrreprt}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[spanish,ngerman,catalan,english]{babel}
\usepackage{color}
%\usepackage[round]{natbib}
\usepackage{natbib}
\usepackage{etex}
\usepackage{booktabs}
\usepackage{url}
\usepackage{paralist}
\usepackage{mystyle}
\usepackage{acronym}
\usepackage{graphicx}
\usepackage{appendix}
\usepackage{longtable}
\usepackage{color}
\usepackage{rotating}
\usepackage{tabularx}
\usepackage{enumitem}
\usepackage{caption}
\usepackage{pgfplots}
\usepackage{tabu}
\usepackage{lscape}
\usepackage{textcomp}
\usepackage{pdflscape}
\usepackage{geometry}
\usepackage{soul}
%\usepackage{legend}

\usepackage{tablefootnote}
\usepackage{afterpage}
\usepackage{ltxtable}
\captionsetup[table]{labelsep=quad} 
\captionsetup[figure]{labelsep=quad}




%\toc=listof


\addto\captionsspanish{%
%\renewcommand{\listfigurename}{Índice de Figuras}
\renewcommand{\listfigurename}{Índice de Figuras}
\renewcommand{\listtablename}{Índice de Tablas}
\renewcommand{\figurename}{Figura}
\renewcommand{\tablename}{Tabla}
\renewcommand{\bibname}{Referencias bibliográficas}
\renewcommand{\appendixname}{Apéndices}
\renewcommand{\appendixtocname}{Apéndices}
\renewcommand{\appendixpagename}{Apéndices}}

%\listofgraficos
%\DeclareCaptionType{grafico}[Gr\'afico][\'Indice de Gr\'aficos]

\raggedbottom

\setcounter{tocdepth}{4}
\setcounter{secnumdepth}{4}







\begin{document}

\begin{longtable}{lp{.7\linewidth}}
  \caption{Respuestas a la pregunta 10 del cuestionario final de
    evaluación: incluir respuesta a la pregunta 10 / incluir respuesta   } \label{tab:respuestas-preg-10-espanoles} \\
  \toprule
   \textbf{Participante} & \textbf{Respuesta} \\
  \midrule
 \endfirsthead
  \multicolumn{2}{r}
    {\parbox{\LTcapwidth}{\tablename\ \thetable{}:    Respuestas a la pregunta 10 del cuestionario final de
    evaluación:  incluir respuesta a la pregunta 10 / incluir respuesta  }} \\
  \toprule
   \textbf{Participante} & \textbf{Respuesta} \\
  \midrule
 \endhead
  \midrule
    &\hfill\emph{continuación} \\
  \bottomrule
 \endfoot
  \bottomrule
 \endlastfoot
1&Einst war Großbritannien die vorherrschende Weltmacht. Im Kampf mit
Portugal, Spanien, Frankreich und den Niederlanden eroberte das
British Empire Gebiete, die zu Hochzeiten fast ein Viertel der Erde
bedeckten. Heute erinnern nur noch 14 kleine Außenposten an die
koloniale Vergangenheit. Der Fotograf Jon Tonks hat sie besucht: Oft
Tausende Meilen vom Festland entfernt, sind die Insulaner britisch –
immer noch und mit Leidenschaft.\\

1&Einst war Großbritannien die vorherrschende Weltmacht. Im Kampf mit
Portugal, Spanien, Frankreich und den Niederlanden eroberte das
British Empire Gebiete, die zu Hochzeiten fast ein Viertel der Erde
bedeckten. Heute erinnern nur noch 14 kleine Außenposten an die
koloniale Vergangenheit. Der Fotograf Jon Tonks hat sie besucht: Oft
Tausende Meilen vom Festland entfernt, sind die Insulaner britisch –
immer noch und mit Leidenschaft.\\


1&Einst war Großbritannien die vorherrschende Weltmacht. Im Kampf mit
Portugal, Spanien, Frankreich und den Niederlanden eroberte das
British Empire Gebiete, die zu Hochzeiten fast ein Viertel der Erde
bedeckten. Heute erinnern nur noch 14 kleine Außenposten an die
koloniale Vergangenheit. Der Fotograf Jon Tonks hat sie besucht: Oft
Tausende Meilen vom Festland entfernt, sind die Insulaner britisch –
immer noch und mit Leidenschaft.\\






1&Einst war Großbritannien die vorherrschende Weltmacht. Im Kampf mit
Portugal, Spanien, Frankreich und den Niederlanden eroberte das
British Empire Gebiete, die zu Hochzeiten fast ein Viertel der Erde
bedeckten. Heute erinnern nur noch 14 kleine Außenposten an die
koloniale Vergangenheit. Der Fotograf Jon Tonks hat sie besucht: Oft
Tausende Meilen vom Festland entfernt, sind die Insulaner britisch –
immer noch und mit Leidenschaft.\\

1&Einst war Großbritannien die vorherrschende Weltmacht. Im Kampf mit
Portugal, Spanien, Frankreich und den Niederlanden eroberte das
British Empire Gebiete, die zu Hochzeiten fast ein Viertel der Erde
bedeckten. Heute erinnern nur noch 14 kleine Außenposten an die
koloniale Vergangenheit. Der Fotograf Jon Tonks hat sie besucht: Oft
Tausende Meilen vom Festland entfernt, sind die Insulaner britisch –
immer noch und mit Leidenschaft.\\




\end{longtable}
\end{document}













%%% emacs stuff %%%
%%% Local Variables:
%%% TeX-PDF-mode: t
%%% mode: auto-fill
%%% ispell-local-dictionary: "castellano8"
%%% eval: (set-input-method "spanish-prefix")
%%% TeX-master: t
%%% End:


Sorry, I included again all my packages. If I do not do it, I feel insecure.

After compiling the document I have two questions/problems again:

1. Table legend: Is it possible to finish the first line after the colon?

2. I am still struggling with the legend in the second page of the table.

As usual, many thanks in advance.

Regards,

Marie
Attachments
second problem/question
second problem/question
finish-line-after-colon-2.png (23.62 KiB) Viewed 5308 times
first problem/question
first problem/question
finish-line-after-colon.png (23.62 KiB) Viewed 5308 times
Last edited by cgnieder on Thu Nov 08, 2012 6:59 pm, edited 1 time in total.
hugovdberg
Posts: 133
Joined: Sat Feb 25, 2012 6:12 pm

problems with the legend of a long table

Post by hugovdberg »

The forced linebreak can be easily accomplished by adding \\ after the colon, I can't help you with the second problem, I think your screenshot is wrong though, if I compile it the header gets only as wide as the right column, and I'm guessing that's your problem too. ;)
Ubuntu 13.10 + Tex Live 2013 + Texmaker / Windows 7 Pro + MikTex 2.9 + TexnicCenter / Android 4.3 + TexPortal + DroidEdit
hugovdberg
Posts: 133
Joined: Sat Feb 25, 2012 6:12 pm

problems with the legend of a long table

Post by hugovdberg »

I just couldn't let it go.. I think I fixed your code the way you want it. The trick is using the \caption[ ] command instead of the \multicolumn which does not create a listoftables entry while still printing the table number. The \multicolumn version is identical to the standard caption in the plain latex classes, while the \caption[ ] is updated when using the KOMA script classes.

Code: Select all

\documentclass[12pt%
%,draft%
,twoside%
,BCOR10mm%
,bibtotocnumbered,
,toc=listof,
numbers=noenddot
]{scrreprt}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[spanish,ngerman,catalan,english]{babel}
\usepackage{color}
%\usepackage[round]{natbib}
\usepackage{natbib}
\usepackage{etex}
\usepackage{booktabs}
\usepackage{url}
\usepackage{paralist}
\usepackage{mystyle}
\usepackage{acronym}
\usepackage{graphicx}
\usepackage{appendix}
\usepackage{longtable}
\usepackage{color}
\usepackage{rotating}
\usepackage{tabularx}
\usepackage{enumitem}
\usepackage{caption}
\usepackage{pgfplots}
\usepackage{tabu}
\usepackage{lscape}
\usepackage{textcomp}
\usepackage{pdflscape}
\usepackage{geometry}
\usepackage{soul}
%\usepackage{legend}

\usepackage{tablefootnote}
\usepackage{afterpage}
\usepackage{ltxtable}
\captionsetup[table]{labelsep=quad} 
\captionsetup[figure]{labelsep=quad}




%\toc=listof


\addto\captionsspanish{%
%\renewcommand{\listfigurename}{Índice de Figuras}
\renewcommand{\listfigurename}{Índice de Figuras}
\renewcommand{\listtablename}{Índice de Tablas}
\renewcommand{\figurename}{Figura}
\renewcommand{\tablename}{Tabla}
\renewcommand{\bibname}{Referencias bibliográficas}
\renewcommand{\appendixname}{Apéndices}
\renewcommand{\appendixtocname}{Apéndices}
\renewcommand{\appendixpagename}{Apéndices}}

%\listofgraficos
%\DeclareCaptionType{grafico}[Gr\'afico][\'Indice de Gr\'aficos]

\raggedbottom

\setcounter{tocdepth}{4}
\setcounter{secnumdepth}{4}







\begin{document}

\begin{longtable}{lp{.7\linewidth}}
  \caption{Respuestas a la pregunta 10 del cuestionario final de
    evaluación:\\ incluir respuesta a la pregunta 10 / incluir respuesta   } \label{tab:respuestas-preg-10-espanoles} \\
  \toprule
   \textbf{Participante} & \textbf{Respuesta} \\
  \midrule
 \endfirsthead
  \caption[]{Respuestas a la pregunta 10 del cuestionario final de
    evaluación:\\ incluir respuesta a la pregunta 10 / incluir respuesta   } \\
  \toprule
   \textbf{Participante} & \textbf{Respuesta} \\
  \midrule
 \endhead
  \midrule
    &\hfill\emph{continuación} \\
  \bottomrule
 \endfoot
  \bottomrule
 \endlastfoot
1&Einst war Großbritannien die vorherrschende Weltmacht. Im Kampf mit
Portugal, Spanien, Frankreich und den Niederlanden eroberte das
British Empire Gebiete, die zu Hochzeiten fast ein Viertel der Erde
bedeckten. Heute erinnern nur noch 14 kleine Außenposten an die
koloniale Vergangenheit. Der Fotograf Jon Tonks hat sie besucht: Oft
Tausende Meilen vom Festland entfernt, sind die Insulaner britisch –
immer noch und mit Leidenschaft.\\

1&Einst war Großbritannien die vorherrschende Weltmacht. Im Kampf mit
Portugal, Spanien, Frankreich und den Niederlanden eroberte das
British Empire Gebiete, die zu Hochzeiten fast ein Viertel der Erde
bedeckten. Heute erinnern nur noch 14 kleine Außenposten an die
koloniale Vergangenheit. Der Fotograf Jon Tonks hat sie besucht: Oft
Tausende Meilen vom Festland entfernt, sind die Insulaner britisch –
immer noch und mit Leidenschaft.\\


1&Einst war Großbritannien die vorherrschende Weltmacht. Im Kampf mit
Portugal, Spanien, Frankreich und den Niederlanden eroberte das
British Empire Gebiete, die zu Hochzeiten fast ein Viertel der Erde
bedeckten. Heute erinnern nur noch 14 kleine Außenposten an die
koloniale Vergangenheit. Der Fotograf Jon Tonks hat sie besucht: Oft
Tausende Meilen vom Festland entfernt, sind die Insulaner britisch –
immer noch und mit Leidenschaft.\\






1&Einst war Großbritannien die vorherrschende Weltmacht. Im Kampf mit
Portugal, Spanien, Frankreich und den Niederlanden eroberte das
British Empire Gebiete, die zu Hochzeiten fast ein Viertel der Erde
bedeckten. Heute erinnern nur noch 14 kleine Außenposten an die
koloniale Vergangenheit. Der Fotograf Jon Tonks hat sie besucht: Oft
Tausende Meilen vom Festland entfernt, sind die Insulaner britisch –
immer noch und mit Leidenschaft.\\

1&Einst war Großbritannien die vorherrschende Weltmacht. Im Kampf mit
Portugal, Spanien, Frankreich und den Niederlanden eroberte das
British Empire Gebiete, die zu Hochzeiten fast ein Viertel der Erde
bedeckten. Heute erinnern nur noch 14 kleine Außenposten an die
koloniale Vergangenheit. Der Fotograf Jon Tonks hat sie besucht: Oft
Tausende Meilen vom Festland entfernt, sind die Insulaner britisch –
immer noch und mit Leidenschaft.\\




\end{longtable}
\end{document}













%%% emacs stuff %%%
%%% Local Variables:
%%% TeX-PDF-mode: t
%%% mode: auto-fill
%%% ispell-local-dictionary: "castellano8"
%%% eval: (set-input-method "spanish-prefix")
%%% TeX-master: t
%%% End:
Ubuntu 13.10 + Tex Live 2013 + Texmaker / Windows 7 Pro + MikTex 2.9 + TexnicCenter / Android 4.3 + TexPortal + DroidEdit
marie2011
Posts: 138
Joined: Mon Feb 06, 2012 4:58 pm

problems with the legend of a long table

Post by marie2011 »

Hallo Clemens and Hugovdberg,

Many thanks for your answers and help. Everything works fine now :)

Best regards,

Marie
Post Reply