# Comfortable solution for using ulem together with (r)eledmac

Preface: Sorry for the long text. By writing it, I was able to solve an earlier problem leading to this one.

In Underlining with ulem package breaks footnotes Ulrike Fischer and Heiko Oberdiek answer a question regarding the combination of package ulem and \footnote.

I am now confronted with a very similar problem, but with the footnote macros from package (r)eledmac.

How can I solve the following:

\documentclass{book}
\usepackage{ulem}
\usepackage[noreledmac]{eledmac} % or reledmac

\begin{document}
This is \uline{a test containing\footnoteA{A simple footnote.} a simple footnote.}
\end{document}


Using the approach from the linked question I could use:

This is \uline{a test containing\mbox{\footnoteAmark}}%
\footnoteAtext{A simple footnote.}\uline{ a simple footnote.}


But how do those two macros \footnoteAmark and \footnoteAtext look like? I started with the eledmac manual and took relevant parts of the definition for \footnoteA:

\begingroup%
\prepare@prenotesX{#1}%
\newcommand{\content}{##1}%
\stepcounter{footnote#1}%
\protected@csxdef{@thefnmark#1}{\csuse{thefootnote#1}}%
\csuse{@footnotemark#1}%
\csuse{vfootnote#1}{#1}{\expandonce\content}\m@mmf@prepare%
\endgroup%


Now I split that up into two new definitions:

\makeatletter
\newcommand{\footnoteAmark}{%
\begingroup%
\prepare@prenotesX{A}%
\stepcounter{footnoteA}%
\protected@csxdef{@thefnmarkA}{\csuse{thefootnoteA}}%
\csuse{@footnotemarkA}%
\endgroup%
}%
%
\newcommand{\footnoteAtext}[1]{%
\begingroup%
\csuse{vfootnoteA}{A}{\expandonce{#1}}\m@mmf@prepare%
\endgroup%
}%
\makeatother


It works. However, as I am using this as part of an automated process, is there a way to define some \footnoteAVar doing the magic altogether?

This is \uline{a test containing\footnoteAVar{A simple footnote.} a simple footnote.}


My approach

\newcommand{\footnoteAVar}[1]{%
\mbox{\footnoteAmark}%
\egroup% to end \uline
\footnoteAtext{#1}%
\uline\bgroup%
}%


results in a missing footnote text at the bottom of the page:

\documentclass{book}
\usepackage{ulem}
\usepackage[noreledmac]{eledmac} % or reledmac
\makeatletter
\newcommand{\footnoteAmark}{%
\begingroup%
\prepare@prenotesX{A}%
\stepcounter{footnoteA}%
\protected@csxdef{@thefnmarkA}{\csuse{thefootnoteA}}%
\csuse{@footnotemarkA}%
\endgroup%
}%
%
\newcommand{\footnoteAtext}[1]{%
\begingroup%
\csuse{vfootnoteA}{A}{\expandonce{#1}}\m@mmf@prepare%
\endgroup%
}%
\newcommand{\footnoteAVar}[1]{%
\mbox{\footnoteAmark}%
\egroup% to end \uline
\footnoteAtext{#1}%
\uline\bgroup%
}%
\makeatother
\begin{document}
This is \uline{a test containing\mbox{\footnoteAmark}}\footnoteAtext{A
simple footnote.}\uline{ a simple footnote.}

This is \uline{a test containing\footnoteAVar{A simple footnote.} a
simple footnote.}
\end{document}


I guess my grouping is the problem. Does anybody have the missing link?

• Please open an issue on github. I think that should be implemented directly in reledmac. – Maïeul Mar 31 '17 at 20:44
• Okay, I'll do that. – Martin Apr 1 '17 at 9:50

Thanks to Martin Work, the version 2.19.0 of reledmac, which will be send quickly on CTAN, provides two new command : \footnoteAmark and \footnoteAtext:
\documentclass{article}