thispagestyle has no effect if no page broken(clearpage, newpage) is givenPage styles only work for...

thispagestyle has no effect if no page broken(clearpage, newpage) is given

Is it common to refer to someone as "Prof. Dr. [LastName]"?

Taking an academic pseudonym?

How do I write a maintainable, fast, compile-time bit-mask in C++?

What dissuades people from lying about where they live in order to reduce state income taxes?

Why did some CPUs use two Read/Write lines, and others just one?

Portent, as it relates to the Gambling downtime rules from Xanathar's Guide to Everything

Determining whether a system is consistent or inconsistent from the linear dependence of its columns

How can I make my enemies feel real and make combat more engaging?

What does “to the numbers” mean in landing clearance

"Happy is as happy does" What does this mean?

How sharp are RAW photos before processing?

Why do BLDC motor (1kW) controllers have so many mosfets?

How do I ask to leave because of weather?

Discouraging missile alpha strikes

Is layered encryption more secure than long passwords?

How bad is a Computer Science course that doesn't teach Design Patterns?

What is the correct way to shuffle?

Coworker is trying to get me to sign his petition to run for office. How to decline politely?

Why didn't Lorentz conclude that no object can go faster than light?

The Late Queen Gives in to Remorse - Reverse Hangman

Do error bars on probabilities have any meaning?

How can changes in personality/values of a person who turned into a vampire be explained?

Can "ee" appear in Latin?



thispagestyle has no effect if no page broken(clearpage, newpage) is given


Page styles only work for thispagestyle under afterpagethispagestyle{plain} has no effectCreate a document cover using style classHow can I make pages after the first come out correctly with fancyhdr?Header graphic dissapear from first page when using thispagestyle{plain} in the second oneCreate header with left, center, and right aligned itemsHeader on odd pages













2















At a certain position in the article, the page that it belongs, need a special fancy style which I do by thispagestyle from the package fancyhdr.



In my example as shown in the MWE below, the page, and only the page where the text "bbb" is in(it's at the second page in this example, but may also at the other page, determined by the length of article), need a chead. However, the content of chead is in fact at the first page, not in the second page as I expect.



I think this is because no page-break is given. But the position of text "bbb" is up to the length of article, so how to deal with this problem?



My MWE is:



documentclass{article}
usepackage{fancyhdr}

begin{document}
fancypagestyle{common}{chead{I want my header only on the page at which ``bbb'' is located}}
aaaparvspace{80em}
bbbthispagestyle{common}parvspace{80em}
ccc
end{document}









share|improve this question





























    2















    At a certain position in the article, the page that it belongs, need a special fancy style which I do by thispagestyle from the package fancyhdr.



    In my example as shown in the MWE below, the page, and only the page where the text "bbb" is in(it's at the second page in this example, but may also at the other page, determined by the length of article), need a chead. However, the content of chead is in fact at the first page, not in the second page as I expect.



    I think this is because no page-break is given. But the position of text "bbb" is up to the length of article, so how to deal with this problem?



    My MWE is:



    documentclass{article}
    usepackage{fancyhdr}

    begin{document}
    fancypagestyle{common}{chead{I want my header only on the page at which ``bbb'' is located}}
    aaaparvspace{80em}
    bbbthispagestyle{common}parvspace{80em}
    ccc
    end{document}









    share|improve this question



























      2












      2








      2








      At a certain position in the article, the page that it belongs, need a special fancy style which I do by thispagestyle from the package fancyhdr.



      In my example as shown in the MWE below, the page, and only the page where the text "bbb" is in(it's at the second page in this example, but may also at the other page, determined by the length of article), need a chead. However, the content of chead is in fact at the first page, not in the second page as I expect.



      I think this is because no page-break is given. But the position of text "bbb" is up to the length of article, so how to deal with this problem?



      My MWE is:



      documentclass{article}
      usepackage{fancyhdr}

      begin{document}
      fancypagestyle{common}{chead{I want my header only on the page at which ``bbb'' is located}}
      aaaparvspace{80em}
      bbbthispagestyle{common}parvspace{80em}
      ccc
      end{document}









      share|improve this question
















      At a certain position in the article, the page that it belongs, need a special fancy style which I do by thispagestyle from the package fancyhdr.



      In my example as shown in the MWE below, the page, and only the page where the text "bbb" is in(it's at the second page in this example, but may also at the other page, determined by the length of article), need a chead. However, the content of chead is in fact at the first page, not in the second page as I expect.



      I think this is because no page-break is given. But the position of text "bbb" is up to the length of article, so how to deal with this problem?



      My MWE is:



      documentclass{article}
      usepackage{fancyhdr}

      begin{document}
      fancypagestyle{common}{chead{I want my header only on the page at which ``bbb'' is located}}
      aaaparvspace{80em}
      bbbthispagestyle{common}parvspace{80em}
      ccc
      end{document}






      fancyhdr






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 4 hours ago









      Sebastiano

      10.1k41858




      10.1k41858










      asked 5 hours ago









      lyllyl

      60628




      60628






















          2 Answers
          2






          active

          oldest

          votes


















          3














          You can use a mark command:



          documentclass{article}
          usepackage{fancyhdr}
          fancypagestyle{common}{fancyhf{}chead{rightmark}}
          pagestyle{common}
          begin{document}

          aaaparvspace{80em}
          bbbmarkright{I want my header only on the page at which ``bbb'' is located}markright{}parvspace{80em}
          ccc
          end{document}





          share|improve this answer































            1














            I guess you're using headers, but that's not really relevant.



            The problem is that page breaking is asynchronous: typically TeX reads more that fits in a page before deciding it has to ship out a page. In your case, thispagestyle is seen and processed while TeX has not yet decided to eject page 1.



            The command thispagestyle is only reliable if given shortly after a page break, for instance when a new chapter is started, a feature which standard classes use for issuing thispagestyle{plain}.



            The only reliable method is to use the label-pageref mechanism. Here I implement the job with the help of refcount that provides an expandable version of pageref, namely getpagerefnumber.



            documentclass{article}
            usepackage{fancyhdr}
            usepackage{refcount,pdftexcmds}

            pagestyle{fancy}

            makeatletter
            chead{%
            ifnumpdf@strcmp{thepage}{getpagerefnumber{bbb}}=z@
            I want my header only on the page at which ``bbb'' is located%
            else
            Normal header%
            fi
            }
            makeatother

            begin{document}

            aaaparvspace{80em}
            bbblabel{bbb}parvspace{80em}
            ccc

            end{document}


            enter image description here



            I use pdf@strcmp in order to ensure that any kind of page numbering is supported.






            share|improve this answer
























            • Is z@ equal to zero?

              – Sigur
              2 hours ago






            • 1





              @Sigur Yes. This usage also terminates the number to be looked for.

              – egreg
              2 hours ago











            • But is it testing if some number is zero? I confess that I didn't follow the idea. Without it I got error Missing = inserted for ifnum. but since you used z@, the error after removing it was expected. No surprise.

              – Sigur
              2 hours ago











            • @Sigur pdf@strcmp returns 0 if the two strings given as argument are, after full expansion, equal and a nonzero number otherwise.

              – egreg
              2 hours ago











            • Oh, now it makes sense to me. Now I understand. Thanks for attention.

              – Sigur
              1 hour 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',
            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%2f475877%2fthispagestyle-has-no-effect-if-no-page-broken-clearpage-newpage-is-given%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









            3














            You can use a mark command:



            documentclass{article}
            usepackage{fancyhdr}
            fancypagestyle{common}{fancyhf{}chead{rightmark}}
            pagestyle{common}
            begin{document}

            aaaparvspace{80em}
            bbbmarkright{I want my header only on the page at which ``bbb'' is located}markright{}parvspace{80em}
            ccc
            end{document}





            share|improve this answer




























              3














              You can use a mark command:



              documentclass{article}
              usepackage{fancyhdr}
              fancypagestyle{common}{fancyhf{}chead{rightmark}}
              pagestyle{common}
              begin{document}

              aaaparvspace{80em}
              bbbmarkright{I want my header only on the page at which ``bbb'' is located}markright{}parvspace{80em}
              ccc
              end{document}





              share|improve this answer


























                3












                3








                3







                You can use a mark command:



                documentclass{article}
                usepackage{fancyhdr}
                fancypagestyle{common}{fancyhf{}chead{rightmark}}
                pagestyle{common}
                begin{document}

                aaaparvspace{80em}
                bbbmarkright{I want my header only on the page at which ``bbb'' is located}markright{}parvspace{80em}
                ccc
                end{document}





                share|improve this answer













                You can use a mark command:



                documentclass{article}
                usepackage{fancyhdr}
                fancypagestyle{common}{fancyhf{}chead{rightmark}}
                pagestyle{common}
                begin{document}

                aaaparvspace{80em}
                bbbmarkright{I want my header only on the page at which ``bbb'' is located}markright{}parvspace{80em}
                ccc
                end{document}






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 4 hours ago









                Ulrike FischerUlrike Fischer

                193k8302683




                193k8302683























                    1














                    I guess you're using headers, but that's not really relevant.



                    The problem is that page breaking is asynchronous: typically TeX reads more that fits in a page before deciding it has to ship out a page. In your case, thispagestyle is seen and processed while TeX has not yet decided to eject page 1.



                    The command thispagestyle is only reliable if given shortly after a page break, for instance when a new chapter is started, a feature which standard classes use for issuing thispagestyle{plain}.



                    The only reliable method is to use the label-pageref mechanism. Here I implement the job with the help of refcount that provides an expandable version of pageref, namely getpagerefnumber.



                    documentclass{article}
                    usepackage{fancyhdr}
                    usepackage{refcount,pdftexcmds}

                    pagestyle{fancy}

                    makeatletter
                    chead{%
                    ifnumpdf@strcmp{thepage}{getpagerefnumber{bbb}}=z@
                    I want my header only on the page at which ``bbb'' is located%
                    else
                    Normal header%
                    fi
                    }
                    makeatother

                    begin{document}

                    aaaparvspace{80em}
                    bbblabel{bbb}parvspace{80em}
                    ccc

                    end{document}


                    enter image description here



                    I use pdf@strcmp in order to ensure that any kind of page numbering is supported.






                    share|improve this answer
























                    • Is z@ equal to zero?

                      – Sigur
                      2 hours ago






                    • 1





                      @Sigur Yes. This usage also terminates the number to be looked for.

                      – egreg
                      2 hours ago











                    • But is it testing if some number is zero? I confess that I didn't follow the idea. Without it I got error Missing = inserted for ifnum. but since you used z@, the error after removing it was expected. No surprise.

                      – Sigur
                      2 hours ago











                    • @Sigur pdf@strcmp returns 0 if the two strings given as argument are, after full expansion, equal and a nonzero number otherwise.

                      – egreg
                      2 hours ago











                    • Oh, now it makes sense to me. Now I understand. Thanks for attention.

                      – Sigur
                      1 hour ago
















                    1














                    I guess you're using headers, but that's not really relevant.



                    The problem is that page breaking is asynchronous: typically TeX reads more that fits in a page before deciding it has to ship out a page. In your case, thispagestyle is seen and processed while TeX has not yet decided to eject page 1.



                    The command thispagestyle is only reliable if given shortly after a page break, for instance when a new chapter is started, a feature which standard classes use for issuing thispagestyle{plain}.



                    The only reliable method is to use the label-pageref mechanism. Here I implement the job with the help of refcount that provides an expandable version of pageref, namely getpagerefnumber.



                    documentclass{article}
                    usepackage{fancyhdr}
                    usepackage{refcount,pdftexcmds}

                    pagestyle{fancy}

                    makeatletter
                    chead{%
                    ifnumpdf@strcmp{thepage}{getpagerefnumber{bbb}}=z@
                    I want my header only on the page at which ``bbb'' is located%
                    else
                    Normal header%
                    fi
                    }
                    makeatother

                    begin{document}

                    aaaparvspace{80em}
                    bbblabel{bbb}parvspace{80em}
                    ccc

                    end{document}


                    enter image description here



                    I use pdf@strcmp in order to ensure that any kind of page numbering is supported.






                    share|improve this answer
























                    • Is z@ equal to zero?

                      – Sigur
                      2 hours ago






                    • 1





                      @Sigur Yes. This usage also terminates the number to be looked for.

                      – egreg
                      2 hours ago











                    • But is it testing if some number is zero? I confess that I didn't follow the idea. Without it I got error Missing = inserted for ifnum. but since you used z@, the error after removing it was expected. No surprise.

                      – Sigur
                      2 hours ago











                    • @Sigur pdf@strcmp returns 0 if the two strings given as argument are, after full expansion, equal and a nonzero number otherwise.

                      – egreg
                      2 hours ago











                    • Oh, now it makes sense to me. Now I understand. Thanks for attention.

                      – Sigur
                      1 hour ago














                    1












                    1








                    1







                    I guess you're using headers, but that's not really relevant.



                    The problem is that page breaking is asynchronous: typically TeX reads more that fits in a page before deciding it has to ship out a page. In your case, thispagestyle is seen and processed while TeX has not yet decided to eject page 1.



                    The command thispagestyle is only reliable if given shortly after a page break, for instance when a new chapter is started, a feature which standard classes use for issuing thispagestyle{plain}.



                    The only reliable method is to use the label-pageref mechanism. Here I implement the job with the help of refcount that provides an expandable version of pageref, namely getpagerefnumber.



                    documentclass{article}
                    usepackage{fancyhdr}
                    usepackage{refcount,pdftexcmds}

                    pagestyle{fancy}

                    makeatletter
                    chead{%
                    ifnumpdf@strcmp{thepage}{getpagerefnumber{bbb}}=z@
                    I want my header only on the page at which ``bbb'' is located%
                    else
                    Normal header%
                    fi
                    }
                    makeatother

                    begin{document}

                    aaaparvspace{80em}
                    bbblabel{bbb}parvspace{80em}
                    ccc

                    end{document}


                    enter image description here



                    I use pdf@strcmp in order to ensure that any kind of page numbering is supported.






                    share|improve this answer













                    I guess you're using headers, but that's not really relevant.



                    The problem is that page breaking is asynchronous: typically TeX reads more that fits in a page before deciding it has to ship out a page. In your case, thispagestyle is seen and processed while TeX has not yet decided to eject page 1.



                    The command thispagestyle is only reliable if given shortly after a page break, for instance when a new chapter is started, a feature which standard classes use for issuing thispagestyle{plain}.



                    The only reliable method is to use the label-pageref mechanism. Here I implement the job with the help of refcount that provides an expandable version of pageref, namely getpagerefnumber.



                    documentclass{article}
                    usepackage{fancyhdr}
                    usepackage{refcount,pdftexcmds}

                    pagestyle{fancy}

                    makeatletter
                    chead{%
                    ifnumpdf@strcmp{thepage}{getpagerefnumber{bbb}}=z@
                    I want my header only on the page at which ``bbb'' is located%
                    else
                    Normal header%
                    fi
                    }
                    makeatother

                    begin{document}

                    aaaparvspace{80em}
                    bbblabel{bbb}parvspace{80em}
                    ccc

                    end{document}


                    enter image description here



                    I use pdf@strcmp in order to ensure that any kind of page numbering is supported.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered 2 hours ago









                    egregegreg

                    721k8719113210




                    721k8719113210













                    • Is z@ equal to zero?

                      – Sigur
                      2 hours ago






                    • 1





                      @Sigur Yes. This usage also terminates the number to be looked for.

                      – egreg
                      2 hours ago











                    • But is it testing if some number is zero? I confess that I didn't follow the idea. Without it I got error Missing = inserted for ifnum. but since you used z@, the error after removing it was expected. No surprise.

                      – Sigur
                      2 hours ago











                    • @Sigur pdf@strcmp returns 0 if the two strings given as argument are, after full expansion, equal and a nonzero number otherwise.

                      – egreg
                      2 hours ago











                    • Oh, now it makes sense to me. Now I understand. Thanks for attention.

                      – Sigur
                      1 hour ago



















                    • Is z@ equal to zero?

                      – Sigur
                      2 hours ago






                    • 1





                      @Sigur Yes. This usage also terminates the number to be looked for.

                      – egreg
                      2 hours ago











                    • But is it testing if some number is zero? I confess that I didn't follow the idea. Without it I got error Missing = inserted for ifnum. but since you used z@, the error after removing it was expected. No surprise.

                      – Sigur
                      2 hours ago











                    • @Sigur pdf@strcmp returns 0 if the two strings given as argument are, after full expansion, equal and a nonzero number otherwise.

                      – egreg
                      2 hours ago











                    • Oh, now it makes sense to me. Now I understand. Thanks for attention.

                      – Sigur
                      1 hour ago

















                    Is z@ equal to zero?

                    – Sigur
                    2 hours ago





                    Is z@ equal to zero?

                    – Sigur
                    2 hours ago




                    1




                    1





                    @Sigur Yes. This usage also terminates the number to be looked for.

                    – egreg
                    2 hours ago





                    @Sigur Yes. This usage also terminates the number to be looked for.

                    – egreg
                    2 hours ago













                    But is it testing if some number is zero? I confess that I didn't follow the idea. Without it I got error Missing = inserted for ifnum. but since you used z@, the error after removing it was expected. No surprise.

                    – Sigur
                    2 hours ago





                    But is it testing if some number is zero? I confess that I didn't follow the idea. Without it I got error Missing = inserted for ifnum. but since you used z@, the error after removing it was expected. No surprise.

                    – Sigur
                    2 hours ago













                    @Sigur pdf@strcmp returns 0 if the two strings given as argument are, after full expansion, equal and a nonzero number otherwise.

                    – egreg
                    2 hours ago





                    @Sigur pdf@strcmp returns 0 if the two strings given as argument are, after full expansion, equal and a nonzero number otherwise.

                    – egreg
                    2 hours ago













                    Oh, now it makes sense to me. Now I understand. Thanks for attention.

                    – Sigur
                    1 hour ago





                    Oh, now it makes sense to me. Now I understand. Thanks for attention.

                    – Sigur
                    1 hour 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.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f475877%2fthispagestyle-has-no-effect-if-no-page-broken-clearpage-newpage-is-given%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

                    ORA-01691 (unable to extend lob segment) even though my tablespace has AUTOEXTEND onORA-01692: unable to...

                    Always On Availability groups resolving state after failover - Remote harden of transaction...

                    Circunscripción electoral de Guipúzcoa Referencias Menú de navegaciónLas claves del sistema electoral en...