Makeuppercase in section formatting












1















I was trying to make a section style with uppercase fonts and color. But when I use MakeUppercase like



makeatletter
renewcommand{@seccntformat}[1]{{textcolor{purple}{csname the#1endcsname}hspace{1em}}}
renewcommand{section}{@startsection{section}{1}{z@}
{-4ex @plus -1ex @minus -.4ex}
{1ex @plus.2ex }
{normalfontlargesffamilybfseriesMakeUppercasecolor{purple}}}


The following errors are shown



Argument of @declaredcolor has an extra }. section{}









share|improve this question




















  • 1





    Welcome to TeX.SE! Try swapping MakeUppercase and color{purple} on the last line: {normalfontlargesffamilybfseriescolor{purple}MakeUppercase}. All of normalfont, large, sffamily, bfseries, and color{purple} are switches (i.e. their effect last until the current scope ends) while MakeUppercase is a macro that takes one argument, so the way the sectioning commands work, the command which takes one argument must be last.

    – Phelype Oleinik
    Feb 12 at 18:54


















1















I was trying to make a section style with uppercase fonts and color. But when I use MakeUppercase like



makeatletter
renewcommand{@seccntformat}[1]{{textcolor{purple}{csname the#1endcsname}hspace{1em}}}
renewcommand{section}{@startsection{section}{1}{z@}
{-4ex @plus -1ex @minus -.4ex}
{1ex @plus.2ex }
{normalfontlargesffamilybfseriesMakeUppercasecolor{purple}}}


The following errors are shown



Argument of @declaredcolor has an extra }. section{}









share|improve this question




















  • 1





    Welcome to TeX.SE! Try swapping MakeUppercase and color{purple} on the last line: {normalfontlargesffamilybfseriescolor{purple}MakeUppercase}. All of normalfont, large, sffamily, bfseries, and color{purple} are switches (i.e. their effect last until the current scope ends) while MakeUppercase is a macro that takes one argument, so the way the sectioning commands work, the command which takes one argument must be last.

    – Phelype Oleinik
    Feb 12 at 18:54
















1












1








1








I was trying to make a section style with uppercase fonts and color. But when I use MakeUppercase like



makeatletter
renewcommand{@seccntformat}[1]{{textcolor{purple}{csname the#1endcsname}hspace{1em}}}
renewcommand{section}{@startsection{section}{1}{z@}
{-4ex @plus -1ex @minus -.4ex}
{1ex @plus.2ex }
{normalfontlargesffamilybfseriesMakeUppercasecolor{purple}}}


The following errors are shown



Argument of @declaredcolor has an extra }. section{}









share|improve this question
















I was trying to make a section style with uppercase fonts and color. But when I use MakeUppercase like



makeatletter
renewcommand{@seccntformat}[1]{{textcolor{purple}{csname the#1endcsname}hspace{1em}}}
renewcommand{section}{@startsection{section}{1}{z@}
{-4ex @plus -1ex @minus -.4ex}
{1ex @plus.2ex }
{normalfontlargesffamilybfseriesMakeUppercasecolor{purple}}}


The following errors are shown



Argument of @declaredcolor has an extra }. section{}






sectioning formatting






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 12 at 18:53









Phelype Oleinik

23.5k54586




23.5k54586










asked Feb 12 at 18:51









Fawaz OlappilanFawaz Olappilan

102




102








  • 1





    Welcome to TeX.SE! Try swapping MakeUppercase and color{purple} on the last line: {normalfontlargesffamilybfseriescolor{purple}MakeUppercase}. All of normalfont, large, sffamily, bfseries, and color{purple} are switches (i.e. their effect last until the current scope ends) while MakeUppercase is a macro that takes one argument, so the way the sectioning commands work, the command which takes one argument must be last.

    – Phelype Oleinik
    Feb 12 at 18:54
















  • 1





    Welcome to TeX.SE! Try swapping MakeUppercase and color{purple} on the last line: {normalfontlargesffamilybfseriescolor{purple}MakeUppercase}. All of normalfont, large, sffamily, bfseries, and color{purple} are switches (i.e. their effect last until the current scope ends) while MakeUppercase is a macro that takes one argument, so the way the sectioning commands work, the command which takes one argument must be last.

    – Phelype Oleinik
    Feb 12 at 18:54










1




1





Welcome to TeX.SE! Try swapping MakeUppercase and color{purple} on the last line: {normalfontlargesffamilybfseriescolor{purple}MakeUppercase}. All of normalfont, large, sffamily, bfseries, and color{purple} are switches (i.e. their effect last until the current scope ends) while MakeUppercase is a macro that takes one argument, so the way the sectioning commands work, the command which takes one argument must be last.

– Phelype Oleinik
Feb 12 at 18:54







Welcome to TeX.SE! Try swapping MakeUppercase and color{purple} on the last line: {normalfontlargesffamilybfseriescolor{purple}MakeUppercase}. All of normalfont, large, sffamily, bfseries, and color{purple} are switches (i.e. their effect last until the current scope ends) while MakeUppercase is a macro that takes one argument, so the way the sectioning commands work, the command which takes one argument must be last.

– Phelype Oleinik
Feb 12 at 18:54












1 Answer
1






active

oldest

votes


















1














If you swap the order of MakeUppercase and color{purple} it works. Internally, the sectioning commands do (approximately) this:



<formatting>{@seccntformat{<number>} <title>}


where <formatting> is the last argument of @startsection, <number> is the section number and <title>, you guessed, the title :)



If we do like you suggested, section{hello} becomes:



normalfontlargesffamilybfseriesMakeUppercasecolor{purple}{1 hello}


(@seccntformat is not important right now). Try running the above and you'll see the same error. That happens because MakeUppercase grabs color as argument and when color tries to do its thing it won't find the droids color name it was looking for and chaos will ensue. But if you swap the order it works :)



normalfontlargesffamilybfseriescolor{purple}MakeUppercase{1 hello}


But now you'll get another error:



! Package xcolor Error: Undefined color `PURPLE'.


but why?! Remember the @seccntformat back then? You had:



<formatting>{@seccntformat{<number>} <title>}


when <formatting> contains MakeUppercase and @seccntformat contains textcolor{purple}{<number>}, then you have:



MakeUppercase{textcolor{purple}{<number>} <title>}


which will MakeUppercase before textcolor is executed:



{textcolor{PURPLE}{<NUMBER>} <TITLE>}


Yes, the NUMBER too :)



But you don't need that. The counter is used after the color{purple}, so it will already be coloured. You can remove that and the number will be purple too. If you take that out, your definition of @seccntformat is identical to LaTeX's one, so you can remove it altogether.



After all this the output is:




enter image description here




MWE:



documentclass{article}

usepackage{xcolor}

makeatletter
% renewcommand{@seccntformat}[1]{csname the#1endcsnamehspace{1em}} == default :)
renewcommand{section}{@startsection{section}{1}{z@}
{-4ex @plus -1ex @minus -.4ex}
{1ex @plus.2ex }
{normalfontlargesffamilybfseriescolor{purple}MakeUppercase}}
makeatother

begin{document}
pagestyle{empty}

section{Hello}

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

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%2f474564%2fmakeuppercase-in-section-formatting%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









    1














    If you swap the order of MakeUppercase and color{purple} it works. Internally, the sectioning commands do (approximately) this:



    <formatting>{@seccntformat{<number>} <title>}


    where <formatting> is the last argument of @startsection, <number> is the section number and <title>, you guessed, the title :)



    If we do like you suggested, section{hello} becomes:



    normalfontlargesffamilybfseriesMakeUppercasecolor{purple}{1 hello}


    (@seccntformat is not important right now). Try running the above and you'll see the same error. That happens because MakeUppercase grabs color as argument and when color tries to do its thing it won't find the droids color name it was looking for and chaos will ensue. But if you swap the order it works :)



    normalfontlargesffamilybfseriescolor{purple}MakeUppercase{1 hello}


    But now you'll get another error:



    ! Package xcolor Error: Undefined color `PURPLE'.


    but why?! Remember the @seccntformat back then? You had:



    <formatting>{@seccntformat{<number>} <title>}


    when <formatting> contains MakeUppercase and @seccntformat contains textcolor{purple}{<number>}, then you have:



    MakeUppercase{textcolor{purple}{<number>} <title>}


    which will MakeUppercase before textcolor is executed:



    {textcolor{PURPLE}{<NUMBER>} <TITLE>}


    Yes, the NUMBER too :)



    But you don't need that. The counter is used after the color{purple}, so it will already be coloured. You can remove that and the number will be purple too. If you take that out, your definition of @seccntformat is identical to LaTeX's one, so you can remove it altogether.



    After all this the output is:




    enter image description here




    MWE:



    documentclass{article}

    usepackage{xcolor}

    makeatletter
    % renewcommand{@seccntformat}[1]{csname the#1endcsnamehspace{1em}} == default :)
    renewcommand{section}{@startsection{section}{1}{z@}
    {-4ex @plus -1ex @minus -.4ex}
    {1ex @plus.2ex }
    {normalfontlargesffamilybfseriescolor{purple}MakeUppercase}}
    makeatother

    begin{document}
    pagestyle{empty}

    section{Hello}

    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
    tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
    quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
    consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
    cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
    proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

    end{document}





    share|improve this answer




























      1














      If you swap the order of MakeUppercase and color{purple} it works. Internally, the sectioning commands do (approximately) this:



      <formatting>{@seccntformat{<number>} <title>}


      where <formatting> is the last argument of @startsection, <number> is the section number and <title>, you guessed, the title :)



      If we do like you suggested, section{hello} becomes:



      normalfontlargesffamilybfseriesMakeUppercasecolor{purple}{1 hello}


      (@seccntformat is not important right now). Try running the above and you'll see the same error. That happens because MakeUppercase grabs color as argument and when color tries to do its thing it won't find the droids color name it was looking for and chaos will ensue. But if you swap the order it works :)



      normalfontlargesffamilybfseriescolor{purple}MakeUppercase{1 hello}


      But now you'll get another error:



      ! Package xcolor Error: Undefined color `PURPLE'.


      but why?! Remember the @seccntformat back then? You had:



      <formatting>{@seccntformat{<number>} <title>}


      when <formatting> contains MakeUppercase and @seccntformat contains textcolor{purple}{<number>}, then you have:



      MakeUppercase{textcolor{purple}{<number>} <title>}


      which will MakeUppercase before textcolor is executed:



      {textcolor{PURPLE}{<NUMBER>} <TITLE>}


      Yes, the NUMBER too :)



      But you don't need that. The counter is used after the color{purple}, so it will already be coloured. You can remove that and the number will be purple too. If you take that out, your definition of @seccntformat is identical to LaTeX's one, so you can remove it altogether.



      After all this the output is:




      enter image description here




      MWE:



      documentclass{article}

      usepackage{xcolor}

      makeatletter
      % renewcommand{@seccntformat}[1]{csname the#1endcsnamehspace{1em}} == default :)
      renewcommand{section}{@startsection{section}{1}{z@}
      {-4ex @plus -1ex @minus -.4ex}
      {1ex @plus.2ex }
      {normalfontlargesffamilybfseriescolor{purple}MakeUppercase}}
      makeatother

      begin{document}
      pagestyle{empty}

      section{Hello}

      Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
      tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
      quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
      consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
      cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
      proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

      end{document}





      share|improve this answer


























        1












        1








        1







        If you swap the order of MakeUppercase and color{purple} it works. Internally, the sectioning commands do (approximately) this:



        <formatting>{@seccntformat{<number>} <title>}


        where <formatting> is the last argument of @startsection, <number> is the section number and <title>, you guessed, the title :)



        If we do like you suggested, section{hello} becomes:



        normalfontlargesffamilybfseriesMakeUppercasecolor{purple}{1 hello}


        (@seccntformat is not important right now). Try running the above and you'll see the same error. That happens because MakeUppercase grabs color as argument and when color tries to do its thing it won't find the droids color name it was looking for and chaos will ensue. But if you swap the order it works :)



        normalfontlargesffamilybfseriescolor{purple}MakeUppercase{1 hello}


        But now you'll get another error:



        ! Package xcolor Error: Undefined color `PURPLE'.


        but why?! Remember the @seccntformat back then? You had:



        <formatting>{@seccntformat{<number>} <title>}


        when <formatting> contains MakeUppercase and @seccntformat contains textcolor{purple}{<number>}, then you have:



        MakeUppercase{textcolor{purple}{<number>} <title>}


        which will MakeUppercase before textcolor is executed:



        {textcolor{PURPLE}{<NUMBER>} <TITLE>}


        Yes, the NUMBER too :)



        But you don't need that. The counter is used after the color{purple}, so it will already be coloured. You can remove that and the number will be purple too. If you take that out, your definition of @seccntformat is identical to LaTeX's one, so you can remove it altogether.



        After all this the output is:




        enter image description here




        MWE:



        documentclass{article}

        usepackage{xcolor}

        makeatletter
        % renewcommand{@seccntformat}[1]{csname the#1endcsnamehspace{1em}} == default :)
        renewcommand{section}{@startsection{section}{1}{z@}
        {-4ex @plus -1ex @minus -.4ex}
        {1ex @plus.2ex }
        {normalfontlargesffamilybfseriescolor{purple}MakeUppercase}}
        makeatother

        begin{document}
        pagestyle{empty}

        section{Hello}

        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
        tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
        quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
        consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
        cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
        proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

        end{document}





        share|improve this answer













        If you swap the order of MakeUppercase and color{purple} it works. Internally, the sectioning commands do (approximately) this:



        <formatting>{@seccntformat{<number>} <title>}


        where <formatting> is the last argument of @startsection, <number> is the section number and <title>, you guessed, the title :)



        If we do like you suggested, section{hello} becomes:



        normalfontlargesffamilybfseriesMakeUppercasecolor{purple}{1 hello}


        (@seccntformat is not important right now). Try running the above and you'll see the same error. That happens because MakeUppercase grabs color as argument and when color tries to do its thing it won't find the droids color name it was looking for and chaos will ensue. But if you swap the order it works :)



        normalfontlargesffamilybfseriescolor{purple}MakeUppercase{1 hello}


        But now you'll get another error:



        ! Package xcolor Error: Undefined color `PURPLE'.


        but why?! Remember the @seccntformat back then? You had:



        <formatting>{@seccntformat{<number>} <title>}


        when <formatting> contains MakeUppercase and @seccntformat contains textcolor{purple}{<number>}, then you have:



        MakeUppercase{textcolor{purple}{<number>} <title>}


        which will MakeUppercase before textcolor is executed:



        {textcolor{PURPLE}{<NUMBER>} <TITLE>}


        Yes, the NUMBER too :)



        But you don't need that. The counter is used after the color{purple}, so it will already be coloured. You can remove that and the number will be purple too. If you take that out, your definition of @seccntformat is identical to LaTeX's one, so you can remove it altogether.



        After all this the output is:




        enter image description here




        MWE:



        documentclass{article}

        usepackage{xcolor}

        makeatletter
        % renewcommand{@seccntformat}[1]{csname the#1endcsnamehspace{1em}} == default :)
        renewcommand{section}{@startsection{section}{1}{z@}
        {-4ex @plus -1ex @minus -.4ex}
        {1ex @plus.2ex }
        {normalfontlargesffamilybfseriescolor{purple}MakeUppercase}}
        makeatother

        begin{document}
        pagestyle{empty}

        section{Hello}

        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
        tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
        quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
        consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
        cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
        proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

        end{document}






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Feb 12 at 19:16









        Phelype OleinikPhelype Oleinik

        23.5k54586




        23.5k54586






























            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%2f474564%2fmakeuppercase-in-section-formatting%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

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

            ComboBox Display Member on multiple fields

            Is it possible to collect Nectar points via Trainline?