Now i need to attach an endnote to the number of the beginning of section 16, and naive manipulations like \section{\endnote{$\pi=3.14$}} will make a big gap between the number 16 (which is automatically generated) and the mark of the endnote, therefore I changed it to \section*{16\endnote{$\pi=3.14$}} which consequently makes the number of the next section (which is section 17) 16. I don't want to adjust following sections' titles manually, so is there a way to attach the endnote/footnote? Or generally is there a way to control the sequence of numbering of the titles?

A minimal example

\section*{1\footnote{In this section we take $c=0$}}%This one being the title of the first section.
This is the material of the first section.
\section{}%This is the title of the supposedly second section
This is what is contained in the second section.
  • 1
    If you want help, please provide a minimal example, meta.tex.stackexchange.com/q/228. Then we know what you are starting out from and also have something to start debugging on. – daleif Jul 11 '14 at 12:51
  • Where does \endnote come from. From the equally named package? – user31729 Jul 11 '14 at 13:31
  • @ChristianHupfer aye. – Zhipu 'Wilson' Zhao Jul 12 '14 at 10:38
  • @daleif Is has been done so. – Zhipu 'Wilson' Zhao Jul 12 '14 at 10:42
  • 2
    @ChristianHupfer - I think the footnote/endnote thing is a red herring: If the endnotes package is loaded, normal footnotes (i.e., those created by \footnote) are converted to endnotes automatically. The major issue seems to be the OP's attempt to attach a footnote (or endnote) marker directly to the section's number. Of course, I may not have understood the objective correctly. – Mico Jul 12 '14 at 11:19

Here's a solution, where \@seccntformat is hijacked to add an endnote marker. The endnote text is provided as a trailing optional argument to \Section.



  \gdef\thissectionnote{}% reinitialize
  \IfValueT{#4}{\gdef\thissectionnote{#4}}% set up the endnote
    {\section*{#3}} % starred section
    {\IfNoValueTF{#2} % unstarred section
       {\section{#3}} % no optional argument
       {\section[#2]{#3}}% optional argument

  \csname the#1\endcsname
  \ifcsname #1@seccntformat\endcsname


\Section{A title}

This is a normal section

\Section{Another title}[In this section we take $c=0$]

This section has an endnote.

\Section[Short title]{Long title}

This is another section.



enter image description here

If you need to use \section because the text is automatically generated, you can save the meaning of \section: just the part with \NewDocumentCommand needs a change.

  \gdef\thissectionnote{}% reinitialize
  \IfValueT{#4}{\gdef\thissectionnote{#4}}% set up the endnote
    {\latexsection*{#3}} % starred section
    {\IfNoValueTF{#2} % unstarred section
       {\latexsection{#3}} % no optional argument
       {\latexsection[#2]{#3}}% optional argument
| improve this answer | |
  • I have an idea: \phantom{\section}. If we can start a section whose title does not appear but the number counts, the next section's number will automatically be adjusted at the right place, and it works. But the cmd gives error message (albeit that it works) – Zhipu 'Wilson' Zhao Jul 15 '14 at 9:31
  • @WilsonofGordon I have added the workaround for being able to use \section instead of a new command. – egreg Jul 15 '14 at 9:31
  • (continue) the error message reads – Zhipu 'Wilson' Zhao Jul 15 '14 at 9:32
  • ! Missing } inserted. <inserted text> } l.4 \phantom{\section} ? ! Too many }'s. \makeph@nt ...color@begingroup #1\color@endgroup } \finph@nt l.4 \phantom{\section} ? [1 – Zhipu 'Wilson' Zhao Jul 15 '14 at 9:32
  • Thanks for the lengthy response, but I feel myself failed to understand it. What is the package xparse for? – Zhipu 'Wilson' Zhao Jul 15 '14 at 9:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.