Fancyhdr and redefinition of leftmark/rightmark
up vote
3
down vote
favorite
I am writing a long document and I decided to change the headers, using fancyhdr
:
documentclass[12pt,a4paper]{book}
renewcommand*thesection{arabic{section}}
usepackage{fancyhdr}
% Fancyhdr setup
fancypagestyle{main}{
fancyhead{} % clear all header fields
fancyhead[LE]{footnotesize{scshapenouppercase{Chapitre~thechapter ~- ~leftmark}}}
fancyhead[RO]{footnotesize{scshapenouppercase{thesection~-~rightmark}}}
fancyfoot{} % clear all footer fields
fancyfoot[LE,RO]{thepage}
renewcommand{headrulewidth}{0 pt}
renewcommand{footrulewidth}{0 pt}
renewcommand{sectionmark}[1]{markright{#1}}
renewcommand{chaptermark}[1]{markboth{#1}{}}
}
begin{document}
end{document}
The problem is this code does not compile, and the problem is whit the two lines :
renewcommand{sectionmark}[1]{markright{#1}}
renewcommand{chaptermark}[1]{markboth{#1}{}}
To solve the problem I just put them outside the definition of main
headers, but it doesn't give the same result.
How should I fix this error without changing my headers ?
PS. I want the headers to be on right pages like "3 - Section title" and on the left pages (except at a begining of a chapter) like "Chapitre 1 - Title of chapter"
Thanks.
header-footer fancyhdr
add a comment |
up vote
3
down vote
favorite
I am writing a long document and I decided to change the headers, using fancyhdr
:
documentclass[12pt,a4paper]{book}
renewcommand*thesection{arabic{section}}
usepackage{fancyhdr}
% Fancyhdr setup
fancypagestyle{main}{
fancyhead{} % clear all header fields
fancyhead[LE]{footnotesize{scshapenouppercase{Chapitre~thechapter ~- ~leftmark}}}
fancyhead[RO]{footnotesize{scshapenouppercase{thesection~-~rightmark}}}
fancyfoot{} % clear all footer fields
fancyfoot[LE,RO]{thepage}
renewcommand{headrulewidth}{0 pt}
renewcommand{footrulewidth}{0 pt}
renewcommand{sectionmark}[1]{markright{#1}}
renewcommand{chaptermark}[1]{markboth{#1}{}}
}
begin{document}
end{document}
The problem is this code does not compile, and the problem is whit the two lines :
renewcommand{sectionmark}[1]{markright{#1}}
renewcommand{chaptermark}[1]{markboth{#1}{}}
To solve the problem I just put them outside the definition of main
headers, but it doesn't give the same result.
How should I fix this error without changing my headers ?
PS. I want the headers to be on right pages like "3 - Section title" and on the left pages (except at a begining of a chapter) like "Chapitre 1 - Title of chapter"
Thanks.
header-footer fancyhdr
1
You shouldn't have the redefinition ofsectionmark
andchaptermark
in the code for the page style.
– egreg
May 17 '16 at 12:16
@egreg I know but where to put it ? When I put it elsewhere it is not taken into acompt during the compilation.
– John Marjan
May 17 '16 at 12:35
add a comment |
up vote
3
down vote
favorite
up vote
3
down vote
favorite
I am writing a long document and I decided to change the headers, using fancyhdr
:
documentclass[12pt,a4paper]{book}
renewcommand*thesection{arabic{section}}
usepackage{fancyhdr}
% Fancyhdr setup
fancypagestyle{main}{
fancyhead{} % clear all header fields
fancyhead[LE]{footnotesize{scshapenouppercase{Chapitre~thechapter ~- ~leftmark}}}
fancyhead[RO]{footnotesize{scshapenouppercase{thesection~-~rightmark}}}
fancyfoot{} % clear all footer fields
fancyfoot[LE,RO]{thepage}
renewcommand{headrulewidth}{0 pt}
renewcommand{footrulewidth}{0 pt}
renewcommand{sectionmark}[1]{markright{#1}}
renewcommand{chaptermark}[1]{markboth{#1}{}}
}
begin{document}
end{document}
The problem is this code does not compile, and the problem is whit the two lines :
renewcommand{sectionmark}[1]{markright{#1}}
renewcommand{chaptermark}[1]{markboth{#1}{}}
To solve the problem I just put them outside the definition of main
headers, but it doesn't give the same result.
How should I fix this error without changing my headers ?
PS. I want the headers to be on right pages like "3 - Section title" and on the left pages (except at a begining of a chapter) like "Chapitre 1 - Title of chapter"
Thanks.
header-footer fancyhdr
I am writing a long document and I decided to change the headers, using fancyhdr
:
documentclass[12pt,a4paper]{book}
renewcommand*thesection{arabic{section}}
usepackage{fancyhdr}
% Fancyhdr setup
fancypagestyle{main}{
fancyhead{} % clear all header fields
fancyhead[LE]{footnotesize{scshapenouppercase{Chapitre~thechapter ~- ~leftmark}}}
fancyhead[RO]{footnotesize{scshapenouppercase{thesection~-~rightmark}}}
fancyfoot{} % clear all footer fields
fancyfoot[LE,RO]{thepage}
renewcommand{headrulewidth}{0 pt}
renewcommand{footrulewidth}{0 pt}
renewcommand{sectionmark}[1]{markright{#1}}
renewcommand{chaptermark}[1]{markboth{#1}{}}
}
begin{document}
end{document}
The problem is this code does not compile, and the problem is whit the two lines :
renewcommand{sectionmark}[1]{markright{#1}}
renewcommand{chaptermark}[1]{markboth{#1}{}}
To solve the problem I just put them outside the definition of main
headers, but it doesn't give the same result.
How should I fix this error without changing my headers ?
PS. I want the headers to be on right pages like "3 - Section title" and on the left pages (except at a begining of a chapter) like "Chapitre 1 - Title of chapter"
Thanks.
header-footer fancyhdr
header-footer fancyhdr
asked May 17 '16 at 12:06
John Marjan
13017
13017
1
You shouldn't have the redefinition ofsectionmark
andchaptermark
in the code for the page style.
– egreg
May 17 '16 at 12:16
@egreg I know but where to put it ? When I put it elsewhere it is not taken into acompt during the compilation.
– John Marjan
May 17 '16 at 12:35
add a comment |
1
You shouldn't have the redefinition ofsectionmark
andchaptermark
in the code for the page style.
– egreg
May 17 '16 at 12:16
@egreg I know but where to put it ? When I put it elsewhere it is not taken into acompt during the compilation.
– John Marjan
May 17 '16 at 12:35
1
1
You shouldn't have the redefinition of
sectionmark
and chaptermark
in the code for the page style.– egreg
May 17 '16 at 12:16
You shouldn't have the redefinition of
sectionmark
and chaptermark
in the code for the page style.– egreg
May 17 '16 at 12:16
@egreg I know but where to put it ? When I put it elsewhere it is not taken into acompt during the compilation.
– John Marjan
May 17 '16 at 12:35
@egreg I know but where to put it ? When I put it elsewhere it is not taken into acompt during the compilation.
– John Marjan
May 17 '16 at 12:35
add a comment |
2 Answers
2
active
oldest
votes
up vote
4
down vote
accepted
Redefine chaptermark
and sectionmark
outside the page style definition after using pagstyle{fancy}
.
usepackage{fancyhdr}
pagestyle{fancy}
renewcommand{sectionmark}[1]{markright{thesection~- ~#1}}
renewcommand{chaptermark}[1]{markboth{chaptername~thechapter~-~ #1}{}}
Code:
documentclass[12pt,a4paper,french]{book}
renewcommand*thesection{arabic{section}}
usepackage[T1]{fontenc}
usepackage{babel}
usepackage{fancyhdr}
pagestyle{fancy}
renewcommand{sectionmark}[1]{markright{thesection~- ~#1}}
renewcommand{chaptermark}[1]{markboth{chaptername~thechapter~-~ #1}{}}
% Fancyhdr setup
fancypagestyle{main}{
fancyhf{} % clear all header fields
fancyhead[LE]{footnotesizescshapeleftmark}
fancyhead[RO]{footnotesizescshaperightmark}
fancyfoot[LE,RO]{thepage}
renewcommand{headrulewidth}{0 pt}
renewcommand{footrulewidth}{0 pt}
}
pagestyle{main}
usepackage{blindtext}% dummy text
begin{document}
blinddocument
end{document}
documentclass[extrafontsizes]{memoir}
InputIfFileExists{scrsize10pt.clo}{}
%usepackage[fontsize=13pt]{scrextend}
usepackage{garamondx}
begin{document}
test
end{document}
Well, that does not work in my computer. Everything is in capital letters in the headings and there is a dot, not an hyphon.
– John Marjan
May 17 '16 at 13:18
1
See my changed answer. You have to usepagestyle{fancy}
before redefiningsectionmark
andchaptermark
.
– esdd
May 17 '16 at 13:34
Ok, thank you ! It works perfectly.
– John Marjan
May 17 '16 at 13:36
add a comment |
up vote
0
down vote
It worked. Thanks. Saved a lot of time.
New contributor
Please don't add "thank you" as an answer. Once you have sufficient reputation, you will be able to vote up questions and answers that you found helpful. - From Review
– samcarter
2 hours ago
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
accepted
Redefine chaptermark
and sectionmark
outside the page style definition after using pagstyle{fancy}
.
usepackage{fancyhdr}
pagestyle{fancy}
renewcommand{sectionmark}[1]{markright{thesection~- ~#1}}
renewcommand{chaptermark}[1]{markboth{chaptername~thechapter~-~ #1}{}}
Code:
documentclass[12pt,a4paper,french]{book}
renewcommand*thesection{arabic{section}}
usepackage[T1]{fontenc}
usepackage{babel}
usepackage{fancyhdr}
pagestyle{fancy}
renewcommand{sectionmark}[1]{markright{thesection~- ~#1}}
renewcommand{chaptermark}[1]{markboth{chaptername~thechapter~-~ #1}{}}
% Fancyhdr setup
fancypagestyle{main}{
fancyhf{} % clear all header fields
fancyhead[LE]{footnotesizescshapeleftmark}
fancyhead[RO]{footnotesizescshaperightmark}
fancyfoot[LE,RO]{thepage}
renewcommand{headrulewidth}{0 pt}
renewcommand{footrulewidth}{0 pt}
}
pagestyle{main}
usepackage{blindtext}% dummy text
begin{document}
blinddocument
end{document}
documentclass[extrafontsizes]{memoir}
InputIfFileExists{scrsize10pt.clo}{}
%usepackage[fontsize=13pt]{scrextend}
usepackage{garamondx}
begin{document}
test
end{document}
Well, that does not work in my computer. Everything is in capital letters in the headings and there is a dot, not an hyphon.
– John Marjan
May 17 '16 at 13:18
1
See my changed answer. You have to usepagestyle{fancy}
before redefiningsectionmark
andchaptermark
.
– esdd
May 17 '16 at 13:34
Ok, thank you ! It works perfectly.
– John Marjan
May 17 '16 at 13:36
add a comment |
up vote
4
down vote
accepted
Redefine chaptermark
and sectionmark
outside the page style definition after using pagstyle{fancy}
.
usepackage{fancyhdr}
pagestyle{fancy}
renewcommand{sectionmark}[1]{markright{thesection~- ~#1}}
renewcommand{chaptermark}[1]{markboth{chaptername~thechapter~-~ #1}{}}
Code:
documentclass[12pt,a4paper,french]{book}
renewcommand*thesection{arabic{section}}
usepackage[T1]{fontenc}
usepackage{babel}
usepackage{fancyhdr}
pagestyle{fancy}
renewcommand{sectionmark}[1]{markright{thesection~- ~#1}}
renewcommand{chaptermark}[1]{markboth{chaptername~thechapter~-~ #1}{}}
% Fancyhdr setup
fancypagestyle{main}{
fancyhf{} % clear all header fields
fancyhead[LE]{footnotesizescshapeleftmark}
fancyhead[RO]{footnotesizescshaperightmark}
fancyfoot[LE,RO]{thepage}
renewcommand{headrulewidth}{0 pt}
renewcommand{footrulewidth}{0 pt}
}
pagestyle{main}
usepackage{blindtext}% dummy text
begin{document}
blinddocument
end{document}
documentclass[extrafontsizes]{memoir}
InputIfFileExists{scrsize10pt.clo}{}
%usepackage[fontsize=13pt]{scrextend}
usepackage{garamondx}
begin{document}
test
end{document}
Well, that does not work in my computer. Everything is in capital letters in the headings and there is a dot, not an hyphon.
– John Marjan
May 17 '16 at 13:18
1
See my changed answer. You have to usepagestyle{fancy}
before redefiningsectionmark
andchaptermark
.
– esdd
May 17 '16 at 13:34
Ok, thank you ! It works perfectly.
– John Marjan
May 17 '16 at 13:36
add a comment |
up vote
4
down vote
accepted
up vote
4
down vote
accepted
Redefine chaptermark
and sectionmark
outside the page style definition after using pagstyle{fancy}
.
usepackage{fancyhdr}
pagestyle{fancy}
renewcommand{sectionmark}[1]{markright{thesection~- ~#1}}
renewcommand{chaptermark}[1]{markboth{chaptername~thechapter~-~ #1}{}}
Code:
documentclass[12pt,a4paper,french]{book}
renewcommand*thesection{arabic{section}}
usepackage[T1]{fontenc}
usepackage{babel}
usepackage{fancyhdr}
pagestyle{fancy}
renewcommand{sectionmark}[1]{markright{thesection~- ~#1}}
renewcommand{chaptermark}[1]{markboth{chaptername~thechapter~-~ #1}{}}
% Fancyhdr setup
fancypagestyle{main}{
fancyhf{} % clear all header fields
fancyhead[LE]{footnotesizescshapeleftmark}
fancyhead[RO]{footnotesizescshaperightmark}
fancyfoot[LE,RO]{thepage}
renewcommand{headrulewidth}{0 pt}
renewcommand{footrulewidth}{0 pt}
}
pagestyle{main}
usepackage{blindtext}% dummy text
begin{document}
blinddocument
end{document}
documentclass[extrafontsizes]{memoir}
InputIfFileExists{scrsize10pt.clo}{}
%usepackage[fontsize=13pt]{scrextend}
usepackage{garamondx}
begin{document}
test
end{document}
Redefine chaptermark
and sectionmark
outside the page style definition after using pagstyle{fancy}
.
usepackage{fancyhdr}
pagestyle{fancy}
renewcommand{sectionmark}[1]{markright{thesection~- ~#1}}
renewcommand{chaptermark}[1]{markboth{chaptername~thechapter~-~ #1}{}}
Code:
documentclass[12pt,a4paper,french]{book}
renewcommand*thesection{arabic{section}}
usepackage[T1]{fontenc}
usepackage{babel}
usepackage{fancyhdr}
pagestyle{fancy}
renewcommand{sectionmark}[1]{markright{thesection~- ~#1}}
renewcommand{chaptermark}[1]{markboth{chaptername~thechapter~-~ #1}{}}
% Fancyhdr setup
fancypagestyle{main}{
fancyhf{} % clear all header fields
fancyhead[LE]{footnotesizescshapeleftmark}
fancyhead[RO]{footnotesizescshaperightmark}
fancyfoot[LE,RO]{thepage}
renewcommand{headrulewidth}{0 pt}
renewcommand{footrulewidth}{0 pt}
}
pagestyle{main}
usepackage{blindtext}% dummy text
begin{document}
blinddocument
end{document}
documentclass[extrafontsizes]{memoir}
InputIfFileExists{scrsize10pt.clo}{}
%usepackage[fontsize=13pt]{scrextend}
usepackage{garamondx}
begin{document}
test
end{document}
edited May 17 '16 at 13:32
answered May 17 '16 at 12:57
esdd
58k34486
58k34486
Well, that does not work in my computer. Everything is in capital letters in the headings and there is a dot, not an hyphon.
– John Marjan
May 17 '16 at 13:18
1
See my changed answer. You have to usepagestyle{fancy}
before redefiningsectionmark
andchaptermark
.
– esdd
May 17 '16 at 13:34
Ok, thank you ! It works perfectly.
– John Marjan
May 17 '16 at 13:36
add a comment |
Well, that does not work in my computer. Everything is in capital letters in the headings and there is a dot, not an hyphon.
– John Marjan
May 17 '16 at 13:18
1
See my changed answer. You have to usepagestyle{fancy}
before redefiningsectionmark
andchaptermark
.
– esdd
May 17 '16 at 13:34
Ok, thank you ! It works perfectly.
– John Marjan
May 17 '16 at 13:36
Well, that does not work in my computer. Everything is in capital letters in the headings and there is a dot, not an hyphon.
– John Marjan
May 17 '16 at 13:18
Well, that does not work in my computer. Everything is in capital letters in the headings and there is a dot, not an hyphon.
– John Marjan
May 17 '16 at 13:18
1
1
See my changed answer. You have to use
pagestyle{fancy}
before redefining sectionmark
and chaptermark
.– esdd
May 17 '16 at 13:34
See my changed answer. You have to use
pagestyle{fancy}
before redefining sectionmark
and chaptermark
.– esdd
May 17 '16 at 13:34
Ok, thank you ! It works perfectly.
– John Marjan
May 17 '16 at 13:36
Ok, thank you ! It works perfectly.
– John Marjan
May 17 '16 at 13:36
add a comment |
up vote
0
down vote
It worked. Thanks. Saved a lot of time.
New contributor
Please don't add "thank you" as an answer. Once you have sufficient reputation, you will be able to vote up questions and answers that you found helpful. - From Review
– samcarter
2 hours ago
add a comment |
up vote
0
down vote
It worked. Thanks. Saved a lot of time.
New contributor
Please don't add "thank you" as an answer. Once you have sufficient reputation, you will be able to vote up questions and answers that you found helpful. - From Review
– samcarter
2 hours ago
add a comment |
up vote
0
down vote
up vote
0
down vote
It worked. Thanks. Saved a lot of time.
New contributor
It worked. Thanks. Saved a lot of time.
New contributor
New contributor
answered 3 hours ago
PARIKSHIT UMRIKAR
1
1
New contributor
New contributor
Please don't add "thank you" as an answer. Once you have sufficient reputation, you will be able to vote up questions and answers that you found helpful. - From Review
– samcarter
2 hours ago
add a comment |
Please don't add "thank you" as an answer. Once you have sufficient reputation, you will be able to vote up questions and answers that you found helpful. - From Review
– samcarter
2 hours ago
Please don't add "thank you" as an answer. Once you have sufficient reputation, you will be able to vote up questions and answers that you found helpful. - From Review
– samcarter
2 hours ago
Please don't add "thank you" as an answer. Once you have sufficient reputation, you will be able to vote up questions and answers that you found helpful. - From Review
– samcarter
2 hours ago
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%2f310046%2ffancyhdr-and-redefinition-of-leftmark-rightmark%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
1
You shouldn't have the redefinition of
sectionmark
andchaptermark
in the code for the page style.– egreg
May 17 '16 at 12:16
@egreg I know but where to put it ? When I put it elsewhere it is not taken into acompt during the compilation.
– John Marjan
May 17 '16 at 12:35