Accessing chapter's name in Koma-Script Announcing the arrival of Valued Associate #679: Cesar...

If Jon Snow became King of the Seven Kingdoms what would his regnal number be?

How to assign captions for two tables in LaTeX?

How to motivate offshore teams and trust them to deliver?

How to recreate this effect in Photoshop?

Do I really need recursive chmod to restrict access to a folder?

Is there a concise way to say "all of the X, one of each"?

When -s is used with third person singular. What's its use in this context?

Why is "Captain Marvel" translated as male in Portugal?

How widely used is the term Treppenwitz? Is it something that most Germans know?

Is a manifold-with-boundary with given interior and non-empty boundary essentially unique?

I am not a queen, who am I?

How can players work together to take actions that are otherwise impossible?

Why was the term "discrete" used in discrete logarithm?

What is a Meta algorithm?

Is the Standard Deduction better than Itemized when both are the same amount?

Examples of mediopassive verb constructions

Why is "Consequences inflicted." not a sentence?

Check which numbers satisfy the condition [A*B*C = A! + B! + C!]

What do you call a plan that's an alternative plan in case your initial plan fails?

What is the longest distance a 13th-level monk can jump while attacking on the same turn?

Why don't the Weasley twins use magic outside of school if the Trace can only find the location of spells cast?

How to draw this diagram using TikZ package?

What LEGO pieces have "real-world" functionality?

Is the address of a local variable a constexpr?



Accessing chapter's name in Koma-Script



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)How to get the current chapter* name, section* name, subsection* name, etc?Separate column in table of contents (in Memoir)Different labels for subsection titles and referencesConversion of Sectioning Numbers in ConTeXtUsing the long form of a section title in the TOCincluding book name and chapter name above section name in memoirCustomizing chapter and section style (scrbook)Insert the number and name of the section in the header, (including on a chapter's opening page)Default dimensions sections name in book classFormat fonts for TOC/LOF/LOT with tocloftHeader with Section short title and Chapter short title using KOMA-script












0















I looked up for a solution to access the name of current sections (chapters, sections, etc.) from macros (including starred variations of the section command). The set of macros proposed here works like a charm in the base class book.



documentclass{book}

usepackage{etoolbox}
% Patch the sectioning commands to provide a hook to be used later
preto{chapter}{defleveltitle{chaptertitle}}
preto{section}{defleveltitle{sectiontitle}}
preto{subsection}{defleveltitle{subsectiontitle}}
preto{subsubsection}{defleveltitle{subsubsectiontitle}}

makeatletter
pretocmd{@sect}
{expandaftergdefleveltitle{#8}}
{}{}
pretocmd{@ssect}
{expandaftergdefleveltitle{#5}}
{}{}
pretocmd{@chapter}
{expandaftergdefleveltitle{#2}}
{}{}
pretocmd{@schapter}
{expandaftergdefleveltitle{#1}}
{}{}
makeatother

newcommandtest{%
noindent
The chapter title is chaptertitle\
The section title is sectiontitle\
The subsection title is subsectiontitle\
The subsubsection title is subsubsectiontitle
}

begin{document}
chapter{First chapter}
section{First section}
subsection{First subsection}
subsubsection{First subsubsection}

test

chapter*{Second chapter}
section*{Second section}
subsection*{Second subsection}
subsubsection*{Second subsubsection}

test
end{document}


book_example



However I need to implement my macros in Koma-Script, with scrbook and here things start to get unexpected. With the same code but with class scrbook I get the following:



enter image description here



The chapter name is not rendered. I looked up the code of scrbook and the title is indeed #2. Is there something wrong with the macros and how to fix this issue?



For my needs, it is not possible to use nameref, I need a hard-coded solution. Thanks for you help.



Bonus: Is it possible to choose between long titles and short titles (the ones defined with section[short]{long}? Thanks again.









share



























    0















    I looked up for a solution to access the name of current sections (chapters, sections, etc.) from macros (including starred variations of the section command). The set of macros proposed here works like a charm in the base class book.



    documentclass{book}

    usepackage{etoolbox}
    % Patch the sectioning commands to provide a hook to be used later
    preto{chapter}{defleveltitle{chaptertitle}}
    preto{section}{defleveltitle{sectiontitle}}
    preto{subsection}{defleveltitle{subsectiontitle}}
    preto{subsubsection}{defleveltitle{subsubsectiontitle}}

    makeatletter
    pretocmd{@sect}
    {expandaftergdefleveltitle{#8}}
    {}{}
    pretocmd{@ssect}
    {expandaftergdefleveltitle{#5}}
    {}{}
    pretocmd{@chapter}
    {expandaftergdefleveltitle{#2}}
    {}{}
    pretocmd{@schapter}
    {expandaftergdefleveltitle{#1}}
    {}{}
    makeatother

    newcommandtest{%
    noindent
    The chapter title is chaptertitle\
    The section title is sectiontitle\
    The subsection title is subsectiontitle\
    The subsubsection title is subsubsectiontitle
    }

    begin{document}
    chapter{First chapter}
    section{First section}
    subsection{First subsection}
    subsubsection{First subsubsection}

    test

    chapter*{Second chapter}
    section*{Second section}
    subsection*{Second subsection}
    subsubsection*{Second subsubsection}

    test
    end{document}


    book_example



    However I need to implement my macros in Koma-Script, with scrbook and here things start to get unexpected. With the same code but with class scrbook I get the following:



    enter image description here



    The chapter name is not rendered. I looked up the code of scrbook and the title is indeed #2. Is there something wrong with the macros and how to fix this issue?



    For my needs, it is not possible to use nameref, I need a hard-coded solution. Thanks for you help.



    Bonus: Is it possible to choose between long titles and short titles (the ones defined with section[short]{long}? Thanks again.









    share

























      0












      0








      0








      I looked up for a solution to access the name of current sections (chapters, sections, etc.) from macros (including starred variations of the section command). The set of macros proposed here works like a charm in the base class book.



      documentclass{book}

      usepackage{etoolbox}
      % Patch the sectioning commands to provide a hook to be used later
      preto{chapter}{defleveltitle{chaptertitle}}
      preto{section}{defleveltitle{sectiontitle}}
      preto{subsection}{defleveltitle{subsectiontitle}}
      preto{subsubsection}{defleveltitle{subsubsectiontitle}}

      makeatletter
      pretocmd{@sect}
      {expandaftergdefleveltitle{#8}}
      {}{}
      pretocmd{@ssect}
      {expandaftergdefleveltitle{#5}}
      {}{}
      pretocmd{@chapter}
      {expandaftergdefleveltitle{#2}}
      {}{}
      pretocmd{@schapter}
      {expandaftergdefleveltitle{#1}}
      {}{}
      makeatother

      newcommandtest{%
      noindent
      The chapter title is chaptertitle\
      The section title is sectiontitle\
      The subsection title is subsectiontitle\
      The subsubsection title is subsubsectiontitle
      }

      begin{document}
      chapter{First chapter}
      section{First section}
      subsection{First subsection}
      subsubsection{First subsubsection}

      test

      chapter*{Second chapter}
      section*{Second section}
      subsection*{Second subsection}
      subsubsection*{Second subsubsection}

      test
      end{document}


      book_example



      However I need to implement my macros in Koma-Script, with scrbook and here things start to get unexpected. With the same code but with class scrbook I get the following:



      enter image description here



      The chapter name is not rendered. I looked up the code of scrbook and the title is indeed #2. Is there something wrong with the macros and how to fix this issue?



      For my needs, it is not possible to use nameref, I need a hard-coded solution. Thanks for you help.



      Bonus: Is it possible to choose between long titles and short titles (the ones defined with section[short]{long}? Thanks again.









      share














      I looked up for a solution to access the name of current sections (chapters, sections, etc.) from macros (including starred variations of the section command). The set of macros proposed here works like a charm in the base class book.



      documentclass{book}

      usepackage{etoolbox}
      % Patch the sectioning commands to provide a hook to be used later
      preto{chapter}{defleveltitle{chaptertitle}}
      preto{section}{defleveltitle{sectiontitle}}
      preto{subsection}{defleveltitle{subsectiontitle}}
      preto{subsubsection}{defleveltitle{subsubsectiontitle}}

      makeatletter
      pretocmd{@sect}
      {expandaftergdefleveltitle{#8}}
      {}{}
      pretocmd{@ssect}
      {expandaftergdefleveltitle{#5}}
      {}{}
      pretocmd{@chapter}
      {expandaftergdefleveltitle{#2}}
      {}{}
      pretocmd{@schapter}
      {expandaftergdefleveltitle{#1}}
      {}{}
      makeatother

      newcommandtest{%
      noindent
      The chapter title is chaptertitle\
      The section title is sectiontitle\
      The subsection title is subsectiontitle\
      The subsubsection title is subsubsectiontitle
      }

      begin{document}
      chapter{First chapter}
      section{First section}
      subsection{First subsection}
      subsubsection{First subsubsection}

      test

      chapter*{Second chapter}
      section*{Second section}
      subsection*{Second subsection}
      subsubsection*{Second subsubsection}

      test
      end{document}


      book_example



      However I need to implement my macros in Koma-Script, with scrbook and here things start to get unexpected. With the same code but with class scrbook I get the following:



      enter image description here



      The chapter name is not rendered. I looked up the code of scrbook and the title is indeed #2. Is there something wrong with the macros and how to fix this issue?



      For my needs, it is not possible to use nameref, I need a hard-coded solution. Thanks for you help.



      Bonus: Is it possible to choose between long titles and short titles (the ones defined with section[short]{long}? Thanks again.







      sectioning cross-referencing koma-script





      share












      share










      share



      share










      asked 6 mins ago









      8173781737

      284




      284






















          0






          active

          oldest

          votes












          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%2f485065%2faccessing-chapters-name-in-koma-script%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          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%2f485065%2faccessing-chapters-name-in-koma-script%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

          Paper upload error, “Upload failed: The top margin is 0.715 in on page 3, which is below the required...

          Emraan Hashmi Filmografia | Linki zewnętrzne | Menu nawigacyjneGulshan GroverGulshan...

          How can I write this formula?newline and italics added with leqWhy does widehat behave differently if I...