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 2 hours ago
strpeter
2,57721855
2,57721855
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
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
2 hours ago
@strpeter No, it is not. You only have to take care of the obvious babel commands.
– TeXnician
2 hours ago
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
1 hour ago
1
@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
1 hour ago
@strpeter A much better explanation and workaround is given in Schweinbacke's answer.
– TeXnician
1 hour ago
add a comment |
You could use KOMA-Script packege scrwfile
:
documentclass{scrbook}
usepackage[english]{babel}
usepackage{scrwfile}
TOCclone[Short Contents]{toc}{stoc}
addtocontents{stoc}{protectvalue{tocdepth}=0}% or AfterStartingTOC[stoc]{value{tocdepth}=0}
begin{document}
listofstoc
tableofcontents
chapter{Intro}
section{Sub A}
section{Sub B}
end{document}
or
documentclass{scrbook}
usepackage[english]{babel}
addtotoclist[jobname]{stoc}
AfterStartingTOC[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}
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}
AfterStartingTOC[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}%
}
2
Alternatively you could useBeforeStartingTOC[stoc]{value{tocdepth}=0}
to setup the depth of the short ToC.
– Schweinebacke
1 hour ago
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 |
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
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
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
2 hours ago
@strpeter No, it is not. You only have to take care of the obvious babel commands.
– TeXnician
2 hours ago
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
1 hour ago
1
@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
1 hour ago
@strpeter A much better explanation and workaround is given in Schweinbacke's answer.
– TeXnician
1 hour ago
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
2 hours ago
@strpeter No, it is not. You only have to take care of the obvious babel commands.
– TeXnician
2 hours ago
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
1 hour ago
1
@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
1 hour ago
@strpeter A much better explanation and workaround is given in Schweinbacke's answer.
– TeXnician
1 hour ago
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 2 hours ago
answered 2 hours ago
TeXnician
24.3k63084
24.3k63084
This solution seems incompatible with the packagebabel
. Try withusepackage[english]{babel}
.
– strpeter
2 hours ago
@strpeter No, it is not. You only have to take care of the obvious babel commands.
– TeXnician
2 hours ago
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
1 hour ago
1
@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
1 hour ago
@strpeter A much better explanation and workaround is given in Schweinbacke's answer.
– TeXnician
1 hour ago
add a comment |
This solution seems incompatible with the packagebabel
. Try withusepackage[english]{babel}
.
– strpeter
2 hours ago
@strpeter No, it is not. You only have to take care of the obvious babel commands.
– TeXnician
2 hours ago
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
1 hour ago
1
@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
1 hour ago
@strpeter A much better explanation and workaround is given in Schweinbacke's answer.
– TeXnician
1 hour ago
This solution seems incompatible with the package
babel
. Try with usepackage[english]{babel}
.– strpeter
2 hours ago
This solution seems incompatible with the package
babel
. Try with usepackage[english]{babel}
.– strpeter
2 hours ago
@strpeter No, it is not. You only have to take care of the obvious babel commands.
– TeXnician
2 hours ago
@strpeter No, it is not. You only have to take care of the obvious babel commands.
– TeXnician
2 hours ago
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
1 hour ago
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
1 hour ago
1
1
@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
1 hour ago
@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
1 hour ago
@strpeter A much better explanation and workaround is given in Schweinbacke's answer.
– TeXnician
1 hour ago
@strpeter A much better explanation and workaround is given in Schweinbacke's answer.
– TeXnician
1 hour ago
add a comment |
You could use KOMA-Script packege scrwfile
:
documentclass{scrbook}
usepackage[english]{babel}
usepackage{scrwfile}
TOCclone[Short Contents]{toc}{stoc}
addtocontents{stoc}{protectvalue{tocdepth}=0}% or AfterStartingTOC[stoc]{value{tocdepth}=0}
begin{document}
listofstoc
tableofcontents
chapter{Intro}
section{Sub A}
section{Sub B}
end{document}
or
documentclass{scrbook}
usepackage[english]{babel}
addtotoclist[jobname]{stoc}
AfterStartingTOC[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}
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}
AfterStartingTOC[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}%
}
2
Alternatively you could useBeforeStartingTOC[stoc]{value{tocdepth}=0}
to setup the depth of the short ToC.
– Schweinebacke
1 hour ago
add a comment |
You could use KOMA-Script packege scrwfile
:
documentclass{scrbook}
usepackage[english]{babel}
usepackage{scrwfile}
TOCclone[Short Contents]{toc}{stoc}
addtocontents{stoc}{protectvalue{tocdepth}=0}% or AfterStartingTOC[stoc]{value{tocdepth}=0}
begin{document}
listofstoc
tableofcontents
chapter{Intro}
section{Sub A}
section{Sub B}
end{document}
or
documentclass{scrbook}
usepackage[english]{babel}
addtotoclist[jobname]{stoc}
AfterStartingTOC[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}
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}
AfterStartingTOC[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}%
}
2
Alternatively you could useBeforeStartingTOC[stoc]{value{tocdepth}=0}
to setup the depth of the short ToC.
– Schweinebacke
1 hour ago
add a comment |
You could use KOMA-Script packege scrwfile
:
documentclass{scrbook}
usepackage[english]{babel}
usepackage{scrwfile}
TOCclone[Short Contents]{toc}{stoc}
addtocontents{stoc}{protectvalue{tocdepth}=0}% or AfterStartingTOC[stoc]{value{tocdepth}=0}
begin{document}
listofstoc
tableofcontents
chapter{Intro}
section{Sub A}
section{Sub B}
end{document}
or
documentclass{scrbook}
usepackage[english]{babel}
addtotoclist[jobname]{stoc}
AfterStartingTOC[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}
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}
AfterStartingTOC[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 packege scrwfile
:
documentclass{scrbook}
usepackage[english]{babel}
usepackage{scrwfile}
TOCclone[Short Contents]{toc}{stoc}
addtocontents{stoc}{protectvalue{tocdepth}=0}% or AfterStartingTOC[stoc]{value{tocdepth}=0}
begin{document}
listofstoc
tableofcontents
chapter{Intro}
section{Sub A}
section{Sub B}
end{document}
or
documentclass{scrbook}
usepackage[english]{babel}
addtotoclist[jobname]{stoc}
AfterStartingTOC[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}
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}
AfterStartingTOC[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 1 hour ago
Herbert
269k24408717
269k24408717
answered 1 hour ago
esdd
58.5k34586
58.5k34586
2
Alternatively you could useBeforeStartingTOC[stoc]{value{tocdepth}=0}
to setup the depth of the short ToC.
– Schweinebacke
1 hour ago
add a comment |
2
Alternatively you could useBeforeStartingTOC[stoc]{value{tocdepth}=0}
to setup the depth of the short ToC.
– Schweinebacke
1 hour ago
2
2
Alternatively you could use
BeforeStartingTOC[stoc]{value{tocdepth}=0}
to setup the depth of the short ToC.– Schweinebacke
1 hour ago
Alternatively you could use
BeforeStartingTOC[stoc]{value{tocdepth}=0}
to setup the depth of the short ToC.– Schweinebacke
1 hour ago
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 52 mins ago
answered 1 hour ago
Schweinebacke
21k4474
21k4474
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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