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







New contributor




Sermak is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • 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
    yesterday















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







New contributor




Sermak is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • 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
    yesterday













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







New contributor




Sermak is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











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







New contributor




Sermak is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




Sermak is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




Sermak is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Dec 4 at 23:05









Sermak

261




261




New contributor




Sermak is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Sermak is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Sermak is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • 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
    yesterday


















  • 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
    yesterday
















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
yesterday




@Sermak Are you using hyperref in your real document?
– samcarter
yesterday










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























      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
      });


      }
      });






      Sermak is a new contributor. Be nice, and check out our Code of Conduct.










      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

          163k769192




          163k769192






















              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



























                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

























                  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

                  31.8k22781




                  31.8k22781






















                      Sermak is a new contributor. Be nice, and check out our Code of Conduct.










                      draft saved

                      draft discarded


















                      Sermak is a new contributor. Be nice, and check out our Code of Conduct.













                      Sermak is a new contributor. Be nice, and check out our Code of Conduct.












                      Sermak is a new contributor. Be nice, and check out our Code of Conduct.
















                      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

                      "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

                      Alcedinidae

                      Origin of the phrase “under your belt”?