Fancyhdr and redefinition of leftmark/rightmark











up vote
3
down vote

favorite
6












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.










share|improve this question


















  • 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










  • @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















up vote
3
down vote

favorite
6












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.










share|improve this question


















  • 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










  • @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













up vote
3
down vote

favorite
6









up vote
3
down vote

favorite
6






6





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.










share|improve this question













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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked May 17 '16 at 12:06









John Marjan

13017




13017








  • 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










  • @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




    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








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










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}{}}


enter image description here



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}





share|improve this answer























  • 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 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




















up vote
0
down vote













It worked. Thanks. Saved a lot of time.






share|improve this answer








New contributor




PARIKSHIT UMRIKAR is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.


















  • 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











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',
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
});


}
});














draft saved

draft discarded


















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

























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}{}}


enter image description here



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}





share|improve this answer























  • 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 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

















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}{}}


enter image description here



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}





share|improve this answer























  • 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 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















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}{}}


enter image description here



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}





share|improve this answer














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}{}}


enter image description here



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}






share|improve this answer














share|improve this answer



share|improve this answer








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 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




















  • 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 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


















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












up vote
0
down vote













It worked. Thanks. Saved a lot of time.






share|improve this answer








New contributor




PARIKSHIT UMRIKAR is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.


















  • 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















up vote
0
down vote













It worked. Thanks. Saved a lot of time.






share|improve this answer








New contributor




PARIKSHIT UMRIKAR is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.


















  • 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













up vote
0
down vote










up vote
0
down vote









It worked. Thanks. Saved a lot of time.






share|improve this answer








New contributor




PARIKSHIT UMRIKAR is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









It worked. Thanks. Saved a lot of time.







share|improve this answer








New contributor




PARIKSHIT UMRIKAR is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this answer



share|improve this answer






New contributor




PARIKSHIT UMRIKAR is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









answered 3 hours ago









PARIKSHIT UMRIKAR

1




1




New contributor




PARIKSHIT UMRIKAR is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





PARIKSHIT UMRIKAR is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






PARIKSHIT UMRIKAR is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • 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




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


















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Contact image not getting when fetch all contact list from iPhone by CNContact

count number of partitions of a set with n elements into k subsets

A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks