Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Activating math tagging causes many Warnings for TOC with hyperref usage #78

Closed
jfbu opened this issue May 15, 2023 · 8 comments
Closed

Comments

@jfbu
Copy link

jfbu commented May 15, 2023

\DocumentMetadata{testphase={phase-III,math}}
\documentclass[a4paper]{article}

\usepackage{color}

\usepackage{hyperref}

\hypersetup{
%  linktoc=all,%
  colorlinks=true,%
}

\usepackage{bookmark}


\def\mst{mst }
\def\href#1#2{[#2](#1)}

\begin{document}

%\show\foo
\tableofcontents
%\show\foo

\section{What \mst does}

\subsection{Aim of this package and basic usage}


\subsection{Miscellanea}


\subsection{Examples}


\subsection{Main options}

\subsubsection{The {italic} option}



\subsubsection{The {defaultmathsizes} option}


\subsubsection{The {subdued} option}


\subsubsection{The {LGRgreek} option}


\subsection{More miscellanea}


\subsubsection{Derivative, minus, asterisk}


\subsubsection{load \mst always last}

\subsubsection{sans in math}

\subsubsection{using \mst with \href{https://ctan.org/pkg/beamer}{beamer}}


\subsubsection{avoid \texorpdfstring{\texttt{OT1}}{OT1} encoding}

\subsubsection{using \mst with \href{https://ctan.org/pkg/frenchmath}{frenchmath}}

\subsection{Math versions}

\subsection{Greek letters}

\subsubsection{The Greek-related options}

\subsubsection{Shape of Greek letters}

\subsubsection{New with {1.3x}: alphabets {mathgreekup} and
  {mathgreekit}, control sequences to access directly upright or italic
  Greek letters}

\subsection{Extra spaces around letters}

\subsection{Italic corrections}

\subsection{Extra  glue after \texorpdfstring{{exists}}{\textbackslash
exists}, \texorpdfstring{{forall}}{\textbackslash forall}, and before the prime glyph}

\subsection{Extended scope of the math alphabets commands}

\subsection{Unicode engines}

\subsubsection{The unicodeminus option}

\subsubsection{Two examples}

\subsection{Compatibility issues}

\section{Package commands}

\subsection{Commands for regular usage}

\subsubsection{Preamble-only commands}

\subsubsection{Commands for body or math}

\subsection{Commands for expert usage}

\subsubsection{Expert commands usable everywhere}

\subsubsection{Expert commands which are preamble-only}

\subsubsection{Expert commands usable only outside of math mode}

\subsubsection{Expert commands usable only in math mode}

\section{Package options}

\subsection{Summary of main options}

\subsection{Complete list of options}

\section{Change log}

\end{document}

is a not quite MWE, but comes from real life. Many Warnings are raised of the type

Package tagpdf Warning: Rule 'Reference/' --> 'Formula/pdf2' is not allowed
(tagpdf)                (struct 11, /Reference --> struct 14)

test_tagging_hypertoc.log

@u-fischer
Copy link
Member

Ah, hidden math (the leaders use math mode). Try this:

\ExplSyntaxOn
\makeatletter
\def\@dottedtocline@cfgpoint@leaders#1{%
 \tag_mc_begin:n{artifact}\tag_stop:n{leaders}\nobreak#1\nobreak\tag_start:n{leaders}\tag_mc_end:}
\ExplSyntaxOff

I will add that to the toc-tagging code.

@jfbu
Copy link
Author

jfbu commented May 15, 2023

confirming your patch makes the warnings go away...

this also explains why in my real life example which was with etoc package I did not have those warnings, but I have other stuff I will report later on only for the record, but currently etoc has no special tagging support so this was not unexpected

@jfbu
Copy link
Author

jfbu commented May 15, 2023

Well with etoc activated like something like this in preamble

\usepackage{etoc}
\etoctoclines
\etocruledstyle{\color{blue}\normalfont\large\bfseries\contentsname }

there are no Warnings as \@dottedtocline is not executed.

The problems I had encountered was when \href had not been neutralized by the \def\href#1#2{[#2](#1)} in the preamble. But these problems also show without etoc:

\DocumentMetadata{testphase={phase-III,math}}
\documentclass[a4paper]{article}

\ExplSyntaxOn
\makeatletter
\def\@dottedtocline@cfgpoint@leaders#1{%
 \tag_mc_begin:n{artifact}\tag_stop:n{leaders}\nobreak#1\nobreak\tag_start:n{leaders}\tag_mc_end:}
\ExplSyntaxOff

\usepackage{color}

\usepackage{hyperref}

\hypersetup{
%  linktoc=all,%
  colorlinks=true,%
}

\usepackage{bookmark}


\def\mst{mst }
% \def\href#1#2{[#2](#1)}

\begin{document}

%\show\foo
\tableofcontents
%\show\foo

\section{What \mst does}

\subsection{Aim of this package and basic usage}


\subsection{Miscellanea}


\subsection{Examples}


\subsection{Main options}

\subsubsection{The {italic} option}



\subsubsection{The {defaultmathsizes} option}


\subsubsection{The {subdued} option}


\subsubsection{The {LGRgreek} option}


\subsection{More miscellanea}


\subsubsection{Derivative, minus, asterisk}


\subsubsection{load \mst always last}

\subsubsection{sans in math}

\subsubsection{using \mst with \href{https://ctan.org/pkg/beamer}{beamer}}


\subsubsection{avoid \texorpdfstring{\texttt{OT1}}{OT1} encoding}

\subsubsection{using \mst with \href{https://ctan.org/pkg/frenchmath}{frenchmath}}

\subsection{Math versions}

\subsection{Greek letters}

\subsubsection{The Greek-related options}

\subsubsection{Shape of Greek letters}

\subsubsection{New with {1.3x}: alphabets {mathgreekup} and
  {mathgreekit}, control sequences to access directly upright or italic
  Greek letters}

\subsection{Extra spaces around letters}

\subsection{Italic corrections}

\subsection{Extra  glue after \texorpdfstring{{exists}}{\textbackslash
exists}, \texorpdfstring{{forall}}{\textbackslash forall}, and before the prime glyph}

\subsection{Extended scope of the math alphabets commands}

\subsection{Unicode engines}

\subsubsection{The unicodeminus option}

\subsubsection{Two examples}

\subsection{Compatibility issues}

\section{Package commands}

\subsection{Commands for regular usage}

\subsubsection{Preamble-only commands}

\subsubsection{Commands for body or math}

\subsection{Commands for expert usage}

\subsubsection{Expert commands usable everywhere}

\subsubsection{Expert commands which are preamble-only}

\subsubsection{Expert commands usable only outside of math mode}

\subsubsection{Expert commands usable only in math mode}

\section{Package options}

\subsection{Summary of main options}

\subsection{Complete list of options}

\section{Change log}

\end{document}

one gets

Package tagpdf Warning: Rule 'Link/' --> 'Link/pdf2' is not allowed (struct
(tagpdf)                62, /Link --> struct 64)

====>first-result=macro:->
====>first-tmpmathcontent=macro:->
====>formula has no subparts
====>first-result=macro:->
====>first-tmpmathcontent=macro:->
====>formula has no subparts

Package tagpdf Warning: Rule 'Link/' --> 'Link/pdf2' is not allowed (struct
(tagpdf)                71, /Link --> struct 73)

@u-fischer
Copy link
Member

Package tagpdf Warning: Rule 'Link/' --> 'Link/pdf2' is not allowed (struct
(tagpdf) 62, /Link --> struct 64)

well yes, link in link is not allowed. But it also doesn't make much sense to have an active url-link inside the toc-link. What should a click do in this case? Imho either disable links on the text in the toc, or use \texorpdfstring to avoid to get a link in the toc.

@jfbu
Copy link
Author

jfbu commented May 15, 2023

in mathastext.pdf table of contents on page 2 (texdoc mathastext) the TOC uses hidelinks and the embedded \href linking to beamer or frenchmath on CTAN are not made distinctive visually (and anyhow are not functional) and if one clicks on "beamer" or "frenchmath" one ends up redirected (as expected) to the subsubsection title in mathastext.pdf. But from there the links are active: so the \href are inserted not for TOC but for the sub-sub-section titles themselves.

Using \texorpdfstring will only influence bookmark right?

Edit: workaround here is simply to use optional argument of \subsubsection to avoid having links inside the TOC entries.

@u-fischer
Copy link
Member

Using \texorpdfstring will only influence bookmark right?

Yes, sorry.

are not made distinctive visually

Well tagging is (beside others) also meant as support for blind people. It is therefore not enough to get only a visually pleasing result; the structure tree should be sane. This is a problem that will imho appear in various places, as there is lots of code around which use tricks that assume that only the visual output matters.

@jfbu
Copy link
Author

jfbu commented May 16, 2023

Well tagging is (beside others) also meant as support for blind people. It is therefore not enough to get only a visually pleasing result; the structure tree should be sane. This is a problem that will imho appear in various places, as there is lots of code around which use tricks that assume that only the visual output matters.

Yes. Sorry for my confusing langage. When I said "are not made distinctive visually" I meant to say this was anyhow quite desired and in this context the TOC used hidelinks (although not relevant to nested situations probably). I have many voices in my brain and sometimes they all speak at the same time causing confused discourse.

@u-fischer
Copy link
Member

Closing here as most of it is resolved. The "link-in-link" problem is tracked in latex3/tagging-project#26

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants