Re: [RISOLTO] Riferimenti ai paragrafi

#52615
Up
0
Down
::

`\documentclass[a4paper]{book}
\usepackage{etoolbox}
\makeatletter
\apptocmd{\@chapter}{\expandafter\label\expandafter{\unexpanded{#2}}}{}{}
\apptocmd{\@sect}{\expandafter\label\expandafter{\unexpanded{#8}}}{}{}
\makeatother

\usepackage{hyperref}

\begin{document}
\mainmatter
\chapter{Pippo}

\section{Tetrapiloctomia applicata}
Ecco il riferimento a un capitolo:~\ref{Pippo}

\section{Altre tetratomie}

Questo a un paragrafo:~\ref{Tetrapiloctomia applicata}

Due spazi non contano:~\ref{Tetrapiloctomia applicata}

\end{document}`

Oh mamma!!! 😯

Detto questo caro Enrico non so se ti ricordi ma stiamo sempre parlando del ricettario, e il mio intento è quello di potersi riferire ad una ricetta in un’altra ricetta. Siccome, per comodità, darei alla label lo stesso argomento della section mi sembrerebbe stupido fare il lavoro “a mano”.

Il problema sono i caratteri accentati. Se tu usassi un ambiente completamente Unicode (XeLaTeX o LuaLaTeX) non sarebbe un problema, con (pdf)LaTeX lo è.

Con quei compilatori ti basterebbe
`\makeatletter
\let\@@@chapter\chapter
\let\@@@section\section
\def\chapter{\afterassignment\do@chapter\toks@}
\def\section{\afterassignment\do@section\toks@}
\def\do@chapter{\@@@chapter{\the\toks@}%
\expandafter\label\expandafter{\the\toks@}}
\def\do@section{\@@@section{\the\toks@}%
\expandafter\label\expandafter{\the\toks@}}
\makeatother`
ammesso che tu usi sempre \chapter{titolo} e \section{titolo}. Altrimenti occorre qualcosa di più.

Ciao
Enrico

Go to top