How can I make a coloured footrule using fancyhdr?











up vote
1
down vote

favorite












I found this on the Internet:



renewcommand{footrule}{hbox to headwidth{color{red}leadershrule height footrulewidthhfill}}


So I was wondering if there are any other solutions, that are more simple or just more understandable.



MWE:



documentclass[11pt]{article}
usepackage{color}
usepackage{fancyhdr}
pagestyle{fancy}
renewcommand{footrulewidth}{1pt}
renewcommand{footrule}{hbox to headwidth{color{red}leadershrule height footrulewidthhfill}}









share|improve this question









New contributor




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




















  • Welcome to TeX.SE. It would be helpful if you composed a fully compilable minimal working example (MWE) including documentclass and the appropriate packages that sets up the problem. While solving problems can be fun, setting them up is not. Then, those trying to help can simply cut and paste your MWE and get started on solving the problem.
    – samcarter
    19 hours ago










  • @samcarter I don't have some problems. I just want to know how to make a colored footrule, and I found the code that works for me, but I want to know if there are any other options.
    – Vlashious
    19 hours ago










  • If you would add a small minimal working example (MWE) to your question, it would make it much easier to work on alternative ways too change the footrule colour.
    – samcarter
    19 hours ago










  • @samcarter Okay, I added MWE to the question :)
    – Vlashious
    19 hours ago















up vote
1
down vote

favorite












I found this on the Internet:



renewcommand{footrule}{hbox to headwidth{color{red}leadershrule height footrulewidthhfill}}


So I was wondering if there are any other solutions, that are more simple or just more understandable.



MWE:



documentclass[11pt]{article}
usepackage{color}
usepackage{fancyhdr}
pagestyle{fancy}
renewcommand{footrulewidth}{1pt}
renewcommand{footrule}{hbox to headwidth{color{red}leadershrule height footrulewidthhfill}}









share|improve this question









New contributor




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




















  • Welcome to TeX.SE. It would be helpful if you composed a fully compilable minimal working example (MWE) including documentclass and the appropriate packages that sets up the problem. While solving problems can be fun, setting them up is not. Then, those trying to help can simply cut and paste your MWE and get started on solving the problem.
    – samcarter
    19 hours ago










  • @samcarter I don't have some problems. I just want to know how to make a colored footrule, and I found the code that works for me, but I want to know if there are any other options.
    – Vlashious
    19 hours ago










  • If you would add a small minimal working example (MWE) to your question, it would make it much easier to work on alternative ways too change the footrule colour.
    – samcarter
    19 hours ago










  • @samcarter Okay, I added MWE to the question :)
    – Vlashious
    19 hours ago













up vote
1
down vote

favorite









up vote
1
down vote

favorite











I found this on the Internet:



renewcommand{footrule}{hbox to headwidth{color{red}leadershrule height footrulewidthhfill}}


So I was wondering if there are any other solutions, that are more simple or just more understandable.



MWE:



documentclass[11pt]{article}
usepackage{color}
usepackage{fancyhdr}
pagestyle{fancy}
renewcommand{footrulewidth}{1pt}
renewcommand{footrule}{hbox to headwidth{color{red}leadershrule height footrulewidthhfill}}









share|improve this question









New contributor




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











I found this on the Internet:



renewcommand{footrule}{hbox to headwidth{color{red}leadershrule height footrulewidthhfill}}


So I was wondering if there are any other solutions, that are more simple or just more understandable.



MWE:



documentclass[11pt]{article}
usepackage{color}
usepackage{fancyhdr}
pagestyle{fancy}
renewcommand{footrulewidth}{1pt}
renewcommand{footrule}{hbox to headwidth{color{red}leadershrule height footrulewidthhfill}}






color fancyhdr






share|improve this question









New contributor




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









New contributor




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




share|improve this question








edited 19 hours ago





















New contributor




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









asked 19 hours ago









Vlashious

83




83




New contributor




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





New contributor





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






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












  • Welcome to TeX.SE. It would be helpful if you composed a fully compilable minimal working example (MWE) including documentclass and the appropriate packages that sets up the problem. While solving problems can be fun, setting them up is not. Then, those trying to help can simply cut and paste your MWE and get started on solving the problem.
    – samcarter
    19 hours ago










  • @samcarter I don't have some problems. I just want to know how to make a colored footrule, and I found the code that works for me, but I want to know if there are any other options.
    – Vlashious
    19 hours ago










  • If you would add a small minimal working example (MWE) to your question, it would make it much easier to work on alternative ways too change the footrule colour.
    – samcarter
    19 hours ago










  • @samcarter Okay, I added MWE to the question :)
    – Vlashious
    19 hours ago


















  • Welcome to TeX.SE. It would be helpful if you composed a fully compilable minimal working example (MWE) including documentclass and the appropriate packages that sets up the problem. While solving problems can be fun, setting them up is not. Then, those trying to help can simply cut and paste your MWE and get started on solving the problem.
    – samcarter
    19 hours ago










  • @samcarter I don't have some problems. I just want to know how to make a colored footrule, and I found the code that works for me, but I want to know if there are any other options.
    – Vlashious
    19 hours ago










  • If you would add a small minimal working example (MWE) to your question, it would make it much easier to work on alternative ways too change the footrule colour.
    – samcarter
    19 hours ago










  • @samcarter Okay, I added MWE to the question :)
    – Vlashious
    19 hours ago
















Welcome to TeX.SE. It would be helpful if you composed a fully compilable minimal working example (MWE) including documentclass and the appropriate packages that sets up the problem. While solving problems can be fun, setting them up is not. Then, those trying to help can simply cut and paste your MWE and get started on solving the problem.
– samcarter
19 hours ago




Welcome to TeX.SE. It would be helpful if you composed a fully compilable minimal working example (MWE) including documentclass and the appropriate packages that sets up the problem. While solving problems can be fun, setting them up is not. Then, those trying to help can simply cut and paste your MWE and get started on solving the problem.
– samcarter
19 hours ago












@samcarter I don't have some problems. I just want to know how to make a colored footrule, and I found the code that works for me, but I want to know if there are any other options.
– Vlashious
19 hours ago




@samcarter I don't have some problems. I just want to know how to make a colored footrule, and I found the code that works for me, but I want to know if there are any other options.
– Vlashious
19 hours ago












If you would add a small minimal working example (MWE) to your question, it would make it much easier to work on alternative ways too change the footrule colour.
– samcarter
19 hours ago




If you would add a small minimal working example (MWE) to your question, it would make it much easier to work on alternative ways too change the footrule colour.
– samcarter
19 hours ago












@samcarter Okay, I added MWE to the question :)
– Vlashious
19 hours ago




@samcarter Okay, I added MWE to the question :)
– Vlashious
19 hours ago










2 Answers
2






active

oldest

votes

















up vote
2
down vote



accepted










Not sure if this is really easier than to just add the colour to the definition of the footline, but another method could be patch the command by adding the red colour before and switching back to black afterwards:



documentclass[11pt]{article}
usepackage{color}
usepackage{fancyhdr}
pagestyle{fancy}
renewcommand{footrulewidth}{1pt}

usepackage{xpatch}
xapptocmd{footrule}{color{black}}{}{}
xpretocmd{footrule}{color{red}}{}{}


begin{document}

x

newpage

x

end{document}





share|improve this answer





















  • Thank you for the response. You said I can add the colour to the defenition of the footline. Could you tell me more about this? @samcarter
    – Vlashious
    18 hours ago












  • @Vlashious Adding the colour directly to the footrule definition is what you do in the code in your question
    – samcarter
    18 hours ago


















up vote
2
down vote













The definition you are using for the footrule is actually a little different to the default one contained in fancyhdr.sty, which is:



deffootrule{{if@fancyplainletfootrulewidthplainfootrulewidthfi
vskip-footruleskipvskip-footrulewidth
hrule@widthheadwidth@heightfootrulewidthvskipfootruleskip}}


It's not really necessary to understand this to use it. That's half the point of a package.



To make it coloured, you want to put color{red} at the start of the command, but after the brace that is immediately before if@fancyplain. Puting it within the group will ensure that the colour does not continue beyond the rule.



I would do this by patching footnoterule using the etoolbox package. Something like this (I also prefer xcolor to color—nicer features):



documentclass[11pt]{article}
usepackage{xcolor}
usepackage{fancyhdr}
pagestyle{fancy}
renewcommand{footrulewidth}{1pt}
usepackage{etoolbox}
makeatletter
patchcmd{footrule}
{if@fancyplain}
{color{red}if@fancyplain}
{}
{}
makeatother
begin{document}
null
end{document}


output






share|improve this answer





















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


    }
    });






    Vlashious is a new contributor. Be nice, and check out our Code of Conduct.










     

    draft saved


    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f461675%2fhow-can-i-make-a-coloured-footrule-using-fancyhdr%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
    2
    down vote



    accepted










    Not sure if this is really easier than to just add the colour to the definition of the footline, but another method could be patch the command by adding the red colour before and switching back to black afterwards:



    documentclass[11pt]{article}
    usepackage{color}
    usepackage{fancyhdr}
    pagestyle{fancy}
    renewcommand{footrulewidth}{1pt}

    usepackage{xpatch}
    xapptocmd{footrule}{color{black}}{}{}
    xpretocmd{footrule}{color{red}}{}{}


    begin{document}

    x

    newpage

    x

    end{document}





    share|improve this answer





















    • Thank you for the response. You said I can add the colour to the defenition of the footline. Could you tell me more about this? @samcarter
      – Vlashious
      18 hours ago












    • @Vlashious Adding the colour directly to the footrule definition is what you do in the code in your question
      – samcarter
      18 hours ago















    up vote
    2
    down vote



    accepted










    Not sure if this is really easier than to just add the colour to the definition of the footline, but another method could be patch the command by adding the red colour before and switching back to black afterwards:



    documentclass[11pt]{article}
    usepackage{color}
    usepackage{fancyhdr}
    pagestyle{fancy}
    renewcommand{footrulewidth}{1pt}

    usepackage{xpatch}
    xapptocmd{footrule}{color{black}}{}{}
    xpretocmd{footrule}{color{red}}{}{}


    begin{document}

    x

    newpage

    x

    end{document}





    share|improve this answer





















    • Thank you for the response. You said I can add the colour to the defenition of the footline. Could you tell me more about this? @samcarter
      – Vlashious
      18 hours ago












    • @Vlashious Adding the colour directly to the footrule definition is what you do in the code in your question
      – samcarter
      18 hours ago













    up vote
    2
    down vote



    accepted







    up vote
    2
    down vote



    accepted






    Not sure if this is really easier than to just add the colour to the definition of the footline, but another method could be patch the command by adding the red colour before and switching back to black afterwards:



    documentclass[11pt]{article}
    usepackage{color}
    usepackage{fancyhdr}
    pagestyle{fancy}
    renewcommand{footrulewidth}{1pt}

    usepackage{xpatch}
    xapptocmd{footrule}{color{black}}{}{}
    xpretocmd{footrule}{color{red}}{}{}


    begin{document}

    x

    newpage

    x

    end{document}





    share|improve this answer












    Not sure if this is really easier than to just add the colour to the definition of the footline, but another method could be patch the command by adding the red colour before and switching back to black afterwards:



    documentclass[11pt]{article}
    usepackage{color}
    usepackage{fancyhdr}
    pagestyle{fancy}
    renewcommand{footrulewidth}{1pt}

    usepackage{xpatch}
    xapptocmd{footrule}{color{black}}{}{}
    xpretocmd{footrule}{color{red}}{}{}


    begin{document}

    x

    newpage

    x

    end{document}






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered 19 hours ago









    samcarter

    82.3k793263




    82.3k793263












    • Thank you for the response. You said I can add the colour to the defenition of the footline. Could you tell me more about this? @samcarter
      – Vlashious
      18 hours ago












    • @Vlashious Adding the colour directly to the footrule definition is what you do in the code in your question
      – samcarter
      18 hours ago


















    • Thank you for the response. You said I can add the colour to the defenition of the footline. Could you tell me more about this? @samcarter
      – Vlashious
      18 hours ago












    • @Vlashious Adding the colour directly to the footrule definition is what you do in the code in your question
      – samcarter
      18 hours ago
















    Thank you for the response. You said I can add the colour to the defenition of the footline. Could you tell me more about this? @samcarter
    – Vlashious
    18 hours ago






    Thank you for the response. You said I can add the colour to the defenition of the footline. Could you tell me more about this? @samcarter
    – Vlashious
    18 hours ago














    @Vlashious Adding the colour directly to the footrule definition is what you do in the code in your question
    – samcarter
    18 hours ago




    @Vlashious Adding the colour directly to the footrule definition is what you do in the code in your question
    – samcarter
    18 hours ago










    up vote
    2
    down vote













    The definition you are using for the footrule is actually a little different to the default one contained in fancyhdr.sty, which is:



    deffootrule{{if@fancyplainletfootrulewidthplainfootrulewidthfi
    vskip-footruleskipvskip-footrulewidth
    hrule@widthheadwidth@heightfootrulewidthvskipfootruleskip}}


    It's not really necessary to understand this to use it. That's half the point of a package.



    To make it coloured, you want to put color{red} at the start of the command, but after the brace that is immediately before if@fancyplain. Puting it within the group will ensure that the colour does not continue beyond the rule.



    I would do this by patching footnoterule using the etoolbox package. Something like this (I also prefer xcolor to color—nicer features):



    documentclass[11pt]{article}
    usepackage{xcolor}
    usepackage{fancyhdr}
    pagestyle{fancy}
    renewcommand{footrulewidth}{1pt}
    usepackage{etoolbox}
    makeatletter
    patchcmd{footrule}
    {if@fancyplain}
    {color{red}if@fancyplain}
    {}
    {}
    makeatother
    begin{document}
    null
    end{document}


    output






    share|improve this answer

























      up vote
      2
      down vote













      The definition you are using for the footrule is actually a little different to the default one contained in fancyhdr.sty, which is:



      deffootrule{{if@fancyplainletfootrulewidthplainfootrulewidthfi
      vskip-footruleskipvskip-footrulewidth
      hrule@widthheadwidth@heightfootrulewidthvskipfootruleskip}}


      It's not really necessary to understand this to use it. That's half the point of a package.



      To make it coloured, you want to put color{red} at the start of the command, but after the brace that is immediately before if@fancyplain. Puting it within the group will ensure that the colour does not continue beyond the rule.



      I would do this by patching footnoterule using the etoolbox package. Something like this (I also prefer xcolor to color—nicer features):



      documentclass[11pt]{article}
      usepackage{xcolor}
      usepackage{fancyhdr}
      pagestyle{fancy}
      renewcommand{footrulewidth}{1pt}
      usepackage{etoolbox}
      makeatletter
      patchcmd{footrule}
      {if@fancyplain}
      {color{red}if@fancyplain}
      {}
      {}
      makeatother
      begin{document}
      null
      end{document}


      output






      share|improve this answer























        up vote
        2
        down vote










        up vote
        2
        down vote









        The definition you are using for the footrule is actually a little different to the default one contained in fancyhdr.sty, which is:



        deffootrule{{if@fancyplainletfootrulewidthplainfootrulewidthfi
        vskip-footruleskipvskip-footrulewidth
        hrule@widthheadwidth@heightfootrulewidthvskipfootruleskip}}


        It's not really necessary to understand this to use it. That's half the point of a package.



        To make it coloured, you want to put color{red} at the start of the command, but after the brace that is immediately before if@fancyplain. Puting it within the group will ensure that the colour does not continue beyond the rule.



        I would do this by patching footnoterule using the etoolbox package. Something like this (I also prefer xcolor to color—nicer features):



        documentclass[11pt]{article}
        usepackage{xcolor}
        usepackage{fancyhdr}
        pagestyle{fancy}
        renewcommand{footrulewidth}{1pt}
        usepackage{etoolbox}
        makeatletter
        patchcmd{footrule}
        {if@fancyplain}
        {color{red}if@fancyplain}
        {}
        {}
        makeatother
        begin{document}
        null
        end{document}


        output






        share|improve this answer












        The definition you are using for the footrule is actually a little different to the default one contained in fancyhdr.sty, which is:



        deffootrule{{if@fancyplainletfootrulewidthplainfootrulewidthfi
        vskip-footruleskipvskip-footrulewidth
        hrule@widthheadwidth@heightfootrulewidthvskipfootruleskip}}


        It's not really necessary to understand this to use it. That's half the point of a package.



        To make it coloured, you want to put color{red} at the start of the command, but after the brace that is immediately before if@fancyplain. Puting it within the group will ensure that the colour does not continue beyond the rule.



        I would do this by patching footnoterule using the etoolbox package. Something like this (I also prefer xcolor to color—nicer features):



        documentclass[11pt]{article}
        usepackage{xcolor}
        usepackage{fancyhdr}
        pagestyle{fancy}
        renewcommand{footrulewidth}{1pt}
        usepackage{etoolbox}
        makeatletter
        patchcmd{footrule}
        {if@fancyplain}
        {color{red}if@fancyplain}
        {}
        {}
        makeatother
        begin{document}
        null
        end{document}


        output







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 19 hours ago









        David Purton

        8,3361834




        8,3361834






















            Vlashious is a new contributor. Be nice, and check out our Code of Conduct.










             

            draft saved


            draft discarded


















            Vlashious is a new contributor. Be nice, and check out our Code of Conduct.













            Vlashious is a new contributor. Be nice, and check out our Code of Conduct.












            Vlashious is a new contributor. Be nice, and check out our Code of Conduct.















             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f461675%2fhow-can-i-make-a-coloured-footrule-using-fancyhdr%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

            Accessing regular linux commands in Huawei's Dopra Linux

            Can't connect RFCOMM socket: Host is down

            Kernel panic - not syncing: Fatal Exception in Interrupt