Changes

Jump to navigation Jump to search
some considerations about link border colors
</texcode>
This makes all links generated with the {{cmd|goto}} command (and indirectly the {{cmd|in}} and {{cmd|at}} commands) clickable. A page is dedicated to this system of '''[[References]]'''.
= Link coloring =
By default, the link text gets a green or red [[Color|color]], depending on whether the link is to another page or to the same page. You can change the link colors with the <tt>color</tt> (links to other pages) and <tt>contrastcolor</tt> (links to the same page) properties. For example, to disable link coloring alltogether:
By default, the link text gets a green or red [[Color|color]], depending on whether the link is to another page or to the same page. You can change the link colors with the <tt>color</tt> (links to other pages) and <tt>contrastcolor</tt> (links to the same page) properties. Link style is by default set to bold. For example, to disable link highlighting altogether: <texcodecontext source="yes">\startTEXpage[offset=1dk]\setupinteraction[state=start]\goto{https://contextgarden.net/}[url(https://contextgarden.net/)] is a great source of information. \setupinteraction[state=start,color=,contrastcolor=, style=,]\goto{https://contextgarden.net/}[url(https://contextgarden.net/)]is a great source of information.\stopTEXpage</context> = Alternative link highlighting = There is an alternative way of highlighting interactive links, by adding a colored border to the link text, such as in:  <context source="yes">\startTEXpage[offset=1dk]\setupinteraction[state=start,color=,contrastcolor=, style=,]\enabledirectives[references.border=darkgreen]\goto{https://contextgarden.net/}[url(https://contextgarden.net/)] is a great source of information.\stopTEXpage</context> This is a special PDF feature (a link annotation border), not just a frame added to the link text. Depending on your PDF viewer, these link annotation borders may be displayed and/or printed. According to the specification, the links generated by ConTeXt are only to be displayed, not to be printed. Just in case you wonder, this feature comes handy in order to have exactly the same PDF document in print and on screen.<ref>If you have a ConTeXt version from 2024 (as the wiki doesn’t have at the time of writing), there is also a way to distinguish border colors according to link types, such as in: <context source="yes">\starttext\definecolor[internal][x=00cc00]\definecolor[external][x=0000cc]\definecolor[urls][x=cc0000]\definecolor[programs][x=000000]\enabledirectives[references.border=internal]\enabledirectives[references.border=inner:internal]\enabledirectives[references.border=special operation+internal:internal]\enabledirectives[references.border=special operation+page:internal]\enabledirectives[references.border=outer:external]\enabledirectives[references.border=outer with inner:external]\enabledirectives[references.border=special outer with operation+page:external]\enabledirectives[references.border=special operation+file:programs]\enabledirectives[references.border=special operation+program:programs]\enabledirectives[references.border=special operation+url:urls] \startTEXpage[offset=1dk]\goto{this page}[page(1)]\blank\goto{page 25 from “Dealing with XML”}[xml-mkiv.pdf::25]\blank\goto{https://contextgarden.net/}[url(https://contextgarden.net/)]\blank\goto{the source of this file}[program(\jobname.tex)]\stopTEXpage\stoptext</context> The previous sample makes three categories: URLs, internal (parts of the same document), external (parts of other PDF documents), and programs or file (better avoid using these ones, since they might be considered security issues). Please, consider the following questions before using this feature: # Since it is not related to typesetting, it is not an official feature in ConTeXt.# It depends completely on which viewer is being used to display PDF documents.# In any case, this feature is useless when not used sparingly (too many border colors may confuse users).</texcoderef>
= Clickable table of contents =
 
To make table of contents items clickable, use the {{cmd|setupcombinedlist}} command.
\setupinteraction[state=start,focus=standard]
</texcode>
 
== Named destinations (and links to them) ==
Having other {{code|focus}} value than {{code|tight}} or the default ({{code|fit}}), gives PDF named destinations (which allow direct links to those destinations).
 
With the following code, the links to named destinations would read:
 
<texcode>
\setupinteraction[state=start, focus=standard, prefix=_]
\starttext
\completecontent
\dorecurse{25}
{\section{Section}
a\footnote{}}
\stoptext
</texcode>
 
# Link to a section: https://wiki.contextgarden.net/images/1/14/nameddest.pdf#nameddest=_62.
# Link to the last footnote in the document: https://wiki.contextgarden.net/images/1/14/nameddest.pdf#nameddest=_75.
= PDF Bookmarks =
\placebookmarks[chapter,section,subsection][chapter,section]
\setupinteractionscreen[option=bookmark]
% expand macros in bookmarks
\enabledirectives[references.bookmarks.preroll]
\starttext
\startchapter[title=The beginning]
\stoptext
</texcode>
 
It’s important to note that ConTeXt LMTX expands macros in bookmarks and document metadata fields.
== Explanation ==
This will open the document with the bookmarks for chapters and sections visible (read as: and open up the chapter bookmarks)
 
If your titles contain TeX commands or braces, you can choose to expand macros in bookmarks (not required in LMTX):
 
<texcode>
\enabledirectives[references.bookmarks.preroll]
</texcode>
 
If you want the same document metadata (again, not required in LMTX), you can expand macros here, too:
 
<texcode>
\def\title{Some \emph{title}!}
\setupinteraction[title=\title, subtitle=..., author=...]
\enabledirectives[interaction.identity.preroll]
</texcode>
The [[Titles|unnumbered headings]] ({{cmd|title}}, {{cmd|subject}} etc.) do '''not''' create bookmarks, even when listed in {{cmd|placebookmarks}}.
</texcode>
== XML source == When processing XML input file information in TUC file is stored as the XML command with the reference to XML node <texcode>["titledata"]={ ["label"]="section", ["title"]="\\xmlatt{xml:name::4}{title}", ["userdata"]={ ["usertitle"]=\\xmlatt{xml:name::4}{title}, }</texcode> You have to expand the information to get the text in TUC file and subsequently in bookmarks by modifying sections: <texcode>\setuphead [section] [expansion=yes]</texcode> To expand userdata also, you can use <tt>\normalexpanded{\startsection[..,..=..,..][..,..=..,..]}</tt> instead of <tt>expansion=yes</tt>. They are not in conflict. <texcode>\normalexpanded{\startsection[title=\\xmlatt{xml:name::4}{title}, bookmark=\\xmlatt{xml:name::4}{title}] [usertitle=\\xmlatt{xml:name::4}{title}]}...\stopsection</texcode>  = PDF Headers and Custom Properties =
In order to add '''Author''', '''Title''', '''Keywords''', ... to PDF headers, use:
subtitle={...},
keyword={...}]
</texcode>
 
In order to add custom key-value properties in the PDF Document, use:
 
<texcode>
\pdfbackendsetinfo{foo}{bar}
</texcode>
== Prevent certain characters from appearing in pdf headers ==
To ignore certain TeX commands in {{cmd|setupinteraction}} add them to {{cmd|simplifiedcommands}}. For example, to ignore {{cmd|quad}} in <code>pdfauthor</code>, use the following(again, this is default in LMTX):
<texcode>
</texcode>}}
== Import PDF metadata fields from other PDF documents==
 
Inspired by a mailing list reply from Hans, here is a minimal sample:
 
<texcode>
\starttext
\startluacode
function document.transfer_metadata(name)
local main_doc = lpdf.epdf.load(name)
lpdf.addtocatalog("Lang", lpdf.unicode(main_doc.Catalog.Lang), lpdf.string(main_doc.Catalog.Lang))
context.setupinteraction{ title = main_doc.Info.Title }
context.setupinteraction{ subtitle = main_doc.Info.Subject }
context.setupinteraction{ author = main_doc.Info.Author }
lpdf.epdf.unload(name)
end
\stopluacode
\unexpanded\def\TransferMetadata#1%
{\ctxlua{document.transfer_metadata("#1")}}
\null
\TransferMetadata{name.pdf}
\stoptext
</texcode>
 
It also imports language to the PDF document (not to the document language).
= Further reading =
* [[URL]]: typesetting of URLs references.
* [[Presentations]], [[Presentation Styles]], [[SlideWithSteps]], [[Presentation effects]]
* [[Widgets]] (interactive elements, form fields etc.) and [[Interaction and button]]
* See in [[Using Graphics| using graphics]] how to use movies.
* [[Multimedia Inclusion]] describes how to add audio and video files.
= Footnotes =
[[Category:PDF]][[Category:Presentation]][[Category:Command/Interaction|Interaction]] {{Getting started navbox}}
139

edits

Navigation menu