Friday, June 25, 2010

fancyvrb package in LaTeX

In order to insert a code snippet (e.g. from R) into a LaTeX document, one could use a "verbatim" environment (e.g. with \begin{verbatim} and \end{verbatim}). This works, but isn't very customizable, e.g. cant' change font or fontsize easily.

Instead, download a package called fancyvrb. The manual is at  For example (and note capital V in Verbatim):


  function(X, tol = sqrt(.Machine$double.eps)) {
    ## Generalized Inverse of a Matrix
    dnx <- dimnames(X)
    if(is.null(dnx)) dnx <- vector("list", 2)
    s <- svd(X)
    nz <- s$d > tol * s$d[1]
      if(any(nz)) s$v[, nz] %*% (t(s$u[, nz])/s$d[nz]) else X,
      dimnames = dnx[2:1])


To install a LaTeX package (at least in my setup of WinEdt + MikTeX under Windows), do the following:
- Got to MikTeX Package Manager
- Wait for it to update the list of available packages
- Find the one you want to install, and double click on it.

No comments:

Post a Comment

Subscribe via email

Enter your email address:

Delivered by FeedBurner


Blog Archive

google analytics