使用 ocgx2 而不是 ocg-p:\AddToShipoutPictureBG 无法识别

使用 ocgx2 而不是 ocg-p:\AddToShipoutPictureBG 无法识别
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}

在此处输入图片描述

答案1

如果您使用内核内置的钩子工具(自 2020 年 1 月 10 日起可用),则所有引擎上的一切都可以正常运行:

\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}

可以使用节点的选项调整按钮之间的间距inner sep

相关内容