Hmisc (version 2.0-0)

latex: Convert an S object to LaTeX, and Related Utilities

Description

latex converts its argument to a .tex file appropriate for inclusion in a LaTeX2e document. latex is a generic function that calls one of latex.default, latex.function, latex.list.

latex.default does appropriate rounding and decimal alignment and produces a file containing a LaTeX tabular environment to print the matrix or data.frame x as a table.

latex.function prepares an S function for printing by issuing sed commands that are similar to those in the S.to.latex procedure in the s.to.latex package (Chambers and Hastie, 1993).

latex.list calls latex recursively for each element in the argument.

latexTranslate translates particular items in character strings to LaTeX format, e.g., makes a^2 = a$^2$ for superscript within variable labels. Math mode is inserted as needed. latexTranslate assumes that input text always has matches, e.g. [) [] (] (), and that surrounding by $$ is OK.

latexSN converts a vector floating point numbers to character strings using LaTeX exponents. Dollar signs to enter math mode are not added.

latexVerbatim on an object executes the object's print method, capturing the output for a file inside a LaTeX verbatim environment.

dvi uses the system latex command to compile LaTeX code produced by latex, including any needed styles. dvi will put a documentclass{report} and end{document} wrapper around a file produced by latex. By default, the geometry LaTeX package is used to omit all margins and to set the paper size to a default of 5.5in wide by 7in tall. The result of dvi is a .dvi file. To both format and screen display a non-default size, use for example print(dvi(latex(x), width=3, height=4),width=3,height=4). Note that you can use something like xdvi -geometry 460x650 -margins 2.25in file without changing LaTeX defaults to emulate this.

dvips will use the system dvips command to print the .dvi file to the default system printer, or create a postscript file if file is specified.

dvigv uses the system dvips command to convert the input object to a .dvi file, and uses the system dvips command to convert it to postscript. Then the postscript file is displayed using Ghostview (assumed to be the system command gv).

There are show methods for displaying typeset LaTeX on the screen using the system xdvi command. If you show a LaTeX file created by latex without running it through dvi using show.dvi(object), the show method will run it through dvi automatically. These show methods are not S Version 4 methods so you have to use full names such as show.dvi and show.latex. Use the print methods for more automatic display of typesetting, e.g. typing latex(x) will invoke xdvi to view the typeset document.

Usage

latex(object, title=first.word(deparse(substitute(object))), ...)

## S3 method for class 'default': latex(object, title=first.word(expr=substitute(x)), file=paste(title, ".tex", sep=""), append=FALSE, label=title, rowlabel=title, rowlabel.just="l", cgroup=NULL, n.cgroup=NULL, rgroup=NULL, n.rgroup=NULL, rowname=dimnames(x)[[1]], cgroup.just=rep("c",length(n.cgroup)), extracolheads=NULL, extracolsize='scriptsize', dcolumn=FALSE, numeric.dollar=!dcolumn, cdot=FALSE, longtable=FALSE, draft.longtable=TRUE, ctable=FALSE, booktabs=FALSE, table.env=TRUE, here=FALSE, lines.page=40, caption=NULL, caption.lot=NULL, double.slash=FALSE, vbar=FALSE, collabel.just=rep("c",nc), na.blank=TRUE, insert.bottom=NULL, first.hline.double=!(booktabs|ctable), where='!tbp', size=NULL, ...) # x is a matrix or data.frame

## S3 method for class 'function': latex( object, title=first.word(expr=substitute(object)), file=paste(title, ".tex", sep=""), append=FALSE, assignment=TRUE, type=c('example','verbatim'), ...)

## S3 method for class 'list': latex( object, title=first.word(expr=substitute(x)), file=paste(title, ".tex", sep=""), append=FALSE, label, caption, caption.lot, ...) # x is a list. latex is called recursively for each element

## S3 method for class 'latex': print(x, ...)

latexTranslate(object, inn=NULL, out=NULL, pb=FALSE, ...)

latexSN(x)

latexVerbatim(x, title=first.word(expr=substitute(x)), file=paste(title, ".tex", sep=""), append=FALSE, size=NULL, hspace=NULL, width=.Options$width, length=.Options$length, ...)

dvi(object, ...) ## S3 method for class 'latex': dvi(object, prlog=FALSE, nomargins=TRUE, width=5.5, height=7, \dots) ## S3 method for class 'dvi': print(x, \dots) dvips(object, ...) ## S3 method for class 'latex': dvips(object, \dots) ## S3 method for class 'dvi': dvips(object, file, \dots) ## S3 method for class 'latex': show(object) # or show.dvi(object) or just object dvigv(object, ...) ## S3 method for class 'latex': dvigv(object, \dots) # or gvdvi(dvi(object)) ## S3 method for class 'dvi': dvigv(object, \ldots)

Arguments

object
For latex, any S object. For dvi or dvigv, an object created by latex. For latexTranslate is a vector of character strings to translate.
x
any object to be printed verbatim for latexVerbatim. For latexSN x is a numeric vector.
title
name of file to create without the .tex extension.
file
name of the file to create. The default file name is x.tex where x is the first word in the name of the argument for x. Set file="" to have the generated LaTeX code just printed to standard output. Thi
append
defaults to FALSE. Set to TRUE to append output to an existing file.
label
a text string representing a symbolic label for the table for referencing in the LaTeX \label and \ref commands. label is only used if caption is given.
rowlabel
If x has row dimnames, rowlabel is a character string containing the column heading for the row dimnames. The default is the name of the argument for x.
rowlabel.just
If x has row dimnames, specifies the justification for printing them. Possible values are "l", "r", "c". The heading (rowlabel) itself is left justified if rowlabel.just="l", ot
cgroup
a vector of character strings defining major column headings. The default is to have none.
n.cgroup
a vector containing the number of columns for which each element in cgroup is a heading. For example, specify cgroup=c("Major 1","Major 2"), n.cgroup=c(3,3) if "Major 1" is to span columns 1-3 and "Major 2"
rgroup
a vector of character strings containing headings for row groups. n.rgroup must be present when rgroup is given. The first n.rgroup[1] rows are sectioned off and rgroup[1] is used as a bold heading for t
n.rgroup
integer vector giving the number of rows in each grouping. If rgroup is not specified, n.rgroup is just used to divide off blocks of rows by horizontal lines. If rgroup is given but n.rgroup is omitted,
na.blank
Set to TRUE to use blanks rather than NA for missing values. This usually looks better in latex.
insert.bottom
an optional character string to typeset at the bottom of the table. For "ctable" style tables, this is placed in an unmarked footnote.
first.hline.double
set to FALSE to use single horizontal rules for styles other than "bookmark" or "ctable"
rowname
rownames for tabular environment. Default is rownames of matrix or data.frame.
cgroup.just
justification for labels for column groups. Defaults to "c".
extracolheads
an optional vector of extra column headings that will appear under the main headings (e.g., sample sizes). This character vector does not need to include an empty space for any rowname in effect, as this will be added automatically. Y
extracolsize
size for extracolheads or for any second lines in column names; default is "scriptsize"
dcolumn
numeric.dollar
logical, default !dcolumn. Set to TRUE to place dollar signs around numeric values when dcolumn=FALSE. This assures that latex will use minus signs rather than hyphens to indicate negative numbers. S
cdot
longtable
Set to TRUE to use David Carlisle's LaTeX longtable style, allowing long tables to be split over multiple pages with headers repeated on each page. The "style" element is set to "longtable". The la
draft.longtable
I forgot what this does.
ctable
set to TRUE to use Wybo Dekker's ctable style from CTAN. Even though for historical reasons it is not the default, it is generally the preferred method. Thicker but not doubled hlines are used to
booktabs
set booktabs=TRUE to use the booktabs style of horizontal rules for better tables. In this case, double hlines are not used to start a table.
table.env
Set table.env=FALSE to suppress enclosing the table in a LaTeX table environment. table.env only applies when longtable=FALSE. You may not specify a caption if table.env=FALSE
here
Set to TRUE if you are using table.env=TRUE with longtable=FALSE and you have installed David Carlisle's here.sty LaTeX style. This will cause the LaTeX table environment to be set up with o
lines.page
Applies if longtable=TRUE. No more than lines.page lines in the body of a table will be placed on a single page. Page breaks will only occur at rgroup boundaries.
caption
a text string to use as a caption to print at the top of the first page of the table. Default is no caption.
caption.lot
a text string representing a short caption to be used in the "List of Tables". By default, LaTeX will use caption. If you get inexplicable latex errors, you may need to supply caption.lot to make the errors go away.
double.slash
set to TRUE to output \ as \\ in LaTeX commands. Useful when you are reading the output file back into an S vector for later output.
vbar
logical. When vbar==TRUE, columns in the tabular environment are separated with vertical bar characters. When vbar==FALSE, columns are separated with white space. The default, vbar==FALSE, produces tables consisten
collabel.just
justification for column labels.
assignment
logical. When TRUE, the default, the name of the function and the assignment arrow are printed to the file.
where
specifies placement of floats if a table environment is used. Default is "!tbp". To allow tables to appear in the middle of a page of text you might specify where="!htbp" to latex.default.
size
size of table text if a size change is needed (default is no change). For example you might specify size="small" to use LaTeX font size "small".
type
The default uses the S Example environment for latex.function, assuming you have installed S.sty in a location that the system latex command automatically accesses. Set type="verbatim" to instead use th
...
other arguments are accepted and ignored except that latex passes arguments to format.df. For latexVerbatim these arguments are passed to the print function. Ignored for latexTranslate.
inn, out
specify additional input and translated strings over the usual defaults
pb
If pb=TRUE, latexTranslate also translates [()] to math mode using , . hspace{ horizontal space, e.g., extra left margin for verbatim text. Default is none