Trevor
I have a Latex document, inside of which I have figures written in Metapost (included using the `luamplib` package). I would like to include references to parts of the Latex document (e.g., sections) within the Metapost code. I have tried to do this, but unfortunately the link positions end up either not matching the text position, or the links are not created at all.
Here is a minimal working example (compiled with `lualatex`).
```
\documentclass[10pt]{article}
\usepackage{hyperref}
\usepackage{luamplib}
\mplibtextextlabel{enable}
\begin{document}
\section{My section} \label{sec:my_section}
Hi
\begin{mplibcode}
beginfig(1);
label(btex \ref{sec:my_section} etex, (14,6)); % this creates a link in the wrong location
label(btex \ref{sec:my_section} etex, (39,6)); % this also creates a link in the same wrong location
endfig;
\end{mplibcode}
\end{document}
```
An snippet image of the resulting document is shown below. The first `label()` command creates a "1" (the leftmost "1") and a link (the red box), but the positions don't match. The second `label()` command also creates a "1" (the rightmost "1"), with the same link position as the first link.

Top Answer
Udi Fogiel
This is fixed in the latest version of luamplib.
The problem was the use of (the LuaTeX equivalent of) `\pdfliteral` to make affine troansformations, which `\pdfstartlink` does not account for.
Now a combination of boxes (for translation) and `\pdfsetmatrix` (for rotation/reflection) is used instead.
See https://github.com/lualatex/luamplib/issues/189 for more details.