Ross Boylan wrote: > On Mon, 2005-11-21 at 10:27 +0000, Hin-Tak Leung wrote: > >>Kurt Hornik wrote: >><snipped> >> >>>Definitely a problem in Rdconv. >>> >>>E.g., >>> >>>$ cat foo.Rd >>>\description{ >>> \eqn{{A}}{B} >>>} >>>[EMAIL PROTECTED]:~/tmp$ R-d CMD Rdconv -t latex foo.Rd | grep eqn >>>\eqn{{A}}{A}{{B} >>> >>>shows what is going on. >> >>There is a "work-around" - putting extra spaces between the two braces: >> >>$ cat foo.Rd >>\description{ >> \eqn{ {A} }{B} >>} >> >>$R CMD Rdconv -t latex foo.Rd >>\HeaderA{}{}{} >>\begin{Description}\relax >>\eqn{ {A} }{B} >>\end{Description} >> >> >>HT > > Terrific! I can confirm that works for me and, in a way, a work-around > is better than a fix. With the work-around, I can distribute the > package without needing to require that people get some not-yet-release > version of R that fixes the problem. I do hope the problem gets fixed > though :) > > By the way, I couldn't see how the perl code excerpted earlier paid any > attention to {}. But perl is not my native tongue. > > Ross >
Glad to hear - the extra space in the latex-eqn-processed part of \eqn (versus the ascii part) possibly get skipped so there shouldn't be visual difference if it works. Regarding the perl code - "share/perl/R/Rdconv.pm" around line 400 - reproduced again here - the way I understand it, "\eqn{{a}}{b}" is first transformed into something like "\eqnbraces1brace2abrace2brace1brace1bbrace1", then called as "get_arguments {'eqn', ..., 2}", which then tries to extract "a" and "b". $ID is defined elsewhere to be "brace1", etc. That's the idea. The 4 regular expressions - the 1st, 2nd and the 4th probably should be non-greedy (i.e. "??" instead of "?", and ".*?" instead of ".*"). But then, this is just my idea and I haven't tried very hard to figure out what it is supposed and not supposed to do... For those who wants to get to the bottom of it, I think inserting something like this (this just append $text into a tmp file) would be useful, against the small snipplet that Kurt provided: open(JUNK, ">> /tmp/junk"); print JUNK "outer/inner loop:", $text, "\n"; close(JUNK); HT ======================= ## Get the arguments of a command. sub get_arguments { my ($command, $text, $nargs) = @_; ## Arguments of get_arguments: ## 1, command: next occurence of 'command' is searched ## 2, text: 'text' is the text containing the command ## 3, nargs: the optional number of arguments to be extracted; ## default 1 my @retval; ## Returns a list with the id of the last closing bracket and the ## arguments. if($text =~ /\\($command)(\[[^\]]+\])?($ID)/){ $id = $3; $text =~ /$id(.*)$id/s; $retval[1] = $1; my $k=2; while(($k<=$nargs) && ($text =~ /$id($ID)/)){ $id = $1; $text =~ /$id\s*(.*)$id/s; $retval[$k++] = $1; } } $retval[0] = $id; @retval; } ================== HT ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel