Skip to content

Commit

Permalink
allow to suppress the sectioning patches
Browse files Browse the repository at this point in the history
  • Loading branch information
Ulrike Fischer committed May 1, 2022
1 parent de34dce commit d3b7c80
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
36 changes: 30 additions & 6 deletions doc/hyperref-doc.tex
Expand Up @@ -180,7 +180,7 @@ \section{Preface---February 2022}
As can be already seen in the following introduction, \xpackage{hyperref}
has a long history and has seen many changes over time. The introduction
mentions workflows, drivers and problems which are no longer relevant,
or only in edge cases. The documentation reflect this varied history: changes
or only in edge cases. The documentation reflects this varied history: changes
and extensions and explanations were and are spread over various papers and sources and
only incorporated later and so are not always in a coherent order and in sync which each other.

Expand All @@ -200,8 +200,8 @@ \section{Preface---February 2022}
\subsection{Restoring removed patches}

\xpackage{hyperref} has over time patched quite a number of packages to resolve clashes and incompabilities.
Quite a number are either no longer needed or should be done by by the original packages.
These patches are now slowly removed from \xpackage{hyperref}. It should normally not lead to problems, but
Quite a number are either no longer needed or should be done by the original packages.
Those patches are now slowly removed from \xpackage{hyperref}. It should normally not lead to problems, but
in case that the patches should be restored they can be loaded through the package \xpackage{hyperref-patches} which
is a part of this bundle.

Expand Down Expand Up @@ -351,7 +351,7 @@ \section{Interfaces for class and package authors}
hyperlink features are nowadays a common requirement. \xpackage{hyperref}
patches quite a number of commands from the \LaTeX{} core and from packages
to add such features. But this is rather fragile and it add dependencies
on the loading order and can break if the external packages break.
on the loading order and can break if the external packages changes.
It is therefore much better if packages add suitable support to their commands directly.
Quite a lot packages actually did this, but due to missing documentation of the interface
they often looked into the code and then used internal commands not meant as public command.
Expand All @@ -363,6 +363,30 @@ \section{Interfaces for class and package authors}

This section is work in progress. Suggestions or comments are welcome.

\subsection{Patches and how to suppress them}

Patches to external commands can be avoided alltogether by loading hyperref with the option \texttt{implicit=false}. But is often too drastic. There is a work in progress to classify
the patches and to offer interfaces to suppress them in a more granular way.

We start with the sectioning commands.

\begin{itemize}
\item hyperref patches \cs{@sect}, \cs{@ssect}, \cs{@chapter}, \cs{@schapter},
\cs{@part}, \cs{@spart}.

To commands for the starred sections a target for a link is added. To the other commands
it is added if the sectioning is unnumbered, e.g. because of the \texttt{secnumdepth} setting or in the
frontmatter.

The patch can be suppressed by defining the command \cs{hyper@nopatch@sectioning}. This should normally
be done only by a class or a package which provides sectioning commands and can add the targets itself.
Targets have a location on the page and e.g. the section commands should take indents into
account. Note that the nameref package patches these commands too to add commands to store the title text
for a label. Check the nameref documentation about a way to suppress these patches.
\end{itemize}



\subsection{Counters}
Counters play an important part in the code. They are used to create destination names and
to define hierarchies like the bookmarks. To work correctly often they require some additional
Expand Down Expand Up @@ -1661,8 +1685,8 @@ \subsection{Option `localanchorname'}

The option is deprecated: it makes it difficult for package authors
to add targets for links if it is unclear if \verb|\@currentHref| is
set locally or globally.
set locally or globally.

\subsection{Option `customdriver'}

The value of option `customdriver' is the name of an external
Expand Down
4 changes: 3 additions & 1 deletion hyperref.dtx
Expand Up @@ -10232,7 +10232,6 @@
\fi
%</pdfmarkbase|dvipdfm|xetex>
% \end{macrocode}
%
% \begin{macrocode}
%<*package>
% \end{macrocode}
Expand Down Expand Up @@ -19756,6 +19755,8 @@
\hss
}%
}
\@ifundefined{hyper@nopatch@sectioning}
{
\let\H@old@ssect\@ssect
\def\@ssect#1#2#3#4#5{%
\Hy@MakeCurrentHrefAuto{section*}%
Expand Down Expand Up @@ -19851,6 +19852,7 @@
\H@old@sect{#1}{#2}{#3}{#4}{#5}{#6}[{#7}]{#8}%
}%
}
}{}
% \end{macrocode}
% \begin{macrocode}
%</outlines|hypertex>
Expand Down

0 comments on commit d3b7c80

Please sign in to comment.