[Tex/LaTex] Placing footnotes or endnotes at the end of the current paragraph

endnotesfootnotesparnotespositioning

This question led to a new package:
parnotes

How can I get footnote or endnote text to appear right after the paragraph in which it was mentioned?

Update:

As my question lacks sufficient detail, I'll try to clarify.

  • The goal is to place the notes closer to the reader and to have a document which flows from start to finish, rather than one that is interrupted continuously by footnotes.
  • By "footnote" or "endnote", I mean anything with a cross-reference mark (e.g. "1") pointing to another place on the page (the end of the paragraph).

Update:

The provided answer greatly solves the initial problem quite well. It is, however, incompatible with a number of other options provided by addition packages, such as footmisc and its included options such as para and stable. The bounty will go to an extended solution which:

  • Provides the ability to define the mark and text in different locations so that footnote marks can be placed within section titles (see footnotemark and footnotetext and stable options in footmisc for an example). E.g.:

    \begin{footnotepar}
    \section{This is a section title\footnotemark}
        \footnotetext{This is the text for a footnote which has a mark in the section title.}
        This is text in the paragraph.
    \end{footnotepar}
    
  • Treats the footnote text as if it is no different from text within a standard paragraph and allows the text to behave in a similar manner (e.g. flowing into a paragraph, breaking at the end of the page). E.g.:

1 This is the text of the first footnote. 2 This is the text of

the second footnote. 3 This is the text of the third footnote.

4 This is the text of the fourth footnote. 5 This is the text of


the fifth footnote which partially appears on the top of the

second page. 6 This is the text of the sixth footnote.

  • Leaves points for uniformly controlling the size, font, and position of the footnote mark (the one appearing near the footnote), the footnote text itself, and the space after each footnote (e.g. placing \newline to go to a new line, or \hspace to add some space).
  • Leaves points for uniformly enclosing an environment around each group of footnotes, for e.g., to enable the groups of footnote texts to be enclosed with \begin{multicols}{2} and \end{multicols} (or other environments).

Best Answer

You may put each paragraph into a minipage, because minipages have their own footnotes:

\documentclass{article}
\usepackage[english]{babel}
\usepackage{blindtext}

\newenvironment{mpar}{\par\noindent\minipage{\linewidth}%
  \setlength{\parindent}{1em}%
}{\endminipage\par\medskip}

\begin{document}
\section{Test}
\blindtext
\begin{mpar}First example.\footnote{A note at the foot of the minipage}
\blindtext\end{mpar}
\begin{mpar}Second example.\footnote{A note at the foot of the minipage}
\blindtext\end{mpar}
\blindtext
\end{document}

Or you may define an environment, that does only copy the footnote feature of minipage:

\documentclass{article}
\usepackage{lipsum}

\makeatletter
\newenvironment{footnotepar}{%
  \par
  \def\@mpfn{mpfootnote}\def\thempfn{\thempfootnote}\c@mpfootnote\z@
  \let\@footnotetext\@mpfootnotetext
}{%
  \ifvoid\@mpfootins\else
    \vskip\skip\@mpfootins
    \normalcolor
    \footnoterule
    \unvbox\@mpfootins
  \fi
  \par\smallskip
}
\makeatother

\begin{document}
\lipsum[1-3]
\begin{footnotepar}Lipsum test:\footnote{lipsum is a
    package}\lipsum[2]\end{footnotepar}
\begin{footnotepar}Another\footnote{Not really another one}
  test:\footnote{This is a lipsum test}\lipsum[3]\end{footnotepar}
\lipsum[4]
\end{document}