TikZ in section heading











up vote
5
down vote

favorite
1












I am trying to include a first circled and then boxed word in a section heading.



Currently, I am only able to create this highlighted word within a normal paragraph, but not inside of a heading. My attempt so far:



documentclass[a4paper]{article}
usepackage{tikz}
newcommand*circled[1]{tikz[baseline=(char.base)]{
node[shape=circle,draw,inner sep=2pt] (char) {#1};}}
begin{document}
section{Custom fbox{word} in Section heading}
fbox{circled{word}}
end{document}


Which renders like this:



rendered output
.



Ideally, I want to be able to write something similar to fbox{circled{word}} inside of my section heading, which currently simply throws an error about the "undefined control sequence def.










share|improve this question






















  • Welcome to TeX.SE!
    – Kurt
    Dec 4 at 23:17










  • section{Custom fbox{protectcircled{word}} in Section heading} also works...
    – marmot
    Dec 4 at 23:40










  • @Sermak Are you using hyperref in your real document?
    – samcarter
    Dec 7 at 10:25















up vote
5
down vote

favorite
1












I am trying to include a first circled and then boxed word in a section heading.



Currently, I am only able to create this highlighted word within a normal paragraph, but not inside of a heading. My attempt so far:



documentclass[a4paper]{article}
usepackage{tikz}
newcommand*circled[1]{tikz[baseline=(char.base)]{
node[shape=circle,draw,inner sep=2pt] (char) {#1};}}
begin{document}
section{Custom fbox{word} in Section heading}
fbox{circled{word}}
end{document}


Which renders like this:



rendered output
.



Ideally, I want to be able to write something similar to fbox{circled{word}} inside of my section heading, which currently simply throws an error about the "undefined control sequence def.










share|improve this question






















  • Welcome to TeX.SE!
    – Kurt
    Dec 4 at 23:17










  • section{Custom fbox{protectcircled{word}} in Section heading} also works...
    – marmot
    Dec 4 at 23:40










  • @Sermak Are you using hyperref in your real document?
    – samcarter
    Dec 7 at 10:25













up vote
5
down vote

favorite
1









up vote
5
down vote

favorite
1






1





I am trying to include a first circled and then boxed word in a section heading.



Currently, I am only able to create this highlighted word within a normal paragraph, but not inside of a heading. My attempt so far:



documentclass[a4paper]{article}
usepackage{tikz}
newcommand*circled[1]{tikz[baseline=(char.base)]{
node[shape=circle,draw,inner sep=2pt] (char) {#1};}}
begin{document}
section{Custom fbox{word} in Section heading}
fbox{circled{word}}
end{document}


Which renders like this:



rendered output
.



Ideally, I want to be able to write something similar to fbox{circled{word}} inside of my section heading, which currently simply throws an error about the "undefined control sequence def.










share|improve this question













I am trying to include a first circled and then boxed word in a section heading.



Currently, I am only able to create this highlighted word within a normal paragraph, but not inside of a heading. My attempt so far:



documentclass[a4paper]{article}
usepackage{tikz}
newcommand*circled[1]{tikz[baseline=(char.base)]{
node[shape=circle,draw,inner sep=2pt] (char) {#1};}}
begin{document}
section{Custom fbox{word} in Section heading}
fbox{circled{word}}
end{document}


Which renders like this:



rendered output
.



Ideally, I want to be able to write something similar to fbox{circled{word}} inside of my section heading, which currently simply throws an error about the "undefined control sequence def.







tikz-pgf sectioning






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Dec 4 at 23:05









Sermak

261




261












  • Welcome to TeX.SE!
    – Kurt
    Dec 4 at 23:17










  • section{Custom fbox{protectcircled{word}} in Section heading} also works...
    – marmot
    Dec 4 at 23:40










  • @Sermak Are you using hyperref in your real document?
    – samcarter
    Dec 7 at 10:25


















  • Welcome to TeX.SE!
    – Kurt
    Dec 4 at 23:17










  • section{Custom fbox{protectcircled{word}} in Section heading} also works...
    – marmot
    Dec 4 at 23:40










  • @Sermak Are you using hyperref in your real document?
    – samcarter
    Dec 7 at 10:25
















Welcome to TeX.SE!
– Kurt
Dec 4 at 23:17




Welcome to TeX.SE!
– Kurt
Dec 4 at 23:17












section{Custom fbox{protectcircled{word}} in Section heading} also works...
– marmot
Dec 4 at 23:40




section{Custom fbox{protectcircled{word}} in Section heading} also works...
– marmot
Dec 4 at 23:40












@Sermak Are you using hyperref in your real document?
– samcarter
Dec 7 at 10:25




@Sermak Are you using hyperref in your real document?
– samcarter
Dec 7 at 10:25










2 Answers
2






active

oldest

votes

















up vote
2
down vote













This is because you command is fragile. Here is a solution:



documentclass[a4paper]{article}
usepackage{tikz}
DeclareRobustCommandcircled[1]{fbox{tikz[baseline=(char.base)]{
node[shape=circle,draw,inner sep=2pt] (char) {#1};}}}

begin{document}

section{Custom circled{word} in Section heading}

circled{word}

end{document}


enter image description here






share|improve this answer




























    up vote
    2
    down vote













    Anything inside sectioning commands must be robust or protected using protect, so you need to change you newcommand to DeclareRobustCommand.



    documentclass[a4paper]{article}
    usepackage{tikz}
    DeclareRobustCommandcircled[1]{tikz[baseline=(char.base)]{
    node[shape=circle,draw,inner sep=2pt] (char) {#1};}}
    begin{document}
    section{Custom fbox{circled{word}} in Section heading}
    fbox{circled{word}}
    end{document}



    enter image description here







    share|improve this answer























    • A typical AboAmmar action. You write an answer, I write a comment about protect, and after you read my comment you just to your answer. We had these conversations before and I am starting to wonder if there is any answer of yours that is really your answer, i.e. not just "adapted" from someone else.
      – marmot
      Dec 9 at 10:27










    • A typical marmot action: attack others without even thinking. Both answers were posted at 23:36 and your comment at 23:40. Do you think that people are reading your mind and stealing your ideas before you post them? We answer questions here in our free time just for fun and to pay back the community who helped us in the past. This is not a marathon or a war, just take a deep breath and relax. Happy TeX-ing anyway.
      – AboAmmar
      Dec 9 at 15:25










    • No. Your answer was updated considerable time after my comment, which was on protect. No, I am not claiming I was the first to point out one may want to use protect in sections. But you definitely added protect after my comment was there and before that protect was not part of your answer. Please stop doing this. Academic honesty is not an unnecessary habit.
      – marmot
      Dec 9 at 15:37













    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "85"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f463233%2ftikz-in-section-heading%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    2
    down vote













    This is because you command is fragile. Here is a solution:



    documentclass[a4paper]{article}
    usepackage{tikz}
    DeclareRobustCommandcircled[1]{fbox{tikz[baseline=(char.base)]{
    node[shape=circle,draw,inner sep=2pt] (char) {#1};}}}

    begin{document}

    section{Custom circled{word} in Section heading}

    circled{word}

    end{document}


    enter image description here






    share|improve this answer

























      up vote
      2
      down vote













      This is because you command is fragile. Here is a solution:



      documentclass[a4paper]{article}
      usepackage{tikz}
      DeclareRobustCommandcircled[1]{fbox{tikz[baseline=(char.base)]{
      node[shape=circle,draw,inner sep=2pt] (char) {#1};}}}

      begin{document}

      section{Custom circled{word} in Section heading}

      circled{word}

      end{document}


      enter image description here






      share|improve this answer























        up vote
        2
        down vote










        up vote
        2
        down vote









        This is because you command is fragile. Here is a solution:



        documentclass[a4paper]{article}
        usepackage{tikz}
        DeclareRobustCommandcircled[1]{fbox{tikz[baseline=(char.base)]{
        node[shape=circle,draw,inner sep=2pt] (char) {#1};}}}

        begin{document}

        section{Custom circled{word} in Section heading}

        circled{word}

        end{document}


        enter image description here






        share|improve this answer












        This is because you command is fragile. Here is a solution:



        documentclass[a4paper]{article}
        usepackage{tikz}
        DeclareRobustCommandcircled[1]{fbox{tikz[baseline=(char.base)]{
        node[shape=circle,draw,inner sep=2pt] (char) {#1};}}}

        begin{document}

        section{Custom circled{word} in Section heading}

        circled{word}

        end{document}


        enter image description here







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Dec 4 at 23:36









        Bernard

        164k769192




        164k769192






















            up vote
            2
            down vote













            Anything inside sectioning commands must be robust or protected using protect, so you need to change you newcommand to DeclareRobustCommand.



            documentclass[a4paper]{article}
            usepackage{tikz}
            DeclareRobustCommandcircled[1]{tikz[baseline=(char.base)]{
            node[shape=circle,draw,inner sep=2pt] (char) {#1};}}
            begin{document}
            section{Custom fbox{circled{word}} in Section heading}
            fbox{circled{word}}
            end{document}



            enter image description here







            share|improve this answer























            • A typical AboAmmar action. You write an answer, I write a comment about protect, and after you read my comment you just to your answer. We had these conversations before and I am starting to wonder if there is any answer of yours that is really your answer, i.e. not just "adapted" from someone else.
              – marmot
              Dec 9 at 10:27










            • A typical marmot action: attack others without even thinking. Both answers were posted at 23:36 and your comment at 23:40. Do you think that people are reading your mind and stealing your ideas before you post them? We answer questions here in our free time just for fun and to pay back the community who helped us in the past. This is not a marathon or a war, just take a deep breath and relax. Happy TeX-ing anyway.
              – AboAmmar
              Dec 9 at 15:25










            • No. Your answer was updated considerable time after my comment, which was on protect. No, I am not claiming I was the first to point out one may want to use protect in sections. But you definitely added protect after my comment was there and before that protect was not part of your answer. Please stop doing this. Academic honesty is not an unnecessary habit.
              – marmot
              Dec 9 at 15:37

















            up vote
            2
            down vote













            Anything inside sectioning commands must be robust or protected using protect, so you need to change you newcommand to DeclareRobustCommand.



            documentclass[a4paper]{article}
            usepackage{tikz}
            DeclareRobustCommandcircled[1]{tikz[baseline=(char.base)]{
            node[shape=circle,draw,inner sep=2pt] (char) {#1};}}
            begin{document}
            section{Custom fbox{circled{word}} in Section heading}
            fbox{circled{word}}
            end{document}



            enter image description here







            share|improve this answer























            • A typical AboAmmar action. You write an answer, I write a comment about protect, and after you read my comment you just to your answer. We had these conversations before and I am starting to wonder if there is any answer of yours that is really your answer, i.e. not just "adapted" from someone else.
              – marmot
              Dec 9 at 10:27










            • A typical marmot action: attack others without even thinking. Both answers were posted at 23:36 and your comment at 23:40. Do you think that people are reading your mind and stealing your ideas before you post them? We answer questions here in our free time just for fun and to pay back the community who helped us in the past. This is not a marathon or a war, just take a deep breath and relax. Happy TeX-ing anyway.
              – AboAmmar
              Dec 9 at 15:25










            • No. Your answer was updated considerable time after my comment, which was on protect. No, I am not claiming I was the first to point out one may want to use protect in sections. But you definitely added protect after my comment was there and before that protect was not part of your answer. Please stop doing this. Academic honesty is not an unnecessary habit.
              – marmot
              Dec 9 at 15:37















            up vote
            2
            down vote










            up vote
            2
            down vote









            Anything inside sectioning commands must be robust or protected using protect, so you need to change you newcommand to DeclareRobustCommand.



            documentclass[a4paper]{article}
            usepackage{tikz}
            DeclareRobustCommandcircled[1]{tikz[baseline=(char.base)]{
            node[shape=circle,draw,inner sep=2pt] (char) {#1};}}
            begin{document}
            section{Custom fbox{circled{word}} in Section heading}
            fbox{circled{word}}
            end{document}



            enter image description here







            share|improve this answer














            Anything inside sectioning commands must be robust or protected using protect, so you need to change you newcommand to DeclareRobustCommand.



            documentclass[a4paper]{article}
            usepackage{tikz}
            DeclareRobustCommandcircled[1]{tikz[baseline=(char.base)]{
            node[shape=circle,draw,inner sep=2pt] (char) {#1};}}
            begin{document}
            section{Custom fbox{circled{word}} in Section heading}
            fbox{circled{word}}
            end{document}



            enter image description here








            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Dec 4 at 23:41

























            answered Dec 4 at 23:36









            AboAmmar

            32.2k22781




            32.2k22781












            • A typical AboAmmar action. You write an answer, I write a comment about protect, and after you read my comment you just to your answer. We had these conversations before and I am starting to wonder if there is any answer of yours that is really your answer, i.e. not just "adapted" from someone else.
              – marmot
              Dec 9 at 10:27










            • A typical marmot action: attack others without even thinking. Both answers were posted at 23:36 and your comment at 23:40. Do you think that people are reading your mind and stealing your ideas before you post them? We answer questions here in our free time just for fun and to pay back the community who helped us in the past. This is not a marathon or a war, just take a deep breath and relax. Happy TeX-ing anyway.
              – AboAmmar
              Dec 9 at 15:25










            • No. Your answer was updated considerable time after my comment, which was on protect. No, I am not claiming I was the first to point out one may want to use protect in sections. But you definitely added protect after my comment was there and before that protect was not part of your answer. Please stop doing this. Academic honesty is not an unnecessary habit.
              – marmot
              Dec 9 at 15:37




















            • A typical AboAmmar action. You write an answer, I write a comment about protect, and after you read my comment you just to your answer. We had these conversations before and I am starting to wonder if there is any answer of yours that is really your answer, i.e. not just "adapted" from someone else.
              – marmot
              Dec 9 at 10:27










            • A typical marmot action: attack others without even thinking. Both answers were posted at 23:36 and your comment at 23:40. Do you think that people are reading your mind and stealing your ideas before you post them? We answer questions here in our free time just for fun and to pay back the community who helped us in the past. This is not a marathon or a war, just take a deep breath and relax. Happy TeX-ing anyway.
              – AboAmmar
              Dec 9 at 15:25










            • No. Your answer was updated considerable time after my comment, which was on protect. No, I am not claiming I was the first to point out one may want to use protect in sections. But you definitely added protect after my comment was there and before that protect was not part of your answer. Please stop doing this. Academic honesty is not an unnecessary habit.
              – marmot
              Dec 9 at 15:37


















            A typical AboAmmar action. You write an answer, I write a comment about protect, and after you read my comment you just to your answer. We had these conversations before and I am starting to wonder if there is any answer of yours that is really your answer, i.e. not just "adapted" from someone else.
            – marmot
            Dec 9 at 10:27




            A typical AboAmmar action. You write an answer, I write a comment about protect, and after you read my comment you just to your answer. We had these conversations before and I am starting to wonder if there is any answer of yours that is really your answer, i.e. not just "adapted" from someone else.
            – marmot
            Dec 9 at 10:27












            A typical marmot action: attack others without even thinking. Both answers were posted at 23:36 and your comment at 23:40. Do you think that people are reading your mind and stealing your ideas before you post them? We answer questions here in our free time just for fun and to pay back the community who helped us in the past. This is not a marathon or a war, just take a deep breath and relax. Happy TeX-ing anyway.
            – AboAmmar
            Dec 9 at 15:25




            A typical marmot action: attack others without even thinking. Both answers were posted at 23:36 and your comment at 23:40. Do you think that people are reading your mind and stealing your ideas before you post them? We answer questions here in our free time just for fun and to pay back the community who helped us in the past. This is not a marathon or a war, just take a deep breath and relax. Happy TeX-ing anyway.
            – AboAmmar
            Dec 9 at 15:25












            No. Your answer was updated considerable time after my comment, which was on protect. No, I am not claiming I was the first to point out one may want to use protect in sections. But you definitely added protect after my comment was there and before that protect was not part of your answer. Please stop doing this. Academic honesty is not an unnecessary habit.
            – marmot
            Dec 9 at 15:37






            No. Your answer was updated considerable time after my comment, which was on protect. No, I am not claiming I was the first to point out one may want to use protect in sections. But you definitely added protect after my comment was there and before that protect was not part of your answer. Please stop doing this. Academic honesty is not an unnecessary habit.
            – marmot
            Dec 9 at 15:37




















            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.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • 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%2f463233%2ftikz-in-section-heading%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

            flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

            Mangá

             ⁒  ․,‪⁊‑⁙ ⁖, ⁇‒※‌, †,⁖‗‌⁝    ‾‸⁘,‖⁔⁣,⁂‾
”‑,‥–,‬ ,⁀‹⁋‴⁑ ‒ ,‴⁋”‼ ⁨,‷⁔„ ‰′,‐‚ ‥‡‎“‷⁃⁨⁅⁣,⁔
⁇‘⁔⁡⁏⁌⁡‿‶‏⁨ ⁣⁕⁖⁨⁩⁥‽⁀  ‴‬⁜‟ ⁃‣‧⁕‮ …‍⁨‴ ⁩,⁚⁖‫ ,‵ ⁀,‮⁝‣‣ ⁑  ⁂– ․, ‾‽ ‏⁁“⁗‸ ‾… ‹‡⁌⁎‸‘ ‡⁏⁌‪ ‵⁛ ‎⁨ ―⁦⁤⁄⁕