[tex-eplain] Outlines side panel without pdftex?
Karl Berry
karl at freefriends.org
Mon May 30 00:59:47 CEST 2016
I'm attaching two minimal examples.
Thanks Rodolfo. Those examples were excellent.
Yes, it is possible. I've constructed the following example document to
show how. I can run this with either:
dvips -z outline-eplain.dvi && ps2pdf outline-eplain.ps
or
pdftex '\nonstopmode\input outline-eplain.tex'
and get an outline-eplain.pdf file with bookmarks.
I wrote a bunch of comments to explain what's needed.
The document uses Eplain's hyperlink stuff to define the destinations
(\hldest) sec1 and sec1.1. This is why it is necessary to pass -z to
dvips. You could redo all the logic to define destinations in both
pdftex and dvips, but why ...
This fails with dvipdfm(x). I doubt it would be hard to make it work,
but since you didn't ask for it, I didn't spend time on it.
I am not sure if there is any functionality to be added to Eplain here.
I guess I could imagine a macro to define a bookmark (aka outline) entry
in a backend-agnostic way, like \hlbookmark{label}{count}{text}, but I
thought it would be better to see how this actually works out in
practice before working on such a thing.
See what you think ... --thanks, karl.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\input eplain
\enablehyperlinks %[dvipdfm] doesn't work
% The "count" specifies the number of subentries in this entry.
% If negative, the bookmark is closed (subentries hidden).
\ifpdf
\pdfoutline goto name {sec1} count -1 {Mysec-pdf}%
\pdfoutline goto name {sec1.1} {Mysubsec-pdf}%
\else
% [ ... pdfmark (no closing ]) is a extension to the PostScript
% language to allow specifying various PDF-ish things. It is
% recognized by Ghostscript and Distiller, et al. Adobe publishes a
% reference manual for it:
% adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/pdfmark_reference.pdf
%
% The ps: prefix tells dvips that the following is literal PostScript.
%
% The /DOCVIEW pdfmark is says the outline panel should be used.
\special{ps:[/PageMode /UseOutlines /DOCVIEW pdfmark}
%
% The individual outline entries, using a different syntax from pdftex
% but it's the same information.
\special{ps:[/Count -1 /Dest (sec1) cvn /Title (Mysec-dvi) /OUT pdfmark}
\special{ps:[/Count -0 /Dest (sec1.1) cvn /Title (Mysubsec-dvi) /OUT pdfmark}
\fi
% In the above, the "-pdf" and "-dvi" strings in the outline entries are
% just to make it clear which branch is being executed for purposes of
% this example. Ordinarily the entries would be the same in both branches.
% The strings above are just constants, again for this example. Usually
% they would come from control sequences, e.g., as the table of contents
% is read. It is necessary to "pdf-escape" such arbitary strings, else
% backslashes, parentheses, etc., would not come out right. pdftex's
% \pdfescapestring (I hope also available in other engines) is the
% easiest way to do this, e.g., \xdef#1{\pdfescapestring{#1}}.
% End commentary, start document text.
First page.\vfil\eject
\hldest{}{}{sec1}%
1. Mysec on second page.\vfil\eject
\hldest{}{}{sec1.1}%
1.1. Mysubsec on third page.
\end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
More information about the tex-eplain
mailing list