Fail to renewcommand contentsname if pagesty{fancy} is introduced
When I customize the contentsname with renewcommand, I find that the existence of pagestyle{fancy} or thispagestyle{fancy} will cause compile fail. I can't understand this. why? Is this a problem of contentsname or of the package fancyhdr?
MWE:
documentclass{article}
usepackage{geometry,fancyhdr}
geometry{showframe}
begin{document}
pagestyle{fancy}% This command leads to un-compiled. If this command is commented, or replaced bypagestyle{plain}, everyting is all right.
renewcommandcontentsname{%
LARGE%
centering%
my\ content%
}
tableofcontents
section{section}
text
end{document}
PS: I find that macros related to position like centering, \ are the failure reason. Other macros not related to position like color, Large don't affect renewcommandcontentsname.

fancyhdr titlesec titletoc
|
show 7 more comments
When I customize the contentsname with renewcommand, I find that the existence of pagestyle{fancy} or thispagestyle{fancy} will cause compile fail. I can't understand this. why? Is this a problem of contentsname or of the package fancyhdr?
MWE:
documentclass{article}
usepackage{geometry,fancyhdr}
geometry{showframe}
begin{document}
pagestyle{fancy}% This command leads to un-compiled. If this command is commented, or replaced bypagestyle{plain}, everyting is all right.
renewcommandcontentsname{%
LARGE%
centering%
my\ content%
}
tableofcontents
section{section}
text
end{document}
PS: I find that macros related to position like centering, \ are the failure reason. Other macros not related to position like color, Large don't affect renewcommandcontentsname.

