mystmd icon indicating copy to clipboard operation
mystmd copied to clipboard

LaTeX/PDF export doesn't respect hyperlink text (`[text](#label)` syntax) when the target is a proof

Open RBerga06 opened this issue 1 month ago • 0 comments

Description

When exporting a MyST file to PDF through LaTeX, references to {prf:definition label="lbl"} blocks that are meant to show a custom text (defined in Markdown with hyperlink syntax [text](#lbl)) are instead converted to the standard Definition %s textual format, discarding the custom text.

This is a problem because it heavily interferes with the intended fluency of the text.

Proposed solution

The ideal solution would be to leaverage the \hyperref package (as proposed in #1127), but, until that feature is implemented, it should at least be possible to replace the hyperlink with the bare custom text.

Note: The behaviour I am proposing here for {prf:definition} references (and in general {prf:*} references) has apparently already been implemented for section references with custom text - see the example below.

Note: Potentially related to #1680.

Additional notes

  • myst -v shows 1.6.2

Minimal reproduction

Edit: I can reproduce the behaviour in the sandbox (see the LaTeX output).

<!--- index.md --->

(the-section)=
# First section
:::{prf:definition label="def-wizard"} Wizard
Not important
:::

# Second section
Let X be a [wizard](#def-wizard). We defined X [above](#the-section).
# myst.yml
version: 1
project:
  id: 6ebf22de-5448-4bf4-9e19-d91aa2d01744
  title: Title
  authors:
  - name: Author One
  exports:
  - format: pdf+tex
site:
  template: book-theme
Generated LaTeX file

% Created with jtex v.1.0.20
\documentclass{article}
\usepackage{hyperref}
\usepackage{datetime}
\usepackage{graphicx}
\usepackage{natbib}
\bibliographystyle{abbrvnat}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%  imports  %%%%%%%%%%%%%%%%%%%
\usepackage{amsthm}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%  theorem  %%%%%%%%%%%%%%%%%%%
\newtheorem{theorem}{Theorem}[section]
\newtheorem{corollary}{Corollary}[theorem]
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{proposition}{Proposition}[section]
\newtheorem{definition}{Definition}[section]
\newtheorem{example}{Example}[section]
\newtheorem{remark}{Remark}[section]
\newtheorem{axiom}{Axiom}[section]
\newtheorem{conjecture}{Conjecture}[section]
\newtheorem{observation}{Observation}[section]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%




% colors for hyperlinks
\hypersetup{colorlinks=true, allcolors=blue}

\newcommand{\logo}{
  \href{https://curvenote.com}{\includegraphics[width=2cm]{curvenote.png}}
}

\title{First section}

\author{Author One}

\newdate{articleDate}{28}{9}{2025}
\date{\displaydate{articleDate}}

\begin{document}
\maketitle
\begin{center}\logo\end{center}


% - index.md -

\section{First section}\label{the-section}

\begin{definition}[Wizard]\label{def-wizard}Not important

\end{definition}\section{Second section}

Let X be a Definition~\ref{def-wizard}. We defined X above.


\end{document}

RBerga06 avatar Sep 28 '25 17:09 RBerga06