4

I try to learn LaTex via TexStudio on Ubuntu. I need to reference to a paragraph like that:

\paragraph{Théorème 5.}\label{theoreme5}

And I need that:

\section{Preuve du Théorème \nameref{theoreme5}}

But that print that (pdflatex):

enter image description here

It's all the name of the paragraph that is clickable. But me I want to just have the "5" clickable (and put any number or word instead of the 5, if possible).

I'm not sure that I was clear. If someone can help me I will really gratefull.

Cordially

3
  • 1
    \paragraph os the 4th level section heading after section, subsection and subsubsection, it's more common to use a theorem environment declared with \newtheorem for theorems. Oct 20, 2021 at 21:59
  • Welcome to TeX.SE!
    – Mensch
    Oct 20, 2021 at 22:03
  • @Mensch Thanks. Oct 20, 2021 at 22:15

2 Answers 2

3

Use \hyperref[<internal link>]{<stuff>} (with starred \ref inside <stuff>):

\section[Preuve du Théorème \ref*{theoreme5}]
  {Preuve du \hyperref[theoreme5]{Théorème \ref*{theoreme5}}}

The optional argument ensures that \hyperref doesn't sneak into the PDF bookmarks, which you can also do using \texorpdfstring:

\section{Preuve du 
  \texorpdfstring
    {\hyperref[theoreme5]{Théorème \ref*{theoreme5}}}% TeX string
    {Théorème \ref*{theoreme5}}}% PDF string
2

I would like to suggest you employ the cleveref package and its \cref user macro to achieve your typesetting goal. I would further suggest that you employ either the amsthm or ntheorem package and their theorem-like environments instead of \paragraph{...} to generate, well, theorem-like environments.

enter image description here

\documentclass[french]{article}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{amsthm}
\usepackage[colorlinks]{hyperref}
\usepackage[capitalize,noabbrev]{cleveref}
\newtheorem{thm}{Théorème}

\begin{document}
\addtocounter{thm}{4} % just for this example
\begin{thm} \label{thm5} 
\dots 
\end{thm}

\dots

\stepcounter{section}
\section[Preuve du Théorème 5]{Preuve du \cref{thm5}}
\dots
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .