Three different captions: longtable












7















My problem is that I have tables that are three pages long. Thus, I would like to have three different captions when using the longtable package.



The similar question How to use a longtable with only one entry in the list of tables does not solve my problem. As far as I know this is how we could use longtable regarded this matter:



caption{Example of longtable}
endfirsthead
caption{Continued}
endhead


However, if the table occupies three pages, so that's how the captions are:




Table 2.1 - Example of longtable (page 1)



Table 2.1 - Continued (page 2)



Table 2.1 - Continued (page 3)




In other words, I can not get different captions for the second and third pages. That's what I want and that's the problem.










share|improve this question

























  • Welcome to TeX.sx! We closed your question as it seems to be a duplicate, also to prevent duplicate answers. Please have a look at the answers to the other question linked above. If your question is different, please edit it to show that, we could reopen it for you if desired.

    – Stefan Kottwitz
    Dec 30 '11 at 15:32











  • Sant, I reopened the question now. I also took the liberty to fix some formatting things and brought in a suitable form. You might want to check if it is ok like this. @StefanKottwitz

    – Martin Scharrer
    Dec 30 '11 at 16:38
















7















My problem is that I have tables that are three pages long. Thus, I would like to have three different captions when using the longtable package.



The similar question How to use a longtable with only one entry in the list of tables does not solve my problem. As far as I know this is how we could use longtable regarded this matter:



caption{Example of longtable}
endfirsthead
caption{Continued}
endhead


However, if the table occupies three pages, so that's how the captions are:




Table 2.1 - Example of longtable (page 1)



Table 2.1 - Continued (page 2)



Table 2.1 - Continued (page 3)




In other words, I can not get different captions for the second and third pages. That's what I want and that's the problem.










share|improve this question

























  • Welcome to TeX.sx! We closed your question as it seems to be a duplicate, also to prevent duplicate answers. Please have a look at the answers to the other question linked above. If your question is different, please edit it to show that, we could reopen it for you if desired.

    – Stefan Kottwitz
    Dec 30 '11 at 15:32











  • Sant, I reopened the question now. I also took the liberty to fix some formatting things and brought in a suitable form. You might want to check if it is ok like this. @StefanKottwitz

    – Martin Scharrer
    Dec 30 '11 at 16:38














7












7








7








My problem is that I have tables that are three pages long. Thus, I would like to have three different captions when using the longtable package.



The similar question How to use a longtable with only one entry in the list of tables does not solve my problem. As far as I know this is how we could use longtable regarded this matter:



caption{Example of longtable}
endfirsthead
caption{Continued}
endhead


However, if the table occupies three pages, so that's how the captions are:




Table 2.1 - Example of longtable (page 1)



Table 2.1 - Continued (page 2)



Table 2.1 - Continued (page 3)




In other words, I can not get different captions for the second and third pages. That's what I want and that's the problem.










share|improve this question
















My problem is that I have tables that are three pages long. Thus, I would like to have three different captions when using the longtable package.



The similar question How to use a longtable with only one entry in the list of tables does not solve my problem. As far as I know this is how we could use longtable regarded this matter:



caption{Example of longtable}
endfirsthead
caption{Continued}
endhead


However, if the table occupies three pages, so that's how the captions are:




Table 2.1 - Example of longtable (page 1)



Table 2.1 - Continued (page 2)



Table 2.1 - Continued (page 3)




In other words, I can not get different captions for the second and third pages. That's what I want and that's the problem.







captions longtable






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 13 '17 at 12:35









Community

1




1










asked Dec 30 '11 at 15:01









SantSant

3613




3613













  • Welcome to TeX.sx! We closed your question as it seems to be a duplicate, also to prevent duplicate answers. Please have a look at the answers to the other question linked above. If your question is different, please edit it to show that, we could reopen it for you if desired.

    – Stefan Kottwitz
    Dec 30 '11 at 15:32











  • Sant, I reopened the question now. I also took the liberty to fix some formatting things and brought in a suitable form. You might want to check if it is ok like this. @StefanKottwitz

    – Martin Scharrer
    Dec 30 '11 at 16:38



















  • Welcome to TeX.sx! We closed your question as it seems to be a duplicate, also to prevent duplicate answers. Please have a look at the answers to the other question linked above. If your question is different, please edit it to show that, we could reopen it for you if desired.

    – Stefan Kottwitz
    Dec 30 '11 at 15:32











  • Sant, I reopened the question now. I also took the liberty to fix some formatting things and brought in a suitable form. You might want to check if it is ok like this. @StefanKottwitz

    – Martin Scharrer
    Dec 30 '11 at 16:38

















