# How to use ocg-p with LuaLaTeX (TeXlive 2015)?

If I compile the following MWE

\documentclass{scrartcl}
\usepackage{ocg-p}%Layers
\begin{document}
\end{document}


with luaLaTeX, it stops with the following error:

! Package ocg-p Error: pdfeTeX, version >= 1.20, required.


The ocg-p package is supported only for pdflatex and xelatex, but in the past (TeXLive 2014) I had no problems to use it in combination with luaLaTeX.

I need the combination of ocg-p and luaLaTeX.

The ocg-p-package itself is unchanged since 2013, so this check for pdfeTeX-version already existed in the previous version.

• ocgx2 fully replaces ocg-p and fixes a few bugs (e. g. non-functional dvips support). – AlexG Sep 10 '15 at 4:39

Package ocgx2 serves as a drop-in replacement for ocg-p, ocg and ocgxpackages.

See README for fixes and additions in comparison with the other packages.

\documentclass{scrartcl}
%\documentclass[dvipdfmx]{scrartcl}

\usepackage{ocgx2} %pdflatex, lualatex, xelatex, latex+dvips+ps2pdf

\begin{document}

%same interface as ocg.sty, ocg-p.sty, ocgx.sty
\begin{ocg}{hello}{hello}{1}
\strut Hello!
\end{ocg}
\begin{ocg}{good bye}{good bye}{0}
\strut Good bye!
\end{ocg}

\toggleocgs{hello {good bye}}{\fbox{Toggle visibility}} %ocg-p
%\switchocg{hello {good bye}}{\fbox{Toggle visibility}} %ocgx

\end{document}

• Good to know, I missed this new package. It is not contained on the TeXlive 2015-DVD - I will check it when I have access to update my TeX-installation. – knut Sep 10 '15 at 7:41
• I have problems to use ocgx2 as a drop in replacement. ocg-p supports optional options in \toggleocgs (page 5 in documentation), ocg-x supports no optional parameters in \switchocg. If I add a \renewcommand{\toggleocgs}[3][]{\switchocg{#2}{#3}} my document is processed. – knut Sep 10 '15 at 9:35
• @knut Ok, I will look into it. – AlexG Sep 10 '15 at 10:11
• Accepted. The usage of the optional parameters in toggleocgs is no must in my document, I was able to use \switchocg.. – knut Sep 10 '15 at 12:25
• @knut: The new version 0.8 of ocgx2 is now online. It fully supports the one option (triggerocg) that ocg-p provides for its OCG setting commands. – AlexG Sep 12 '15 at 11:03

Quick help: Set the pdftexversion-number to the expected value.

\documentclass{scrartcl}
\def\pdftexversion{120}
\usepackage{ocg-p}%Layers

\begin{document}
\end{document}


Background:

ocg-p makes the following checks:

\RequirePackage{ifpdf}
\RequirePackage{ifxetex}
[...]
\ifpdf
\ifnum\pdftexversion<120
\PackageError{ocg-p}{%
pdfeTeX, version >= 1.20, required%
}{%
}%
\fi
\else
\ifxetex
\else
% dvips
\@ocgp@ifpstrue
\PackageWarningNoLine{ocg-p}{%
Only XeLaTeX and pdfLaTeX are supported%
}%
\fi
\fi


In the past lualatex 79 set pdftexversion 200. Since TeXlive 2015 the value is set to the value of lualatexversion (actually 80). So this check fails and you get the error.

In the future pdftexversion will not be defined.

In case somebody has a similar problem in another package. The version check could be modified to:

\RequirePackage{ifpdf}
\RequirePackage{ifxetex}
\RequirePackage{ifluatex}

%....

\ifluatex
%already ok (tested with luatexversion ...)
\else
\ifpdf
\ifnum\pdftexversion<120
\PackageError{ocg-p}{%
pdfeTeX, version >= 1.20, required%
}{%
}%
\fi
\else
\ifxetex

• Thanks! This also solves the problem that luatex in TeX Live 2015 won’t accept the option interpolate=true with \includegraphics, which worked without complaint in 2014. – Thérèse Sep 9 '15 at 20:56