Issue with section text assuming same color as body textHow can I make footnote text color match body text...

What does 'acting greedily' mean?

Pure Functions: Does "No Side Effects" Imply "Always Same Output, Given Same Input"?

I encountered my boss during an on-site interview at another company. Should I bring it up when seeing him next time?

What is a term for a function that when called repeatedly, has the same effect as calling once?

How can I handle a player who pre-plans arguments about my rulings on RAW?

What do the pedals on grand pianos do?

When should a commit not be version tagged?

How can I be pwned if I'm not registered on that site?

Avoiding unpacking an array when altering its dimension

Are paired adjectives bad style?

What is this waxed root vegetable?

Real life puzzle: Unknown alphabet or shorthand

Is there a frame of reference in which I was born before I was conceived?

Infrastructure damage from sudden thickening of water

How do ISS astronauts "get their stripes"?

Is divide-by-zero a security vulnerability?

Did Amazon pay $0 in taxes last year?

Sometimes a banana is just a banana

What are these green text/line displays shown during the livestream of Crew Dragon's approach to dock with the ISS?

Non-Italian European mafias in USA?

Borrowing Characters

Tcolorbox as an item in list environment

Logistics of a hovering watercraft in a fantasy setting

If a druid in Wild Shape swallows a creature whole, then turns back to her normal form, what happens?



Issue with section text assuming same color as body text


How can I make footnote text color match body text color?Color box issueSection heading in moderncv with color gradientColor Underline Section Headingscolorbox{color}{text} display issue with same math expressions but different syntaxLaTex - Change color of sectionChanging color of keywords, theorems and more with each sectionChange color of section heading and text until next sectionHaving multiple section with different color which have the same environmentUse same color for all text













1















I am trying to understand a behavior where section headers assume the color of the first word in the section.



Here is my MWE:



documentclass{minimal}    
usepackage{xcolor}
makeatletter
newcommandsection{@startsection{section}{1}{.25in}%
{1.3ex @plus .5ex @minus .2ex}%
{-.5em @plus -.1em}%
{reset@fontnormalsizebfseries}}
makeatother
begin{document}
section{First}
{color{red} Hello there} More text
end{document}


The desired outcome is for "Hello there" to be red but the rest of the text (including "First") to be black. However, "First" is red. If a word is inserted before "{color" then the desired behavior occurs. What is going on here? The answer must be some basic fact about latex that I don't know.



Many thanks in advance.










share|improve this question




















  • 1





    Simply use textcolor{red}{Hello there}

    – Bernard
    20 hours ago











  • Thanks--it works. Why does it behave this way?

    – Zach Boyd
    20 hours ago











  • No idea. Anyway, personally, I use the titlesec package for this sort of modifications to the defaults, and I don't think you'd have this sort of problem.

    – Bernard
    20 hours ago











  • I will check it out. Thanks

    – Zach Boyd
    20 hours ago






  • 2





    Without the negative vertical space the problem doesn't occur. (Just a debuging result to help you figuring out the problem... But I can't explain it... possibly this negative space says to latex to start coloring from the beginning of the line... If you knew a way to add the #1 argument of the section inside the command you could possibly solve the problem -that is the "why?"-)

    – koleygr
    20 hours ago


















1















I am trying to understand a behavior where section headers assume the color of the first word in the section.



Here is my MWE:



documentclass{minimal}    
usepackage{xcolor}
makeatletter
newcommandsection{@startsection{section}{1}{.25in}%
{1.3ex @plus .5ex @minus .2ex}%
{-.5em @plus -.1em}%
{reset@fontnormalsizebfseries}}
makeatother
begin{document}
section{First}
{color{red} Hello there} More text
end{document}


The desired outcome is for "Hello there" to be red but the rest of the text (including "First") to be black. However, "First" is red. If a word is inserted before "{color" then the desired behavior occurs. What is going on here? The answer must be some basic fact about latex that I don't know.



Many thanks in advance.










share|improve this question




















  • 1





    Simply use textcolor{red}{Hello there}

    – Bernard
    20 hours ago











  • Thanks--it works. Why does it behave this way?

    – Zach Boyd
    20 hours ago











  • No idea. Anyway, personally, I use the titlesec package for this sort of modifications to the defaults, and I don't think you'd have this sort of problem.

    – Bernard
    20 hours ago











  • I will check it out. Thanks

    – Zach Boyd
    20 hours ago






  • 2





    Without the negative vertical space the problem doesn't occur. (Just a debuging result to help you figuring out the problem... But I can't explain it... possibly this negative space says to latex to start coloring from the beginning of the line... If you knew a way to add the #1 argument of the section inside the command you could possibly solve the problem -that is the "why?"-)

    – koleygr
    20 hours ago
















1












1








1








