I have a document with cleveref and hyperref, both of which I don't want to miss. I need to reuse footnotes using cleveref which works fine thanks to https://tex.stackexchange.com/a/10116. I also want to automatically insert superscript commas between footnotemarks which works fine thanks to https://tex.stackexchange.com/a/71347. Taken separately, both of them work fine. Combined using code from https://tex.stackexchange.com/a/285630/154602, the footnote is duplicated and formatted incorrectly and the superscript comma is missing.
\documentclass{article}
\usepackage{biblatex}
\usepackage[colorlinks]{hyperref}
\usepackage{cleveref} % must be loaded after hyperref
% Source: https://tex.stackexchange.com/a/10116
\crefformat{footnote}{#2\footnotemark[#1]#3}
%\iffalse % without these lines, footnote marks look fine but miss a comma inbetween
% Inspiration: https://tex.stackexchange.com/a/285630/154602 and https://tex.stackexchange.com/a/71347
\let\oldFootnote\footnote
\let\oldFootnotemark\footnotemark
\newcommand\nextToken\relax
\renewcommand\footnote[1]{%
\oldFootnote{#1}\futurelet\nextToken\isFootnoteOrSimilar}
\renewcommand\footnotemark[1]{%
\oldFootnotemark{#1}\futurelet\nextToken\isFootnoteOrSimilar}
\newcommand\isFootnoteOrSimilar{%
\ifx\footnote%
\nextToken\textsuperscript{,}%
\else%
\ifx\footnotemark%
\nextToken\textsuperscript{,}%
\fi%
\fi%
}
%\fi
\textheight=7cm
\begin{document}
Text\footnote{First footnote}\footnote{Second footnote}\footnote{Third footnote} Text\footnote{Fourth footnote} Text
Referencing future footnote\cref{second}. Creating a footnote which will be referenced later\footnote{\label{first}First footnote!}
Creating the previously referenced footnote\footnote{\label{second}Second footnote}, and referencing a previously created footnote\cref{first}.
Footnote followed by referenced footnote\cref{first}\footnote{footnote B}
Referenced footnote followed by new footnote\footnote{footnote C}\cref{second}
\end{document}
How can I make the combination of \footnote and \cref on a footnote look nice, just as when two \footnotes follow each other in the first line of the output?
I think the issue is caused by the fact that when checking \isFootnoteOrSimilar, the \cref is not expanded. The macro expansion of \isFootnoteOrSimilar must be run last, after \cref is fully expanded, but I don't know how to do that.


\footnotemarkinstruction in the argument of\crefformat. Please describe in words how call-outs to cross-referenced footnotes should look like. – Mico Jun 05 '18 at 09:11\footnote{}, see the first line of the resulting text. I.e. they should be a superscripted hyperlinked number with commas inbetween consecutive call-outs of any footnote type. – genodeftest Jun 05 '18 at 09:19\crefformat? Are cross-referenced footnote markers supposed to be surrounded by square brackets? Please advise. – Mico Jun 05 '18 at 09:36