- I want to use the ocgx2 package under
luatex. - In the past, I used the ocg-p package but the ocg-p package does not work with
luatex, see ocg-p: Optional Content Groups in LuaTeX. - My (apparently wrong) understanding is, that the ocgx2 package is code-compatible with the ocg-p package.
- Problem: The below code works fine with the ocg-p package under
pdflatexbut does not work with the ocgx2 package underluatex.
l.19 \AddToShipoutPictureBGThe control sequence at the end of the top line of your error message was never \def'ed. If you have misspelled it (e.g.,
\hobx'), typeI' and the correct spelling (e.g., `I\hbox'). Otherwise just continue, and I'll forget about whatever was undefined.
\documentclass[]{article}
\usepackage[a6paper]{geometry}
\usepackage{fontawesome5}
\usepackage{tikz}
\usepackage{hyperref}
%\usepackage{ocgx2} % Works not fine under luatex
\usepackage{ocg-p} % Works fine under pdflatex
%https://tex.stackexchange.com/questions/276532
\AddToShipoutPictureBG
{\begin{ocg}[printocg = never]{PDF Navigation Elements}{oc1}{1}
\begin{tikzpicture}[remember picture, overlay]
\node [anchor = west, font = \large, align = left] () at (current page.west){\Acrobatmenu{GoBack}{\faArrowAltCircleLeft}\\Acrobatmenu{GoForward}{\faArrowAltCircleRight}};
\end{tikzpicture}
\end{ocg}%
}
\begin{document}
Test
\end{document}

\AddToShipoutPictureBGis defined in pkgeso-picwhich seems to be a dependency ofocg-p. I would use the hook facilities built into the LaTeX kernel instead. See below. – AlexG Feb 24 '23 at 11:00