From 1769b85180b12e30c11d4e293cafbd7d0f90737a Mon Sep 17 00:00:00 2001 From: "Cassio M. M. Pereira" Date: Tue, 24 Jul 2012 09:13:41 -0300 Subject: [PATCH 1/2] adding package amsmath in case outdec is not a period --- R/header.R | 1 + 1 file changed, 1 insertion(+) diff --git a/R/header.R b/R/header.R index 34a0f2f370..a029ec4865 100644 --- a/R/header.R +++ b/R/header.R @@ -13,6 +13,7 @@ insert_header = function(doc) { make_header_latex = function() { h = paste(c( '\\usepackage{graphicx, color}', .header.maxwidth, opts_knit$get('header'), + if(getOption('OutDec') != '.') '\\usepackage{amsmath}', if (out_format('latex')) { if (opts_knit$get('use.highlight')) highlight_fun('boxes_latex')() else '\\usepackage{alltt}' } From 7723b2260214d6a171cbdffa5bed137eb99d6822 Mon Sep 17 00:00:00 2001 From: "Cassio M. M. Pereira" Date: Tue, 24 Jul 2012 09:25:07 -0300 Subject: [PATCH 2/2] modifying inline latex hook to account for different decimal separators on numeric inputs --- R/hooks-latex.R | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/R/hooks-latex.R b/R/hooks-latex.R index 36eba4aa3d..20cc549444 100644 --- a/R/hooks-latex.R +++ b/R/hooks-latex.R @@ -129,7 +129,13 @@ hook_plot_tex = function(x, options) { ## inline hook for tex .inline.hook.tex = function(x) { - if (is.numeric(x)) x = format_sci(x, 'latex') + if(is.numeric(x)) { + if(getOption('OutDec') != '.') { + if(!inherits(x, 'AsIs')) x = sprintf('\\text{%s}', format_sci(x, 'latex')) + } else { + x = format_sci(x, 'latex') + } + } .inline.hook(x) } # an example of a chunk hook