Welcome to TeX.sx! We closed your question as it seems to be a duplicate, also to prevent duplicate answers. Please have a look at the answers to the other question linked above. If your question is different, please edit it to show that, we could reopen it for you if desired.

– Stefan Kottwitz
Dec 30 '11 at 15:32





Welcome to TeX.sx! We closed your question as it seems to be a duplicate, also to prevent duplicate answers. Please have a look at the answers to the other question linked above. If your question is different, please edit it to show that, we could reopen it for you if desired.

– Stefan Kottwitz
Dec 30 '11 at 15:32













Sant, I reopened the question now. I also took the liberty to fix some formatting things and brought in a suitable form. You might want to check if it is ok like this. @StefanKottwitz

– Martin Scharrer
Dec 30 '11 at 16:38





Sant, I reopened the question now. I also took the liberty to fix some formatting things and brought in a suitable form. You might want to check if it is ok like this. @StefanKottwitz

– Martin Scharrer
Dec 30 '11 at 16:38










1 Answer
1






active

oldest

votes


















5














longtable has two settings for the headers of the table: endfirsthead and endhead. The contents of endfirsthead will be saved in the save box LT@firsthead and the contents of endhead in LT@head. If the box LT@firsthead is empty, longtable uses the contents of LT@head. The same procedure will be used for the footer. In the same way I defined a endsecondhead



defendsecondhead{LT@end@hd@ftLT@secondhead}


To use this command I have to define a new save box which will be set only on the second page.



newboxLT@secondhead


To make sure that only on the second page this box will be used I have to manipulate the output of longtable. Therefore I use a simple ifvoid clause.



ifvoidLT@secondhead
copyLT@headnobreak
else
boxLT@secondheadnobreak
fi


ifvoid tests whether the save box LT@secondhead is empty or not. If you set a second head, the box will be printed by box. This command prints the box and clears the box. So on the next page the test above is true. In this way you make sure that when no second head is defined the endhead will be used.



To allow for more than three different headings you must define new save boxes and extend the test.



documentclass{article}
usepackage{forloop,longtable}
newcounter{count}
setcounter{count}{1}
makeatletter
newboxLT@secondhead
defendsecondhead{LT@end@hd@ftLT@secondhead}
defLT@output{%
ifnumoutputpenalty <-@Mi
ifnumoutputpenalty > -LT@end@pen
LT@err{floats and marginpars not allowed in a longtable}@ehc
else
setboxz@vbox{unvbox@cclv}%
ifdim htLT@lastfoot>htLT@foot
dimen@pagegoal
advancedimen@-htLT@lastfoot
ifdimdimen@<htz@
setbox@cclvvbox{unvboxz@copyLT@footvss}%
@makecol
@outputpage
ifvoidLT@secondhead
setboxz@vbox{boxLT@head}%
else
setboxz@vbox{boxLT@secondhead}%
fi
fi
fi
global@colroom@colht
globalvsize@colht
vbox
{unvboxz@boxifvoidLT@lastfootLT@footelseLT@lastfootfi}%
fi
else
setbox@cclvvbox{unvbox@cclvcopyLT@footvss}%
@makecol
@outputpage
globalvsize@colroom
ifvoidLT@secondhead
copyLT@headnobreak
else
boxLT@secondheadnobreak
fi
fi}
makeatother


begin{document}
listoftables
section{section}
begin{longtable}{c}
caption{foo}\stepcounter{table}endfirsthead
caption{foo bar}\stepcounter{table}endsecondhead
caption{bar}\endhead
whiledo{value{count} < 100}{stepcounter{count}
arabic{count} \}
end{longtable}
end{document}





share|improve this answer


























  • This will work only for three page tables, though.

    – egreg
    Dec 30 '11 at 22:43











  • @egreg: The request were 3 ;-). For more you have to define more boxes which will influence the calculation.

    – Marco Daniel
    Dec 30 '11 at 22:45








  • 1





    Maybe you can specify it in your (very clever) answer.

    – egreg
    Dec 30 '11 at 22:47












Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f39657%2fthree-different-captions-longtable%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









5














