Placing footnotes or endnotes at the end of the current paragraph

This is a stripped-down version of the code in the parnotes package.

NOTE to anyone wanting to "do x after every paragraph": The proper way to make long-term changes to \par is through \@setpar, or by modifying \@par along with \par. Many LaTeX environments reset \par to \@par at end; see source2e chapter ltpar.dtx.

Here's a hack using \g@addto@macro to collect notes and place them in the main text flow later. Use \parnote{TEXT} to place a mark, then call \parnotes to put the notes in manually, anywhere you'd like. For a custom mark, use \parnote[MARK]{TEXT}.

There's also an autopn environment which sets parnotes automatically at the end of every paragraph by redefining \par and \@par. If you enter another environment while in autopn and you still want notes, you'll need to nest autopn within it. (Credit to Ahmed Musa)

\documentclass{article}
\usepackage{multicol}

\makeatletter
% Format for parnotes - \PN@notes@shape is blank (\relax) by default
\providecommand{\parnotefmt}[1]{\footnotesize%
                \PN@notes@shape\PN@narrower@optional\noindent #1}
% Format for parnote marks
\providecommand{\parnotemark}[1]{\textsuperscript{#1}}
% Minimum vertical space before and after parnotes
\providecommand{\parnotevskip}{\medskipamount}
% Full command used between parnotes
\providecommand{\parnoteintercmd}{\hspace{1em plus 0.3em minus 0.2em}}

\global\def\PN@text{}
\global\newcount\c@parnotemark
\def\@PN@autopn{autopn}
\newif\ifPN@inparnotes
\def\PN@disable@indent{\@afterindentfalse\@afterheading}
\let\PN@reset@optional\relax
\let\PN@mark@set\@arabic
\let\PN@narrower@optional\relax
\let\PN@notes@shape\relax

\newcommand\parnote{%
    \ifx\protect\@typeset@protect
        \@ifnextchar [
            {\expandafter\PN@parnote@twoargs}%
            {\expandafter\PN@parnote@onearg}%
    \else
        \expandafter\PN@gobble@opt
    \fi
}
\DeclareRobustCommand\PN@gobble@opt{%
    \@ifnextchar [
        \PN@gobble@opt@@
        \@gobble
}
\def\PN@parnote@twoargs[#1]#2{\PN@parnote@real{#1}{#2}}
\def\PN@parnote@onearg#1{%
    \global\advance\c@parnotemark\@ne
    \begingroup\edef\@x{\endgroup\noexpand\PN@parnote@real%
                        {\PN@mark@set{\c@parnotemark}}}\@x{#1}%
}
\def\PN@gobble@opt@@[#1]#2{}

\long\def\PN@parnote@real#1#2{%
    \leavevmode
    \ifhmode\edef\@x@sf{\the\spacefactor}\nobreak\fi
    \parnotemark{#1}%
    \ifhmode\spacefactor\@x@sf\fi\relax
    \unless\ifx\PN@text\@empty\g@addto@macro\PN@text{\parnoteintercmd}\fi
    \g@addto@macro\PN@text{\parnotemark{#1}\nolinebreak\thinspace#2}%
}

\newcommand\parnotes{%
    \unless\ifx\PN@text\@empty
        \expandafter\PN@parnotes@real
    \fi
}

\def\PN@parnotes@real{%
    \PN@inparnotestrue
    \unless\ifvmode\par\fi
    \nopagebreak\addvspace{\parnotevskip}%
    {\parnotefmt{\PN@text}\par}%
    \global\def\PN@text{}%
    \addvspace{\parnotevskip}%
    \PN@disable@indent
    \PN@reset@optional
    \PN@inparnotesfalse
}

\newenvironment{autopn}{%
    \let\PN@par\par
    \def\par{\PN@parnotes@auto\PN@par}%
    \def\@par{\PN@parnotes@auto\@@par}%
}
{\PN@parnotes@auto}

\def\PN@parnotes@auto{%
    \ifx\@currenvir\@PN@autopn
        \unless\ifPN@inparnotes
            \unless\ifx\PN@text\@empty
                \expandafter\PN@parnotes@real
            \fi
        \fi
    \fi
}
\makeatother

\begin{document}
\tableofcontents
\vspace{0.3in}
\begin{autopn}
\noindent%
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer aliquet
quam\parnote{Vitae mauris tempus!} consequat. In nec neque vitae magna
pulvinar pretium.\parnote{Nunc purus augue, egestas vitae lobortis at,
eleifend quis erat.  Vestibulum ante ipsum primis in faucibus orci luctus
et ultrices posuere cubilia Curae.} In aliquet tortor sed tellus
\parnote{Porta} et elementum diam sagittis.

\section{On parnotes\parnote{Section note.}}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer aliquet
quam\parnote{Vitae mauris tempus!} consequat. In nec neque vitae magna
pulvinar pretium.\parnote{Nunc purus augue, egestas vitae lobortis at,
eleifend quis erat.  Vestibulum ante ipsum primis in faucibus orci luctus
et ultrices posuere cubilia Curae.} In aliquet tortor sed tellus
\parnote{Porta} et elementum diam sagittis.

Ut vel ante eros, in lobortis risus.

Lorem ipsum dolor.

\vspace{0.1in}
\noindent Notes inside \texttt{multicols}:
\begin{multicols}{2}
\begin{autopn} % CHANGED: YOU MUST NEST autopn WITHIN ENVIRONMENTS
\noindent Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Integer aliquet quam\parnote{Vitae mauris tempus!} consequat.

New paragraph vitae magna
pulvinar pretium.\parnote{Nunc purus augue, egestas vitae lobortis at,
eleifend quis erat.  Vestibulum ante ipsum primis in faucibus orci luctus
et ultrices posuere cubilia Curae.} In aliquet tortor sed tellus
\parnote{Porta} et elementum diam sagittis.
\end{autopn}
\end{multicols}
\end{autopn}

\noindent Notes outside \texttt{multicols}:
\begin{multicols}{2}
\noindent Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Integer aliquet quam\parnote{Vitae mauris tempus!} consequat.

New paragraph vitae magna
pulvinar pretium.\parnote{Nunc purus augue, egestas vitae lobortis at,
eleifend quis erat.  Vestibulum ante ipsum primis in faucibus orci luctus
et ultrices posuere cubilia Curae.} In aliquet tortor sed tellus
\parnote{Porta} et elementum diam sagittis.
\end{multicols}
\parnotes

\vspace{0.1in}
\noindent Notes break pages:\\[0.08in]
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer aliquet
quam\parnote{Vitae mauris tempus consequat. In nec neque vitae magna
pulvinar pretium. Nunc purus augue, egestas vitae lobortis at,
eleifend quis erat.  Vestibulum ante ipsum primis in faucibus orci luctus
et ultrices posuere cubilia Curae. In aliquet tortor sed tellus
Porta et elementum diam sagittis. Lorem ipsum dolor sit amet,
pulvinar pretium. Nunc purus augue, egestas vitae lobortis at,
eleifend quis erat.  Vestibulum ante ipsum primis in faucibus orci luctus
et ultrices posuere cubilia Curae. In aliquet tortor sed tellus
Porta et elementum diam sagittis. Lorem ipsum dolor sit amet,
consectetur adipiscing elit.} In nec neque vitae magna pulvinar
pretium.
\parnotes
\end{document}

enter image description here


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}

\begin{filecontents*}{parnotes.sty}
\ProvidesPackage{parnotes}[2011/12/10 v0.0.1 Paragraph notes (Ahmed Musa)]
\NeedsTeXFormat{LaTeX2e}[2011/06/27]
\RequirePackage{combokeys}
\let\parnotesnosep\medbreak
\declarecombokeys[keyprefix=KVA,keyfamily=parnotes,macroprefix=pnt@]{%
  cmd/notecolor/black;
  cmd/noteformat/\@firstofone;
  cmd/notefont/\footnotesize;
  cmd/markformat/\@firstofone;
  cmd/vskip/\medskipamount;
  cmd/interskip/.5em;
}
\protected\def\declareparnotesformat#1{%
  \setkeys[KVA]{parnotes}{#1}%
}
\newcommand*\pnt@hook{}
\newcount\pnt@cnta
\@ifdefinable\parnote\relax
\protected\def\parnote#1{%
  \dkyifx\protect\@typeset@protect{%
    \global\advance\pnt@cnta\@ne
    \xdef\pnt@hook{%
      \dkyexpandonce\pnt@hook
      \begingroup
      \noindent
      \dkyexpandonce\pnt@notefont
      \noexpand\color{\pnt@notecolor}%
      \dkyexpandonce\pnt@markformat{%
        \noexpand\textsuperscript{\number\pnt@cnta}%
      }%
      \dkyexpandonce\pnt@noteformat{\unexpanded{~#1}}%
      \noexpand\hspace{\pnt@interskip}%
      \endgroup
    }%
    \ifvmode\else\unskip\fi
    \pnt@markformat{\textsuperscript{\number\pnt@cnta}}%
  }{}%
}
\protected\def\pnt@print{%
  \pnt@hook
  \global\pnt@cnta\z@
  \gdef\pnt@hook{}%
  \@saved@par
  \vspace{\pnt@vskip}%
  \@afterindentfalse\@afterheading
}
\newenvironment{parnotes}{%
  \let\@saved@par\par
  \def\par{%
    \@saved@par
    \dkyifx\pnt@hook\@empty{}{%
      \vspace{\pnt@vskip}%
      \parskip\z@
      \pnt@print
    }%
  }%
}{%
  \dkyifx\pnt@hook\@empty{}{%
    \@saved@par
    \vspace{\pnt@vskip}%
    \parskip\z@
    \pnt@print
  }%
  \let\par\@saved@par
  \let\@saved@par\@undefined
  \par
}

\endinput
\end{filecontents*} 

\documentclass{article}
\usepackage{multicol}
\usepackage{parnotes}
\usepackage[table,dvipsnames,hyperref]{xcolor}
\declareparnotesformat{%
  noteformat=\textsf,markformat=\textsf,notecolor=ForestGreen,
  notefont=\footnotesize,vskip=\medskipamount,
  interskip=.5em
}

\begin{document}

\begin{parnotes}

\section{Let us start with a multicolumn}

\begin{multicols}{2}

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer aliquet
quam \parnote{Vitae mauris tempus!} consequat. In nec neque vitae magna
pulvinar pretium. \parnote{Nunc purus augue, egestas vitae lobortis at,
eleifend quis erat.  Vestibulum ante ipsum primis in faucibus orci luctus
et ultrices posuere cubilia Curae.} In aliquet tortor sed tellus

\parnote{Porta} et elementum diam sagittis.

\end{multicols}

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer aliquet
quam\parnote{Vitae mauris tempus!} consequat. In nec neque vitae magna
pulvinar pretium.\parnote{Nunc purus augue, egestas vitae lobortis at,
eleifend quis erat.  Vestibulum ante ipsum primis in faucibus orci luctus
et ultrices posuere cubilia Curae.} In aliquet tortor sed tellus
\parnote{Porta} et elementum diam sagittis.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer aliquet
quam\parnote{Vitae mauris tempus!} consequat. In nec neque vitae magna
pulvinar pretium.\parnote{Nunc purus augue, egestas vitae lobortis at,
eleifend quis erat.  Vestibulum ante ipsum primis in faucibus orci luctus
et ultrices posuere cubilia Curae.} In aliquet tortor sed tellus
\parnote{Porta} et elementum diam sagittis.

\section{On parnotes\parnote{Section note.}}

\parnotesnosep
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer aliquet
quam\parnote{Vitae mauris tempus!} consequat. In nec neque vitae magna
pulvinar pretium.\parnote{Nunc purus augue, egestas vitae lobortis at,
eleifend quis erat.  Vestibulum ante ipsum primis in faucibus orci luctus
et ultrices posuere cubilia Curae.} In aliquet tortor sed tellus
\parnote{Porta} et elementum diam sagittis.

Ut vel ante eros, in lobortis risus. Nullam pretium, ipsum sit amet
pharetra faucibus, felis diam aliquet sem, bibendum eleifend turpis metus
in ligula.

\vspace{2ex}
\noindent
Notes outside \texttt{multicols}:

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer aliquet
quam\parnote{Vitae mauris tempus!} consequat. In nec neque vitae magna
pulvinar pretium.\parnote{Nunc purus augue, egestas vitae lobortis at,
eleifend quis erat.  Vestibulum ante ipsum primis in faucibus orci luctus
et ultrices posuere cubilia Curae.} In aliquet tortor sed tellus
\parnote{Porta} et elementum diam sagittis.

\parnotesnosep

\noindent Notes inside \texttt{multicols}:

\begin{multicols}{2}

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer aliquet
quam\parnote{Vitae mauris tempus!} consequat. In nec neque vitae magna
pulvinar pretium.\parnote{Nunc purus augue, egestas vitae lobortis at,
eleifend quis erat.  Vestibulum ante ipsum primis in faucibus orci luctus
et ultrices posuere cubilia Curae.} In aliquet tortor sed tellus
\parnote{Porta} et elementum diam sagittis.

\end{multicols}

\noindent Notes break pages:\\

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer aliquet
quam\parnote{Vitae mauris tempus!} consequat. In nec neque vitae magna
pulvinar pretium.\parnote{Nunc purus augue, egestas vitae lobortis at,
eleifend quis erat.  Vestibulum ante ipsum primis in faucibus orci luctus
eleifend quis erat.  Vestibulum ante ipsum primis in faucibus orci luctus
et ultrices posuere cubilia Curae.} In aliquet tortor sed tellus

\parnote{Porta} et elementum diam sagittis.
\end{parnotes}
\end{document}

enter image description here