4
l.19 \AddToShipoutPictureBG
                           
The 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'), type `I' 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}

enter image description here

1
  • \AddToShipoutPictureBG is defined in pkg eso-pic which seems to be a dependency of ocg-p. I would use the hook facilities built into the LaTeX kernel instead. See below.
    – AlexG
    Feb 24, 2023 at 11:00

1 Answer 1

4

If you use the Kernel-builtin hook facilities (available since 1/10/2020), everything works fine across all engines:

\documentclass[]{article} 
\usepackage[a6paper]{geometry} 
 
\usepackage{fontawesome5} 
 
\usepackage{hyperref} 
\usepackage{ocgx2} 
\usepackage{tikz} 
 
\AddToHook{shipout/background}{% 
  \setlength\unitlength{\paperheight}% 
  \begin{ocg}[printocg=never]{PDF Navigation Elements}{oc1}{on} 
  \hypersetup{pdfborder=0 0 0}% 
  \large% 
  \put(0,-0.5){% 
    \tikz\node[inner sep=2pt]{\Acrobatmenu{GoBack}{\faArrowAltCircleLeft}}; 
  }% 
  \put(0,-0.5){% 
    \raisebox{-\height}{\tikz\node[inner sep=2pt]{\Acrobatmenu{GoForward}{\faArrowAltCircleRight}};} 
  }% 
  \end{ocg}% 
} 
 
\begin{document} 
Test 
\end{document}

The spacing between the buttons can be adjusted with the node's inner sepoption.

3
  • Great! (1) How are the elements positioned in your code, I do not see remember picture etc? (2) Do you know if there is an overview of the available hooks somewhere? For example, if there is a shipout/foreground? Feb 24, 2023 at 14:24
  • 1
    With \put all absolute positioning is made and (0,0) is the top-left page corner. texdoc ltshipout should take you to the documentation. The whole hook management is introduced in texdoc lthooks.
    – AlexG
    Feb 24, 2023 at 15:06
  • Thanks a lot, very helpful. Feb 24, 2023 at 16:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .