# Creating a decent PDF/A document

Let's say I have a simple document having some sections and Unicode and/or math in their titles. How to produce a decent PDF output? By that I mean:

• It contains correct bookmarks.
• It is a PDF/A document.

I have produced the following example. (I know that it may not be a good idea to have that much math and Unicode in titles, but to some extent it's ok, and the source below is just an example.)

\begin{filecontents*}{\jobname.xmpdata}
\Title{Properties of ℝ^ω}
\Author{Foo Barovič\sep Baz Pequeño}
\end{filecontents*}

\documentclass[a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[nomath]{lmodern}
\usepackage{amssymb}
\usepackage[a-2u]{pdfx}

\pdfstringdefDisableCommands{
\def\omega{ω}
}
\begin{document}
\title{Properties of $\mathbb{R}^\omega$}
\author{Foo Barovič, Baz Pequeño}
\date{}
\maketitle

\section{\texorpdfstring
{Basic properties of $\mathbb{R}^\omega$}
{Basic properties of ℝ\textasciicircumω}
}
Here we shall talk about the basic properties.

\subsection{\texorpdfstring
{$\mathbb{R}^\omega$ vs.\ $\bigcup_{n \in \omega} \mathbb{R}^n$ according to Pequeño}
{ℝ\textasciicircumω vs. ⋃\_\{n ∈ ω\} ℝ\textasciicircum n according to Pequeño}
}

\section{\texorpdfstring
{Advanced properties of $\mathbb{R}^\omega$}

• The duplicities in titles. It is possible to map a Unicode character to a macro via the inputenc package. For PDF bookmarks the situation is opposite: it is possible to map macros to Unicode characters using \pdfstringdefDisableCommands. This works well for \omega or \bigcup, but what to do with superscripts, subscripts, groups, $, and \mathbb{R}? Is there a way to declare that ^, _, {, } should be taken literally, $ should be ignored, and \mathbb{R} means ℝ? Then, \texorpdfstring won't be needed.
• The fact that filecontents* does not rewrite existing document. I know this can be changed by filecontents package, but it still emits a warning, and it cannot be loaded before \documentclass, while generating of xmpdata is recommended before \documentclass.