[R] latex() hangs R console

Yihui Xie xie at yihui.name
Wed Dec 8 03:35:17 CET 2010


I guess I know the answer but I am not completely clear about the
reason; print.latex() calls show.dvi() to open the DVI file using
system(), and under Windows it is usually better using shell() instead
of system(). The help page says shell() is a "friendly" wrapper of
system() under Windows, and this works:

shell(paste("yap", "C:/WINDOWS/TEMP/Rtmpz0QkT8/file311f289a.dvi"))

So if might help to add an additional line for Windows:

if (.Platform$OS.type == 'windows') system = shell

> show.dvi
function (object, width = 5.5, height = 7)
{
    viewer <- optionsCmds("xdvi")
    cmd <- if (viewer == "yap") {
        paste(viewer, object$file)
    }
    else if (viewer == "kdvi") {
        paste(viewer, object$file)
    }
    else if (viewer == "xdvi") {
        paste(viewer, " -paper ", width, "x", height, "in -s 0 ",
            object$file, sep = "")
    }
    else {
        paste(viewer, object$file)
    }
    if (.Platform$OS.type == 'windows') system = shell
    system(cmd, intern = TRUE, wait = TRUE)
    invisible(NULL)
}
<environment: namespace:Hmisc>


Regards,
Yihui
--
Yihui Xie <xieyihui at gmail.com>
Phone: 515-294-2465 Web: http://yihui.name
Department of Statistics, Iowa State University
2215 Snedecor Hall, Ames, IA



On Tue, Dec 7, 2010 at 8:05 PM, Dennis Murphy <djmuser at gmail.com> wrote:
> Hi:
>
> I've experienced the same behavior as Dr. Friendly when trying to use
> latex() in an Sweave code chunk (with results = tex in the chunk header) on
> a Win7 system with 64-bit R (everything up to date). Is the answer the same
> in that case?
>
> TIA for your assistance,
> Dennis
>
> On Tue, Dec 7, 2010 at 9:52 AM, RICHARD M. HEIBERGER <rmh at temple.edu> wrote:
>
>> Michael,
>>
>> The easiest workaround is to assign the result of the latex() command.
>>
>> myfilename <- latex(x)
>> print.default(myfilename)
>>
>>
>> It looks to me like the insides of the dvi.latex function aren't quite
>> right
>> for Windows.
>>
>> Rich
>>
>>        [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list