I am trying to understand a behavior where section headers assume the color of the first word in the section.



Here is my MWE:



documentclass{minimal}    
usepackage{xcolor}
makeatletter
newcommandsection{@startsection{section}{1}{.25in}%
{1.3ex @plus .5ex @minus .2ex}%
{-.5em @plus -.1em}%
{reset@fontnormalsizebfseries}}
makeatother
begin{document}
section{First}
{color{red} Hello there} More text
end{document}


The desired outcome is for "Hello there" to be red but the rest of the text (including "First") to be black. However, "First" is red. If a word is inserted before "{color" then the desired behavior occurs. What is going on here? The answer must be some basic fact about latex that I don't know.



Many thanks in advance.










share|improve this question
















I am trying to understand a behavior where section headers assume the color of the first word in the section.



Here is my MWE:



documentclass{minimal}    
usepackage{xcolor}
makeatletter
newcommandsection{@startsection{section}{1}{.25in}%
{1.3ex @plus .5ex @minus .2ex}%
{-.5em @plus -.1em}%
{reset@fontnormalsizebfseries}}
makeatother
begin{document}
section{First}
{color{red} Hello there} More text
end{document}


The desired outcome is for "Hello there" to be red but the rest of the text (including "First") to be black. However, "First" is red. If a word is inserted before "{color" then the desired behavior occurs. What is going on here? The answer must be some basic fact about latex that I don't know.



Many thanks in advance.







sectioning color document-classes






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 20 hours ago









Bernard

172k776204




172k776204










asked 20 hours ago









Zach BoydZach Boyd

1336




1336








  • 1





    Simply use textcolor{red}{Hello there}

    – Bernard
    20 hours ago











  • Thanks--it works. Why does it behave this way?

    – Zach Boyd
    20 hours ago











  • No idea. Anyway, personally, I use the titlesec package for this sort of modifications to the defaults, and I don't think you'd have this sort of problem.

    – Bernard
    20 hours ago











  • I will check it out. Thanks

    – Zach Boyd
    20 hours ago






  • 2





    Without the negative vertical space the problem doesn't occur. (Just a debuging result to help you figuring out the problem... But I can't explain it... possibly this negative space says to latex to start coloring from the beginning of the line... If you knew a way to add the #1 argument of the section inside the command you could possibly solve the problem -that is the "why?"-)

    – koleygr
    20 hours ago
















  • 1





    Simply use textcolor{red}{Hello there}

    – Bernard
    20 hours ago











  • Thanks--it works. Why does it behave this way?

    – Zach Boyd
    20 hours ago











  • No idea. Anyway, personally, I use the titlesec package for this sort of modifications to the defaults, and I don't think you'd have this sort of problem.

    – Bernard
    20 hours ago











  • I will check it out. Thanks

    – Zach Boyd
    20 hours ago






  • 2





    Without the negative vertical space the problem doesn't occur. (Just a debuging result to help you figuring out the problem... But I can't explain it... possibly this negative space says to latex to start coloring from the beginning of the line... If you knew a way to add the #1 argument of the section inside the command you could possibly solve the problem -that is the "why?"-)

    – koleygr
    20 hours ago










1




1





Simply use textcolor{red}{Hello there}

– Bernard
20 hours ago





Simply use textcolor{red}{Hello there}

– Bernard
20 hours ago













Thanks--it works. Why does it behave this way?

– Zach Boyd
20 hours ago





Thanks--it works. Why does it behave this way?

– Zach Boyd
20 hours ago













No idea. Anyway, personally, I use the titlesec package for this sort of modifications to the defaults, and I don't think you'd have this sort of problem.

– Bernard
20 hours ago





No idea. Anyway, personally, I use the titlesec package for this sort of modifications to the defaults, and I don't think you'd have this sort of problem.

– Bernard
20 hours ago













I will check it out. Thanks

– Zach Boyd
20 hours ago





I will check it out. Thanks

– Zach Boyd
20 hours ago




2




2





Without the negative vertical space the problem doesn't occur. (Just a debuging result to help you figuring out the problem... But I can't explain it... possibly this negative space says to latex to start coloring from the beginning of the line... If you knew a way to add the #1 argument of the section inside the command you could possibly solve the problem -that is the "why?"-)

– koleygr
20 hours ago







Without the negative vertical space the problem doesn't occur. (Just a debuging result to help you figuring out the problem... But I can't explain it... possibly this negative space says to latex to start coloring from the beginning of the line... If you knew a way to add the #1 argument of the section inside the command you could possibly solve the problem -that is the "why?"-)

– koleygr
20 hours ago












1 Answer
1






active

oldest

votes


















0














First, let say that the issue have nothing to do with the definition of section. So the problem is not here, but in using color{red}...
instead of textcolor{red}{...}.



Here is a MWE that replicate the issue



documentclass{article}    
usepackage{color}

begin{document}
paragraph{Foo}
{color{red}Bar} bla bla
end{document}


Why?



When the fifth argument of @startsection is negatif the heading is prepended to the paragraph of following text with the everypar command.
The command everypar is executed in horizontal mode i.e. when TeX see the character H in Hello, but at this moment is too late and the color change is already done. Here is another exemple



documentclass{article}    
usepackage{color}

begin{document}
everypar{Foo everypar{}}
{color{red}ifvmodehrulevskip1cmfi Bar} bla bla
end{document}


The solution is to use textcolor{red}{...} or leavevmode{color{red}...}.






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%2f477734%2fissue-with-section-text-assuming-same-color-as-body-text%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









    0














    First, let say that the issue have nothing to do with the definition of section. So the problem is not here, but in using color{red}...
    instead of textcolor{red}{...}.



    Here is a MWE that replicate the issue



    documentclass{article}    
    usepackage{color}

    begin{document}
    paragraph{Foo}
    {color{red}Bar} bla bla
    end{document}


    Why?



    When the fifth argument of @startsection is negatif the heading is prepended to the paragraph of following text with the everypar command.
    The command everypar is executed in horizontal mode i.e. when TeX see the character H in Hello, but at this moment is too late and the color change is already done. Here is another exemple



    documentclass{article}    
    usepackage{color}

    begin{document}
    everypar{Foo everypar{}}
    {color{red}ifvmodehrulevskip1cmfi Bar} bla bla
    end{document}


    The solution is to use textcolor{red}{...} or leavevmode{color{red}...}.






    share|improve this answer




























      0














      First, let say that the issue have nothing to do with the definition of section. So the problem is not here, but in using color{red}...
      instead of textcolor{red}{...}.



      Here is a MWE that replicate the issue



      documentclass{article}    
      usepackage{color}

      begin{document}
      paragraph{Foo}
      {color{red}Bar} bla bla
      end{document}


      Why?



      When the fifth argument of @startsection is negatif the heading is prepended to the paragraph of following text with the everypar command.
      The command everypar is executed in horizontal mode i.e. when TeX see the character H in Hello, but at this moment is too late and the color change is already done. Here is another exemple



      documentclass{article}    
      usepackage{color}

      begin{document}
      everypar{Foo everypar{}}
      {color{red}ifvmodehrulevskip1cmfi Bar} bla bla
      end{document}


      The solution is to use textcolor{red}{...} or leavevmode{color{red}...}.






      share|improve this answer


























        0












        0








        0







        First, let say that the issue have nothing to do with the definition of section. So the problem is not here, but in using color{red}...
        instead of textcolor{red}{...}.



        Here is a MWE that replicate the issue



        documentclass{article}    
        usepackage{color}

        begin{document}
        paragraph{Foo}
        {color{red}Bar} bla bla
        end{document}


        Why?



        When the fifth argument of @startsection is negatif the heading is prepended to the paragraph of following text with the everypar command.
        The command everypar is executed in horizontal mode i.e. when TeX see the character H in Hello, but at this moment is too late and the color change is already done. Here is another exemple



        documentclass{article}    
        usepackage{color}

        begin{document}
        everypar{Foo everypar{}}
        {color{red}ifvmodehrulevskip1cmfi Bar} bla bla
        end{document}


        The solution is to use textcolor{red}{...} or leavevmode{color{red}...}.






        share|improve this answer













        First, let say that the issue have nothing to do with the definition of section. So the problem is not here, but in using color{red}...
        instead of textcolor{red}{...}.



        Here is a MWE that replicate the issue



        documentclass{article}    
        usepackage{color}

        begin{document}
        paragraph{Foo}
        {color{red}Bar} bla bla
        end{document}


        Why?



        When the fifth argument of @startsection is negatif the heading is prepended to the paragraph of following text with the everypar command.
        The command everypar is executed in horizontal mode i.e. when TeX see the character H in Hello, but at this moment is too late and the color change is already done. Here is another exemple



        documentclass{article}    
        usepackage{color}

        begin{document}
        everypar{Foo everypar{}}
        {color{red}ifvmodehrulevskip1cmfi Bar} bla bla
        end{document}


        The solution is to use textcolor{red}{...} or leavevmode{color{red}...}.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 1 hour ago









        touhamitouhami

        17.1k21245




        17.1k21245






























            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%2f477734%2fissue-with-section-text-assuming-same-color-as-body-text%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

            Installing LyX: “No textclass is found.”LyX installation error- text class not found- 'Reconfigure' or...

            (1602) Indiana Índice Designación y nombre Características orbitales Véase...

            Universidad Autónoma de Occidente Índice Historia Campus Facultades Programas Académicos Medios de...