{"id":8782,"date":"2024-09-26T12:15:30","date_gmt":"2024-09-26T11:15:30","guid":{"rendered":"https:\/\/research.kent.ac.uk\/pqm\/?p=8782"},"modified":"2025-03-11T16:26:00","modified_gmt":"2025-03-11T16:26:00","slug":"producing-tagged-latex","status":"publish","type":"post","link":"https:\/\/research.kent.ac.uk\/pqm\/2024\/09\/26\/producing-tagged-latex\/","title":{"rendered":"Producing Technical Documents as Tagged PDF documents &#8211; Accessibility in Latex"},"content":{"rendered":"<h1>Accessibility with Latex<\/h1>\n<h2>The problem<\/h2>\n<p>Ensuring the accessibility of scientific and technical documents that we rely on in our research and teaching poses a significant challenge: Lots of our documents are produced using LaTex &#8211; the format of choice for equation-heavy documents. Unfortunately, LaTex does not natively support tagged pdfs, quite yet.<\/p>\n<h2>Preparatory Steps<\/h2>\n<p>However, the required features are now ready to be used (though still only experimentally so). Hence, you can achieve PDF tagging by including some specialised Latex packages, and this requires only a few extra tweaks:<\/p>\n<ul>\n<li>make sure to use the very latest Latex engines, as older versions do not support tagged pdf at all. The TexLive 2024 distribution and later are appropriate.<\/li>\n<li>update your tex distribution so you get the latest development versions for all packages<\/li>\n<li>make sure you are careful to have a clean latex file satisfying all coding conventions closely. You can check this using tools such as &#8216;chktex&#8217;<\/li>\n<li>not all Tex functionality is currently supported for tagged pdf output, so it&#8217;s best to stick to simple packages and classes<\/li>\n<\/ul>\n<h2>Concrete Implementation<\/h2>\n<p>Once those conditions are met, you need to add a few things in the preamble of your latex file to activate the functionality of the &#8220;pdfmanagement-testphase&#8221; package. Unlike most packages this requires you to include a few lines <i>preceding<\/i> the \\documentclass command. (For a full documentation of the package, see <a href=\"https:\/\/ctan.org\/pkg\/pdfmanagement-testphase\">its CTAN page<\/a>.)<\/p>\n<p>To satisfy the requirements for screen readers, you also need to include some document metadata. This includes defining the title, author, language, etc. These can be set directly via the \\DocumentMetadata command, or via the \\hypersetup entries of the hyperref package. Here is an example:<\/p>\n<blockquote><p>\\RequirePackage{pdfmanagement-testphase} % Enable PDF management for tagging<br \/>\n\\DocumentMetadata{<br \/>\ntestphase = phase-II, % Use Phase-II for intermediate level tagging (Phase-III features are more comprehensive, but not fully functional currently)<br \/>\npdfversion = 2.0, % Set the PDF version to 2.0 for better compatibility<br \/>\nlang=en-UK % set language for the document<br \/>\n}<\/p>\n<p>\\documentclass[11pt]{article}<\/p>\n<p>\\usepackage{amsmath} % AMS Math Package<\/p>\n<p>\\usepackage{hyperref}<br \/>\n\\hypersetup{<br \/>\npdftitle={Your title goes here}, % Title of the PDF<br \/>\npdfauthor={Gunnar Moeller}, % Author<br \/>\npdfkeywords={some topics maybe},% Keywords for the PDF<br \/>\npdfsubject={What this is all about}, % Subject or description<br \/>\n}<\/p>\n<p>\\usepackage{tagpdf} % For tagged PDFs<\/p>\n<p>% Activate tagging and PDF resource management<br \/>\n\\tagpdfsetup{activate-all,uncompress}<\/p>\n<p>&#8230; remainder of your header and the usual<\/p>\n<p>\\begin{document} &#8230; \\end{document}<\/p><\/blockquote>\n<p>That&#8217;s all. Some LaTex environments may use offending syntax and lead to compilation errors. Most of them are not serious errors though, and you can convince latex to ignore these and produce a tagged pdf by responding &#8220;R&#8221; to any queries.<\/p>\n<p>In terms of LaTex engines, lualatex is advertised to be most compatible with &#8220;pdfmanagement-testphase&#8221;, but in practice I found that the more common pdflatex engine is doing fine, as well.<\/p>\n<p>&nbsp;<\/p>\n<h2>A complete example<\/h2>\n<p>A live version of an example is available to view and compile on overleaf (<a href=\"https:\/\/www.overleaf.com\/read\/wqqmfhzcpswz#bd44fa\">see overleaf project<\/a>). For convenience, you can also find below the latex code which you can compile the following test document to produce this <a href=\"http:\/\/false\">DummyTaggedPDF<\/a>:<\/p>\n<blockquote><p>% !TEX encoding = UTF-8 Unicode<br \/>\n\\RequirePackage{pdfmanagement-testphase}<br \/>\n\\DocumentMetadata{<br \/>\ntestphase = phase-II, % Use Phase-II for intermediate level tagging<br \/>\npdfversion = 2.0, % Set the PDF version to 2.0 for better compatibility<br \/>\nlang=en-UK % set language for the document<br \/>\n}<\/p>\n<p>\\documentclass{article}<br \/>\n\\usepackage{hyperref}<br \/>\n\\hypersetup{<br \/>\npdftitle={A sample document supporting tagged pdf}, % Title of the PDF<br \/>\npdfauthor={Dr Gunnar M\u00f6ller, PQM Group, Physics and Astronomy, University of Kent}, % Author<br \/>\npdfkeywords={how to make tagged latex},% Keywords for the PDF<br \/>\npdfsubject={trying out tagged pdf}, % Subject or description<br \/>\n}<\/p>\n<p>\\title{Sample Document supporting tagged pdf}<br \/>\n\\author{Dr Gunnar M\u00f6ller, PQM Group, Physics and Astronomy, University of Kent}<br \/>\n\\date{\\today}<\/p>\n<p>\\begin{document}<\/p>\n<p>\\maketitle<\/p>\n<p>\\section{Introduction}<br \/>\n%\\section{Introduction}<br \/>\nThis section should be recognized as a heading in the PDF structure.<\/p>\n<p>\\subsection{Background}<br \/>\nThis is a subsection that should also be tagged.<\/p>\n<p>\\subsubsection{Details}<br \/>\nThis is a subsubsection.<\/p>\n<p>\\section{Compilation}<\/p>\n<p>You can compile this document using within an up-to date Latex distribution. \\verb|lualatex| is the recommended engine, but \\verb|pdflatex| can also handle most situations.<\/p>\n<p>\\section{Notes}<\/p>\n<p>\\begin{itemize}<br \/>\n\\item For full compatibility, you should use UTF-8 encoding for the source file.<br \/>\n\\end{itemize}<\/p>\n<p>It is also possible to tag figures by embedding the \\verb|tagpdf| package<br \/>\n% Example of adding alt-text to an image<br \/>\n\\tagstructbegin{tag=Figure, alttext={This is a random smiley face.}}<br \/>\n\\tagmcbegin{tag=Figure}<br \/>\n\\includegraphics[width=0.2\\textwidth]{a-smiley-face.png} % Your image here<br \/>\n\\tagmcend<br \/>\n\\tagstructend<\/p>\n<p>\\end{document}<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Accessibility with Latex The problem Ensuring the accessibility of scientific and technical documents that we rely on in our research and teaching poses a significant challenge: Lots of our documents are produced using LaTex &#8211; the format of choice for equation-heavy documents. Unfortunately, LaTex does not natively support tagged pdfs, quite yet. Preparatory Steps However, [&hellip;]<\/p>\n","protected":false},"author":140,"featured_media":9103,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[592,1523,1003],"tags":[],"class_list":["post-8782","post","type-post","status-publish","format-standard","hentry","category-engagement","category-research","category-teaching"],"acf":[],"_links":{"self":[{"href":"https:\/\/research.kent.ac.uk\/pqm\/wp-json\/wp\/v2\/posts\/8782","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/research.kent.ac.uk\/pqm\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/research.kent.ac.uk\/pqm\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/research.kent.ac.uk\/pqm\/wp-json\/wp\/v2\/users\/140"}],"replies":[{"embeddable":true,"href":"https:\/\/research.kent.ac.uk\/pqm\/wp-json\/wp\/v2\/comments?post=8782"}],"version-history":[{"count":5,"href":"https:\/\/research.kent.ac.uk\/pqm\/wp-json\/wp\/v2\/posts\/8782\/revisions"}],"predecessor-version":[{"id":9106,"href":"https:\/\/research.kent.ac.uk\/pqm\/wp-json\/wp\/v2\/posts\/8782\/revisions\/9106"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/research.kent.ac.uk\/pqm\/wp-json\/wp\/v2\/media\/9103"}],"wp:attachment":[{"href":"https:\/\/research.kent.ac.uk\/pqm\/wp-json\/wp\/v2\/media?parent=8782"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/research.kent.ac.uk\/pqm\/wp-json\/wp\/v2\/categories?post=8782"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/research.kent.ac.uk\/pqm\/wp-json\/wp\/v2\/tags?post=8782"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}