How to hide/show section levels in the table of contents?
up vote
27
down vote
favorite
I have a table of contents (tableofcontents
) in my document. How can I hide subsections in it? I want that only names of sections are displayed there.
table-of-contents
|
show 1 more comment
up vote
27
down vote
favorite
I have a table of contents (tableofcontents
) in my document. How can I hide subsections in it? I want that only names of sections are displayed there.
table-of-contents
4
Writesubsection*{}
with the asterisk, for a single case, or includesetcounter{tocdepth}{1}
in your preamble for anything belowSection
(subsections, subsubsections won't appear). I think this question has certainly come up before...
– Alenanno
Feb 5 '16 at 14:42
2
setcounter{tocdepth}{1}
is quicker ;-)
– Christian Hupfer
Feb 5 '16 at 14:44
@Alenanno: Must --- resist--- to answer... this ToC question ;-)
– Christian Hupfer
Feb 5 '16 at 14:45
@ChristianHupfer I added it while you were posting lol
– Alenanno
Feb 5 '16 at 14:45
4
By the way, note that the asterisk will make the affected parts unnumbered!
– Alenanno
Feb 5 '16 at 14:47
|
show 1 more comment
up vote
27
down vote
favorite
up vote
27
down vote
favorite
I have a table of contents (tableofcontents
) in my document. How can I hide subsections in it? I want that only names of sections are displayed there.
table-of-contents
I have a table of contents (tableofcontents
) in my document. How can I hide subsections in it? I want that only names of sections are displayed there.
table-of-contents
table-of-contents
edited Jul 1 '17 at 21:23
egreg
699k8518613134
699k8518613134
asked Feb 5 '16 at 14:41
Lucky_girl
5351418
5351418
4
Writesubsection*{}
with the asterisk, for a single case, or includesetcounter{tocdepth}{1}
in your preamble for anything belowSection
(subsections, subsubsections won't appear). I think this question has certainly come up before...
– Alenanno
Feb 5 '16 at 14:42
2
setcounter{tocdepth}{1}
is quicker ;-)
– Christian Hupfer
Feb 5 '16 at 14:44
@Alenanno: Must --- resist--- to answer... this ToC question ;-)
– Christian Hupfer
Feb 5 '16 at 14:45
@ChristianHupfer I added it while you were posting lol
– Alenanno
Feb 5 '16 at 14:45
4
By the way, note that the asterisk will make the affected parts unnumbered!
– Alenanno
Feb 5 '16 at 14:47
|
show 1 more comment
4
Writesubsection*{}
with the asterisk, for a single case, or includesetcounter{tocdepth}{1}
in your preamble for anything belowSection
(subsections, subsubsections won't appear). I think this question has certainly come up before...
– Alenanno
Feb 5 '16 at 14:42
2
setcounter{tocdepth}{1}
is quicker ;-)
– Christian Hupfer
Feb 5 '16 at 14:44
@Alenanno: Must --- resist--- to answer... this ToC question ;-)
– Christian Hupfer
Feb 5 '16 at 14:45
@ChristianHupfer I added it while you were posting lol
– Alenanno
Feb 5 '16 at 14:45
4
By the way, note that the asterisk will make the affected parts unnumbered!
– Alenanno
Feb 5 '16 at 14:47
4
4
Write
subsection*{}
with the asterisk, for a single case, or include setcounter{tocdepth}{1}
in your preamble for anything below Section
(subsections, subsubsections won't appear). I think this question has certainly come up before...– Alenanno
Feb 5 '16 at 14:42
Write
subsection*{}
with the asterisk, for a single case, or include setcounter{tocdepth}{1}
in your preamble for anything below Section
(subsections, subsubsections won't appear). I think this question has certainly come up before...– Alenanno
Feb 5 '16 at 14:42
2
2
setcounter{tocdepth}{1}
is quicker ;-)– Christian Hupfer
Feb 5 '16 at 14:44
setcounter{tocdepth}{1}
is quicker ;-)– Christian Hupfer
Feb 5 '16 at 14:44
@Alenanno: Must --- resist--- to answer... this ToC question ;-)
– Christian Hupfer
Feb 5 '16 at 14:45
@Alenanno: Must --- resist--- to answer... this ToC question ;-)
– Christian Hupfer
Feb 5 '16 at 14:45
@ChristianHupfer I added it while you were posting lol
– Alenanno
Feb 5 '16 at 14:45
@ChristianHupfer I added it while you were posting lol
– Alenanno
Feb 5 '16 at 14:45
4
4
By the way, note that the asterisk will make the affected parts unnumbered!
– Alenanno
Feb 5 '16 at 14:47
By the way, note that the asterisk will make the affected parts unnumbered!
– Alenanno
Feb 5 '16 at 14:47
|
show 1 more comment
1 Answer
1
active
oldest
votes
up vote
39
down vote
accepted
The tocdepth
counter decides to which depth down the entries appear in the ToC
.
(Code slightly edited, thanks to https://tex.stackexchange.com/users/1357/jdh for pointing me to a typo!)
Usually, following values hold
setcounter{tocdepth}{-1}
-- only parts
setcounter{tocdepth}{0}
-- only parts and chapters
setcounter{tocdepth}{1}
-- part,chapters,sections
setcounter{tocdepth}{2}
-- part,chapters,sections, subsections
setcounter{tocdepth}{3}
-- part,chapters,sections, subsections,subsubsections
setcounter{tocdepth}{4}
-- part,chapters,sections, subsections,subsubsections and paragraphs
setcounter{tocdepth}{5}
-- part,chapters,sections, subsections, subsubsections, paragraphs and subparagraphs.
The memoir
class adds the ToC depth -2
for the book
structure level at all, being higher leveled than part
.
This means, the larger the number for the counter, the greater the number of structuring in the ToC.
The toclevels can be found, for example in article.cls
(and since book.cls
loads article.cls
) looking at the @startsection{...}
commands.
If for example, some parts of the structuring should not appear in the ToC at all, there's a trick
addtocontents{toc}{setcounter{tocdepth}{-10}}
before the 'hidden parts' and later reenable them with
addtocontents{toc}{setcounter{tocdepth}{1}}
See Switching tocdepth in the middle of a document for an example about changing the tocdepth
in between.
Please do not confuse tocdepth
with the secnumdepth
counter!
Just for completeness: Both tocdepth
and secnumdepth
are counters that aren't defined withnewcounter
, but have the internal names c@tocdepth
and c@secnumdepth
in order to allow setcounter
etc. usage. You won't find them in the internal counter list and are no members of counter reset lists by default, which would be no of importance anyway.
The value of the tocdepth
counter controls in the same manner which entries enter the regular bookmarks provided by hyperref
.
1
You are missing {toc} in the trick, in the second line where you reenable the level. (And thanks for this trick!)
– JDH
Aug 11 at 11:26
@JDH: Thanks for notifying -- I've corrected the typo.
– Christian Hupfer
20 hours ago
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
39
down vote
accepted
The tocdepth
counter decides to which depth down the entries appear in the ToC
.
(Code slightly edited, thanks to https://tex.stackexchange.com/users/1357/jdh for pointing me to a typo!)
Usually, following values hold
setcounter{tocdepth}{-1}
-- only parts
setcounter{tocdepth}{0}
-- only parts and chapters
setcounter{tocdepth}{1}
-- part,chapters,sections
setcounter{tocdepth}{2}
-- part,chapters,sections, subsections
setcounter{tocdepth}{3}
-- part,chapters,sections, subsections,subsubsections
setcounter{tocdepth}{4}
-- part,chapters,sections, subsections,subsubsections and paragraphs
setcounter{tocdepth}{5}
-- part,chapters,sections, subsections, subsubsections, paragraphs and subparagraphs.
The memoir
class adds the ToC depth -2
for the book
structure level at all, being higher leveled than part
.
This means, the larger the number for the counter, the greater the number of structuring in the ToC.
The toclevels can be found, for example in article.cls
(and since book.cls
loads article.cls
) looking at the @startsection{...}
commands.
If for example, some parts of the structuring should not appear in the ToC at all, there's a trick
addtocontents{toc}{setcounter{tocdepth}{-10}}
before the 'hidden parts' and later reenable them with
addtocontents{toc}{setcounter{tocdepth}{1}}
See Switching tocdepth in the middle of a document for an example about changing the tocdepth
in between.
Please do not confuse tocdepth
with the secnumdepth
counter!
Just for completeness: Both tocdepth
and secnumdepth
are counters that aren't defined withnewcounter
, but have the internal names c@tocdepth
and c@secnumdepth
in order to allow setcounter
etc. usage. You won't find them in the internal counter list and are no members of counter reset lists by default, which would be no of importance anyway.
The value of the tocdepth
counter controls in the same manner which entries enter the regular bookmarks provided by hyperref
.
1
You are missing {toc} in the trick, in the second line where you reenable the level. (And thanks for this trick!)
– JDH
Aug 11 at 11:26
@JDH: Thanks for notifying -- I've corrected the typo.
– Christian Hupfer
20 hours ago
add a comment |
up vote
39
down vote
accepted
The tocdepth
counter decides to which depth down the entries appear in the ToC
.
(Code slightly edited, thanks to https://tex.stackexchange.com/users/1357/jdh for pointing me to a typo!)
Usually, following values hold
setcounter{tocdepth}{-1}
-- only parts
setcounter{tocdepth}{0}
-- only parts and chapters
setcounter{tocdepth}{1}
-- part,chapters,sections
setcounter{tocdepth}{2}
-- part,chapters,sections, subsections
setcounter{tocdepth}{3}
-- part,chapters,sections, subsections,subsubsections
setcounter{tocdepth}{4}
-- part,chapters,sections, subsections,subsubsections and paragraphs
setcounter{tocdepth}{5}
-- part,chapters,sections, subsections, subsubsections, paragraphs and subparagraphs.
The memoir
class adds the ToC depth -2
for the book
structure level at all, being higher leveled than part
.
This means, the larger the number for the counter, the greater the number of structuring in the ToC.
The toclevels can be found, for example in article.cls
(and since book.cls
loads article.cls
) looking at the @startsection{...}
commands.
If for example, some parts of the structuring should not appear in the ToC at all, there's a trick
addtocontents{toc}{setcounter{tocdepth}{-10}}
before the 'hidden parts' and later reenable them with
addtocontents{toc}{setcounter{tocdepth}{1}}
See Switching tocdepth in the middle of a document for an example about changing the tocdepth
in between.
Please do not confuse tocdepth
with the secnumdepth
counter!
Just for completeness: Both tocdepth
and secnumdepth
are counters that aren't defined withnewcounter
, but have the internal names c@tocdepth
and c@secnumdepth
in order to allow setcounter
etc. usage. You won't find them in the internal counter list and are no members of counter reset lists by default, which would be no of importance anyway.
The value of the tocdepth
counter controls in the same manner which entries enter the regular bookmarks provided by hyperref
.
1
You are missing {toc} in the trick, in the second line where you reenable the level. (And thanks for this trick!)
– JDH
Aug 11 at 11:26
@JDH: Thanks for notifying -- I've corrected the typo.
– Christian Hupfer
20 hours ago
add a comment |
up vote
39
down vote
accepted
up vote
39
down vote
accepted
The tocdepth
counter decides to which depth down the entries appear in the ToC
.
(Code slightly edited, thanks to https://tex.stackexchange.com/users/1357/jdh for pointing me to a typo!)
Usually, following values hold
setcounter{tocdepth}{-1}
-- only parts
setcounter{tocdepth}{0}
-- only parts and chapters
setcounter{tocdepth}{1}
-- part,chapters,sections
setcounter{tocdepth}{2}
-- part,chapters,sections, subsections
setcounter{tocdepth}{3}
-- part,chapters,sections, subsections,subsubsections
setcounter{tocdepth}{4}
-- part,chapters,sections, subsections,subsubsections and paragraphs
setcounter{tocdepth}{5}
-- part,chapters,sections, subsections, subsubsections, paragraphs and subparagraphs.
The memoir
class adds the ToC depth -2
for the book
structure level at all, being higher leveled than part
.
This means, the larger the number for the counter, the greater the number of structuring in the ToC.
The toclevels can be found, for example in article.cls
(and since book.cls
loads article.cls
) looking at the @startsection{...}
commands.
If for example, some parts of the structuring should not appear in the ToC at all, there's a trick
addtocontents{toc}{setcounter{tocdepth}{-10}}
before the 'hidden parts' and later reenable them with
addtocontents{toc}{setcounter{tocdepth}{1}}
See Switching tocdepth in the middle of a document for an example about changing the tocdepth
in between.
Please do not confuse tocdepth
with the secnumdepth
counter!
Just for completeness: Both tocdepth
and secnumdepth
are counters that aren't defined withnewcounter
, but have the internal names c@tocdepth
and c@secnumdepth
in order to allow setcounter
etc. usage. You won't find them in the internal counter list and are no members of counter reset lists by default, which would be no of importance anyway.
The value of the tocdepth
counter controls in the same manner which entries enter the regular bookmarks provided by hyperref
.
The tocdepth
counter decides to which depth down the entries appear in the ToC
.
(Code slightly edited, thanks to https://tex.stackexchange.com/users/1357/jdh for pointing me to a typo!)
Usually, following values hold
setcounter{tocdepth}{-1}
-- only parts
setcounter{tocdepth}{0}
-- only parts and chapters
setcounter{tocdepth}{1}
-- part,chapters,sections
setcounter{tocdepth}{2}
-- part,chapters,sections, subsections
setcounter{tocdepth}{3}
-- part,chapters,sections, subsections,subsubsections
setcounter{tocdepth}{4}
-- part,chapters,sections, subsections,subsubsections and paragraphs
setcounter{tocdepth}{5}
-- part,chapters,sections, subsections, subsubsections, paragraphs and subparagraphs.
The memoir
class adds the ToC depth -2
for the book
structure level at all, being higher leveled than part
.
This means, the larger the number for the counter, the greater the number of structuring in the ToC.
The toclevels can be found, for example in article.cls
(and since book.cls
loads article.cls
) looking at the @startsection{...}
commands.
If for example, some parts of the structuring should not appear in the ToC at all, there's a trick
addtocontents{toc}{setcounter{tocdepth}{-10}}
before the 'hidden parts' and later reenable them with
addtocontents{toc}{setcounter{tocdepth}{1}}
See Switching tocdepth in the middle of a document for an example about changing the tocdepth
in between.
Please do not confuse tocdepth
with the secnumdepth
counter!
Just for completeness: Both tocdepth
and secnumdepth
are counters that aren't defined withnewcounter
, but have the internal names c@tocdepth
and c@secnumdepth
in order to allow setcounter
etc. usage. You won't find them in the internal counter list and are no members of counter reset lists by default, which would be no of importance anyway.
The value of the tocdepth
counter controls in the same manner which entries enter the regular bookmarks provided by hyperref
.
edited 20 hours ago
answered Feb 5 '16 at 14:59
Christian Hupfer
146k14188379
146k14188379
1
You are missing {toc} in the trick, in the second line where you reenable the level. (And thanks for this trick!)
– JDH
Aug 11 at 11:26
@JDH: Thanks for notifying -- I've corrected the typo.
– Christian Hupfer
20 hours ago
add a comment |
1
You are missing {toc} in the trick, in the second line where you reenable the level. (And thanks for this trick!)
– JDH
Aug 11 at 11:26
@JDH: Thanks for notifying -- I've corrected the typo.
– Christian Hupfer
20 hours ago
1
1
You are missing {toc} in the trick, in the second line where you reenable the level. (And thanks for this trick!)
– JDH
Aug 11 at 11:26
You are missing {toc} in the trick, in the second line where you reenable the level. (And thanks for this trick!)
– JDH
Aug 11 at 11:26
@JDH: Thanks for notifying -- I've corrected the typo.
– Christian Hupfer
20 hours ago
@JDH: Thanks for notifying -- I've corrected the typo.
– Christian Hupfer
20 hours ago
add a comment |
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%2f291307%2fhow-to-hide-show-section-levels-in-the-table-of-contents%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
4
Write
subsection*{}
with the asterisk, for a single case, or includesetcounter{tocdepth}{1}
in your preamble for anything belowSection
(subsections, subsubsections won't appear). I think this question has certainly come up before...– Alenanno
Feb 5 '16 at 14:42
2
setcounter{tocdepth}{1}
is quicker ;-)– Christian Hupfer
Feb 5 '16 at 14:44
@Alenanno: Must --- resist--- to answer... this ToC question ;-)
– Christian Hupfer
Feb 5 '16 at 14:45
@ChristianHupfer I added it while you were posting lol
– Alenanno
Feb 5 '16 at 14:45
4
By the way, note that the asterisk will make the affected parts unnumbered!
– Alenanno
Feb 5 '16 at 14:47