# Footnotes with a symbol in section headings

I would like to combine a method of customising footnote symbols which allows for commands like:

\footnote[*]{foo}

with a method of putting footnotes into section titles so that they don't show up in the Table of Contents.

If have tried simply putting the two methods together:

\makeatletter
\def\@xfootnote[#1]{\protected@xdef\@thefnmark{#1}\@footnotemark\@footnotetext}
\makeatother
\makeatletter
\def\titlefootnote{\ifx\protect\@typeset@protect\expandafter\footnote\else\expandafter\@gobble\fi}
\makeatother


and this allows me to do, for example:

\section{My new section\titlefootnote[*]{This section has footnotes}}


1 My new section*]This section has footnotes

How can I adjust the code to allow for the \footnote[*]-type command and the \titlefootnote tweak?

Here's a MWE:

\documentclass{article}
% Allow footnotes to chapter (and other heading) titles without them
\makeatletter
\def\@xfootnote[#1]{\protected@xdef\@thefnmark{#1}\@footnotemark\@footnotetext}
\makeatother
\makeatletter
\def\titlefootnote{\ifx\protect\@typeset@protect\expandafter\footnote\else\expandafter\@gobble\fi}
\makeatother

\begin{document}
\tableofcontents
\section{My new section\titlefootnote[*]{This section has footnotes}}
\end{document}


(by the way, I know some people say you shouldn't use footnotes in a section title.)

• Have you tried the optional argument of \section, as in \section[My new section]{My new section\titlefootnote{...}} – Steven B. Segletes Apr 12 '16 at 13:18

As suggested in my comment, the use of the optional argument of \section can avoid the footnote in the toc.

\documentclass{article}
\makeatletter
\def\@xfootnote[#1]{\protected@xdef\@thefnmark{#1}\@footnotemark\@footnotetext}
\makeatother
\makeatletter
\def\titlefootnote{\ifx\protect\@typeset@protect\expandafter\footnote\else\expandafter\@gobble\fi}
\makeatother
\textheight 2in% FOR DEMONSTRATION PURPOSES ONLY
\begin{document}
\tableofcontents

\noindent\hrulefill

\section[Title]{Title\titlefootnote[*]{my footnote}}
\end{document}


• This is a pretty good solution. There's obviously a risk of mismatches between chapter titles and table of contents due to lack of DRY but I'm happy to put up with this limitation. – LondonRob Apr 12 '16 at 13:31
• @LondonRob DRY can be avoided with this: \def\DRY{Section Title} \section[\DRY]{\DRY\titlefootnote[*]{my footnote}} – Steven B. Segletes Jun 28 '17 at 11:15