[tex-eplain] \definexref problem

John Culleton john at wexfordpress.com
Sun Dec 5 15:04:07 CET 2010


On Sunday 05 December 2010 07:01:43 Adam Fenn wrote:
> How can I modify this:
>
> %----------------------------%<--------------------------
> \def\book#1#2#3{%
>      \definexref{#3:long}{#1}{}%
>      \definexref{#3:short}{#2}{}%
>      \definexref{#3full}{#1}{}%
>      }
>
>    \def\bookref#1{%
>      \readauxfile % make sure the xrefs are loaded
>      \expandafter \ifx\csname\xrlabel{#1}\endcsname\relax % no
> marker defined
>        \global\expandafter\let\csname\xrlabel{#1}\endcsname\empty %
> define it
>        \csname\xrlabel{#1:long}\endcsname % produce the long ref
>      \else % the marker already defined
>        \csname\xrlabel{#1:short}\endcsname % produce the short ref
>      \fi
>    }
>
>
> \book
> {first book (long reference)}
> {first book (short ref)}
> {firstbook}
>
> \book
> {article in \string\xrefn{firstbookfull}}
> {article (short ref)}
> {article}
>
> \bookref{firstbook} % a long first reference
>
> \bookref{firstbook} % a short second reference
>
> \bookref{article} % a long reference to article in first book
>
> \bookref{article} % a short reference
> %----------------------------%<--------------------------
>
> so that the macro \book also prints the book title at the place
> where it appears?
>
> If I do something like:
>
> \def\book#1#2#3{%
> #1
>      \definexref{#3:long}{#1}{}%
>      \definexref{#3:short}{#2}{}%
>      \definexref{#3full}{#1}{}%
>      }
>
> then it prints \xrefnfirstbookfull because of the preceding \string
> (which is needed to suppress expansion of \xrefn).
>
> Hope this is clear.
>
> TIA
> Adam.

Would it not be simpler to just define three separate text fields?
-- 
John Culleton, 
 typesetting and indexing http://wexfordpress.com
book sales http://wexfordpress.net
Free  barcode: http://www.tux.org/~milgram/bookland/



More information about the tex-eplain mailing list