Skip to content

Commit

Permalink
Merge pull request #349 from cmmp/master
Browse files Browse the repository at this point in the history
Work on inline latex numeric input using different decimal separators; closes #348
  • Loading branch information
yihui committed Jul 24, 2012
2 parents 68e8345 + 7723b22 commit ceaa141
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions R/header.R
Original file line number Diff line number Diff line change
Expand Up @@ -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}'
}
Expand Down
8 changes: 7 additions & 1 deletion R/hooks-latex.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ceaa141

Please sign in to comment.