# PDF links generated by \cite do not work when using project component files

When using the project files shown below, links generated by \cite[…] are displayed as links, but when I click on them nothing happens.

But when \completepublications[…] is directly written in main.tex, everything works as expected.

My project is a bit more complex, so that I would like to use separate component files and include them in the main file. But how to make links work?

(Is this a bug?)

main.tex:

\project test-project

\setupinteraction[state=start]

\setupbibtex[database={literature}]
\setuppublications[refcommand=short, numbering=short]

\startproduct test-product
\component a-chapter
\component bibliography  % does not work
%\completepublications[criterium=text]  % this works
\stopproduct


a-chapter.tex:

\startcomponent a-chapter
\chapter{A Chapter}

Some text. \cite[birche2012]
\stopcomponent


bibliography.tex:

\startcomponent bibliography
\completepublications[criterium=text]
\stopcomponent


literature.bib:

@article{birche2012,
Title = {{Complete System Power Estimation Using Processor Performance Events}},
Author = {W. Lloyd Birche and Lizy K. John},
Journal = {IEEE TRANSACTIONS ON COMPUTERS},
Month = {4},
Number = {4},
Pages = {563-577},
Volume = {61},
Year = {2012}
}


Context version is 2012.05.30 11:26.

-
It works if you use place the \completepublications call in a product instead of a component. –  Marco Dec 11 '12 at 19:56
@Marco OK, this works for this minimal example. But in my original document (where I extracted this minimal example from) this does not make it work. I noticed that links to figures created with \in[…] don't work, too. But the links in TOC work fine. I'll try to make a minimal example with this problem. –  hiddenbit Dec 11 '12 at 20:23
@Marco It seems \(start|stop)component really causes all the PDF link problems in my document. I replaced this commands with \(start|stop)product and all links work now. But why? Because it does not make much sense to me to create products and include them with \component. Are projects meant to work this way? –  hiddenbit Dec 11 '12 at 20:53
No. It seems like a bug to me. It should generate an internal link, instead it links to an external file bibliography.pdf (just try to place a PDF named bibliography.pdf in the working directory and click the link). A component should work within a product (see Project Structure). I would suggest to create a minimal example and ask on the ConteXt mailing list. –  Marco Dec 11 '12 at 21:11
@Marco OK, thanks. –  hiddenbit Dec 11 '12 at 21:25

This was a bug in the ConTeXt core and has been fixed as of version 2013.08.06 15:50. Your example runs fine with a current ConTeXt.

It wasn't a problem with the bibliography, but a general problem with references in components.

-
This is good to hear. –  hiddenbit Aug 7 '13 at 17:56

Just for the sake of completeness: I have to use the currently stable version (because when using newer ConTeXt versions the Charter font is not found; maybe because I'm using standalone ConTeXt?) where the problem is not fixed. As a workaround I redefined the project commands, so that every file can be left unchanged:

% based on: http://tex.stackexchange.com/a/10454
\def\newlinecommand#1#2{%
\def#1{%
\begingroup%
\escapechar=\\%
\catcode\endlinechar=\active%
\csname\string#1\endcsname%
}%
\begingroup%
\escapechar=\\%
\lccode\~=\endlinechar%
\lowercase{%
\expandafter\endgroup
\expandafter\def\csname\string#1\endcsname##1~%
}{\endgroup#2\space}%
}

\newlinecommand{\IgnoreRestOfLine}{}

\let\environment\input
\let\component\input

\def\startproduct{\starttext\IgnoreRestOfLine}
\def\stopproduct{\stoptext}

\let\startenvironment\IgnoreRestOfLine
\def\stopenvironment{}

\let\startcomponent\IgnoreRestOfLine
\def\stopcomponent{}
`

Probably this can be done more elegant, but for this purpose it works fine. And when this code snippet is removed and the document is compiled with the ConTeXt version where the problem is fixed, the rest of the code doesn't have to be changed.

-