Additional short TOC in scrbook
Visibly the KOMA class lacks the possibility to add a second, e.g. short, table of contents (TOC), while memoir does as in the following adopted example.
See also Include Detailed Contents entry in short TOC?
Nevertheless I want to use it in scrbook
but then the detailed TOC is not printed.
Does someone know an implementation that works with pdfpages
?
documentclass{scrbook}
begin{document}
{renewcommand*{contentsname}{Short Contents}
setcounter{tocdepth}{0}
tableofcontents
}
tableofcontents
chapter{Intro}
section{Sub A}
section{Sub B}
end{document}
Comment
The use of the package pdfpages
(with addtotoc=...
) seems to be incompatible with etoc
, which itself could serve as a solution.
table-of-contents koma-script
add a comment |
Visibly the KOMA class lacks the possibility to add a second, e.g. short, table of contents (TOC), while memoir does as in the following adopted example.
See also Include Detailed Contents entry in short TOC?
Nevertheless I want to use it in scrbook
but then the detailed TOC is not printed.
Does someone know an implementation that works with pdfpages
?
documentclass{scrbook}
begin{document}
{renewcommand*{contentsname}{Short Contents}
setcounter{tocdepth}{0}
tableofcontents
}
tableofcontents
chapter{Intro}
section{Sub A}
section{Sub B}
end{document}
Comment
The use of the package pdfpages
(with addtotoc=...
) seems to be incompatible with etoc
, which itself could serve as a solution.
table-of-contents koma-script
add a comment |
Visibly the KOMA class lacks the possibility to add a second, e.g. short, table of contents (TOC), while memoir does as in the following adopted example.
See also Include Detailed Contents entry in short TOC?
Nevertheless I want to use it in scrbook
but then the detailed TOC is not printed.
Does someone know an implementation that works with pdfpages
?
documentclass{scrbook}
begin{document}
{renewcommand*{contentsname}{Short Contents}
setcounter{tocdepth}{0}
tableofcontents
}
tableofcontents
chapter{Intro}
section{Sub A}
section{Sub B}
end{document}
Comment
The use of the package pdfpages
(with addtotoc=...
) seems to be incompatible with etoc
, which itself could serve as a solution.
table-of-contents koma-script
Visibly the KOMA class lacks the possibility to add a second, e.g. short, table of contents (TOC), while memoir does as in the following adopted example.
See also Include Detailed Contents entry in short TOC?
Nevertheless I want to use it in scrbook
but then the detailed TOC is not printed.
Does someone know an implementation that works with pdfpages
?
documentclass{scrbook}
begin{document}
{renewcommand*{contentsname}{Short Contents}
setcounter{tocdepth}{0}
tableofcontents
}
tableofcontents
chapter{Intro}
section{Sub A}
section{Sub B}
end{document}
Comment
The use of the package pdfpages
(with addtotoc=...
) seems to be incompatible with etoc
, which itself could serve as a solution.
table-of-contents koma-script
table-of-contents koma-script
asked Dec 30 '18 at 12:46
strpeterstrpeter
2,58921955
2,58921955
add a comment |
add a comment |
4 Answers
4
active
oldest
votes
You could use KOMA-Script package scrwfile
:
documentclass{scrbook}
usepackage[english]{babel}
usepackage{scrwfile}
TOCclone[Short Contents]{toc}{stoc}
addtocontents{stoc}{protectvalue{tocdepth}=0}% or BeforeStartingTOC[stoc]{value{tocdepth}=0}
begin{document}
listofstoc
tableofcontents
chapter{Intro}
section{Sub A}
section{Sub B}
end{document}
Another possibility is patching addtocentrydefault
to write all ToC entries in a new file with the extension .stoc
.
documentclass{scrbook}
usepackage[english]{babel}
addtotoclist[jobname]{stoc}
BeforeStartingTOC[stoc]{value{tocdepth}=0}
usepackage{xpatch}
xapptocmdaddtocentrydefault
{addxcontentsline{stoc}{#1}[#2]{#3}}
{}{PatchFailed}
begin{document}
listoftoc[Short Contents]{stoc}
tableofcontents
chapter{Intro}
section{Sub A}
section{Sub B}
addchap{Test}
end{document}
If the TOC should get an entry in the "Short Contents" add the following lines to the preamble of the examples above:
BeforeStartingTOC[toc]{%
addxcontentsline{stoc}{chapter}{protectcontentsname}%
}
add a comment |
Use the technique from this post. As you want it to work with babel you have to take care of babel commands.
It seems that including babel will also break the grouping of tocdepth
, so you might need to setcounter{tocdepth}{2}
before issuing your second tableofcontents
.
documentclass{scrbook}
usepackage[english]{babel}
begin{document}
{
makeatletter
renewcommand*{contentsname}{Short Contents}
setcounter{tocdepth}{0}
expandafterdefcsname @starttocendcsname#1{InputIfFileExists{jobname.#1}{}{}}tableofcontents
makeatother
}
tableofcontents
chapter{Intro}
section{Sub A}
section{Sub B}
end{document}
This solution seems incompatible with the packagebabel
. Try withusepackage[english]{babel}
.
– strpeter
Dec 30 '18 at 13:03
@strpeter No, it is not. You only have to take care of the obvious babel commands.
– TeXnician
Dec 30 '18 at 13:12
True it works! Great thank you. Could you explain a bit more in depth what the following command does?expandafterdefcsname @starttocendcsname#1{InputIfFileExists{jobname.#1}{}{}}
– strpeter
Dec 30 '18 at 13:30
2
@strpeter@starttoc
is the core piece oftableofcontents
and it is simply redefined to input the toc file if it exists. As it is now in a makeatletter context one would not even need the expandafter-csname magic here…
– TeXnician
Dec 30 '18 at 14:16
@strpeter A much better explanation and workaround is given in Schweinbacke's answer.
– TeXnician
Dec 30 '18 at 14:23
add a comment |
To read the toc
-file twice, you have to avoid to open it to write before the second reading. LaTeX's kernel macro @starttoc
, which is used by tableoofcontents
, usually also opens the file for writing. Loading scrwfile
as shown in esdd's answer already avoids opening files for writing when @starttoc
is used. Also local redefinition of @starttoc
as show in TeXnician's answer can be used to avoid the opening for writing. Another suggestion would be to deactivate LaTeX's opening of auxiliary files for writing, e.g.:
documentclass{scrbook}
usepackage[english]{babel}
usepackage{scrwfile}
usepackage{mwe}% provides Blinddocument
makeatletter
newcommand*{shorttableofcontents}{%
begingroup
value{tocdepth}=z@ % set tocdepth locally to zero
@fileswfalse % deactivate opening of auxiliary files
listoftoc[Short Contents]{ext@toc}%
endgroup
}
makeatother
begin{document}
shorttableofcontents% must be before tableofcontents
tableofcontents
Blinddocument
end{document}
Here KOMA-Script's listoftoc
is used to show the short version of the ToC. See the manual for more information.
However this suggestion would fail, if shorttableofcontents
would be used after tableofcontents
! And you cannot add extra entries to the short table of contents, that are not shown in the normal table of contents. If you need such things, esdd's answer would be the better suggestion.
However you could use another KOMA-Script macro to clone the main ToC:
documentclass{scrbook}
usepackage[english]{babel}
usepackage{scrwfile}
usepackage{mwe}% provides Blinddocument
DeclareNewTOC[%
listname={Short Contents},
]{stoc}
makeatletter
renewcommand{addtocentrydefault}[3]{%
expandaftertocbasic@addxcontentslineexpandafter{ext@toc}{#1}{#2}{#3}%
tocbasic@addxcontentsline{stoc}{#1}{#2}{#3}%
}
makeatother
BeforeStartingTOC[stoc]{value{tocdepth}=0relax}
letshorttableofcontentslistofstocs
begin{document}
shorttableofcontents
tableofcontents
Blinddocument
end{document}
KOMA-Script uses addtocentrydefault
to generate the ToC entries of all headings. But this does not work, if a package generates ToC entries without using addtocentryefault
e.g. using addcontentsline
directly.
Instead of redefining addtocentrydefault
you can try to patch it as shown in esdd's second suggestion.
add a comment |
ah sorry, posted this before seeing your pdfpages
comment. Maybe this should be topic of another question if there is incompatibility with etoc
? (a mwe showing the problem would be helpful)
documentclass{scrbook}
usepackage{etoc}
begin{document}
{renewcommand*{contentsname}{Short Contents}
etocsetnexttocdepth{chapter}
tableofcontents
}
tableofcontents
chapter{Intro}
section{Sub A}
section{Sub B}
end{document}
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f467899%2fadditional-short-toc-in-scrbook%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
You could use KOMA-Script package scrwfile
:
documentclass{scrbook}
usepackage[english]{babel}
usepackage{scrwfile}
TOCclone[Short Contents]{toc}{stoc}
addtocontents{stoc}{protectvalue{tocdepth}=0}% or BeforeStartingTOC[stoc]{value{tocdepth}=0}
begin{document}
listofstoc
tableofcontents
chapter{Intro}
section{Sub A}
section{Sub B}
end{document}
Another possibility is patching addtocentrydefault
to write all ToC entries in a new file with the extension .stoc
.
documentclass{scrbook}
usepackage[english]{babel}
addtotoclist[jobname]{stoc}
BeforeStartingTOC[stoc]{value{tocdepth}=0}
usepackage{xpatch}
xapptocmdaddtocentrydefault
{addxcontentsline{stoc}{#1}[#2]{#3}}
{}{PatchFailed}
begin{document}
listoftoc[Short Contents]{stoc}
tableofcontents
chapter{Intro}
section{Sub A}
section{Sub B}
addchap{Test}
end{document}
If the TOC should get an entry in the "Short Contents" add the following lines to the preamble of the examples above:
BeforeStartingTOC[toc]{%
addxcontentsline{stoc}{chapter}{protectcontentsname}%
}
add a comment |
You could use KOMA-Script package scrwfile
:
documentclass{scrbook}
usepackage[english]{babel}
usepackage{scrwfile}
TOCclone[Short Contents]{toc}{stoc}
addtocontents{stoc}{protectvalue{tocdepth}=0}% or BeforeStartingTOC[stoc]{value{tocdepth}=0}
begin{document}
listofstoc
tableofcontents
chapter{Intro}
section{Sub A}
section{Sub B}
end{document}
Another possibility is patching addtocentrydefault
to write all ToC entries in a new file with the extension .stoc
.
documentclass{scrbook}
usepackage[english]{babel}
addtotoclist[jobname]{stoc}
BeforeStartingTOC[stoc]{value{tocdepth}=0}
usepackage{xpatch}
xapptocmdaddtocentrydefault
{addxcontentsline{stoc}{#1}[#2]{#3}}
{}{PatchFailed}
begin{document}
listoftoc[Short Contents]{stoc}
tableofcontents
chapter{Intro}
section{Sub A}
section{Sub B}
addchap{Test}
end{document}
If the TOC should get an entry in the "Short Contents" add the following lines to the preamble of the examples above:
BeforeStartingTOC[toc]{%
addxcontentsline{stoc}{chapter}{protectcontentsname}%
}
add a comment |
You could use KOMA-Script package scrwfile
:
documentclass{scrbook}
usepackage[english]{babel}
usepackage{scrwfile}
TOCclone[Short Contents]{toc}{stoc}
addtocontents{stoc}{protectvalue{tocdepth}=0}% or BeforeStartingTOC[stoc]{value{tocdepth}=0}
begin{document}
listofstoc
tableofcontents
chapter{Intro}
section{Sub A}
section{Sub B}
end{document}
Another possibility is patching addtocentrydefault
to write all ToC entries in a new file with the extension .stoc
.
documentclass{scrbook}
usepackage[english]{babel}
addtotoclist[jobname]{stoc}
BeforeStartingTOC[stoc]{value{tocdepth}=0}
usepackage{xpatch}
xapptocmdaddtocentrydefault
{addxcontentsline{stoc}{#1}[#2]{#3}}
{}{PatchFailed}
begin{document}
listoftoc[Short Contents]{stoc}
tableofcontents
chapter{Intro}
section{Sub A}
section{Sub B}
addchap{Test}
end{document}
If the TOC should get an entry in the "Short Contents" add the following lines to the preamble of the examples above:
BeforeStartingTOC[toc]{%
addxcontentsline{stoc}{chapter}{protectcontentsname}%
}
You could use KOMA-Script package scrwfile
:
documentclass{scrbook}
usepackage[english]{babel}
usepackage{scrwfile}
TOCclone[Short Contents]{toc}{stoc}
addtocontents{stoc}{protectvalue{tocdepth}=0}% or BeforeStartingTOC[stoc]{value{tocdepth}=0}
begin{document}
listofstoc
tableofcontents
chapter{Intro}
section{Sub A}
section{Sub B}
end{document}
Another possibility is patching addtocentrydefault
to write all ToC entries in a new file with the extension .stoc
.
documentclass{scrbook}
usepackage[english]{babel}
addtotoclist[jobname]{stoc}
BeforeStartingTOC[stoc]{value{tocdepth}=0}
usepackage{xpatch}
xapptocmdaddtocentrydefault
{addxcontentsline{stoc}{#1}[#2]{#3}}
{}{PatchFailed}
begin{document}
listoftoc[Short Contents]{stoc}
tableofcontents
chapter{Intro}
section{Sub A}
section{Sub B}
addchap{Test}
end{document}
If the TOC should get an entry in the "Short Contents" add the following lines to the preamble of the examples above:
BeforeStartingTOC[toc]{%
addxcontentsline{stoc}{chapter}{protectcontentsname}%
}
edited Dec 31 '18 at 11:25
answered Dec 30 '18 at 13:28
esddesdd
58.7k34588
58.7k34588
add a comment |
add a comment |
Use the technique from this post. As you want it to work with babel you have to take care of babel commands.
It seems that including babel will also break the grouping of tocdepth
, so you might need to setcounter{tocdepth}{2}
before issuing your second tableofcontents
.
documentclass{scrbook}
usepackage[english]{babel}
begin{document}
{
makeatletter
renewcommand*{contentsname}{Short Contents}
setcounter{tocdepth}{0}
expandafterdefcsname @starttocendcsname#1{InputIfFileExists{jobname.#1}{}{}}tableofcontents
makeatother
}
tableofcontents
chapter{Intro}
section{Sub A}
section{Sub B}
end{document}
This solution seems incompatible with the packagebabel
. Try withusepackage[english]{babel}
.
– strpeter
Dec 30 '18 at 13:03
@strpeter No, it is not. You only have to take care of the obvious babel commands.
– TeXnician
Dec 30 '18 at 13:12
True it works! Great thank you. Could you explain a bit more in depth what the following command does?expandafterdefcsname @starttocendcsname#1{InputIfFileExists{jobname.#1}{}{}}
– strpeter
Dec 30 '18 at 13:30
2
@strpeter@starttoc
is the core piece oftableofcontents
and it is simply redefined to input the toc file if it exists. As it is now in a makeatletter context one would not even need the expandafter-csname magic here…
– TeXnician
Dec 30 '18 at 14:16
@strpeter A much better explanation and workaround is given in Schweinbacke's answer.
– TeXnician
Dec 30 '18 at 14:23
add a comment |
Use the technique from this post. As you want it to work with babel you have to take care of babel commands.
It seems that including babel will also break the grouping of tocdepth
, so you might need to setcounter{tocdepth}{2}
before issuing your second tableofcontents
.
documentclass{scrbook}
usepackage[english]{babel}
begin{document}
{
makeatletter
renewcommand*{contentsname}{Short Contents}
setcounter{tocdepth}{0}
expandafterdefcsname @starttocendcsname#1{InputIfFileExists{jobname.#1}{}{}}tableofcontents
makeatother
}
tableofcontents
chapter{Intro}
section{Sub A}
section{Sub B}
end{document}
This solution seems incompatible with the packagebabel
. Try withusepackage[english]{babel}
.
– strpeter
Dec 30 '18 at 13:03
@strpeter No, it is not. You only have to take care of the obvious babel commands.
– TeXnician
Dec 30 '18 at 13:12
True it works! Great thank you. Could you explain a bit more in depth what the following command does?expandafterdefcsname @starttocendcsname#1{InputIfFileExists{jobname.#1}{}{}}
– strpeter
Dec 30 '18 at 13:30
2
@strpeter@starttoc
is the core piece oftableofcontents
and it is simply redefined to input the toc file if it exists. As it is now in a makeatletter context one would not even need the expandafter-csname magic here…
– TeXnician
Dec 30 '18 at 14:16
@strpeter A much better explanation and workaround is given in Schweinbacke's answer.
– TeXnician
Dec 30 '18 at 14:23
add a comment |
Use the technique from this post. As you want it to work with babel you have to take care of babel commands.
It seems that including babel will also break the grouping of tocdepth
, so you might need to setcounter{tocdepth}{2}
before issuing your second tableofcontents
.
documentclass{scrbook}
usepackage[english]{babel}
begin{document}
{
makeatletter
renewcommand*{contentsname}{Short Contents}
setcounter{tocdepth}{0}
expandafterdefcsname @starttocendcsname#1{InputIfFileExists{jobname.#1}{}{}}tableofcontents
makeatother
}
tableofcontents
chapter{Intro}
section{Sub A}
section{Sub B}
end{document}
Use the technique from this post. As you want it to work with babel you have to take care of babel commands.
It seems that including babel will also break the grouping of tocdepth
, so you might need to setcounter{tocdepth}{2}
before issuing your second tableofcontents
.
documentclass{scrbook}
usepackage[english]{babel}
begin{document}
{
makeatletter
renewcommand*{contentsname}{Short Contents}
setcounter{tocdepth}{0}
expandafterdefcsname @starttocendcsname#1{InputIfFileExists{jobname.#1}{}{}}tableofcontents
makeatother
}
tableofcontents
chapter{Intro}
section{Sub A}
section{Sub B}
end{document}
edited Dec 30 '18 at 13:11
answered Dec 30 '18 at 12:52
TeXnicianTeXnician
24.7k63187
24.7k63187
This solution seems incompatible with the packagebabel
. Try withusepackage[english]{babel}
.
– strpeter
Dec 30 '18 at 13:03
@strpeter No, it is not. You only have to take care of the obvious babel commands.
– TeXnician
Dec 30 '18 at 13:12
True it works! Great thank you. Could you explain a bit more in depth what the following command does?expandafterdefcsname @starttocendcsname#1{InputIfFileExists{jobname.#1}{}{}}
– strpeter
Dec 30 '18 at 13:30
2
@strpeter@starttoc
is the core piece oftableofcontents
and it is simply redefined to input the toc file if it exists. As it is now in a makeatletter context one would not even need the expandafter-csname magic here…
– TeXnician
Dec 30 '18 at 14:16
@strpeter A much better explanation and workaround is given in Schweinbacke's answer.
– TeXnician
Dec 30 '18 at 14:23
add a comment |
This solution seems incompatible with the packagebabel
. Try withusepackage[english]{babel}
.
– strpeter
Dec 30 '18 at 13:03
@strpeter No, it is not. You only have to take care of the obvious babel commands.
– TeXnician
Dec 30 '18 at 13:12
True it works! Great thank you. Could you explain a bit more in depth what the following command does?expandafterdefcsname @starttocendcsname#1{InputIfFileExists{jobname.#1}{}{}}
– strpeter
Dec 30 '18 at 13:30
2
@strpeter@starttoc
is the core piece oftableofcontents
and it is simply redefined to input the toc file if it exists. As it is now in a makeatletter context one would not even need the expandafter-csname magic here…
– TeXnician
Dec 30 '18 at 14:16
@strpeter A much better explanation and workaround is given in Schweinbacke's answer.
– TeXnician
Dec 30 '18 at 14:23
This solution seems incompatible with the package
babel
. Try with usepackage[english]{babel}
.– strpeter
Dec 30 '18 at 13:03
This solution seems incompatible with the package
babel
. Try with usepackage[english]{babel}
.– strpeter
Dec 30 '18 at 13:03
@strpeter No, it is not. You only have to take care of the obvious babel commands.
– TeXnician
Dec 30 '18 at 13:12
@strpeter No, it is not. You only have to take care of the obvious babel commands.
– TeXnician
Dec 30 '18 at 13:12
True it works! Great thank you. Could you explain a bit more in depth what the following command does?
expandafterdefcsname @starttocendcsname#1{InputIfFileExists{jobname.#1}{}{}}
– strpeter
Dec 30 '18 at 13:30
True it works! Great thank you. Could you explain a bit more in depth what the following command does?
expandafterdefcsname @starttocendcsname#1{InputIfFileExists{jobname.#1}{}{}}
– strpeter
Dec 30 '18 at 13:30
2
2
@strpeter
@starttoc
is the core piece of tableofcontents
and it is simply redefined to input the toc file if it exists. As it is now in a makeatletter context one would not even need the expandafter-csname magic here…– TeXnician
Dec 30 '18 at 14:16
@strpeter
@starttoc
is the core piece of tableofcontents
and it is simply redefined to input the toc file if it exists. As it is now in a makeatletter context one would not even need the expandafter-csname magic here…– TeXnician
Dec 30 '18 at 14:16
@strpeter A much better explanation and workaround is given in Schweinbacke's answer.
– TeXnician
Dec 30 '18 at 14:23
@strpeter A much better explanation and workaround is given in Schweinbacke's answer.
– TeXnician
Dec 30 '18 at 14:23
add a comment |
To read the toc
-file twice, you have to avoid to open it to write before the second reading. LaTeX's kernel macro @starttoc
, which is used by tableoofcontents
, usually also opens the file for writing. Loading scrwfile
as shown in esdd's answer already avoids opening files for writing when @starttoc
is used. Also local redefinition of @starttoc
as show in TeXnician's answer can be used to avoid the opening for writing. Another suggestion would be to deactivate LaTeX's opening of auxiliary files for writing, e.g.:
documentclass{scrbook}
usepackage[english]{babel}
usepackage{scrwfile}
usepackage{mwe}% provides Blinddocument
makeatletter
newcommand*{shorttableofcontents}{%
begingroup
value{tocdepth}=z@ % set tocdepth locally to zero
@fileswfalse % deactivate opening of auxiliary files
listoftoc[Short Contents]{ext@toc}%
endgroup
}
makeatother
begin{document}
shorttableofcontents% must be before tableofcontents
tableofcontents
Blinddocument
end{document}
Here KOMA-Script's listoftoc
is used to show the short version of the ToC. See the manual for more information.
However this suggestion would fail, if shorttableofcontents
would be used after tableofcontents
! And you cannot add extra entries to the short table of contents, that are not shown in the normal table of contents. If you need such things, esdd's answer would be the better suggestion.
However you could use another KOMA-Script macro to clone the main ToC:
documentclass{scrbook}
usepackage[english]{babel}
usepackage{scrwfile}
usepackage{mwe}% provides Blinddocument
DeclareNewTOC[%
listname={Short Contents},
]{stoc}
makeatletter
renewcommand{addtocentrydefault}[3]{%
expandaftertocbasic@addxcontentslineexpandafter{ext@toc}{#1}{#2}{#3}%
tocbasic@addxcontentsline{stoc}{#1}{#2}{#3}%
}
makeatother
BeforeStartingTOC[stoc]{value{tocdepth}=0relax}
letshorttableofcontentslistofstocs
begin{document}
shorttableofcontents
tableofcontents
Blinddocument
end{document}
KOMA-Script uses addtocentrydefault
to generate the ToC entries of all headings. But this does not work, if a package generates ToC entries without using addtocentryefault
e.g. using addcontentsline
directly.
Instead of redefining addtocentrydefault
you can try to patch it as shown in esdd's second suggestion.
add a comment |
To read the toc
-file twice, you have to avoid to open it to write before the second reading. LaTeX's kernel macro @starttoc
, which is used by tableoofcontents
, usually also opens the file for writing. Loading scrwfile
as shown in esdd's answer already avoids opening files for writing when @starttoc
is used. Also local redefinition of @starttoc
as show in TeXnician's answer can be used to avoid the opening for writing. Another suggestion would be to deactivate LaTeX's opening of auxiliary files for writing, e.g.:
documentclass{scrbook}
usepackage[english]{babel}
usepackage{scrwfile}
usepackage{mwe}% provides Blinddocument
makeatletter
newcommand*{shorttableofcontents}{%
begingroup
value{tocdepth}=z@ % set tocdepth locally to zero
@fileswfalse % deactivate opening of auxiliary files
listoftoc[Short Contents]{ext@toc}%
endgroup
}
makeatother
begin{document}
shorttableofcontents% must be before tableofcontents
tableofcontents
Blinddocument
end{document}
Here KOMA-Script's listoftoc
is used to show the short version of the ToC. See the manual for more information.
However this suggestion would fail, if shorttableofcontents
would be used after tableofcontents
! And you cannot add extra entries to the short table of contents, that are not shown in the normal table of contents. If you need such things, esdd's answer would be the better suggestion.
However you could use another KOMA-Script macro to clone the main ToC:
documentclass{scrbook}
usepackage[english]{babel}
usepackage{scrwfile}
usepackage{mwe}% provides Blinddocument
DeclareNewTOC[%
listname={Short Contents},
]{stoc}
makeatletter
renewcommand{addtocentrydefault}[3]{%
expandaftertocbasic@addxcontentslineexpandafter{ext@toc}{#1}{#2}{#3}%
tocbasic@addxcontentsline{stoc}{#1}{#2}{#3}%
}
makeatother
BeforeStartingTOC[stoc]{value{tocdepth}=0relax}
letshorttableofcontentslistofstocs
begin{document}
shorttableofcontents
tableofcontents
Blinddocument
end{document}
KOMA-Script uses addtocentrydefault
to generate the ToC entries of all headings. But this does not work, if a package generates ToC entries without using addtocentryefault
e.g. using addcontentsline
directly.
Instead of redefining addtocentrydefault
you can try to patch it as shown in esdd's second suggestion.
add a comment |
To read the toc
-file twice, you have to avoid to open it to write before the second reading. LaTeX's kernel macro @starttoc
, which is used by tableoofcontents
, usually also opens the file for writing. Loading scrwfile
as shown in esdd's answer already avoids opening files for writing when @starttoc
is used. Also local redefinition of @starttoc
as show in TeXnician's answer can be used to avoid the opening for writing. Another suggestion would be to deactivate LaTeX's opening of auxiliary files for writing, e.g.:
documentclass{scrbook}
usepackage[english]{babel}
usepackage{scrwfile}
usepackage{mwe}% provides Blinddocument
makeatletter
newcommand*{shorttableofcontents}{%
begingroup
value{tocdepth}=z@ % set tocdepth locally to zero
@fileswfalse % deactivate opening of auxiliary files
listoftoc[Short Contents]{ext@toc}%
endgroup
}
makeatother
begin{document}
shorttableofcontents% must be before tableofcontents
tableofcontents
Blinddocument
end{document}
Here KOMA-Script's listoftoc
is used to show the short version of the ToC. See the manual for more information.
However this suggestion would fail, if shorttableofcontents
would be used after tableofcontents
! And you cannot add extra entries to the short table of contents, that are not shown in the normal table of contents. If you need such things, esdd's answer would be the better suggestion.
However you could use another KOMA-Script macro to clone the main ToC:
documentclass{scrbook}
usepackage[english]{babel}
usepackage{scrwfile}
usepackage{mwe}% provides Blinddocument
DeclareNewTOC[%
listname={Short Contents},
]{stoc}
makeatletter
renewcommand{addtocentrydefault}[3]{%
expandaftertocbasic@addxcontentslineexpandafter{ext@toc}{#1}{#2}{#3}%
tocbasic@addxcontentsline{stoc}{#1}{#2}{#3}%
}
makeatother
BeforeStartingTOC[stoc]{value{tocdepth}=0relax}
letshorttableofcontentslistofstocs
begin{document}
shorttableofcontents
tableofcontents
Blinddocument
end{document}
KOMA-Script uses addtocentrydefault
to generate the ToC entries of all headings. But this does not work, if a package generates ToC entries without using addtocentryefault
e.g. using addcontentsline
directly.
Instead of redefining addtocentrydefault
you can try to patch it as shown in esdd's second suggestion.
To read the toc
-file twice, you have to avoid to open it to write before the second reading. LaTeX's kernel macro @starttoc
, which is used by tableoofcontents
, usually also opens the file for writing. Loading scrwfile
as shown in esdd's answer already avoids opening files for writing when @starttoc
is used. Also local redefinition of @starttoc
as show in TeXnician's answer can be used to avoid the opening for writing. Another suggestion would be to deactivate LaTeX's opening of auxiliary files for writing, e.g.:
documentclass{scrbook}
usepackage[english]{babel}
usepackage{scrwfile}
usepackage{mwe}% provides Blinddocument
makeatletter
newcommand*{shorttableofcontents}{%
begingroup
value{tocdepth}=z@ % set tocdepth locally to zero
@fileswfalse % deactivate opening of auxiliary files
listoftoc[Short Contents]{ext@toc}%
endgroup
}
makeatother
begin{document}
shorttableofcontents% must be before tableofcontents
tableofcontents
Blinddocument
end{document}
Here KOMA-Script's listoftoc
is used to show the short version of the ToC. See the manual for more information.
However this suggestion would fail, if shorttableofcontents
would be used after tableofcontents
! And you cannot add extra entries to the short table of contents, that are not shown in the normal table of contents. If you need such things, esdd's answer would be the better suggestion.
However you could use another KOMA-Script macro to clone the main ToC:
documentclass{scrbook}
usepackage[english]{babel}
usepackage{scrwfile}
usepackage{mwe}% provides Blinddocument
DeclareNewTOC[%
listname={Short Contents},
]{stoc}
makeatletter
renewcommand{addtocentrydefault}[3]{%
expandaftertocbasic@addxcontentslineexpandafter{ext@toc}{#1}{#2}{#3}%
tocbasic@addxcontentsline{stoc}{#1}{#2}{#3}%
}
makeatother
BeforeStartingTOC[stoc]{value{tocdepth}=0relax}
letshorttableofcontentslistofstocs
begin{document}
shorttableofcontents
tableofcontents
Blinddocument
end{document}
KOMA-Script uses addtocentrydefault
to generate the ToC entries of all headings. But this does not work, if a package generates ToC entries without using addtocentryefault
e.g. using addcontentsline
directly.
Instead of redefining addtocentrydefault
you can try to patch it as shown in esdd's second suggestion.
edited Dec 30 '18 at 14:30
answered Dec 30 '18 at 14:04
SchweinebackeSchweinebacke
21.2k4474
21.2k4474
add a comment |
add a comment |
ah sorry, posted this before seeing your pdfpages
comment. Maybe this should be topic of another question if there is incompatibility with etoc
? (a mwe showing the problem would be helpful)
documentclass{scrbook}
usepackage{etoc}
begin{document}
{renewcommand*{contentsname}{Short Contents}
etocsetnexttocdepth{chapter}
tableofcontents
}
tableofcontents
chapter{Intro}
section{Sub A}
section{Sub B}
end{document}
add a comment |
ah sorry, posted this before seeing your pdfpages
comment. Maybe this should be topic of another question if there is incompatibility with etoc
? (a mwe showing the problem would be helpful)
documentclass{scrbook}
usepackage{etoc}
begin{document}
{renewcommand*{contentsname}{Short Contents}
etocsetnexttocdepth{chapter}
tableofcontents
}
tableofcontents
chapter{Intro}
section{Sub A}
section{Sub B}
end{document}
add a comment |
ah sorry, posted this before seeing your pdfpages
comment. Maybe this should be topic of another question if there is incompatibility with etoc
? (a mwe showing the problem would be helpful)
documentclass{scrbook}
usepackage{etoc}
begin{document}
{renewcommand*{contentsname}{Short Contents}
etocsetnexttocdepth{chapter}
tableofcontents
}
tableofcontents
chapter{Intro}
section{Sub A}
section{Sub B}
end{document}
ah sorry, posted this before seeing your pdfpages
comment. Maybe this should be topic of another question if there is incompatibility with etoc
? (a mwe showing the problem would be helpful)
documentclass{scrbook}
usepackage{etoc}
begin{document}
{renewcommand*{contentsname}{Short Contents}
etocsetnexttocdepth{chapter}
tableofcontents
}
tableofcontents
chapter{Intro}
section{Sub A}
section{Sub B}
end{document}
answered Dec 31 '18 at 12:06
jfbujfbu
46.4k66148
46.4k66148
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f467899%2fadditional-short-toc-in-scrbook%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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