diff options
Diffstat (limited to 'Master/texmf-dist/doc/latex/tagpdf/ex-patch-sectioning-koma.tex')
-rw-r--r-- | Master/texmf-dist/doc/latex/tagpdf/ex-patch-sectioning-koma.tex | 168 |
1 files changed, 168 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/latex/tagpdf/ex-patch-sectioning-koma.tex b/Master/texmf-dist/doc/latex/tagpdf/ex-patch-sectioning-koma.tex new file mode 100644 index 00000000000..6fccf189d4a --- /dev/null +++ b/Master/texmf-dist/doc/latex/tagpdf/ex-patch-sectioning-koma.tex @@ -0,0 +1,168 @@ +% !Mode:: "TeX:DE:UTF-8:Main" + +%This example shows how one can patch sectioning command and toc entries +%to add tags. +%The patches are layout/option dependant +%With other document options (e.g. chapterprefix) or +%if the sectioning commands are redefined more/different patches are perhaps needed + +%no page break involved. So the example works in lua and generic mode + +\documentclass{scrbook} +\usepackage[english]{babel} + +%set language / can also be done with hyperref +\pdfcatalog{/Lang (en-US)} + +\usepackage{tagpdf} + +\tagpdfifpdftexT + { + \usepackage[T1]{fontenc} + } + +\tagpdfifluatexT + { + \usepackage{fontspec} + \usepackage{luacode} + } + + +\tagpdfsetup{tabsorder=structure, + activate-all, + uncompress + } + +\usepackage{lipsum}%\textheight3cm + +%%%%%%%%%%%%%%% +%Marking the toc entries +%around the whole entry so only structure: +\newcommand\tagscrtocentry[1]{\tagstructbegin{tag=TOCI}#1\tagstructend} + +%leaf so structure and mc: +\newcommand\tagscrtocpagenumber[1]{% + \tagstructbegin{tag=Reference}% + \tagmcbegin{tag=Reference}% + #1% + \tagmcend + \tagstructend} + +\DeclareTOCStyleEntry[ + entryformat=\tagscrtocentry, + pagenumberformat=\tagscrtocpagenumber]{tocline}{chapter} +\DeclareTOCStyleEntry[ + entryformat=\tagscrtocentry, + pagenumberformat=\tagscrtocpagenumber]{tocline}{section} +\DeclareTOCStyleEntry[ + entryformat=\tagscrtocentry, + pagenumberformat=\tagscrtocpagenumber]{tocline}{subsection} +\DeclareTOCStyleEntry[ + entryformat=\tagscrtocentry, + pagenumberformat=\tagscrtocpagenumber]{tocline}{subsubsection} +\DeclareTOCStyleEntry[ + entryformat=\tagscrtocentry, + pagenumberformat=\tagscrtocpagenumber]{tocline}{paragraph} + + + +\renewcommand{\addtocentrydefault}[3]{% + \ifstr{#3}{}{} + {%\ + \ifstr{#2}{} + {% + \addcontentsline{toc}{#1} + {% + \protect\nonumberline + \tagstructbegin{tag=P}% + \tagmcbegin{tag=P}% + #3% + \tagmcend + \tagstructend + }% + }% + {% + \addcontentsline{toc}{#1}{% + \tagstructbegin{tag=Lbl}% + \tagmcbegin{tag=Lbl}% + \protect\numberline{#2}% + \tagmcend\tagstructend + \tagstructbegin{tag=P}% + \tagmcbegin{tag=P}% + #3% + \tagmcend + \tagstructend + }% + }% + }}% + +% the dots must be marked too +\makeatletter +\renewcommand*{\TOCLineLeaderFill}[1][.]{% + \leaders\hbox{$\m@th + \mkern \@dotsep mu\hbox{\tagmcbegin{artifact}#1\tagmcend}\mkern \@dotsep + mu$}\hfill +} + +%%%%%%%%% +% Sectioning commands +%%%%%%%% + +\ExplSyntaxOn +\prop_new:N \g_tag_section_level_prop +\prop_put:Nnn \g_tag_section_level_prop {chapter}{H1} +\prop_put:Nnn \g_tag_section_level_prop {section}{H2} +\prop_put:Nnn \g_tag_section_level_prop {subsection}{H3} +\prop_put:Nnn \g_tag_section_level_prop {subsubsection}{H4} +\prop_put:Nnn \g_tag_section_level_prop {paragraph}{H5} + +\renewcommand{\chapterlinesformat}[3] + { + \@hangfrom + { + \tagstructbegin{tag=\prop_item:Nn\g_tag_section_level_prop{chapter}} + \tagmcbegin {tag=\prop_item:Nn\g_tag_section_level_prop{chapter}} + #2 + } + {#3\tagmcend\tagstructend}% + } + + +\renewcommand{\sectionlinesformat}[4] + { + \@hangfrom + {\hskip #2 + \tagstructbegin{tag=\prop_item:Nn\g_tag_section_level_prop{#1}} + \tagmcbegin {tag=\prop_item:Nn\g_tag_section_level_prop{#1}} + #3 + } + {#4\tagmcend\tagstructend}% + } + +\ExplSyntaxOff +\AfterTOCHead{\tagstructbegin{tag=TOC}} +\AfterStartingTOC{\tagstructend} %end TOC + + +\begin{document} +%I don't want to handle pagestyles, so set everything to empty: +\pagestyle{empty}\renewcommand\chapterpagestyle{empty} + +\tagstructbegin{tag=Document} + +\tableofcontents + +\chapter{chapter} +\addchap{chapter} +\section{section} +\subsection{subsection} +\subsubsection{subsubsection} + + \tagstructbegin{tag=P} + \tagmcbegin{tag=P} + a paragraph\par x + \tagmcend + \tagstructend + +\tagstructend %Document +\end{document}
\ No newline at end of file |