[Rd] RFC: Ability to suppress 'locale' from sessionInfo
Kasper Daniel Hansen
khansen at stat.berkeley.edu
Wed Apr 22 21:49:05 CEST 2009
This is a better way, it does two things
a) enclose the itemize environment in a flushleft environment - this
gives us much better line breaks for the verb.
b) does a replace of ";" with ";| \verb|" so that each "component" of
the locale gets enclosed in its own \verb command, which allows latex
to produce line breaks (since I am using gsub, I do gsub(";", ";| \\\
\verb", object$locale))
Below is a proposed utils:::toLatex.sessionInfo
I think it might make sense to have a locale argument, but I would
argue that the default ought to be TRUE.
Kasper
function (object, ...)
{
opkgver <- sapply(object$otherPkgs, function(x) x$Version)
nspkgver <- sapply(object$loadedOnly, function(x) x$Version)
z <- c("\\begin{flushleft}", "\\begin{itemize}", paste(" \\item
", object$R.version$version.string,
", \\verb|", object$R.version$platform, "|", sep = ""),
paste(" \\item Locale: \\verb|", gsub(";", ";| \\\\verb|",
object$locale), "|",
sep = ""), strwrap(paste("\\item Base packages:",
paste(sort(object$basePkgs), collapse = ", ")), indent = 2,
exdent = 4))
if (length(opkgver)) {
opkgver <- opkgver[sort(names(opkgver))]
z <- c(z, strwrap(paste(" \\item Other packages: ",
paste(names(opkgver), opkgver, sep = "~", collapse = ",
")),
indent = 2, exdent = 4))
}
if (length(nspkgver)) {
nspkgver <- nspkgver[sort(names(nspkgver))]
z <- c(z, strwrap(paste(" \\item Loaded via a namespace (and
not attached): ",
paste(names(nspkgver), nspkgver, sep = "~", collapse = ",
")),
indent = 2, exdent = 4))
}
z <- c(z, "\\end{itemize}", "\\end{flushleft}")
class(z) <- "Latex"
z
}
On Apr 22, 2009, at 1:50 , Martin Maechler wrote:
>>>>>> "TobiasV" == Tobias Verbeke <tobias.verbeke at telenet.be>
>>>>>> on Wed, 22 Apr 2009 09:57:30 +0200 writes:
>
> TobiasV> Friedrich Leisch wrote:
>>>>>>>> On Tue, 21 Apr 2009 21:16:59 -0500,
>>>>>>>> Kevin W (KW) wrote:
>>>
>>>> The printing of the locale information from sessionInfo is not
>>>> very tidy.
>>>> Using toLatex(sessionInfo) pretty much guarantees "badness" from
>>>> breaking
>>>> the margin boundary (though my version of TeX no longer reports
>>>> such
>>>> errors). A random example is here:
>>>> http://cran.r-project.org/web/packages/Matrix/vignettes/Design-issues.pdf
>>>
>>>> I find the locale information unnecessary and right now I hack
>>>> this with
>>>> si = sessionInfo()
>>>> si$locale = "US"
>>>> toLatex(si)
>>>
>>>> I would like to be able to do something a bit cleaner, for example
>>>> sessionInfo(locale=FALSE)
>>>
>>>> For what it's worth, I don't think that early versions of
>>>> sessionInfo
>>>> printed information about the locale.
>>>
>>> It went in on 2006-05-26, so it's bben there for some time now.
>>>
>>>
>>>> Discussion welcome.
>>>
>>> I agree that it doesn't look nice in latex documents, but it is very
>>> handy in bug reports.
>>>
>>> Are there any objections if we add a locale argument to the
>>> toLatex()
>>> method and let that default to FALSE?
>
> TobiasV> No objection although I would not be against
> TobiasV> letting it default to TRUE to preserve current behaviour.
>
> I agree with setting the default to keep the current behavior.
> As Fritz mentioned, there situations where the locale
> (information) is of quite some importance. As we know that
> Sweave is used in quite a few circumstances with automatic
> report generation, of which in *some* cases the locale may also
> matter (and is desired to be visible),
>
> I think we should not change the default behavior lightly
> (apart from the extra spaces, see below).
>
> TobiasV> One improvement in the locale information that would
> make the LaTeX look
> TobiasV> much nicer would be to add a space after the separator,
> i.e.
>
> TobiasV> item1; item2; item3
>
> TobiasV> instead of
>
> TobiasV> item1;item2;item3
>
> TobiasV> That is for me more important than having the
> TobiasV> option to include locale info or not
>
> I agree very much; and indeed, adding the space after ";" is
> trivial to achieve in the next version of toLatex()'s
> "sessionInfo" method, as well.
>
> Martin
>
> TobiasV> as without such a change I found no way to prevent the
> locale
> TobiasV> information to run into the margin (and off the
> TobiasV> page) of the resulting LaTeX document and that is
> TobiasV> esthetically much more displeasing than the mere
> TobiasV> presence of the locale information.
>
> TobiasV> Best,
> TobiasV> Tobias
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
More information about the R-devel
mailing list