fancyhdr titlesec titletoc
3
It is wrong to use font changes to the name to start with. What are you trying to achieve? Centered chapter heads in your document?
– Johannes_B
Feb 24 at 8:13
contentsnameshould contain only the name of the Table of Contents, since it is used e.g. also in the headline, while a different formatting should be achieved using specialized packages (e.g.titlesec).
– zetaeffe
Feb 24 at 8:14
2
Contentsname is a name, not a formatting instruction. Don't add things like centering or large to it.
– Ulrike Fischer
Feb 24 at 8:14
Normally, the title of a tableofcontent is "Contents". I want ot change the text("My Contents in this example) and its style, likelarge, coloretc. But if there is fancy, it fails. Without fancy, I can do nealy everythig oncontentsname
– lyl
Feb 24 at 8:18
3
Even if you can you shouldn't -- the problem with fancyhdr shows why.
– Ulrike Fischer
Feb 24 at 8:28
|
show 7 more comments
When I customize the contentsname with renewcommand, I find that the existence of pagestyle{fancy} or thispagestyle{fancy} will cause compile fail. I can't understand this. why? Is this a problem of contentsname or of the package fancyhdr?
MWE:
documentclass{article}
usepackage{geometry,fancyhdr}
geometry{showframe}
begin{document}
pagestyle{fancy}% This command leads to un-compiled. If this command is commented, or replaced bypagestyle{plain}, everyting is all right.
renewcommandcontentsname{%
LARGE%
centering%
my\ content%
}
tableofcontents
section{section}
text
end{document}
PS: I find that macros related to position like centering, \ are the failure reason. Other macros not related to position like color, Large don't affect renewcommandcontentsname.

fancyhdr titlesec titletoc
When I customize the contentsname with renewcommand, I find that the existence of pagestyle{fancy} or thispagestyle{fancy} will cause compile fail. I can't understand this. why? Is this a problem of contentsname or of the package fancyhdr?
MWE:
documentclass{article}
usepackage{geometry,fancyhdr}
geometry{showframe}
begin{document}
pagestyle{fancy}% This command leads to un-compiled. If this command is commented, or replaced bypagestyle{plain}, everyting is all right.
renewcommandcontentsname{%
LARGE%
centering%
my\ content%
}
tableofcontents
section{section}
text
end{document}
PS: I find that macros related to position like centering, \ are the failure reason. Other macros not related to position like color, Large don't affect renewcommandcontentsname.

fancyhdr titlesec titletoc
fancyhdr titlesec titletoc
edited Feb 24 at 10:10
Zarko
126k867164
126k867164
asked Feb 24 at 8:03
lyllyl
65338
65338
3
It is wrong to use font changes to the name to start with. What are you trying to achieve? Centered chapter heads in your document?
– Johannes_B
Feb 24 at 8:13
contentsnameshould contain only the name of the Table of Contents, since it is used e.g. also in the headline, while a different formatting should be achieved using specialized packages (e.g.titlesec).
– zetaeffe
Feb 24 at 8:14
2
Contentsname is a name, not a formatting instruction. Don't add things like centering or large to it.
– Ulrike Fischer
Feb 24 at 8:14
Normally, the title of a tableofcontent is "Contents". I want ot change the text("My Contents in this example) and its style, likelarge, coloretc. But if there is fancy, it fails. Without fancy, I can do nealy everythig oncontentsname
– lyl
Feb 24 at 8:18
3
Even if you can you shouldn't -- the problem with fancyhdr shows why.
– Ulrike Fischer
Feb 24 at 8:28
|
show 7 more comments
3
It is wrong to use font changes to the name to start with. What are you trying to achieve? Centered chapter heads in your document?
– Johannes_B
Feb 24 at 8:13
contentsnameshould contain only the name of the Table of Contents, since it is used e.g. also in the headline, while a different formatting should be achieved using specialized packages (e.g.titlesec).
– zetaeffe
Feb 24 at 8:14
2
Contentsname is a name, not a formatting instruction. Don't add things like centering or large to it.
– Ulrike Fischer
Feb 24 at 8:14
Normally, the title of a tableofcontent is "Contents". I want ot change the text("My Contents in this example) and its style, likelarge, coloretc. But if there is fancy, it fails. Without fancy, I can do nealy everythig oncontentsname
– lyl
Feb 24 at 8:18
3
Even if you can you shouldn't -- the problem with fancyhdr shows why.
– Ulrike Fischer
Feb 24 at 8:28
3
3
It is wrong to use font changes to the name to start with. What are you trying to achieve? Centered chapter heads in your document?
– Johannes_B
Feb 24 at 8:13
It is wrong to use font changes to the name to start with. What are you trying to achieve? Centered chapter heads in your document?
– Johannes_B
Feb 24 at 8:13
contentsname should contain only the name of the Table of Contents, since it is used e.g. also in the headline, while a different formatting should be achieved using specialized packages (e.g. titlesec).– zetaeffe
Feb 24 at 8:14
contentsname should contain only the name of the Table of Contents, since it is used e.g. also in the headline, while a different formatting should be achieved using specialized packages (e.g. titlesec).– zetaeffe
Feb 24 at 8:14
2
2
Contentsname is a name, not a formatting instruction. Don't add things like centering or large to it.
– Ulrike Fischer
Feb 24 at 8:14
Contentsname is a name, not a formatting instruction. Don't add things like centering or large to it.
– Ulrike Fischer
Feb 24 at 8:14
Normally, the title of a tableofcontent is "
Contents". I want ot change the text("My Contents in this example) and its style, like large, color etc. But if there is fancy, it fails. Without fancy, I can do nealy everythig on contentsname– lyl
Feb 24 at 8:18
Normally, the title of a tableofcontent is "
Contents". I want ot change the text("My Contents in this example) and its style, like large, color etc. But if there is fancy, it fails. Without fancy, I can do nealy everythig on contentsname– lyl
Feb 24 at 8:18
3
3
Even if you can you shouldn't -- the problem with fancyhdr shows why.
– Ulrike Fischer
Feb 24 at 8:28
Even if you can you shouldn't -- the problem with fancyhdr shows why.
– Ulrike Fischer
Feb 24 at 8:28
|
show 7 more comments
1 Answer
1
active
oldest
votes
documentclass{article}
usepackage{geometry,fancyhdr,titlesec,xcolor}
geometry{showframe}
begin{document}
pagestyle{fancy}% This command leads to un-compiled. If this command is commented, or replaced bypagestyle{plain}, everyting is all right.
renewcommandcontentsname{%
My \ content%
}
{
titleformat*{section}{vspace*{-0.5baselineskip}centering LARGEcolor{red}}
tableofcontents
}
section{section}
text
end{document}

This is really what I want! Many thanks. And why titleformat*, not titleformat?
– lyl
Feb 25 at 1:22
@lyltitleformat*is a light version of the more advanced commandtitleformat. In this cas as you can see it is sufficient to usetitleformat*. Now if you ask why the commandtitleformat{chapter}[display]{color{blue}normalfonthugebfseries}{my\ content}{20pt}{Huge}does not work? At first glance I would said that is because indocumentclass{article}there is no chapters
– Hafid Boukhoulda
Feb 25 at 6:37
Your answer and comments perfectly disabuse me. Many thanks!!
– lyl
Feb 25 at 6:45
@lyl You are welcome! and I am very happy that your problem has been solved.
– Hafid Boukhoulda
Feb 25 at 6:47
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%2f476430%2ffail-to-renewcommand-contentsname-if-pagestyfancy-is-introduced%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
documentclass{article}
usepackage{geometry,fancyhdr,titlesec,xcolor}
geometry{showframe}
begin{document}
pagestyle{fancy}% This command leads to un-compiled. If this command is commented, or replaced bypagestyle{plain}, everyting is all right.
renewcommandcontentsname{%
My \ content%
}
{
titleformat*{section}{vspace*{-0.5baselineskip}centering LARGEcolor{red}}
tableofcontents
}
section{section}
text
end{document}

This is really what I want! Many thanks. And why titleformat*, not titleformat?
– lyl
Feb 25 at 1:22
@lyltitleformat*is a light version of the more advanced commandtitleformat. In this cas as you can see it is sufficient to usetitleformat*. Now if you ask why the commandtitleformat{chapter}[display]{color{blue}normalfonthugebfseries}{my\ content}{20pt}{Huge}does not work? At first glance I would said that is because indocumentclass{article}there is no chapters
– Hafid Boukhoulda
Feb 25 at 6:37
Your answer and comments perfectly disabuse me. Many thanks!!
– lyl
Feb 25 at 6:45
@lyl You are welcome! and I am very happy that your problem has been solved.
– Hafid Boukhoulda
Feb 25 at 6:47
add a comment |
documentclass{article}
usepackage{geometry,fancyhdr,titlesec,xcolor}
geometry{showframe}
begin{document}
pagestyle{fancy}% This command leads to un-compiled. If this command is commented, or replaced bypagestyle{plain}, everyting is all right.
renewcommandcontentsname{%
My \ content%
}
{
titleformat*{section}{vspace*{-0.5baselineskip}centering LARGEcolor{red}}
tableofcontents
}
section{section}
text
end{document}

This is really what I want! Many thanks. And why titleformat*, not titleformat?
– lyl
Feb 25 at 1:22
@lyltitleformat*is a light version of the more advanced commandtitleformat. In this cas as you can see it is sufficient to usetitleformat*. Now if you ask why the commandtitleformat{chapter}[display]{color{blue}normalfonthugebfseries}{my\ content}{20pt}{Huge}does not work? At first glance I would said that is because indocumentclass{article}there is no chapters
– Hafid Boukhoulda
Feb 25 at 6:37
Your answer and comments perfectly disabuse me. Many thanks!!
– lyl
Feb 25 at 6:45
@lyl You are welcome! and I am very happy that your problem has been solved.
– Hafid Boukhoulda
Feb 25 at 6:47
add a comment |
documentclass{article}
usepackage{geometry,fancyhdr,titlesec,xcolor}
geometry{showframe}
begin{document}
pagestyle{fancy}% This command leads to un-compiled. If this command is commented, or replaced bypagestyle{plain}, everyting is all right.
renewcommandcontentsname{%
My \ content%
}
{
titleformat*{section}{vspace*{-0.5baselineskip}centering LARGEcolor{red}}
tableofcontents
}
section{section}
text
end{document}

documentclass{article}
usepackage{geometry,fancyhdr,titlesec,xcolor}
geometry{showframe}
begin{document}
pagestyle{fancy}% This command leads to un-compiled. If this command is commented, or replaced bypagestyle{plain}, everyting is all right.
renewcommandcontentsname{%
My \ content%
}
{
titleformat*{section}{vspace*{-0.5baselineskip}centering LARGEcolor{red}}
tableofcontents
}
section{section}
text
end{document}

answered Feb 24 at 19:49
Hafid BoukhouldaHafid Boukhoulda
4,4421625
4,4421625
This is really what I want! Many thanks. And why titleformat*, not titleformat?
– lyl
Feb 25 at 1:22
@lyltitleformat*is a light version of the more advanced commandtitleformat. In this cas as you can see it is sufficient to usetitleformat*. Now if you ask why the commandtitleformat{chapter}[display]{color{blue}normalfonthugebfseries}{my\ content}{20pt}{Huge}does not work? At first glance I would said that is because indocumentclass{article}there is no chapters
– Hafid Boukhoulda
Feb 25 at 6:37
Your answer and comments perfectly disabuse me. Many thanks!!
– lyl
Feb 25 at 6:45
@lyl You are welcome! and I am very happy that your problem has been solved.
– Hafid Boukhoulda
Feb 25 at 6:47
add a comment |
This is really what I want! Many thanks. And why titleformat*, not titleformat?
– lyl
Feb 25 at 1:22
@lyltitleformat*is a light version of the more advanced commandtitleformat. In this cas as you can see it is sufficient to usetitleformat*. Now if you ask why the commandtitleformat{chapter}[display]{color{blue}normalfonthugebfseries}{my\ content}{20pt}{Huge}does not work? At first glance I would said that is because indocumentclass{article}there is no chapters
– Hafid Boukhoulda
Feb 25 at 6:37
Your answer and comments perfectly disabuse me. Many thanks!!
– lyl
Feb 25 at 6:45
@lyl You are welcome! and I am very happy that your problem has been solved.
– Hafid Boukhoulda
Feb 25 at 6:47
This is really what I want! Many thanks. And why titleformat*, not titleformat?
– lyl
Feb 25 at 1:22
This is really what I want! Many thanks. And why titleformat*, not titleformat?
– lyl
Feb 25 at 1:22
@lyl
titleformat* is a light version of the more advanced command titleformat. In this cas as you can see it is sufficient to use titleformat*. Now if you ask why the command titleformat{chapter}[display]{color{blue}normalfonthugebfseries}{my\ content}{20pt}{Huge} does not work? At first glance I would said that is because in documentclass{article} there is no chapters– Hafid Boukhoulda
Feb 25 at 6:37
@lyl
titleformat* is a light version of the more advanced command titleformat. In this cas as you can see it is sufficient to use titleformat*. Now if you ask why the command titleformat{chapter}[display]{color{blue}normalfonthugebfseries}{my\ content}{20pt}{Huge} does not work? At first glance I would said that is because in documentclass{article} there is no chapters– Hafid Boukhoulda
Feb 25 at 6:37
Your answer and comments perfectly disabuse me. Many thanks!!
– lyl
Feb 25 at 6:45
Your answer and comments perfectly disabuse me. Many thanks!!
– lyl
Feb 25 at 6:45
@lyl You are welcome! and I am very happy that your problem has been solved.
– Hafid Boukhoulda
Feb 25 at 6:47
@lyl You are welcome! and I am very happy that your problem has been solved.
– Hafid Boukhoulda
Feb 25 at 6:47
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%2f476430%2ffail-to-renewcommand-contentsname-if-pagestyfancy-is-introduced%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
3
It is wrong to use font changes to the name to start with. What are you trying to achieve? Centered chapter heads in your document?
– Johannes_B
Feb 24 at 8:13
contentsnameshould contain only the name of the Table of Contents, since it is used e.g. also in the headline, while a different formatting should be achieved using specialized packages (e.g.titlesec).– zetaeffe
Feb 24 at 8:14
2
Contentsname is a name, not a formatting instruction. Don't add things like centering or large to it.
– Ulrike Fischer
Feb 24 at 8:14
Normally, the title of a tableofcontent is "
Contents". I want ot change the text("My Contents in this example) and its style, likelarge, coloretc. But if there is fancy, it fails. Without fancy, I can do nealy everythig oncontentsname– lyl
Feb 24 at 8:18
3
Even if you can you shouldn't -- the problem with fancyhdr shows why.
– Ulrike Fischer
Feb 24 at 8:28