1

I am using ocg-p package to add layers of information in a pdf document, to be accessed by the reader interactively. To place the ocg layer in the desired location on the document I used rput command from pstricks package. However, this strategy requires that I adjust the coordinates of the ocg layer in each layer, which will be time consuming in a large document. So I have two questions:

  1. is there a way to conditionally put the ocg layer in the text column opposite to the button that activates it? The heigh of the ocg layer would be equal to the text column height, as well as its width;

  2. in the code I am currently using (see below) the ocg layer, while on the text column opposite to the button that activates it, occupies a vertical space bellow the button. I have used vspace to compensate such vertical displacement but, again, this would require manual adjustment in each situation, a time consuming approach in a long document. Is there a simpler way to solve this?

I paste bellow a simplified working code. I use TexStudio for Mac (the newest version) an xetex, since I use specific fonts on this project. Any code recommendation is very welcome, since I have no previous experience in programming and very new to latex.

\documentclass[a4paper,twocolumn,12pt]{book}
\usepackage[brazilian]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fontspec}
\usepackage[usenames,dvipsnames,svgnames,table,xcdraw]{xcolor}
\usepackage{graphicx,lipsum,eso-pic,colortbl,indentfirst,tikz,ocg-p,pstricks}
\usetikzlibrary{backgrounds}
\usepackage[hmarginratio=1:1]{geometry}
\pagestyle{myheadings}
\frenchspacing
\setlength{\parskip}{2ex plus 0.4ex minus 0.2ex}
\setlength{\parindent}{1cm}
\addtolength{\hoffset}{-1cm}
\addtolength{\voffset}{-1cm}
\addtolength{\textheight}{2cm}
\addtolength{\textwidth}{1cm}
\setlength{\marginparwidth}{0pt}
\definecolor{col1}{HTML}{203753}    
\definecolor{col2}{HTML}{BF9279}        
\definecolor{col3}{HTML}{6BA998}        
\definecolor{col4}{HTML}{708AA9}    
\definecolor{col5}{HTML}{7B75AC}

\begin{document}
\section{Lorem ipsum}
\subsection{Lorem ipsum}
\lipsum[1-2]
\noindent
\begin{tikzpicture}     
    \node [text width=7.3cm,fill=col2,inner sep=0.2cm,rounded corners=2mm] {\toggleocgs{topico1}{\small\textit{Lorem ipsum}}};
\end{tikzpicture}   
\noindent
\begin{tikzpicture}     
    \node [text width=7.3cm,fill=col3,inner sep=0.2cm,rounded corners=2mm] {\toggleocgs{alg1}{\small\textit{Lorem ipsum}}};
\end{tikzpicture}
\noindent
\begin{tikzpicture}     
    \node [text width=7.3cm,fill=col5,inner sep=0.2cm,rounded corners=2mm] {\toggleocgs{codigo1}{\small\textit{Lorem ipsum}}};
\end{tikzpicture}
\noindent
\begin{tikzpicture}[line width=2pt]     
    \node [text width=7.3cm,fill=white,draw=col2,inner sep=0.2cm,rounded corners=2mm] {\toggleocgs{exerc1}{\small\textit{Lorem ipsum}}};
\end{tikzpicture}
\rput(4,-9.5){
\begin{ocg}{topico1}{topico1}{0}    
    \begin{tikzpicture}
        \node [text width=7.5cm,fill=col2,inner sep=0.2cm,rounded corners=2mm,minimum height=23.5cm,align=justify]{\small 
            \textit{\lipsum[1-2]}
        };
    \end{tikzpicture}
\end{ocg}}
\rput(4,-9.5){
\begin{ocg}{alg1}{alg1}{0}  
    \begin{tikzpicture}
        \node [text width=7.5cm,fill=col3,inner sep=0.2cm,rounded corners=2mm,minimum height=23.5cm,align=justify]{\small 
            \textit{\lipsum[1-2]}
        };
    \end{tikzpicture}
\end{ocg}}
\rput(-4.5,-9.5){
\begin{ocg}{codigo1}{codigo1}{0}    
    \begin{tikzpicture}
        \node [text width=7.5cm,fill=col5,inner sep=0.2cm,rounded corners=2mm,minimum height=23.5cm,align=justify]{\small
            \textit{\lipsum[1-2]}
        };
    \end{tikzpicture}
\end{ocg}}
\rput(-4.3,-9.5){
\begin{ocg}{exerc1}{exerc1}{0}  
    \begin{tikzpicture}[line width=2pt] 
        \node [text width=7.5cm,fill=white,draw=col2,inner sep=0.2cm,rounded corners=2mm,minimum height=23.5cm,align=justify]{\small
            \textit{\lipsum[1-2]}
        };
    \end{tikzpicture}
\end{ocg}}
\vspace{-1cm}
\section{Lorem ipsum}
\subsection{Lorem ipsum}
\lipsum[1-1]
\end{document}
1
  • I am also trying to solve a task like this. The only way I have in mind is to compile both files seperately, using hyperref and hyper-xr, to reference to the graphicfiles and use tKIZ to select the position. For text I don't have any solution at the moment. Jul 18, 2014 at 12:19

1 Answer 1

1

I identified a working strategy that solves part of the problem.

The common useage of this command is "\rput[refpoint]{rotation}(x,y){stuff}". "refpoints" determines the reference point of stuff. It take value of the combination of "t,b,B"(for vertical refpoint, means "top","bottom" and "Baseline" respectively) and "l,r"(for horizontal refpoint, means "left" and "right" respectively).

Upon inclusion of the refpoint all ocg content located on the same site (in my case, I used [tl]), given the same coordinates.

Hope this may help someone with the same problem.

You must log in to answer this question.

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