tex.catwitherror: paste a number with error in tex-ready format

View source: R/tex-utils.R

tex.catwitherrorR Documentation

paste a number with error in tex-ready format


A number with error is converted to a string in tex-ready format like xx(yy) thereby automatically determining the digit at which the error applies.


tex.catwitherror(x, dx, digits = 1, with.dollar = TRUE, with.cdot = TRUE,



either a single numeric value, or a numeric vector, where the first element is the value and the second is its error


the error. If supplied, it will be printed as the error and the value is the first element of x. If dx is missing, the second element of x, if available, is used as the error. If dx is missing and the length of x is one, only the value is converted to a string without error.


number of error digits


include the tex dollar in the return string or not


replace the "e" in scientific notation by tex-style "cdot" or not


arguments to be passed to formatC in case of no error, or to format.errors otherwise


It is strongly recommended to install the errors-package. Otherwise the formatting options are significantly reduced.

The value of the first element of x is properly rounded to its significant digits determined by the values of dx or the second element of x (see above) and digits. Then a tex-ready string is returned.


writes a string to standard output


Carsten Urbach, curbach@gmx.de and Johann Ostmeyer


tex.catwitherror(x=0.375567, dx=0.001)
tex.catwitherror(x=c(0.375567, 0.001))
## it can be used with apply
x = array(c(0.1187, 0.291, 0.388, 0.011, 0.037, 0.021), dim=c(3,2))
apply(x, 1, tex.catwitherror, digits=2)

hadron documentation built on Sept. 9, 2022, 5:06 p.m.