- 我想使用ocgx2 包在下面
luatex
。 - 过去,我使用ocg-p 软件包但ocg-p 软件包不适用于
luatex
,请参阅ocg-p:LuaTeX 中的可选内容组。 - 我的理解(显然是错误的)是,ocgx2 包代码兼容ocg-p 软件包。
- 问题:下面的代码可以很好地运行ocg-p 软件包在下面
pdflatex
用于ocgx2 包在下面luatex
。
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
。