# How to automatically put the content of all the footnotes in one document

I wrote a dissertation with bibliographic references in footnotes, and I would like to organize them in a bibliography at the end of the dissertation (using Lyx).

I could copy every single footnote and paste it in such a document, but it would take a lot of time.

Would you know a way of automatically putting the content of every footnote in one single document, that I could organize in order to present it as my bibliography?

Thanks a lot for your help!

• I can't imagine that the footnotes containing bibliographic references are sufficent to act as a bibliography. However, this question could be interesting for you. – Ruben Dec 23 '13 at 16:44
• Sadly, no, it is not the case, since I will have to organize the bibliography. – Simon Dec 23 '13 at 17:02
• In this case you should edit the last sentence of your post. Don't be sad. Setting up a bibliography is one of the nice things in LaTeX because you basically need only two macros. And I think in LyX it is similarly simple. – Ruben Dec 23 '13 at 17:24

You may redefine the internal command \@footnotetext to write its contents into a file.

Here is a simple solution that writes footnotes into a file file.ftn, where file is the name of your .tex file as bibliography references:

\documentclass{article}

\newwrite\footaux
\immediate\openout\footaux\jobname.ftn
\immediate\write\footaux{\string\begin{thebibliography}{99}}
\AtEndDocument{
\immediate\write\footaux{\string\end{thebibliography}}
\closeout\footaux
}
\makeatletter
\let\@footnotetextorig\@footnotetext
\long\def\@footnotetext#1{\@footnotetextorig{#1}\immediate\write\footaux
{\string\bibitem:  #1}}
\makeatother
\begin{document}
This is the text\footnote{First footnote}.
\clearpage
This is the text\footnote{Second footnote}.
\end{document}


Here is the .ftn file:

\begin{thebibliography}{99}
\bibitem: First footnote
\bibitem: Second footnote
\end{thebibliography}


Solution Ideas

1. Redefine \footnote command so that it saves the footnote text in a file formatted for bibliography.
2. Use the saved bibliographies at the end.

The Solution

\documentclass{article}

\usepackage{lipsum}

\usepackage{url}

\let\originalfootnote\footnote
\newwrite\footnotelist
\immediate\openout\footnotelist\jobname.bls
\immediate\write\footnotelist{\unexpanded{\begin{thebibliography}{99}}}
\def\savefootnote#1{\immediate\write\footnotelist{\unexpanded{\bibitem}{fn\thefootnote}\unexpanded{#1}}}
\def\footnote#1{%
\originalfootnote{#1}%
\savefootnote{#1}}

\AtEndDocument{\immediate\write\footnotelist{\unexpanded{\end{thebibliography}}}%
\immediate\closeout\footnotelist%
\IfFileExists{\jobname.bls}{\input{\jobname.bls}}{\relax}}

\begin{document}

\lipsum[1-10]

Put a footnote here.\footnote{\url{http://www.acm.org}}

\lipsum[11-20]

Put another footnote here.\footnote{\url{http://ieeexplore.ieee.org}}

\lipsum[21-30]

\end{document}


Created Footnote List File

\begin {thebibliography}{99}
\bibitem {fn1}\url {http://www.acm.org}
\bibitem {fn2}\url {http://ieeexplore.ieee.org}
\end {thebibliography}


The Output

• @Simon Glad to be of assistance. If the solution worked for you, you can accept it as well. :-) – Masroor Dec 24 '13 at 5:01