longtable has two settings for the headers of the table: endfirsthead and endhead. The contents of endfirsthead will be saved in the save box LT@firsthead and the contents of endhead in LT@head. If the box LT@firsthead is empty, longtable uses the contents of LT@head. The same procedure will be used for the footer. In the same way I defined a endsecondhead



defendsecondhead{LT@end@hd@ftLT@secondhead}


To use this command I have to define a new save box which will be set only on the second page.



newboxLT@secondhead


To make sure that only on the second page this box will be used I have to manipulate the output of longtable. Therefore I use a simple ifvoid clause.



ifvoidLT@secondhead
copyLT@headnobreak
else
boxLT@secondheadnobreak
fi


ifvoid tests whether the save box LT@secondhead is empty or not. If you set a second head, the box will be printed by box. This command prints the box and clears the box. So on the next page the test above is true. In this way you make sure that when no second head is defined the endhead will be used.



To allow for more than three different headings you must define new save boxes and extend the test.



documentclass{article}
usepackage{forloop,longtable}
newcounter{count}
setcounter{count}{1}
makeatletter
newboxLT@secondhead
defendsecondhead{LT@end@hd@ftLT@secondhead}
defLT@output{%
ifnumoutputpenalty <-@Mi
ifnumoutputpenalty > -LT@end@pen
LT@err{floats and marginpars not allowed in a longtable}@ehc
else
setboxz@vbox{unvbox@cclv}%
ifdim htLT@lastfoot>htLT@foot
dimen@pagegoal
advancedimen@-htLT@lastfoot
ifdimdimen@<htz@
setbox@cclvvbox{unvboxz@copyLT@footvss}%
@makecol
@outputpage
ifvoidLT@secondhead
setboxz@vbox{boxLT@head}%
else
setboxz@vbox{boxLT@secondhead}%
fi
fi
fi
global@colroom@colht
globalvsize@colht
vbox
{unvboxz@boxifvoidLT@lastfootLT@footelseLT@lastfootfi}%
fi
else
setbox@cclvvbox{unvbox@cclvcopyLT@footvss}%
@makecol
@outputpage
globalvsize@colroom
ifvoidLT@secondhead
copyLT@headnobreak
else
boxLT@secondheadnobreak
fi
fi}
makeatother


begin{document}
listoftables
section{section}
begin{longtable}{c}
caption{foo}\stepcounter{table}endfirsthead
caption{foo bar}\stepcounter{table}endsecondhead
caption{bar}\endhead
whiledo{value{count} < 100}{stepcounter{count}
arabic{count} \}
end{longtable}
end{document}





share|improve this answer


























  • This will work only for three page tables, though.

    – egreg
    Dec 30 '11 at 22:43











  • @egreg: The request were 3 ;-). For more you have to define more boxes which will influence the calculation.

    – Marco Daniel
    Dec 30 '11 at 22:45








  • 1





    Maybe you can specify it in your (very clever) answer.

    – egreg
    Dec 30 '11 at 22:47
















5














longtable has two settings for the headers of the table: endfirsthead and endhead. The contents of endfirsthead will be saved in the save box LT@firsthead and the contents of endhead in LT@head. If the box LT@firsthead is empty, longtable uses the contents of LT@head. The same procedure will be used for the footer. In the same way I defined a endsecondhead



defendsecondhead{LT@end@hd@ftLT@secondhead}


To use this command I have to define a new save box which will be set only on the second page.



newboxLT@secondhead


To make sure that only on the second page this box will be used I have to manipulate the output of longtable. Therefore I use a simple ifvoid clause.



ifvoidLT@secondhead
copyLT@headnobreak
else
boxLT@secondheadnobreak
fi


ifvoid tests whether the save box LT@secondhead is empty or not. If you set a second head, the box will be printed by box. This command prints the box and clears the box. So on the next page the test above is true. In this way you make sure that when no second head is defined the endhead will be used.



To allow for more than three different headings you must define new save boxes and extend the test.



