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

Inline TOC raises warnings #11

Closed
jfbu opened this issue Jan 11, 2024 · 3 comments
Closed

Inline TOC raises warnings #11

jfbu opened this issue Jan 11, 2024 · 3 comments
Labels
at-2024-01-02 2024-01-02 has the issue at-2024-01-05 2024-01-05 has the issue fixed-at-2024-01-12 Fixed at 2024-01-12 tag help wanted Extra attention is needed tagging Relative to support of the `LaTeX tagged PDF` project

Comments

@jfbu
Copy link
Owner

jfbu commented Jan 11, 2024

\DocumentMetadata{
 uncompress,
 pdfversion=1.7,
 lang=en-US,
 testphase=phase-III
}
\documentclass{article}
\usepackage{etoc}
\begin{document}
\etocsetstyle{section}
  {(start) }
  {\etocname, }%
  {}
  {(end) }%

% The TOC contents with default TOC title starts in vmode.
% With empty TOC title it will depend if \tableofcontents
% is issued when in horizontal mode: by default etoc
% does \par, but \etocinline suppresses that.

\etocinline % avoids an added \par before title

\etocsettocstyle{}{} % no title

This is an inline TOC
\tableofcontents
and the end of the paragraph.

\section{One}

Text

\section{Two}

Text

\end{document}

First warning is

Package tagpdf Warning: Parent-Child 'P/' --> 'TOC/pdf'.
(tagpdf)                Relation is not allowed (struct 5, /text --> struct 6)
(tagpdf)                on line 29
@jfbu jfbu added tagging Relative to support of the `LaTeX tagged PDF` project at-2024-01-02 2024-01-02 has the issue labels Jan 11, 2024
jfbu added a commit that referenced this issue Jan 11, 2024
@jfbu jfbu added the help wanted Extra attention is needed label Jan 11, 2024
@jfbu
Copy link
Owner Author

jfbu commented Jan 11, 2024

I need some help here on whether it is at all possible to insert in a paragraph a PDF tagging TOC structure.

ping @u-fischer if you get this and have time.

@jfbu jfbu added at-2024-01-05 2024-01-05 has the issue at-2024-01-02 2024-01-02 has the issue and removed at-2024-01-02 2024-01-02 has the issue labels Jan 11, 2024
@u-fischer
Copy link

u-fischer commented Jan 11, 2024

The PDF-paragraph (the P tag mentioned in the message) is rather a pain as it has lots of restrictions regarding its children. We therefore do not use it for full paragraphs but only for small pieces. A full paragraph is instead surrounded by a tag text-unit (which is role mapped to Part). (Some background about this can be found in latex-lab-block.pdf in section 3 "tagging support").

So a list inside a paragraph

some text \begin{itemize}\item list item \end{itemize} more text 

is tagged like this:

<text-unit> %= Part
  <text> %= P
     some text
  </text>
  <L> <LI> <LBody> list item </LBody></LI></L>
  <text>more text</text>
</text-unit>

Basically you should do something similar and interrupt the P/text tag. The coding is not necessarly trivial if the inner structure (e.g. the list) contains \par's, as you have to decide if you restart a after the list or not, we use the @doenpe switch for this.

It is not very beautiful, but not illegal to produce empty structures or mc-chunks.

@jfbu jfbu closed this as completed in 7f00546 Jan 12, 2024
@jfbu
Copy link
Owner Author

jfbu commented Jan 12, 2024

Thanks a lot @u-fischer! Based on your help I did a preliminary implementation for tagging inline TOCs. It is certainly much too naive but works with the gh9 and gh11 test files which I checked on ngpdf.com. The tree looks ok there. In the HTML conversion I noticed that text chunks from the input originating in the user custom TOC line styles disappear, which is expected as I tried to mark them as artifacts. Also disappearing from the HTML conversion is some text from user custom \etocaftercontentshook (which is done after the tagged TOC contents) which maybe an after-effect of the preliminary way I handled the present issue #11.

A probably very bad point is that I use \ifhmode rather than querying via tagpdf interface if really we are in <text-unit><text> situation.

As per the #9 which was fixed earlier, I realized the issue originated from the fact that after borrowing from kernel the before and after \@starttoc tagging hooks, it was mandatory to issue \par before exiting the scope limiting group.

edit1: when the TOC contents got started in vertical mode...

edit2: and if the "after hook" was executed while still in paragraph mode, rather. Then a \par had to be inserted before terminating the scope limiting group always added by etoc around the whole TOC structure: i.e. this includes both the contents and the user or etoc-emulating-the-class before and after style, such as a title before and a rule after.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
at-2024-01-02 2024-01-02 has the issue at-2024-01-05 2024-01-05 has the issue fixed-at-2024-01-12 Fixed at 2024-01-12 tag help wanted Extra attention is needed tagging Relative to support of the `LaTeX tagged PDF` project
Projects
None yet
Development

No branches or pull requests

2 participants