Change the color of the header line












4















The answer to the question fancyhdr - Change horizontal line color on top of footer is not completely satisfactory, because it changes the position of the header line,
for example with this example.



documentclass{article}

usepackage{xcolor}
usepackage{fancyhdr}
renewcommand{headrulewidth}{0.5pt}
renewcommand{headrule}{hbox toheadwidth{color{red}leadershrule height headrulewidthhfill}}
fancyhead[LE,RO]{Hello}
pagestyle{fancy}

begin{document}
hello
end{document}


Is it possible to change only the color of the line, without changing its position?










share|improve this question




















  • 1





    A simple renewcommand{headrule}{{color{red}rule{textwidth}{0.5pt}}} should do the trick.

    – Bernard
    Mar 14 at 18:33











  • Thanks, but it does not (at least not on my computer).

    – Rastapopoulos
    Mar 14 at 18:34











  • The position of the line isn't changed, neither with your code nor with mine. How is it modified, precisely?

    – Bernard
    Mar 14 at 19:15
















4















The answer to the question fancyhdr - Change horizontal line color on top of footer is not completely satisfactory, because it changes the position of the header line,
for example with this example.



documentclass{article}

usepackage{xcolor}
usepackage{fancyhdr}
renewcommand{headrulewidth}{0.5pt}
renewcommand{headrule}{hbox toheadwidth{color{red}leadershrule height headrulewidthhfill}}
fancyhead[LE,RO]{Hello}
pagestyle{fancy}

begin{document}
hello
end{document}


Is it possible to change only the color of the line, without changing its position?










share|improve this question




















  • 1





    A simple renewcommand{headrule}{{color{red}rule{textwidth}{0.5pt}}} should do the trick.

    – Bernard
    Mar 14 at 18:33











  • Thanks, but it does not (at least not on my computer).

    – Rastapopoulos
    Mar 14 at 18:34











  • The position of the line isn't changed, neither with your code nor with mine. How is it modified, precisely?

    – Bernard
    Mar 14 at 19:15














4












4








4


1






The answer to the question fancyhdr - Change horizontal line color on top of footer is not completely satisfactory, because it changes the position of the header line,
for example with this example.



documentclass{article}

usepackage{xcolor}
usepackage{fancyhdr}
renewcommand{headrulewidth}{0.5pt}
renewcommand{headrule}{hbox toheadwidth{color{red}leadershrule height headrulewidthhfill}}
fancyhead[LE,RO]{Hello}
pagestyle{fancy}

begin{document}
hello
end{document}


Is it possible to change only the color of the line, without changing its position?










share|improve this question
















The answer to the question fancyhdr - Change horizontal line color on top of footer is not completely satisfactory, because it changes the position of the header line,
for example with this example.



documentclass{article}

usepackage{xcolor}
usepackage{fancyhdr}
renewcommand{headrulewidth}{0.5pt}
renewcommand{headrule}{hbox toheadwidth{color{red}leadershrule height headrulewidthhfill}}
fancyhead[LE,RO]{Hello}
pagestyle{fancy}

begin{document}
hello
end{document}


Is it possible to change only the color of the line, without changing its position?







color fancyhdr rules






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 14 at 19:20









Werner

448k719931698




448k719931698










asked Mar 14 at 18:07









RastapopoulosRastapopoulos

1737




1737








  • 1





    A simple renewcommand{headrule}{{color{red}rule{textwidth}{0.5pt}}} should do the trick.

    – Bernard
    Mar 14 at 18:33











  • Thanks, but it does not (at least not on my computer).

    – Rastapopoulos
    Mar 14 at 18:34











  • The position of the line isn't changed, neither with your code nor with mine. How is it modified, precisely?

    – Bernard
    Mar 14 at 19:15














  • 1





    A simple renewcommand{headrule}{{color{red}rule{textwidth}{0.5pt}}} should do the trick.

    – Bernard
    Mar 14 at 18:33











  • Thanks, but it does not (at least not on my computer).

    – Rastapopoulos
    Mar 14 at 18:34











  • The position of the line isn't changed, neither with your code nor with mine. How is it modified, precisely?

    – Bernard
    Mar 14 at 19:15








1




1





A simple renewcommand{headrule}{{color{red}rule{textwidth}{0.5pt}}} should do the trick.

– Bernard
Mar 14 at 18:33





A simple renewcommand{headrule}{{color{red}rule{textwidth}{0.5pt}}} should do the trick.

– Bernard
Mar 14 at 18:33













Thanks, but it does not (at least not on my computer).

– Rastapopoulos
Mar 14 at 18:34





Thanks, but it does not (at least not on my computer).

– Rastapopoulos
Mar 14 at 18:34













The position of the line isn't changed, neither with your code nor with mine. How is it modified, precisely?

– Bernard
Mar 14 at 19:15





The position of the line isn't changed, neither with your code nor with mine. How is it modified, precisely?

– Bernard
Mar 14 at 19:15










1 Answer
1






active

oldest

votes


















3














Below I save the original headrule in oldheadrule, and then prepend color{<colour>} to a newly-defined headrule that just calls oldheadrule. The approach is similar to etoolbox's pretocmd.



enter image description here



documentclass{article}

usepackage{fancyhdr,xcolor}

letoldheadruleheadrule% Copy headrule into oldheadrule
renewcommand{headrule}{color{red}oldheadrule}% Add colour to headrule
renewcommand{headrulewidth}{0.5pt}
fancyhead{Hello}
pagestyle{fancy}

begin{document}

Lorem ipsumldots

clearpage

Lorem ipsumldots

end{document}





share|improve this answer
























  • Thank you very much! I had tried exactly this, but with newcommand{oldheadrule}{headrule}, which resulted in an infinite loop.

    – Rastapopoulos
    Mar 14 at 19:19











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


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f479529%2fchange-the-color-of-the-header-line%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









3














Below I save the original headrule in oldheadrule, and then prepend color{<colour>} to a newly-defined headrule that just calls oldheadrule. The approach is similar to etoolbox's pretocmd.



enter image description here



documentclass{article}

usepackage{fancyhdr,xcolor}

letoldheadruleheadrule% Copy headrule into oldheadrule
renewcommand{headrule}{color{red}oldheadrule}% Add colour to headrule
renewcommand{headrulewidth}{0.5pt}
fancyhead{Hello}
pagestyle{fancy}

begin{document}

Lorem ipsumldots

clearpage

Lorem ipsumldots

end{document}





share|improve this answer
























  • Thank you very much! I had tried exactly this, but with newcommand{oldheadrule}{headrule}, which resulted in an infinite loop.

    – Rastapopoulos
    Mar 14 at 19:19
















3














Below I save the original headrule in oldheadrule, and then prepend color{<colour>} to a newly-defined headrule that just calls oldheadrule. The approach is similar to etoolbox's pretocmd.



enter image description here



documentclass{article}

usepackage{fancyhdr,xcolor}

letoldheadruleheadrule% Copy headrule into oldheadrule
renewcommand{headrule}{color{red}oldheadrule}% Add colour to headrule
renewcommand{headrulewidth}{0.5pt}
fancyhead{Hello}
pagestyle{fancy}

begin{document}

Lorem ipsumldots

clearpage

Lorem ipsumldots

end{document}





share|improve this answer
























  • Thank you very much! I had tried exactly this, but with newcommand{oldheadrule}{headrule}, which resulted in an infinite loop.

    – Rastapopoulos
    Mar 14 at 19:19














3












3








3







Below I save the original headrule in oldheadrule, and then prepend color{<colour>} to a newly-defined headrule that just calls oldheadrule. The approach is similar to etoolbox's pretocmd.



enter image description here



documentclass{article}

usepackage{fancyhdr,xcolor}

letoldheadruleheadrule% Copy headrule into oldheadrule
renewcommand{headrule}{color{red}oldheadrule}% Add colour to headrule
renewcommand{headrulewidth}{0.5pt}
fancyhead{Hello}
pagestyle{fancy}

begin{document}

Lorem ipsumldots

clearpage

Lorem ipsumldots

end{document}





share|improve this answer













Below I save the original headrule in oldheadrule, and then prepend color{<colour>} to a newly-defined headrule that just calls oldheadrule. The approach is similar to etoolbox's pretocmd.



enter image description here



documentclass{article}

usepackage{fancyhdr,xcolor}

letoldheadruleheadrule% Copy headrule into oldheadrule
renewcommand{headrule}{color{red}oldheadrule}% Add colour to headrule
renewcommand{headrulewidth}{0.5pt}
fancyhead{Hello}
pagestyle{fancy}

begin{document}

Lorem ipsumldots

clearpage

Lorem ipsumldots

end{document}






share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 14 at 19:12









WernerWerner

448k719931698




448k719931698













  • Thank you very much! I had tried exactly this, but with newcommand{oldheadrule}{headrule}, which resulted in an infinite loop.

    – Rastapopoulos
    Mar 14 at 19:19



















  • Thank you very much! I had tried exactly this, but with newcommand{oldheadrule}{headrule}, which resulted in an infinite loop.

    – Rastapopoulos
    Mar 14 at 19:19

















Thank you very much! I had tried exactly this, but with newcommand{oldheadrule}{headrule}, which resulted in an infinite loop.

– Rastapopoulos
Mar 14 at 19:19





Thank you very much! I had tried exactly this, but with newcommand{oldheadrule}{headrule}, which resulted in an infinite loop.

– Rastapopoulos
Mar 14 at 19:19


















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.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f479529%2fchange-the-color-of-the-header-line%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

Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

ComboBox Display Member on multiple fields

Is it possible to collect Nectar points via Trainline?