documentclass{article}
usepackage{forloop,longtable}
newcounter{count}
setcounter{count}{1}
makeatletter
newboxLT@secondhead
defendsecondhead{LT@end@hd@ftLT@secondhead}
defLT@output{%
ifnumoutputpenalty <-@Mi
ifnumoutputpenalty > -LT@end@pen
LT@err{floats and marginpars not allowed in a longtable}@ehc
else
setboxz@vbox{unvbox@cclv}%
ifdim htLT@lastfoot>htLT@foot
dimen@pagegoal
advancedimen@-htLT@lastfoot
ifdimdimen@<htz@
setbox@cclvvbox{unvboxz@copyLT@footvss}%
@makecol
@outputpage
ifvoidLT@secondhead
setboxz@vbox{boxLT@head}%
else
setboxz@vbox{boxLT@secondhead}%
fi
fi
fi
global@colroom@colht
globalvsize@colht
vbox
{unvboxz@boxifvoidLT@lastfootLT@footelseLT@lastfootfi}%
fi
else
setbox@cclvvbox{unvbox@cclvcopyLT@footvss}%
@makecol
@outputpage
globalvsize@colroom
ifvoidLT@secondhead
copyLT@headnobreak
else
boxLT@secondheadnobreak
fi
fi}
makeatother


begin{document}
listoftables
section{section}
begin{longtable}{c}
caption{foo}\stepcounter{table}endfirsthead
caption{foo bar}\stepcounter{table}endsecondhead
caption{bar}\endhead
whiledo{value{count} < 100}{stepcounter{count}
arabic{count} \}
end{longtable}
end{document}





share|improve this answer


























  • This will work only for three page tables, though.

    – egreg
    Dec 30 '11 at 22:43











  • @egreg: The request were 3 ;-). For more you have to define more boxes which will influence the calculation.

    – Marco Daniel
    Dec 30 '11 at 22:45








  • 1





    Maybe you can specify it in your (very clever) answer.

    – egreg
    Dec 30 '11 at 22:47














5












5








5







longtable has two settings for the headers of the table: endfirsthead and endhead. The contents of endfirsthead will be saved in the save box LT@firsthead and the contents of endhead in LT@head. If the box LT@firsthead is empty, longtable uses the contents of LT@head. The same procedure will be used for the footer. In the same way I defined a endsecondhead



defendsecondhead{LT@end@hd@ftLT@secondhead}


To use this command I have to define a new save box which will be set only on the second page.



newboxLT@secondhead


To make sure that only on the second page this box will be used I have to manipulate the output of longtable. Therefore I use a simple ifvoid clause.



ifvoidLT@secondhead
copyLT@headnobreak
else
boxLT@secondheadnobreak
fi


ifvoid tests whether the save box LT@secondhead is empty or not. If you set a second head, the box will be printed by box. This command prints the box and clears the box. So on the next page the test above is true. In this way you make sure that when no second head is defined the endhead will be used.



To allow for more than three different headings you must define new save boxes and extend the test.



documentclass{article}
usepackage{forloop,longtable}
newcounter{count}
setcounter{count}{1}
makeatletter
newboxLT@secondhead
defendsecondhead{LT@end@hd@ftLT@secondhead}
defLT@output{%
ifnumoutputpenalty <-@Mi
ifnumoutputpenalty > -LT@end@pen
LT@err{floats and marginpars not allowed in a longtable}@ehc
else
setboxz@vbox{unvbox@cclv}%
ifdim htLT@lastfoot>htLT@foot
dimen@pagegoal
advancedimen@-htLT@lastfoot
ifdimdimen@<htz@
setbox@cclvvbox{unvboxz@copyLT@footvss}%
@makecol
@outputpage
ifvoidLT@secondhead
setboxz@vbox{boxLT@head}%
else
setboxz@vbox{boxLT@secondhead}%
fi
fi
fi
global@colroom@colht
globalvsize@colht
vbox
{unvboxz@boxifvoidLT@lastfootLT@footelseLT@lastfootfi}%
fi
else
setbox@cclvvbox{unvbox@cclvcopyLT@footvss}%
@makecol
@outputpage
globalvsize@colroom
ifvoidLT@secondhead
copyLT@headnobreak
else
boxLT@secondheadnobreak
fi
fi}
makeatother


begin{document}
listoftables
section{section}
begin{longtable}{c}
caption{foo}\stepcounter{table}endfirsthead
caption{foo bar}\stepcounter{table}endsecondhead
caption{bar}\endhead
whiledo{value{count} < 100}{stepcounter{count}
arabic{count} \}
end{longtable}
end{document}





share|improve this answer















longtable has two settings for the headers of the table: endfirsthead and endhead. The contents of endfirsthead will be saved in the save box LT@firsthead and the contents of endhead in LT@head. If the box LT@firsthead is empty, longtable uses the contents of LT@head. The same procedure will be used for the footer. In the same way I defined a endsecondhead



defendsecondhead{LT@end@hd@ftLT@secondhead}


To use this command I have to define a new save box which will be set only on the second page.



newboxLT@secondhead


To make sure that only on the second page this box will be used I have to manipulate the output of longtable. Therefore I use a simple ifvoid clause.



ifvoidLT@secondhead
copyLT@headnobreak
else
boxLT@secondheadnobreak
fi


ifvoid tests whether the save box LT@secondhead is empty or not. If you set a second head, the box will be printed by box. This command prints the box and clears the box. So on the next page the test above is true. In this way you make sure that when no second head is defined the endhead will be used.



To allow for more than three different headings you must define new save boxes and extend the test.



documentclass{article}
usepackage{forloop,longtable}
newcounter{count}
setcounter{count}{1}
makeatletter
newboxLT@secondhead
defendsecondhead{LT@end@hd@ftLT@secondhead}
defLT@output{%
ifnumoutputpenalty <-@Mi
ifnumoutputpenalty > -LT@end@pen
LT@err{floats and marginpars not allowed in a longtable}@ehc
else
setboxz@vbox{unvbox@cclv}%
ifdim htLT@lastfoot>htLT@foot
dimen@pagegoal
advancedimen@-htLT@lastfoot
ifdimdimen@<htz@
setbox@cclvvbox{unvboxz@copyLT@footvss}%
@makecol
@outputpage
ifvoidLT@secondhead
setboxz@vbox{boxLT@head}%
else
setboxz@vbox{boxLT@secondhead}%
fi
fi
fi
global@colroom@colht
globalvsize@colht
vbox
{unvboxz@boxifvoidLT@lastfootLT@footelseLT@lastfootfi}%
fi
else
setbox@cclvvbox{unvbox@cclvcopyLT@footvss}%
@makecol
@outputpage
globalvsize@colroom
ifvoidLT@secondhead
copyLT@headnobreak
else
boxLT@secondheadnobreak
fi
fi}
makeatother


begin{document}
listoftables
section{section}
begin{longtable}{c}
caption{foo}\stepcounter{table}endfirsthead
caption{foo bar}\stepcounter{table}endsecondhead
caption{bar}\endhead
whiledo{value{count} < 100}{stepcounter{count}
arabic{count} \}
end{longtable}
end{document}






share|improve this answer














share|improve this answer



share|improve this answer








edited Dec 30 '11 at 23:34









egreg

731k8919303250




731k8919303250










answered Dec 30 '11 at 19:09









Marco DanielMarco Daniel

78.5k13223388




78.5k13223388













  • This will work only for three page tables, though.

    – egreg
    Dec 30 '11 at 22:43











  • @egreg: The request were 3 ;-). For more you have to define more boxes which will influence the calculation.

    – Marco Daniel
    Dec 30 '11 at 22:45








  • 1





    Maybe you can specify it in your (very clever) answer.

    – egreg
    Dec 30 '11 at 22:47



















  • This will work only for three page tables, though.

    – egreg
    Dec 30 '11 at 22:43











  • @egreg: The request were 3 ;-). For more you have to define more boxes which will influence the calculation.

    – Marco Daniel
    Dec 30 '11 at 22:45








  • 1





    Maybe you can specify it in your (very clever) answer.

    – egreg
    Dec 30 '11 at 22:47

















This will work only for three page tables, though.

– egreg
Dec 30 '11 at 22:43





This will work only for three page tables, though.

– egreg
Dec 30 '11 at 22:43













@egreg: The request were 3 ;-). For more you have to define more boxes which will influence the calculation.

– Marco Daniel
Dec 30 '11 at 22:45







@egreg: The request were 3 ;-). For more you have to define more boxes which will influence the calculation.

– Marco Daniel
Dec 30 '11 at 22:45






1




1





Maybe you can specify it in your (very clever) answer.

– egreg
Dec 30 '11 at 22:47





Maybe you can specify it in your (very clever) answer.

– egreg
Dec 30 '11 at 22:47


















draft saved

draft discarded




















































Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f39657%2fthree-different-captions-longtable%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

mysqli_query(): Empty query in /home/lucindabrummitt/public_html/blog/wp-includes/wp-db.php on line 1924

How to change which sound is reproduced for terminal bell?

Can I use Tabulator js library in my java Spring + Thymeleaf project?