How to add horizontal line after header and before footer?












10















How can I add horizontal line after header and before footer?



header
---------

---------
footer









share|improve this question

























  • I wonder what the solution for Plain TeX is.

    – Palec
    Apr 4 '15 at 9:51


















10















How can I add horizontal line after header and before footer?



header
---------

---------
footer









share|improve this question

























  • I wonder what the solution for Plain TeX is.

    – Palec
    Apr 4 '15 at 9:51
















10












10








10


4






How can I add horizontal line after header and before footer?



header
---------

---------
footer









share|improve this question
















How can I add horizontal line after header and before footer?



header
---------

---------
footer






header-footer rules






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 17 '13 at 3:19









Werner

445k699811686




445k699811686










asked Apr 17 '13 at 3:05









manishmanish

3,108184674




3,108184674













  • I wonder what the solution for Plain TeX is.

    – Palec
    Apr 4 '15 at 9:51





















  • I wonder what the solution for Plain TeX is.

    – Palec
    Apr 4 '15 at 9:51



















I wonder what the solution for Plain TeX is.

– Palec
Apr 4 '15 at 9:51







I wonder what the solution for Plain TeX is.

– Palec
Apr 4 '15 at 9:51












2 Answers
2






active

oldest

votes


















17














Your easiest approach here would be to include the fancyhdr package and set the header/footer rule widths using renewcommand:



enter image description here



documentclass{article}
usepackage{fancyhdr}% http://ctan.org/pkg/fancyhdr
pagestyle{fancy}% Change page style to fancy
fancyhf{}% Clear header/footer
fancyhead[C]{Header}
fancyfoot[C]{Footer}% fancyfoot[R]{thepage}
renewcommand{headrulewidth}{0.4pt}% Default headrulewidth is 0.4pt
renewcommand{footrulewidth}{0.4pt}% Default footrulewidth is 0pt
begin{document}
Here is some text.
end{document}


Headers and footers are simultaneously cleared using fancyhf{}, and individually set using fancyhead[<pos>]{<stuff>} and fancyfoot[<pos>]{<stuff>}. See the fancyhdr documentation.





Modifying the colour of the header/footer rules is a bit more tricky, since fancyhdr doesn't supply this modification by default. etoolbox can be used to update the two rule macros headrule and footrule to insert the colour as needed. They are defined as follows:



defheadrule{{if@fancyplainletheadrulewidthplainheadrulewidthfi
hrule@heightheadrulewidth@widthheadwidth vskip-headrulewidth}}

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


It is clear that the horizontal rule is drawn using hrule, so we can patch these commands and insert color{<colour>} just before drawing it by means of the following convenient helper macros:



usepackage{etoolbox,fancyhdr,xcolor}% http://ctan.org/pkg/{etoolbox,fancyhdr,xcolor}
% patchcmd{<cmd>}{<search>}{<replace>}{<success>}{<failure>}
newcommand{headrulecolor}[1]{patchcmd{headrule}{hrule}{color{#1}hrule}{}{}}
newcommand{footrulecolor}[1]{patchcmd{footrule}{hrule}{color{#1}hrule}{}{}}


This allows you to use headrulecolor{<colour>} or footrulecolor{<colour>} in order to change them individually. The above patch is standard for etoolbox, so see the etoolbox documentation on how patchcmd works. Here's a complete MWE:



enter image description here



documentclass{article}
usepackage{etoolbox,fancyhdr,xcolor}% http://ctan.org/pkg/{etoolbox,fancyhdr,xcolor}
% patchcmd{<cmd>}{<search>}{<replace>}{<success>}{<failure>}
newcommand{headrulecolor}[1]{patchcmd{headrule}{hrule}{color{#1}hrule}{}{}}
newcommand{footrulecolor}[1]{patchcmd{footrule}{hrule}{color{#1}hrule}{}{}}
pagestyle{fancy}
fancyhf{}% Clear header/footer
fancyhead[C]{Header}
fancyfoot[C]{Footer}% fancyfoot[R]{thepage}
renewcommand{headrulewidth}{0.4pt}% Default headrulewidth is 0.4pt
renewcommand{footrulewidth}{0.4pt}% Default footrulewidth is 0pt
headrulecolor{red!70}% Set header rule colour to 70% red.
begin{document}
Here is some text.
end{document}





share|improve this answer

































    9














    Here's another option using the titleps package:



    documentclass{article}
    usepackage{titleps}

    newpagestyle{ruled}
    {sethead{}{Header}{}headrule
    setfoot{}{Footer}{}footrule}
    pagestyle{ruled}

    begin{document}
    Here is some text.
    end{document}


    enter image description here



    Redefining makeheadrule and makefootrule, you can change the attributes; for example, to change the color:



    documentclass{article}
    usepackage{xcolor}
    usepackage{titleps}

    newpagestyle{ruled}
    {sethead{}{Header}{}headrule
    setfoot{}{Footer}{}footrule}
    pagestyle{ruled}

    renewcommandmakeheadrule{color{cyan}rule[-.3baselineskip]{linewidth}{0.4pt}}
    renewcommandmakefootrule{color{cyan}rule[baselineskip]{linewidth}{0.4pt}}

    begin{document}
    Here is some text.
    end{document}


    enter image description here



    Of course, you can switch to other page style at any moment:



    documentclass{article}
    usepackage{titleps}

    newpagestyle{ruled}
    {sethead{}{Header}{}headrule
    setfoot{}{Footer}{}footrule}
    pagestyle{ruled}

    begin{document}
    Here is some text.newpage
    Here is some text.newpage
    pagestyle{plain}
    text
    end{document}





    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',
      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%2f109153%2fhow-to-add-horizontal-line-after-header-and-before-footer%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









      17














      Your easiest approach here would be to include the fancyhdr package and set the header/footer rule widths using renewcommand:



      enter image description here



      documentclass{article}
      usepackage{fancyhdr}% http://ctan.org/pkg/fancyhdr
      pagestyle{fancy}% Change page style to fancy
      fancyhf{}% Clear header/footer
      fancyhead[C]{Header}
      fancyfoot[C]{Footer}% fancyfoot[R]{thepage}
      renewcommand{headrulewidth}{0.4pt}% Default headrulewidth is 0.4pt
      renewcommand{footrulewidth}{0.4pt}% Default footrulewidth is 0pt
      begin{document}
      Here is some text.
      end{document}


      Headers and footers are simultaneously cleared using fancyhf{}, and individually set using fancyhead[<pos>]{<stuff>} and fancyfoot[<pos>]{<stuff>}. See the fancyhdr documentation.





      Modifying the colour of the header/footer rules is a bit more tricky, since fancyhdr doesn't supply this modification by default. etoolbox can be used to update the two rule macros headrule and footrule to insert the colour as needed. They are defined as follows:



      defheadrule{{if@fancyplainletheadrulewidthplainheadrulewidthfi
      hrule@heightheadrulewidth@widthheadwidth vskip-headrulewidth}}

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


      It is clear that the horizontal rule is drawn using hrule, so we can patch these commands and insert color{<colour>} just before drawing it by means of the following convenient helper macros:



      usepackage{etoolbox,fancyhdr,xcolor}% http://ctan.org/pkg/{etoolbox,fancyhdr,xcolor}
      % patchcmd{<cmd>}{<search>}{<replace>}{<success>}{<failure>}
      newcommand{headrulecolor}[1]{patchcmd{headrule}{hrule}{color{#1}hrule}{}{}}
      newcommand{footrulecolor}[1]{patchcmd{footrule}{hrule}{color{#1}hrule}{}{}}


      This allows you to use headrulecolor{<colour>} or footrulecolor{<colour>} in order to change them individually. The above patch is standard for etoolbox, so see the etoolbox documentation on how patchcmd works. Here's a complete MWE:



      enter image description here



      documentclass{article}
      usepackage{etoolbox,fancyhdr,xcolor}% http://ctan.org/pkg/{etoolbox,fancyhdr,xcolor}
      % patchcmd{<cmd>}{<search>}{<replace>}{<success>}{<failure>}
      newcommand{headrulecolor}[1]{patchcmd{headrule}{hrule}{color{#1}hrule}{}{}}
      newcommand{footrulecolor}[1]{patchcmd{footrule}{hrule}{color{#1}hrule}{}{}}
      pagestyle{fancy}
      fancyhf{}% Clear header/footer
      fancyhead[C]{Header}
      fancyfoot[C]{Footer}% fancyfoot[R]{thepage}
      renewcommand{headrulewidth}{0.4pt}% Default headrulewidth is 0.4pt
      renewcommand{footrulewidth}{0.4pt}% Default footrulewidth is 0pt
      headrulecolor{red!70}% Set header rule colour to 70% red.
      begin{document}
      Here is some text.
      end{document}





      share|improve this answer






























        17














        Your easiest approach here would be to include the fancyhdr package and set the header/footer rule widths using renewcommand:



        enter image description here



        documentclass{article}
        usepackage{fancyhdr}% http://ctan.org/pkg/fancyhdr
        pagestyle{fancy}% Change page style to fancy
        fancyhf{}% Clear header/footer
        fancyhead[C]{Header}
        fancyfoot[C]{Footer}% fancyfoot[R]{thepage}
        renewcommand{headrulewidth}{0.4pt}% Default headrulewidth is 0.4pt
        renewcommand{footrulewidth}{0.4pt}% Default footrulewidth is 0pt
        begin{document}
        Here is some text.
        end{document}


        Headers and footers are simultaneously cleared using fancyhf{}, and individually set using fancyhead[<pos>]{<stuff>} and fancyfoot[<pos>]{<stuff>}. See the fancyhdr documentation.





        Modifying the colour of the header/footer rules is a bit more tricky, since fancyhdr doesn't supply this modification by default. etoolbox can be used to update the two rule macros headrule and footrule to insert the colour as needed. They are defined as follows:



        defheadrule{{if@fancyplainletheadrulewidthplainheadrulewidthfi
        hrule@heightheadrulewidth@widthheadwidth vskip-headrulewidth}}

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


        It is clear that the horizontal rule is drawn using hrule, so we can patch these commands and insert color{<colour>} just before drawing it by means of the following convenient helper macros:



        usepackage{etoolbox,fancyhdr,xcolor}% http://ctan.org/pkg/{etoolbox,fancyhdr,xcolor}
        % patchcmd{<cmd>}{<search>}{<replace>}{<success>}{<failure>}
        newcommand{headrulecolor}[1]{patchcmd{headrule}{hrule}{color{#1}hrule}{}{}}
        newcommand{footrulecolor}[1]{patchcmd{footrule}{hrule}{color{#1}hrule}{}{}}


        This allows you to use headrulecolor{<colour>} or footrulecolor{<colour>} in order to change them individually. The above patch is standard for etoolbox, so see the etoolbox documentation on how patchcmd works. Here's a complete MWE:



        enter image description here



        documentclass{article}
        usepackage{etoolbox,fancyhdr,xcolor}% http://ctan.org/pkg/{etoolbox,fancyhdr,xcolor}
        % patchcmd{<cmd>}{<search>}{<replace>}{<success>}{<failure>}
        newcommand{headrulecolor}[1]{patchcmd{headrule}{hrule}{color{#1}hrule}{}{}}
        newcommand{footrulecolor}[1]{patchcmd{footrule}{hrule}{color{#1}hrule}{}{}}
        pagestyle{fancy}
        fancyhf{}% Clear header/footer
        fancyhead[C]{Header}
        fancyfoot[C]{Footer}% fancyfoot[R]{thepage}
        renewcommand{headrulewidth}{0.4pt}% Default headrulewidth is 0.4pt
        renewcommand{footrulewidth}{0.4pt}% Default footrulewidth is 0pt
        headrulecolor{red!70}% Set header rule colour to 70% red.
        begin{document}
        Here is some text.
        end{document}





        share|improve this answer




























          17












          17








          17







          Your easiest approach here would be to include the fancyhdr package and set the header/footer rule widths using renewcommand:



          enter image description here



          documentclass{article}
          usepackage{fancyhdr}% http://ctan.org/pkg/fancyhdr
          pagestyle{fancy}% Change page style to fancy
          fancyhf{}% Clear header/footer
          fancyhead[C]{Header}
          fancyfoot[C]{Footer}% fancyfoot[R]{thepage}
          renewcommand{headrulewidth}{0.4pt}% Default headrulewidth is 0.4pt
          renewcommand{footrulewidth}{0.4pt}% Default footrulewidth is 0pt
          begin{document}
          Here is some text.
          end{document}


          Headers and footers are simultaneously cleared using fancyhf{}, and individually set using fancyhead[<pos>]{<stuff>} and fancyfoot[<pos>]{<stuff>}. See the fancyhdr documentation.





          Modifying the colour of the header/footer rules is a bit more tricky, since fancyhdr doesn't supply this modification by default. etoolbox can be used to update the two rule macros headrule and footrule to insert the colour as needed. They are defined as follows:



          defheadrule{{if@fancyplainletheadrulewidthplainheadrulewidthfi
          hrule@heightheadrulewidth@widthheadwidth vskip-headrulewidth}}

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


          It is clear that the horizontal rule is drawn using hrule, so we can patch these commands and insert color{<colour>} just before drawing it by means of the following convenient helper macros:



          usepackage{etoolbox,fancyhdr,xcolor}% http://ctan.org/pkg/{etoolbox,fancyhdr,xcolor}
          % patchcmd{<cmd>}{<search>}{<replace>}{<success>}{<failure>}
          newcommand{headrulecolor}[1]{patchcmd{headrule}{hrule}{color{#1}hrule}{}{}}
          newcommand{footrulecolor}[1]{patchcmd{footrule}{hrule}{color{#1}hrule}{}{}}


          This allows you to use headrulecolor{<colour>} or footrulecolor{<colour>} in order to change them individually. The above patch is standard for etoolbox, so see the etoolbox documentation on how patchcmd works. Here's a complete MWE:



          enter image description here



          documentclass{article}
          usepackage{etoolbox,fancyhdr,xcolor}% http://ctan.org/pkg/{etoolbox,fancyhdr,xcolor}
          % patchcmd{<cmd>}{<search>}{<replace>}{<success>}{<failure>}
          newcommand{headrulecolor}[1]{patchcmd{headrule}{hrule}{color{#1}hrule}{}{}}
          newcommand{footrulecolor}[1]{patchcmd{footrule}{hrule}{color{#1}hrule}{}{}}
          pagestyle{fancy}
          fancyhf{}% Clear header/footer
          fancyhead[C]{Header}
          fancyfoot[C]{Footer}% fancyfoot[R]{thepage}
          renewcommand{headrulewidth}{0.4pt}% Default headrulewidth is 0.4pt
          renewcommand{footrulewidth}{0.4pt}% Default footrulewidth is 0pt
          headrulecolor{red!70}% Set header rule colour to 70% red.
          begin{document}
          Here is some text.
          end{document}





          share|improve this answer















          Your easiest approach here would be to include the fancyhdr package and set the header/footer rule widths using renewcommand:



          enter image description here



          documentclass{article}
          usepackage{fancyhdr}% http://ctan.org/pkg/fancyhdr
          pagestyle{fancy}% Change page style to fancy
          fancyhf{}% Clear header/footer
          fancyhead[C]{Header}
          fancyfoot[C]{Footer}% fancyfoot[R]{thepage}
          renewcommand{headrulewidth}{0.4pt}% Default headrulewidth is 0.4pt
          renewcommand{footrulewidth}{0.4pt}% Default footrulewidth is 0pt
          begin{document}
          Here is some text.
          end{document}


          Headers and footers are simultaneously cleared using fancyhf{}, and individually set using fancyhead[<pos>]{<stuff>} and fancyfoot[<pos>]{<stuff>}. See the fancyhdr documentation.





          Modifying the colour of the header/footer rules is a bit more tricky, since fancyhdr doesn't supply this modification by default. etoolbox can be used to update the two rule macros headrule and footrule to insert the colour as needed. They are defined as follows:



          defheadrule{{if@fancyplainletheadrulewidthplainheadrulewidthfi
          hrule@heightheadrulewidth@widthheadwidth vskip-headrulewidth}}

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


          It is clear that the horizontal rule is drawn using hrule, so we can patch these commands and insert color{<colour>} just before drawing it by means of the following convenient helper macros:



          usepackage{etoolbox,fancyhdr,xcolor}% http://ctan.org/pkg/{etoolbox,fancyhdr,xcolor}
          % patchcmd{<cmd>}{<search>}{<replace>}{<success>}{<failure>}
          newcommand{headrulecolor}[1]{patchcmd{headrule}{hrule}{color{#1}hrule}{}{}}
          newcommand{footrulecolor}[1]{patchcmd{footrule}{hrule}{color{#1}hrule}{}{}}


          This allows you to use headrulecolor{<colour>} or footrulecolor{<colour>} in order to change them individually. The above patch is standard for etoolbox, so see the etoolbox documentation on how patchcmd works. Here's a complete MWE:



          enter image description here



          documentclass{article}
          usepackage{etoolbox,fancyhdr,xcolor}% http://ctan.org/pkg/{etoolbox,fancyhdr,xcolor}
          % patchcmd{<cmd>}{<search>}{<replace>}{<success>}{<failure>}
          newcommand{headrulecolor}[1]{patchcmd{headrule}{hrule}{color{#1}hrule}{}{}}
          newcommand{footrulecolor}[1]{patchcmd{footrule}{hrule}{color{#1}hrule}{}{}}
          pagestyle{fancy}
          fancyhf{}% Clear header/footer
          fancyhead[C]{Header}
          fancyfoot[C]{Footer}% fancyfoot[R]{thepage}
          renewcommand{headrulewidth}{0.4pt}% Default headrulewidth is 0.4pt
          renewcommand{footrulewidth}{0.4pt}% Default footrulewidth is 0pt
          headrulecolor{red!70}% Set header rule colour to 70% red.
          begin{document}
          Here is some text.
          end{document}






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Apr 17 '13 at 10:54

























          answered Apr 17 '13 at 3:15









          WernerWerner

          445k699811686




          445k699811686























              9














              Here's another option using the titleps package:



              documentclass{article}
              usepackage{titleps}

              newpagestyle{ruled}
              {sethead{}{Header}{}headrule
              setfoot{}{Footer}{}footrule}
              pagestyle{ruled}

              begin{document}
              Here is some text.
              end{document}


              enter image description here



              Redefining makeheadrule and makefootrule, you can change the attributes; for example, to change the color:



              documentclass{article}
              usepackage{xcolor}
              usepackage{titleps}

              newpagestyle{ruled}
              {sethead{}{Header}{}headrule
              setfoot{}{Footer}{}footrule}
              pagestyle{ruled}

              renewcommandmakeheadrule{color{cyan}rule[-.3baselineskip]{linewidth}{0.4pt}}
              renewcommandmakefootrule{color{cyan}rule[baselineskip]{linewidth}{0.4pt}}

              begin{document}
              Here is some text.
              end{document}


              enter image description here



              Of course, you can switch to other page style at any moment:



              documentclass{article}
              usepackage{titleps}

              newpagestyle{ruled}
              {sethead{}{Header}{}headrule
              setfoot{}{Footer}{}footrule}
              pagestyle{ruled}

              begin{document}
              Here is some text.newpage
              Here is some text.newpage
              pagestyle{plain}
              text
              end{document}





              share|improve this answer






























                9














                Here's another option using the titleps package:



                documentclass{article}
                usepackage{titleps}

                newpagestyle{ruled}
                {sethead{}{Header}{}headrule
                setfoot{}{Footer}{}footrule}
                pagestyle{ruled}

                begin{document}
                Here is some text.
                end{document}


                enter image description here



                Redefining makeheadrule and makefootrule, you can change the attributes; for example, to change the color:



                documentclass{article}
                usepackage{xcolor}
                usepackage{titleps}

                newpagestyle{ruled}
                {sethead{}{Header}{}headrule
                setfoot{}{Footer}{}footrule}
                pagestyle{ruled}

                renewcommandmakeheadrule{color{cyan}rule[-.3baselineskip]{linewidth}{0.4pt}}
                renewcommandmakefootrule{color{cyan}rule[baselineskip]{linewidth}{0.4pt}}

                begin{document}
                Here is some text.
                end{document}


                enter image description here



                Of course, you can switch to other page style at any moment:



                documentclass{article}
                usepackage{titleps}

                newpagestyle{ruled}
                {sethead{}{Header}{}headrule
                setfoot{}{Footer}{}footrule}
                pagestyle{ruled}

                begin{document}
                Here is some text.newpage
                Here is some text.newpage
                pagestyle{plain}
                text
                end{document}





                share|improve this answer




























                  9












                  9








                  9







                  Here's another option using the titleps package:



                  documentclass{article}
                  usepackage{titleps}

                  newpagestyle{ruled}
                  {sethead{}{Header}{}headrule
                  setfoot{}{Footer}{}footrule}
                  pagestyle{ruled}

                  begin{document}
                  Here is some text.
                  end{document}


                  enter image description here



                  Redefining makeheadrule and makefootrule, you can change the attributes; for example, to change the color:



                  documentclass{article}
                  usepackage{xcolor}
                  usepackage{titleps}

                  newpagestyle{ruled}
                  {sethead{}{Header}{}headrule
                  setfoot{}{Footer}{}footrule}
                  pagestyle{ruled}

                  renewcommandmakeheadrule{color{cyan}rule[-.3baselineskip]{linewidth}{0.4pt}}
                  renewcommandmakefootrule{color{cyan}rule[baselineskip]{linewidth}{0.4pt}}

                  begin{document}
                  Here is some text.
                  end{document}


                  enter image description here



                  Of course, you can switch to other page style at any moment:



                  documentclass{article}
                  usepackage{titleps}

                  newpagestyle{ruled}
                  {sethead{}{Header}{}headrule
                  setfoot{}{Footer}{}footrule}
                  pagestyle{ruled}

                  begin{document}
                  Here is some text.newpage
                  Here is some text.newpage
                  pagestyle{plain}
                  text
                  end{document}





                  share|improve this answer















                  Here's another option using the titleps package:



                  documentclass{article}
                  usepackage{titleps}

                  newpagestyle{ruled}
                  {sethead{}{Header}{}headrule
                  setfoot{}{Footer}{}footrule}
                  pagestyle{ruled}

                  begin{document}
                  Here is some text.
                  end{document}


                  enter image description here



                  Redefining makeheadrule and makefootrule, you can change the attributes; for example, to change the color:



                  documentclass{article}
                  usepackage{xcolor}
                  usepackage{titleps}

                  newpagestyle{ruled}
                  {sethead{}{Header}{}headrule
                  setfoot{}{Footer}{}footrule}
                  pagestyle{ruled}

                  renewcommandmakeheadrule{color{cyan}rule[-.3baselineskip]{linewidth}{0.4pt}}
                  renewcommandmakefootrule{color{cyan}rule[baselineskip]{linewidth}{0.4pt}}

                  begin{document}
                  Here is some text.
                  end{document}


                  enter image description here



                  Of course, you can switch to other page style at any moment:



                  documentclass{article}
                  usepackage{titleps}

                  newpagestyle{ruled}
                  {sethead{}{Header}{}headrule
                  setfoot{}{Footer}{}footrule}
                  pagestyle{ruled}

                  begin{document}
                  Here is some text.newpage
                  Here is some text.newpage
                  pagestyle{plain}
                  text
                  end{document}






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Apr 17 '13 at 5:02

























                  answered Apr 17 '13 at 4:18









                  Gonzalo MedinaGonzalo Medina

                  399k4113061574




                  399k4113061574






























                      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%2f109153%2fhow-to-add-horizontal-line-after-header-and-before-footer%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

                      How to change which sound is reproduced for terminal bell?

                      Can I use Tabulator js library in my java Spring + Thymeleaf project?

                      Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents