19

Is there a way to fold/unfold certain sections in a pdf. Only when the user clicks on the section or plus sign the items show up.

Example: user clicks on the plus sign and the items appear as drop down list.

Mensch
  • 65,388
Rene Duchamp
  • 1,491
  • 4
    You can create things like drop-down menus etc. However, if this is a CV, I strongly recommend not to do this. – cfr Apr 16 '14 at 20:39
  • @cfr : yeah it was for CV, I believed it will look for interactive and show my skill in Latex. I did not know it was a bad idea. – Rene Duchamp Apr 16 '14 at 20:40
  • 4
    Do you know which PDF viewer potential employers will view your CV in? Because many of these features work only in certain viewers. Typically, they work in (certain versions of) Adobe Reader and you take your chances with anything else. Also, what if somebody wants to print your CV? You wouldn't be able to use it in any situation where your application might be circulated on paper. (So that rules out all actual job applications.) At best you could post it online with a note that it requires Adobe Reader version n. That is bound to annoy somebody. – cfr Apr 16 '14 at 20:47
  • 1
    Accepted. I drop this idea. – Rene Duchamp Apr 16 '14 at 20:51
  • 3
    Still it is a good question, with other applications too. – alfC Apr 16 '14 at 20:58
  • @alfC I agree that for other applications, interactive PDFs are very useful. But I didn't think it would be good to provide a technically correct answer here when I believed that this particular application would be detrimental in ways the OP probably hadn't thought about. I realise that makes my comment off-topic... – cfr Apr 16 '14 at 21:05
  • 1
    Yes, "unfortunately" the OP mentioned CV in a comment. The question is well posed still (and it doesn't mention CV). – alfC Apr 16 '14 at 21:16
  • @Aditya: How is this connected to \LaTeX? –  Apr 16 '14 at 23:02
  • Not connected to Latex, but a proof of concept that shows dynamic views are possible in PDF. Thus, in principle one should be able to reproduce the result in TeX. – Aditya Apr 16 '14 at 23:56
  • @ChristianHupfer: I realize that the linked PDF does not show folding. I remember that Amrita's website had an example that showed "folding" of a PDF document, but I cannot locate that PDF. Still I'll leave the previous link here. – Aditya Apr 17 '14 at 03:22

1 Answers1

14

"Folding" is a typical application for PDF layers (OCG). This works in most recent viewers, but problems might arise with crippled poppler based so called PDF viewers on Linux

\documentclass[a4paper]{minimal}
\usepackage{ocgx}
\begin{document}
Max Mustermann \switchocg{ocg1}{\fcolorbox{blue}{red}{\bfseries +}}\begin{ocg}{OCG 1}{ocg1}{0}
  \colorbox{yellow}{ \parbox{5cm}{Max Mustermann\\Musterweg 1\\12345 Musterstadt}}
\end{ocg}

Erika Mustermann
\end{document}

folded unfolded

Add a note: Best viewed with Adobe Reader! ;-)

Josef
  • 7,432
  • 3
    Even works in evince (Poppler based ;). – AlexG Apr 17 '14 at 12:48
  • 2
    Referring to poppler-based PDF viewers as 'crippled' is offensive, frankly. Unlike Adobe's Reader, my poppler-based viewer is, in fact, not crippled by design. Reader is. – cfr Jul 04 '15 at 02:02
  • 2
    @AlexG Doesn't work in Okular which is also Poppler based. – cfr Jul 04 '15 at 02:02
  • @cfr: Are you referring to my comment in your first comment??? If so, it is quite a bold extrapolation of my statement. – AlexG Jul 04 '15 at 05:57
  • @cfr: That's okular's fault, not poppler's. – AlexG Jul 04 '15 at 06:00
  • @cfr Not being able to implement parts of a well defined open format like PDF for more than 10 years (PDF annotations) lies exactly within the definition of crippled. "But it's open source ..." is neither good enough nor an excuse. Lack of quality is lack of quality. There are many other flaws like OCGs, Javasrict API, ... (nobody knows exactly - which is another problem in it self). Naming something a PDF viewer does not necessarily make something a PDF viewer. – Josef Jul 04 '15 at 08:23
  • @Josef Not sure why you think annotations are a problem. Indeed, annotating is better supported by Okular, say, than Adobe's software because I can annotate any PDF and not just ones signed by Adobe's Acrobat. Okular used to have an issue: you could annotate, but you could only view the annotations in Okular. But that's not been true for a while now. – cfr Jul 04 '15 at 12:42
  • @AlexG That's what I figured. If it works in Evince, it isn't a poppler problem. – cfr Jul 04 '15 at 12:43
  • 2
    @AlexG Just saw your earlier comment. No, of course I wasn't referring to your comment there. I was referring to the OP's description in the answer. The answer describes poppler-based PDF viewers as 'crippled poppler based so called PDF viewers on Linux' which strikes me as a bit rich considering Adobe distributes deliberately crippled viewers and no longer supports Linux at all. – cfr Jul 04 '15 at 12:47
  • 1
    How would you insert a \switchocg inside of an \eqnarray or \align. This is related to this question: https://tex.stackexchange.com/questions/431853/fold-unfold-system-of-equations-in-long-derivation – ranlot May 16 '18 at 13:28
  • See also: https://tex.stackexchange.com/questions/155518/tooltip-that-works-with-all-pdf-readers – exchange Jun 24 '18 at 08:59