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.

Given a file xref-and-value.texi with contents:

\input texinfo @c -*- TeX-PDF-mode: t; -*-
@setfilename xref-and-value.info
@settitle @code{@@xref} and @code{@@value} in \pdftex

@set fngccint gccint-4.6
@xref{Top,,Introduction, @value{fngccint}, GNU Compiler Collection (GCC) Internals}.
@bye

I get this output from pdfTeX:

This is pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009/Debian) (format=pdftex 2012.2.28)  5 MAR 2012 17:13
entering extended mode
 %&-line parsing enabled.
**\input xref-and-value.texi
(./xref-and-value.texi (/usr/share/texmf/tex/texinfo/texinfo.tex
Loading texinfo [version 2008-04-18.10]:

...

 formatting,
\defaultparindent=\dimen46
 and turning on texinfo input format.)
(./xref-and-value.aux)
\openout1 = `xref-and-value.aux'.

@cpindfile=@write2
@fnindfile=@write3
@vrindfile=@write4
@tpindfile=@write5
@kyindfile=@write6
@pgindfile=@write7

! TeX capacity exceeded, sorry [input stack size=5000].
@makevalueexpandable ->@let @value
                                   = @expandablevalue @catcode `@-=@other @c...

@value ->@begingroup @makevalueexpandable
                                          @valuexxx
@makevalueexpandable ->@let @value
                                   = @expandablevalue @catcode `@-=@other @c...

@value ->@begingroup @makevalueexpandable
                                          @valuexxx
@makevalueexpandable ->@let @value
                                   = @expandablevalue @catcode `@-=@other @c...

@value ->@begingroup @makevalueexpandable
                                          @valuexxx
...
l.6 ...}, GNU Compiler Collection (GCC) Internals}
                                                  .
If you really absolutely need more capacity,
you can ask a wizard to enlarge me.

!  ==> Fatal error occurred, no output PDF file produced!

(This is a known limitation of texinfo.tex.)

So, it looks like the 4th argument to @xref is being used in an expand-only context, but that @value isn't (usefully) expandable.

Can the @set/@value facility be re-implemented such that @value is expandable?


Update:

In response to Bruno's comment about @expandablevalue, I tried this:

\errorcontextlines 100 \input texinfo @c -*- TeX-PDF-mode: t; -*-

@setfilename xref-and-value.info
@settitle @code{@@xref} and @code{@@value} in \pdftex

@set fngccint gccint-4.6
@xref{Top,,Introduction, @expandablevalue{fngccint}, GNU Compiler Collection (GCC) Internals}.
@bye

This at least manages to typeset, but still generates errors:

! Argument of @expandablevalue has an extra }.
<inserted text>
                @par
<to be read again>
                   }
@addtokens ...f @addtoks {@noexpand #1={@the #1#2}
                                                  }@addtoks
@skipspaces ...@else @addtokens {@filename }{@PP }
                                                  @advance @filenamelength b...
<argument>  @expandablevalue
                             {fngccint}
@getfilename ...ngth =0@expandafter @skipspaces #1
                                                  |@relax
@xrefX ...nofonts @turnoffactive @getfilename {#4}
                                                  {@activebackslashdouble @x...
l.7 ...}, GNU Compiler Collection (GCC) Internals}
                                                  .
I've run across a `}' that doesn't seem to match anything.
For example, `\def\a#1{...}' and `\a}' would produce
this error. If you simply proceed now, the `\par' that
I've just inserted will cause me to report a runaway
argument that might be the root of the problem. But if
your `}' was spurious, just type `2' and it will go away.

Runaway argument?
! Paragraph ended before @expandablevalue was complete.
<to be read again>
                   @par
<to be read again>
                   }
@addtokens ...f @addtoks {@noexpand #1={@the #1#2}
                                                  }@addtoks
@skipspaces ...@else @addtokens {@filename }{@PP }
                                                  @advance @filenamelength b...
<argument>  @expandablevalue
                             {fngccint}
@getfilename ...ngth =0@expandafter @skipspaces #1
                                                  |@relax
@xrefX ...nofonts @turnoffactive @getfilename {#4}
                                                  {@activebackslashdouble @x...
l.7 ...}, GNU Compiler Collection (GCC) Internals}
                                                  .
I suspect you've forgotten a `}', causing me to apply this
control sequence to too much text. How can we recover?
My plan is to forget the whole thing and hope for the best.
share|improve this question
    
It seems @expandablevalue is meant as an expandable version of @value. But I'm too lazy to dig carefully. (And somewhat disturbed by the choice of @ as an escape character.) –  Bruno Le Floch Mar 5 '12 at 23:26
    
@BrunoLeFloch: Hmm, doesn't quite seem to work. (And at least texinfo.tex isn't full of @!) –  SamB Mar 6 '12 at 1:54
    
Yay, a Texinfo question! –  Andrey Vihrov Mar 6 '12 at 7:53

2 Answers 2

up vote 4 down vote accepted

The fourth argument of @xref is parsed as a filename by @getfilename (to see that, look for #4 in the log output of @show@xref). This function reads its argument one macro parameter at a time, and expands those independently. When receiving @expandablevalue{fngccint}, it will first read @expandablevalue and try to expand it (within an @edef), but fail because {fngccint} is not within that @edef.

A solution is to put braces around @expandablevalue{fngccint}: then it is grabbed as one macro parameter, and the expansion works.

\errorcontextlines 100 \input texinfo @c -*- TeX-PDF-mode: t; -*-

@setfilename xref-and-value.info
@settitle @code{@@xref} and @code{@@value} in \pdftex

@set fngccint gccint-4.6
@xref{Top,,Introduction, {@expandablevalue{fngccint}}, GNU Compiler Collection (GCC) Internals}.
@bye
share|improve this answer
    
Oh, good catch! I had realized that \getfilename/\skipspaces effectively looped over the input token list item-by-item, but somehow missed the fact that this was reckoned before macro-expansion. I wonder if I can figure out how to change it to expand macros as it goes... –  SamB Mar 8 '12 at 18:45
    
The immensely useful \expandafter\foo\romannumeral-`q construction is your friend then (nothing special about the character q here). Due to subtleties of TeX's grammar, -`q is an incomplete (negative) number: it can be followed by an optional space. Hence, TeX continues looking ahead, expanding tokens as it goes, until finding a space or a nonexpandable token. The big drawback of this command is that is loses spaces. –  Bruno Le Floch Mar 8 '12 at 19:54

By the way, if anyone runs into this problem in the future, it's been fixed in texinfo.tex, so you can just grab the latest texinfo.tex and use that. (This is actually what upstream suggests that everyone do; just search for texinfo.tex on the Texinfo webpage)

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.