knitr-hook_plot_tex

Here are the examples of the r api knitr-hook_plot_tex taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1 Examples 7

19 File: knitting.R, author: agoldst, license: MIT License

 plot_hook_textpos  < - function(x, options) { 

     inside  < - options$inside_textblock 

     pos  < - options$textblock_pos 

     b  < - "" 

     e  < - "" 

     if (is.null(inside)) { 

         inside  < - F 

     } 

     if (is.numeric(options$textblock_width) || inside) { 

         if (!inside && is.numeric(pos) && length(pos) == 2) { 

             b  < - paste0("\\begin{textblock}{", options$textblock_width,  

                 "}(", pos[1], ",", pos[2], ")\n") 

             e  < - "\\end{textblock}\n" 

         } 

         if (!is.null(options$center) && options$center) { 

             b  < - paste0(b, "\\begin{center}\n") 

             e  < - paste0("\n\\end{center}", e) 

         } 

         if (is.null(options$out.width) && is.null(options$out.height)) { 

             opt  < - "" 

         } 

         else if (is.null(options$out.width)) { 

             opt  < - paste0("[height=", options$out.height, "\\TPVertModule]") 

         } 

         else if (is.null(options$out.height)) { 

             opt  < - paste0("[width=", options$out.width, "\\TPHorizModule]") 

         } 

         else { 

             opt  < - paste0("[width=", options$out.width, "\\TPHorizModule],",  

                 "[height=", options$out.height, "\\TPVertModule]") 

         } 

         base_url  < - opts_knit$get("base.url") 

         if (is.null(base_url)) { 

             base_url  < - "" 

         } 

         gfx  < - paste0("\\includegraphics", opt, "{", base_url,  

             x, "}\n") 

         paste0(b, gfx, e) 

     } 

     else { 

         knitr::hook_plot_tex(x, options) 

     } 

 } 

Categories r Tags