Nota de rodapé dentro do cabeçalho da seção: Erro ao usar os pacotes titlesec e footnotebackref

Nota de rodapé dentro do cabeçalho da seção: Erro ao usar os pacotes titlesec e footnotebackref

O seguinte MWE

\documentclass{article}
\usepackage{titlesec}        
\usepackage{footnotebackref} 
\begin{document}
\section{Whatever\protect\footnote{Problematic footnote}}
\end{document}

gera um erro se os pacotes titlesece footnotebackrefforem carregados (embora funcione como esperado se algum deles for removido). Tentei usar \footnotemarke \footnotetext, sem sucesso. Alguma ideia do que pode estar acontecendo e como consertar? (Eu sei que não é aconselhável usar notas de rodapé nos cabeçalhos, mas de qualquer forma...)

Responder1

SeguindoComo usar o pacote footnotebackref com \footnotemark e \footnotetext?, a solução é usar \footnotemarke \footnotetextcom a seguinte redefinição:

\makeatletter
\LetLtxMacro{\BHFN@Old@footnotemark}{\@footnotemark}  
\renewcommand*{\@footnotemark}{%
    \refstepcounter{BackrefHyperFootnoteCounter}%
    \xdef\BackrefFootnoteTag{bhfn:\theBackrefHyperFootnoteCounter}%
    \label{\BackrefFootnoteTag}%
    \BHFN@Old@footnotemark
}
\makeatother

(Um também tem para \protecto \footnotemark). MWE completo:

\documentclass{article}
\usepackage{titlesec}        
\usepackage{footnotebackref} 
\makeatletter
\LetLtxMacro{\BHFN@Old@footnotemark}{\@footnotemark}
\renewcommand*{\@footnotemark}{%
    \refstepcounter{BackrefHyperFootnoteCounter}%
    \xdef\BackrefFootnoteTag{bhfn:\theBackrefHyperFootnoteCounter}%
    \label{\BackrefFootnoteTag}%
    \BHFN@Old@footnotemark
}
\makeatother
\begin{document}
\section{Whatever\protect\footnotemark}
\footnotetext{Problematic footnote}
\end{document}

insira a descrição da imagem aqui

informação relacionada