OCGX and hyperref: visibility and clickability of overlapping links












7















I am using ocgx to display different text blocks (in the same area of the same page) upon clicking links in the PDF.



However, each of these textblocks has its own href links, and these links overlap on the page (concealing earlier-defined OCGs) even when no text is visible(!). Is it possible to make an ocg toggle not just visibility, but also layer ordering?



In the MWE below, note that toggling the textblock visibility with buttons 1,2 does not toggle the presence of href links, and only the link "google.com" is present, even when neither ocg is visible (mouse pointer not captured in my screenshots)....



documentclass{article}
usepackage{ocgx}
usepackage{hyperref}

usepackage{textpos}
setlength{TPHorizModule}{12pt}
setlength{TPVertModule}{12pt}

begin{document}
actionsocg{ocg1}{}{ocg2}{{color{blue}{button 1}}}$|$ %toggle ocg1, hide ocg2
actionsocg{ocg2}{}{ocg1}{{color{blue}{button 2}}}%toggle ocg2, hide ocg1

%define OCGs:
begin{ocg}{}{ocg1}{0}
begin{textblock}{40}(1,1)
href{http://overleaf.com}{Link 1}
end{textblock}
end{ocg}

begin{ocg}{}{ocg2}{0}
begin{textblock}{40}(1,1)
href{http://google.com}{Link 2}
end{textblock}
end{ocg}

end{document}


mouse over link after pressing button 1mouse over link after pressing button 1










share|improve this question




















  • 1





    +1 Very good question!

    – Paul Gaborit
    Mar 5 at 15:42











  • See stackoverflow.com/q/21717943/3384763

    – Paul Gaborit
    Mar 5 at 15:43






  • 1





    The question is certainly a good question since Paul Gaborit, ocgx maintainer, says so. However, I did not understand the problem. Can you be more explicit?

    – AndréC
    Mar 5 at 15:47






  • 1





    @AndréC Updated w/ mouseover screenshots (pointer not visible)

    – Ian Appelbaum
    Mar 5 at 17:19
















7















I am using ocgx to display different text blocks (in the same area of the same page) upon clicking links in the PDF.



However, each of these textblocks has its own href links, and these links overlap on the page (concealing earlier-defined OCGs) even when no text is visible(!). Is it possible to make an ocg toggle not just visibility, but also layer ordering?



In the MWE below, note that toggling the textblock visibility with buttons 1,2 does not toggle the presence of href links, and only the link "google.com" is present, even when neither ocg is visible (mouse pointer not captured in my screenshots)....



documentclass{article}
usepackage{ocgx}
usepackage{hyperref}

usepackage{textpos}
setlength{TPHorizModule}{12pt}
setlength{TPVertModule}{12pt}

begin{document}
actionsocg{ocg1}{}{ocg2}{{color{blue}{button 1}}}$|$ %toggle ocg1, hide ocg2
actionsocg{ocg2}{}{ocg1}{{color{blue}{button 2}}}%toggle ocg2, hide ocg1

%define OCGs:
begin{ocg}{}{ocg1}{0}
begin{textblock}{40}(1,1)
href{http://overleaf.com}{Link 1}
end{textblock}
end{ocg}

begin{ocg}{}{ocg2}{0}
begin{textblock}{40}(1,1)
href{http://google.com}{Link 2}
end{textblock}
end{ocg}

end{document}


mouse over link after pressing button 1mouse over link after pressing button 1










share|improve this question




















  • 1





    +1 Very good question!

    – Paul Gaborit
    Mar 5 at 15:42











  • See stackoverflow.com/q/21717943/3384763

    – Paul Gaborit
    Mar 5 at 15:43






  • 1





    The question is certainly a good question since Paul Gaborit, ocgx maintainer, says so. However, I did not understand the problem. Can you be more explicit?

    – AndréC
    Mar 5 at 15:47






  • 1





    @AndréC Updated w/ mouseover screenshots (pointer not visible)

    – Ian Appelbaum
    Mar 5 at 17:19














7












7








7


2






I am using ocgx to display different text blocks (in the same area of the same page) upon clicking links in the PDF.



However, each of these textblocks has its own href links, and these links overlap on the page (concealing earlier-defined OCGs) even when no text is visible(!). Is it possible to make an ocg toggle not just visibility, but also layer ordering?



In the MWE below, note that toggling the textblock visibility with buttons 1,2 does not toggle the presence of href links, and only the link "google.com" is present, even when neither ocg is visible (mouse pointer not captured in my screenshots)....



documentclass{article}
usepackage{ocgx}
usepackage{hyperref}

usepackage{textpos}
setlength{TPHorizModule}{12pt}
setlength{TPVertModule}{12pt}

begin{document}
actionsocg{ocg1}{}{ocg2}{{color{blue}{button 1}}}$|$ %toggle ocg1, hide ocg2
actionsocg{ocg2}{}{ocg1}{{color{blue}{button 2}}}%toggle ocg2, hide ocg1

%define OCGs:
begin{ocg}{}{ocg1}{0}
begin{textblock}{40}(1,1)
href{http://overleaf.com}{Link 1}
end{textblock}
end{ocg}

begin{ocg}{}{ocg2}{0}
begin{textblock}{40}(1,1)
href{http://google.com}{Link 2}
end{textblock}
end{ocg}

end{document}


mouse over link after pressing button 1mouse over link after pressing button 1










share|improve this question
















I am using ocgx to display different text blocks (in the same area of the same page) upon clicking links in the PDF.



However, each of these textblocks has its own href links, and these links overlap on the page (concealing earlier-defined OCGs) even when no text is visible(!). Is it possible to make an ocg toggle not just visibility, but also layer ordering?



In the MWE below, note that toggling the textblock visibility with buttons 1,2 does not toggle the presence of href links, and only the link "google.com" is present, even when neither ocg is visible (mouse pointer not captured in my screenshots)....



documentclass{article}
usepackage{ocgx}
usepackage{hyperref}

usepackage{textpos}
setlength{TPHorizModule}{12pt}
setlength{TPVertModule}{12pt}

begin{document}
actionsocg{ocg1}{}{ocg2}{{color{blue}{button 1}}}$|$ %toggle ocg1, hide ocg2
actionsocg{ocg2}{}{ocg1}{{color{blue}{button 2}}}%toggle ocg2, hide ocg1

%define OCGs:
begin{ocg}{}{ocg1}{0}
begin{textblock}{40}(1,1)
href{http://overleaf.com}{Link 1}
end{textblock}
end{ocg}

begin{ocg}{}{ocg2}{0}
begin{textblock}{40}(1,1)
href{http://google.com}{Link 2}
end{textblock}
end{ocg}

end{document}


mouse over link after pressing button 1mouse over link after pressing button 1







hyperref ocg ocgx






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 6 at 14:31









AlexG

34.7k482149




34.7k482149










asked Mar 5 at 15:28









Ian AppelbaumIan Appelbaum

384




384








  • 1





    +1 Very good question!

    – Paul Gaborit
    Mar 5 at 15:42











  • See stackoverflow.com/q/21717943/3384763

    – Paul Gaborit
    Mar 5 at 15:43






  • 1





    The question is certainly a good question since Paul Gaborit, ocgx maintainer, says so. However, I did not understand the problem. Can you be more explicit?

    – AndréC
    Mar 5 at 15:47






  • 1





    @AndréC Updated w/ mouseover screenshots (pointer not visible)

    – Ian Appelbaum
    Mar 5 at 17:19














  • 1





    +1 Very good question!

    – Paul Gaborit
    Mar 5 at 15:42











  • See stackoverflow.com/q/21717943/3384763

    – Paul Gaborit
    Mar 5 at 15:43






  • 1





    The question is certainly a good question since Paul Gaborit, ocgx maintainer, says so. However, I did not understand the problem. Can you be more explicit?

    – AndréC
    Mar 5 at 15:47






  • 1





    @AndréC Updated w/ mouseover screenshots (pointer not visible)

    – Ian Appelbaum
    Mar 5 at 17:19








1




1





+1 Very good question!

– Paul Gaborit
Mar 5 at 15:42





+1 Very good question!

– Paul Gaborit
Mar 5 at 15:42













See stackoverflow.com/q/21717943/3384763

– Paul Gaborit
Mar 5 at 15:43





See stackoverflow.com/q/21717943/3384763

– Paul Gaborit
Mar 5 at 15:43




1




1





The question is certainly a good question since Paul Gaborit, ocgx maintainer, says so. However, I did not understand the problem. Can you be more explicit?

– AndréC
Mar 5 at 15:47





The question is certainly a good question since Paul Gaborit, ocgx maintainer, says so. However, I did not understand the problem. Can you be more explicit?

– AndréC
Mar 5 at 15:47




1




1





@AndréC Updated w/ mouseover screenshots (pointer not visible)

– Ian Appelbaum
Mar 5 at 17:19





@AndréC Updated w/ mouseover screenshots (pointer not visible)

– Ian Appelbaum
Mar 5 at 17:19










1 Answer
1






active

oldest

votes


















8














This can be done with package ocgx2 plus patching hyperref a bit to make it PDF layer-aware.



Note however that only Acrobat Reader respects the visibility of links that are placed on PDF layers:



documentclass{article}

usepackage{ocgx2}
usepackage{hyperref}
%patch hyperref to make PDF Annotations PDF-Layer-(OCG)-aware
makeatletter
letHy@setpdfborderOrigHy@setpdfborder
defHy@setpdfborder{ocgbase@insert@ocHy@setpdfborderOrig}%
makeatother

usepackage{textpos}
setlength{TPHorizModule}{12pt}
setlength{TPVertModule}{12pt}

begin{document}
actionsocg{ocg1}{}{ocg2}{{color{blue}{button 1}}}$|$ %toggle ocg1, hide ocg2
actionsocg{ocg2}{}{ocg1}{{color{blue}{button 2}}}%toggle ocg2, hide ocg1

%define OCGs:
begin{ocg}{}{ocg1}{0}
begin{textblock}{40}(1,1)
href{http://overleaf.com}{Link 1}
end{textblock}
end{ocg}

begin{ocg}{}{ocg2}{0}
begin{textblock}{40}(1,1)
href{http://google.com}{Link 2}
end{textblock}
end{ocg}

end{document}


Creating switches for mutually concealing PDF layers by means of actionsocg quickly gets cumbersome if the number of PDF layers increases. In order to simplify, pkg ocgx2 allows OCGs to be grouped into Radio Button Groups. From all OCGs belonging to the same Radio Button Group only one can be enabled at a time, automatically hiding the previously visible OCG. An OCG is added to a Radio Button Group with option radiobtngrp=.... Grouping OCGs into a Radio Button Group allows us to use the simple showocg command to create switches for every layer:



enter image description here



documentclass{article}

usepackage{ocgx2}
usepackage{hyperref}
%patch hyperref to make PDF Annotations PDF-Layer-(OCG)-aware
makeatletter
letHy@setpdfborderOrigHy@setpdfborder
defHy@setpdfborder{ocgbase@insert@ocHy@setpdfborderOrig}%
makeatother

usepackage{fontawesome,pgffor}
parindent=0pt

begin{document}

foreach ocgname / urlicon in {%
GitHub/faGithub, StackExchange/faStackExchange, StackOverflow/faStackOverflow, Google/faGoogle%
}{showocg{ocgname}{urlicon} }\[1ex]
%define OCGs, within the same Radio Button Group
foreach ocgname / weburl in {%
GitHub/{https://github.com}, StackExchange/{https://stackexchange.com}, StackOverflow/{https://stackoverflow.com}, Google/{https://google.com}%
}{%
makebox[0pt][l]{%
begin{ocg}[radiobtngrp=myURLs]{ocgname}{ocgname}{off}
url{weburl}
end{ocg}}%
}

end{document}





share|improve this answer





















  • 2





    One word: bravo!

    – AndréC
    Mar 5 at 16:14






  • 2





    @AndréC :-) approved also for me. :-).

    – Sebastiano
    Mar 5 at 16:21






  • 1





    @AlexG Thanks this works!!

    – Ian Appelbaum
    Mar 5 at 17:21






  • 1





    @Ian It can be further simplified using a Radio Button Group. I'll update tomorrow.

    – AlexG
    Mar 5 at 17:52











  • @IanAppelbaum Ok. Done.

    – AlexG
    Mar 6 at 9:34












Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f477878%2focgx-and-hyperref-visibility-and-clickability-of-overlapping-links%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









8














This can be done with package ocgx2 plus patching hyperref a bit to make it PDF layer-aware.



Note however that only Acrobat Reader respects the visibility of links that are placed on PDF layers:



documentclass{article}

usepackage{ocgx2}
usepackage{hyperref}
%patch hyperref to make PDF Annotations PDF-Layer-(OCG)-aware
makeatletter
letHy@setpdfborderOrigHy@setpdfborder
defHy@setpdfborder{ocgbase@insert@ocHy@setpdfborderOrig}%
makeatother

usepackage{textpos}
setlength{TPHorizModule}{12pt}
setlength{TPVertModule}{12pt}

begin{document}
actionsocg{ocg1}{}{ocg2}{{color{blue}{button 1}}}$|$ %toggle ocg1, hide ocg2
actionsocg{ocg2}{}{ocg1}{{color{blue}{button 2}}}%toggle ocg2, hide ocg1

%define OCGs:
begin{ocg}{}{ocg1}{0}
begin{textblock}{40}(1,1)
href{http://overleaf.com}{Link 1}
end{textblock}
end{ocg}

begin{ocg}{}{ocg2}{0}
begin{textblock}{40}(1,1)
href{http://google.com}{Link 2}
end{textblock}
end{ocg}

end{document}


Creating switches for mutually concealing PDF layers by means of actionsocg quickly gets cumbersome if the number of PDF layers increases. In order to simplify, pkg ocgx2 allows OCGs to be grouped into Radio Button Groups. From all OCGs belonging to the same Radio Button Group only one can be enabled at a time, automatically hiding the previously visible OCG. An OCG is added to a Radio Button Group with option radiobtngrp=.... Grouping OCGs into a Radio Button Group allows us to use the simple showocg command to create switches for every layer:



enter image description here



documentclass{article}

usepackage{ocgx2}
usepackage{hyperref}
%patch hyperref to make PDF Annotations PDF-Layer-(OCG)-aware
makeatletter
letHy@setpdfborderOrigHy@setpdfborder
defHy@setpdfborder{ocgbase@insert@ocHy@setpdfborderOrig}%
makeatother

usepackage{fontawesome,pgffor}
parindent=0pt

begin{document}

foreach ocgname / urlicon in {%
GitHub/faGithub, StackExchange/faStackExchange, StackOverflow/faStackOverflow, Google/faGoogle%
}{showocg{ocgname}{urlicon} }\[1ex]
%define OCGs, within the same Radio Button Group
foreach ocgname / weburl in {%
GitHub/{https://github.com}, StackExchange/{https://stackexchange.com}, StackOverflow/{https://stackoverflow.com}, Google/{https://google.com}%
}{%
makebox[0pt][l]{%
begin{ocg}[radiobtngrp=myURLs]{ocgname}{ocgname}{off}
url{weburl}
end{ocg}}%
}

end{document}





share|improve this answer





















  • 2





    One word: bravo!

    – AndréC
    Mar 5 at 16:14






  • 2





    @AndréC :-) approved also for me. :-).

    – Sebastiano
    Mar 5 at 16:21






  • 1





    @AlexG Thanks this works!!

    – Ian Appelbaum
    Mar 5 at 17:21






  • 1





    @Ian It can be further simplified using a Radio Button Group. I'll update tomorrow.

    – AlexG
    Mar 5 at 17:52











  • @IanAppelbaum Ok. Done.

    – AlexG
    Mar 6 at 9:34
















8














This can be done with package ocgx2 plus patching hyperref a bit to make it PDF layer-aware.



Note however that only Acrobat Reader respects the visibility of links that are placed on PDF layers:



documentclass{article}

usepackage{ocgx2}
usepackage{hyperref}
%patch hyperref to make PDF Annotations PDF-Layer-(OCG)-aware
makeatletter
letHy@setpdfborderOrigHy@setpdfborder
defHy@setpdfborder{ocgbase@insert@ocHy@setpdfborderOrig}%
makeatother

usepackage{textpos}
setlength{TPHorizModule}{12pt}
setlength{TPVertModule}{12pt}

begin{document}
actionsocg{ocg1}{}{ocg2}{{color{blue}{button 1}}}$|$ %toggle ocg1, hide ocg2
actionsocg{ocg2}{}{ocg1}{{color{blue}{button 2}}}%toggle ocg2, hide ocg1

%define OCGs:
begin{ocg}{}{ocg1}{0}
begin{textblock}{40}(1,1)
href{http://overleaf.com}{Link 1}
end{textblock}
end{ocg}

begin{ocg}{}{ocg2}{0}
begin{textblock}{40}(1,1)
href{http://google.com}{Link 2}
end{textblock}
end{ocg}

end{document}


Creating switches for mutually concealing PDF layers by means of actionsocg quickly gets cumbersome if the number of PDF layers increases. In order to simplify, pkg ocgx2 allows OCGs to be grouped into Radio Button Groups. From all OCGs belonging to the same Radio Button Group only one can be enabled at a time, automatically hiding the previously visible OCG. An OCG is added to a Radio Button Group with option radiobtngrp=.... Grouping OCGs into a Radio Button Group allows us to use the simple showocg command to create switches for every layer:



enter image description here



documentclass{article}

usepackage{ocgx2}
usepackage{hyperref}
%patch hyperref to make PDF Annotations PDF-Layer-(OCG)-aware
makeatletter
letHy@setpdfborderOrigHy@setpdfborder
defHy@setpdfborder{ocgbase@insert@ocHy@setpdfborderOrig}%
makeatother

usepackage{fontawesome,pgffor}
parindent=0pt

begin{document}

foreach ocgname / urlicon in {%
GitHub/faGithub, StackExchange/faStackExchange, StackOverflow/faStackOverflow, Google/faGoogle%
}{showocg{ocgname}{urlicon} }\[1ex]
%define OCGs, within the same Radio Button Group
foreach ocgname / weburl in {%
GitHub/{https://github.com}, StackExchange/{https://stackexchange.com}, StackOverflow/{https://stackoverflow.com}, Google/{https://google.com}%
}{%
makebox[0pt][l]{%
begin{ocg}[radiobtngrp=myURLs]{ocgname}{ocgname}{off}
url{weburl}
end{ocg}}%
}

end{document}





share|improve this answer





















  • 2





    One word: bravo!

    – AndréC
    Mar 5 at 16:14






  • 2





    @AndréC :-) approved also for me. :-).

    – Sebastiano
    Mar 5 at 16:21






  • 1





    @AlexG Thanks this works!!

    – Ian Appelbaum
    Mar 5 at 17:21






  • 1





    @Ian It can be further simplified using a Radio Button Group. I'll update tomorrow.

    – AlexG
    Mar 5 at 17:52











  • @IanAppelbaum Ok. Done.

    – AlexG
    Mar 6 at 9:34














8












8








8







This can be done with package ocgx2 plus patching hyperref a bit to make it PDF layer-aware.



Note however that only Acrobat Reader respects the visibility of links that are placed on PDF layers:



documentclass{article}

usepackage{ocgx2}
usepackage{hyperref}
%patch hyperref to make PDF Annotations PDF-Layer-(OCG)-aware
makeatletter
letHy@setpdfborderOrigHy@setpdfborder
defHy@setpdfborder{ocgbase@insert@ocHy@setpdfborderOrig}%
makeatother

usepackage{textpos}
setlength{TPHorizModule}{12pt}
setlength{TPVertModule}{12pt}

begin{document}
actionsocg{ocg1}{}{ocg2}{{color{blue}{button 1}}}$|$ %toggle ocg1, hide ocg2
actionsocg{ocg2}{}{ocg1}{{color{blue}{button 2}}}%toggle ocg2, hide ocg1

%define OCGs:
begin{ocg}{}{ocg1}{0}
begin{textblock}{40}(1,1)
href{http://overleaf.com}{Link 1}
end{textblock}
end{ocg}

begin{ocg}{}{ocg2}{0}
begin{textblock}{40}(1,1)
href{http://google.com}{Link 2}
end{textblock}
end{ocg}

end{document}


Creating switches for mutually concealing PDF layers by means of actionsocg quickly gets cumbersome if the number of PDF layers increases. In order to simplify, pkg ocgx2 allows OCGs to be grouped into Radio Button Groups. From all OCGs belonging to the same Radio Button Group only one can be enabled at a time, automatically hiding the previously visible OCG. An OCG is added to a Radio Button Group with option radiobtngrp=.... Grouping OCGs into a Radio Button Group allows us to use the simple showocg command to create switches for every layer:



enter image description here



documentclass{article}

usepackage{ocgx2}
usepackage{hyperref}
%patch hyperref to make PDF Annotations PDF-Layer-(OCG)-aware
makeatletter
letHy@setpdfborderOrigHy@setpdfborder
defHy@setpdfborder{ocgbase@insert@ocHy@setpdfborderOrig}%
makeatother

usepackage{fontawesome,pgffor}
parindent=0pt

begin{document}

foreach ocgname / urlicon in {%
GitHub/faGithub, StackExchange/faStackExchange, StackOverflow/faStackOverflow, Google/faGoogle%
}{showocg{ocgname}{urlicon} }\[1ex]
%define OCGs, within the same Radio Button Group
foreach ocgname / weburl in {%
GitHub/{https://github.com}, StackExchange/{https://stackexchange.com}, StackOverflow/{https://stackoverflow.com}, Google/{https://google.com}%
}{%
makebox[0pt][l]{%
begin{ocg}[radiobtngrp=myURLs]{ocgname}{ocgname}{off}
url{weburl}
end{ocg}}%
}

end{document}





share|improve this answer















This can be done with package ocgx2 plus patching hyperref a bit to make it PDF layer-aware.



Note however that only Acrobat Reader respects the visibility of links that are placed on PDF layers:



documentclass{article}

usepackage{ocgx2}
usepackage{hyperref}
%patch hyperref to make PDF Annotations PDF-Layer-(OCG)-aware
makeatletter
letHy@setpdfborderOrigHy@setpdfborder
defHy@setpdfborder{ocgbase@insert@ocHy@setpdfborderOrig}%
makeatother

usepackage{textpos}
setlength{TPHorizModule}{12pt}
setlength{TPVertModule}{12pt}

begin{document}
actionsocg{ocg1}{}{ocg2}{{color{blue}{button 1}}}$|$ %toggle ocg1, hide ocg2
actionsocg{ocg2}{}{ocg1}{{color{blue}{button 2}}}%toggle ocg2, hide ocg1

%define OCGs:
begin{ocg}{}{ocg1}{0}
begin{textblock}{40}(1,1)
href{http://overleaf.com}{Link 1}
end{textblock}
end{ocg}

begin{ocg}{}{ocg2}{0}
begin{textblock}{40}(1,1)
href{http://google.com}{Link 2}
end{textblock}
end{ocg}

end{document}


Creating switches for mutually concealing PDF layers by means of actionsocg quickly gets cumbersome if the number of PDF layers increases. In order to simplify, pkg ocgx2 allows OCGs to be grouped into Radio Button Groups. From all OCGs belonging to the same Radio Button Group only one can be enabled at a time, automatically hiding the previously visible OCG. An OCG is added to a Radio Button Group with option radiobtngrp=.... Grouping OCGs into a Radio Button Group allows us to use the simple showocg command to create switches for every layer:



enter image description here



documentclass{article}

usepackage{ocgx2}
usepackage{hyperref}
%patch hyperref to make PDF Annotations PDF-Layer-(OCG)-aware
makeatletter
letHy@setpdfborderOrigHy@setpdfborder
defHy@setpdfborder{ocgbase@insert@ocHy@setpdfborderOrig}%
makeatother

usepackage{fontawesome,pgffor}
parindent=0pt

begin{document}

foreach ocgname / urlicon in {%
GitHub/faGithub, StackExchange/faStackExchange, StackOverflow/faStackOverflow, Google/faGoogle%
}{showocg{ocgname}{urlicon} }\[1ex]
%define OCGs, within the same Radio Button Group
foreach ocgname / weburl in {%
GitHub/{https://github.com}, StackExchange/{https://stackexchange.com}, StackOverflow/{https://stackoverflow.com}, Google/{https://google.com}%
}{%
makebox[0pt][l]{%
begin{ocg}[radiobtngrp=myURLs]{ocgname}{ocgname}{off}
url{weburl}
end{ocg}}%
}

end{document}






share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 6 at 9:28

























answered Mar 5 at 16:10









AlexGAlexG

34.7k482149




34.7k482149








  • 2





    One word: bravo!

    – AndréC
    Mar 5 at 16:14






  • 2





    @AndréC :-) approved also for me. :-).

    – Sebastiano
    Mar 5 at 16:21






  • 1





    @AlexG Thanks this works!!

    – Ian Appelbaum
    Mar 5 at 17:21






  • 1





    @Ian It can be further simplified using a Radio Button Group. I'll update tomorrow.

    – AlexG
    Mar 5 at 17:52











  • @IanAppelbaum Ok. Done.

    – AlexG
    Mar 6 at 9:34














  • 2





    One word: bravo!

    – AndréC
    Mar 5 at 16:14






  • 2





    @AndréC :-) approved also for me. :-).

    – Sebastiano
    Mar 5 at 16:21






  • 1





    @AlexG Thanks this works!!

    – Ian Appelbaum
    Mar 5 at 17:21






  • 1





    @Ian It can be further simplified using a Radio Button Group. I'll update tomorrow.

    – AlexG
    Mar 5 at 17:52











  • @IanAppelbaum Ok. Done.

    – AlexG
    Mar 6 at 9:34








2




2





One word: bravo!

– AndréC
Mar 5 at 16:14





One word: bravo!

– AndréC
Mar 5 at 16:14




2




2





@AndréC :-) approved also for me. :-).

– Sebastiano
Mar 5 at 16:21





@AndréC :-) approved also for me. :-).

– Sebastiano
Mar 5 at 16:21




1




1





@AlexG Thanks this works!!

– Ian Appelbaum
Mar 5 at 17:21





@AlexG Thanks this works!!

– Ian Appelbaum
Mar 5 at 17:21




1




1





@Ian It can be further simplified using a Radio Button Group. I'll update tomorrow.

– AlexG
Mar 5 at 17:52





@Ian It can be further simplified using a Radio Button Group. I'll update tomorrow.

– AlexG
Mar 5 at 17:52













@IanAppelbaum Ok. Done.

– AlexG
Mar 6 at 9:34





@IanAppelbaum Ok. Done.

– AlexG
Mar 6 at 9:34


















draft saved

draft discarded




















































Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f477878%2focgx-and-hyperref-visibility-and-clickability-of-overlapping-links%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How do I know what Microsoft account the skydrive app is syncing to?

Grease: Live!

When does type information flow backwards in C++?