Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Consider the following example (background in this question).

\setupbibtex[database={library},sort=author]
\setuppublications[alternative=apa]

%\define[1]\reference{\cite[data][#1]}

\starttext
\cite[data][Bohr:1923tl]
%\reference{Bohr:1923tl}

\section{References}
\placepublications[criterium=all]

\stoptext

after running it through Mk-IV is shows the expected behavior:

without_define

Simply defining a macros by uncommenting define – without even using it – breaks it. (def does not help either).

enter image description here

How to define citation macros?

share|improve this question
    
That’s because \reference is an internal Context macro which is used to, well, place references (for internal links). Every entry in the bibliography happens to have such a reference, but as you changed the macro definition, breakage ensues as expected ... call it \bibref and things should work. –  phg May 18 '12 at 8:07
    
Please make this an answer, so I can accept it and less people see what I have done... –  Andy May 18 '12 at 8:17
    
Here you go. Also it would be more precise to remove the tag [bibtex] from this question as MkIV does not rely on Bibtex even though it takes .bib files as input. –  phg May 18 '12 at 9:15

1 Answer 1

up vote 5 down vote accepted

To elaborate a bit on my comment: \reference is the Context user interface macro to the pdf hyperlink facility (for the curious: it is defined among similar commands in strc-ref.mkvi). It is used internally as well, for instance in the macro \thebibtexpublicationlistelement, which typesets a single entry of the bibliography list (cf. bibl-bib.mkiv).

For this reason, redefining \reference is a Bad Idea™: It will definitely break automatically generated references, the corrupted bibliography being collateral damage. If you use \define, Context will kindly give you a hint in the log file:

system          > command \reference is already defined

Choose a harmless macro identifier instead: Capitalization for instance will ensure that a macro never conflicts with any of the internals. Thus, \Reference is the preferable choice.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.