### Awesome Table Example with Collapse Rows and Styling in LaTeX Source: https://github.com/haozhu233/kableextra/blob/master/tests/testthat/_snaps/row_spec.md A comprehensive example demonstrating advanced table customization in LaTeX. It includes collapsing rows based on column values, applying bold text, specific column widths, row colors, and using `booktabs` for a professional look. ```R kbl(collapse_rows_dt[-1], align = "c", booktabs = T, format = "latex") %>% column_spec(1, bold = T, width = "5em") %>% row_spec(c(1:7, 11:12) - 1, extra_latex_after = "\\rowcolor{gray!6}") %>% collapse_rows(1, latex_hline = "none") ``` -------------------------------- ### Initialize kableExtra and Load Data (R) Source: https://github.com/haozhu233/kableextra/blob/master/docs/kableExtra_in_other_HTML_themes.html Loads the necessary libraries (knitr and kableExtra) and prepares a subset of the mtcars dataset for table rendering. This is a prerequisite for most kableExtra examples. ```r library(knitr) library(kableExtra) dt <- mtcars[1:5, 1:6] ``` -------------------------------- ### Install kableExtra Package Source: https://github.com/haozhu233/kableextra/blob/master/README.md Provides R code to install the kableExtra package from CRAN or the development version from GitHub. ```r install.packages("kableExtra") # For dev version devtools::install_github("haozhu233/kableExtra") ``` -------------------------------- ### Basic Table Generation with kableExtra Source: https://github.com/haozhu233/kableextra/blob/master/README.md Demonstrates the basic usage of kableExtra to create styled HTML and LaTeX tables. It uses the kbl() function (an alternative to kable()) and pipes %>% to apply styling, add headers, and footnotes. The examples show options for both HTML and LaTeX output formats. ```r library(kableExtra) dt <- mtcars[1:5, 1:4] # HTML table kbl(dt, caption = "Demo Table") %>% kable_styling(bootstrap_options = "striped", full_width = F) %>% add_header_above(c(" ", "Group 1" = 2, "Group 2[note]" = 2)) %>% footnote(c("table footnote")) # LaTeX Table kbl(dt, booktabs = T, caption = "Demo Table") %>% kable_styling(latex_options = c("striped", "hold_position"), full_width = F) %>% add_header_above(c(" ", "Group 1" = 2, "Group 2[note]" = 2)) %>% footnote(c("table footnote")) ``` -------------------------------- ### LaTeX Table Styling Source: https://github.com/haozhu233/kableextra/blob/master/tests/testthat/_snaps/bugfix.md This example demonstrates how to style a LaTeX table using `kableextra`, applying options like 'striped' for alternating row colors and 'hold_position' to control table placement. ```APIDOC ## POST /kableextra/latex_styling ### Description This endpoint generates a LaTeX table with specific styling options applied using the `kableextra` package. It includes options for striping rows and controlling the table's position within the document. ### Method POST ### Endpoint /kableextra/latex_styling ### Parameters #### Request Body - **data** (data.frame) - The input data frame to be rendered as a LaTeX table. - **caption** (string) - The caption for the table. - **format** (string) - The output format, expected to be "latex". - **latex_options** (list) - A list of LaTeX specific options, such as "striped" and "hold_position". ### Request Example ```json { "data": "mtcars[1:3, 1:4]", "caption": "Demo table", "format": "latex", "latex_options": ["striped", "hold_position"] } ``` ### Response #### Success Response (200) - **latex_code** (string) - The generated LaTeX code for the styled table. #### Response Example ```json { "latex_code": "\\begin{table}[!h]\n \\centering\n \\caption{Demo table}\\centering\n \\begin{tabular}[t]{lrrrr}\n \\toprule\n & mpg & cyl & disp & hp\\\n \\midrule\n \\cellcolor{gray!10}{Mazda RX4} & \\cellcolor{gray!10}{21.0} & \\cellcolor{gray!10}{6} & \\cellcolor{gray!10}{160} & \\cellcolor{gray!10}{110}\\ Mazda RX4 Wag & 21.0 & 6 & 160 & 110\\\n \\cellcolor{gray!10}{Datsun 710} & \\cellcolor{gray!10}{22.8} & \\cellcolor{gray!10}{4} & \\cellcolor{gray!10}{108} & \\cellcolor{gray!10}{93}\\ \\bottomrule\n \\end{tabular}\n \\end{table}" } ``` ``` -------------------------------- ### Full-Width LaTeX Table Styling with kableextra Source: https://github.com/haozhu233/kableextra/blob/master/tests/testthat/_snaps/column_spec.md This example shows how to create a full-width LaTeX table using kableextra, with a specified width for the first column. It utilizes piping to chain kable, kable_styling, and column_spec functions. This requires the kableextra and dplyr packages for piping. ```R kbl(dt, format = "latex", booktabs = TRUE) %>% kable_styling(full_width = TRUE) %>% column_spec(1, width = "8cm") ``` -------------------------------- ### Include Stylesheet for Epub Output Source: https://github.com/haozhu233/kableextra/blob/master/docs/bookdown/use-bootstrap-tables-in-gitbooks-epub.html For Epub output, custom CSS cannot be loaded via HTML dependency. This example shows how to manually load a stylesheet by placing it in a CSS file (e.g., 'style.css') and referencing it in the _output.yml file. ```yaml bookdown::epub_book: stylesheet: style.css ``` -------------------------------- ### Custom Rule Widths and Footnotes Source: https://github.com/haozhu233/kableextra/blob/master/tests/testthat/_snaps/bugfix.md Demonstrates how to apply custom line thicknesses to table rules (toprule, midrule, bottomrule, linesep) and add footnotes using the kableextra package. This example also shows how to add headers above columns with custom spanning. ```APIDOC ## POST /kableextra/custom_rules_footnotes ### Description This endpoint showcases the use of `kableextra` to create tables with custom rule widths and add footnotes. It includes advanced styling like repeating header text and grouping columns under custom headers. ### Method POST ### Endpoint /kableextra/custom_rules_footnotes ### Parameters #### Request Body - **data** (data.frame) - The input data frame to be rendered as a table. - **caption** (string) - The caption for the table. - **toprule_width** (string) - The thickness of the top rule (e.g., "4pt"). - **midrule_width** (string) - The thickness of the middle rule (e.g., "3pt"). - **bottomrule_width** (string) - The thickness of the bottom rule (e.g., "5pt"). - **linesep_width** (string) - The thickness of the line separator (e.g., "2pt"). - **footnotes** (list) - A list of footnotes to be added to the table. - **header_groups** (list) - A list defining custom header groups and their column spans. ### Request Example ```json { "data": "mtcars[1:3, 1:4]", "caption": "kable vary line thickness", "toprule_width": "4pt", "midrule_width": "3pt", "bottomrule_width": "5pt", "linesep_width": "2pt", "footnotes": ["The footnote", "Another footnote"], "header_groups": [{"Group 1": 2}, {"Group 2": 2}] } ``` ### Response #### Success Response (200) - **html_table** (string) - The generated HTML table with custom styling. #### Response Example ```json { "html_table": "
kable vary line thickness
Group 1
Group 2
mpg cyl disp hp
Mazda RX4 21.0 6 160 110
Mazda RX4 Wag 21.0 6 160 110
Datsun 710 22.8 4 108 93
a The footnote
Another footnote
" } ``` ``` -------------------------------- ### Custom Cell Styling with kableExtra Source: https://github.com/haozhu233/kableextra/blob/master/docs/bookdown/01-cross-format.md This example shows how to apply custom styling to individual cells in an R data frame using kableExtra. It demonstrates bolding, color scaling based on values, font size adjustments, and background color for specific columns. ```APIDOC ## Custom Cell Styling with kableExtra ### Description This example demonstrates how to apply custom styling to individual cells in an R data frame using the `kableExtra` package. It includes applying bold text, color scaling based on numeric values, adjusting font sizes, and setting background colors for specific columns. ### Method R Code ### Endpoint N/A (This is an R code example, not an API endpoint) ### Parameters N/A ### Request Example ```r library(dplyr) library(kableExtra) options(kableExtra.html.bsTable = T) iris[1:10, ] %>% mutate_if(is.numeric, function(x) { cell_spec(x, bold = T, color = spec_color(x, end = 0.9), font_size = spec_font_size(x)) }) %>% mutate(Species = cell_spec( Species, color = "white", bold = T, background = spec_color(1:10, end = 0.9, option = "A", direction = -1) )) %>% kable(escape = F, align = "c", booktabs = T) %>% kable_styling(c("striped", "condensed"), latex_options = "striped", full_width = F) ``` ### Response #### Success Response (200) Displays an HTML table with styled cells. The numeric columns have values in bold, color-scaled text, and adjusted font sizes. The 'Species' column has white bold text with a background color scaled based on the row number. #### Response Example ```html
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
5.1 3.5 1.4 0.2 setosa
4.9 3 1.4 0.2 setosa
4.7 3.2 1.3 0.2 setosa
4.6 3.1 1.5 0.2 setosa
5 3.6 1.4 0.2 setosa
5.4 3.9 1.7 0.4 setosa
4.6 3.4 1.4 0.3 setosa
5 3.4 1.5 0.2 setosa
4.4 2.9 1.4 0.2 setosa
5 3.0 1.6 0.2 setosa
``` ``` -------------------------------- ### Create Tables with kbl() and Basic Styling Source: https://context7.com/haozhu233/kableextra/llms.txt Demonstrates the basic usage of the kbl() function to create HTML and LaTeX tables. It shows how to set captions, specify formats, and apply initial styling using kable_styling(). ```r library(kableExtra) # Basic HTML table dt <- mtcars[1:5, 1:6] kbl(dt, caption = "Motor Trend Car Road Tests") %>% kable_styling() # LaTeX table with booktabs kbl(dt, format = "latex", booktabs = TRUE, caption = "Motor Trend Car Road Tests", longtable = FALSE) %>% kable_styling(latex_options = "striped") # Table with custom column alignment and formatting kbl(dt, format = "html", digits = 2, col.names = c("MPG", "Cylinders", "Displacement", "HP", "Rear Axle", "Weight"), align = c("l", "c", "c", "r", "r", "r"), caption = "Car Statistics Summary") ``` -------------------------------- ### Initialize Gitbook with Custom Options Source: https://github.com/haozhu233/kableextra/blob/master/docs/bookdown/use-bootstrap-tables-in-gitbooks-epub.html This JavaScript snippet demonstrates how to initialize gitbook with specific configurations, including sharing options, font settings, download links, and table of contents behavior. This is typically used within a Bookdown project. ```javascript gitbook.require(["gitbook"], function(gitbook) { gitbook.start({ "sharing": { "github": false, "facebook": true, "twitter": true, "google": false, "linkedin": false, "weibo": false, "instapper": false, "vk": false, "all": ["facebook", "google", "twitter", "linkedin", "weibo", "instapaper"] }, "fontsettings": { "theme": "white", "family": "sans", "size": 2 }, "edit": { "link": null, "text": null }, "download": ["bookdown_example.pdf", "bookdown_example.epub"], "toc": { "collapse": "subsection" } }); }); ``` -------------------------------- ### add_footnote Function Documentation Source: https://github.com/haozhu233/kableextra/blob/master/docs/legacy_features.html Documentation for the legacy `add_footnote` function in kableExtra, including examples of its usage with different notation systems and in-table markers. ```APIDOC ## add_footnote Function ### Description This function is a legacy feature of the kableExtra package. While it will be maintained for its unique ability to add page footnotes to long tables, it is generally recommended to use the newer `footnote()` function for more flexibility. ### Notation Systems This function supports different notation systems for footnotes: 'number', 'alphabet', and 'symbol'. #### Alphabet Notation Example ```R library(knitr) library(kableExtra) dt <- mtcars[1:5, 1:6] kable(dt, "html") %>% kable_styling("striped") %>% add_footnote(c("Footnote 1", "Have a good day."), notation = "alphabet") ``` #### Number Notation Example ```R library(knitr) library(kableExtra) dt <- mtcars[1:5, 1:6] kable(dt, "html") %>% kable_styling("striped") %>% add_footnote(c("Footnote 1", "Have a good day."), notation = "number") ``` #### Symbol Notation Example ```R library(knitr) library(kableExtra) dt <- mtcars[1:5, 1:6] kable(dt, "html") %>% kable_styling("striped") %>% add_footnote(c("Footnote 1", "Footnote 2", "Footnote 3"), notation = "symbol") ``` ### In-table Markers The `add_footnote()` function can transform `[note]` text into in-table footnote markers. #### In-table Markers Example ```R library(knitr) library(kableExtra) dt <- mtcars[1:5, 1:6] kable(dt, "html", caption = "Demo Table[note]") %>% kable_styling("striped") %>% add_header_above(c(" ", "Group 1[note]" = 3, "Group 2[note]" = 3)) %>% add_footnote(c("This table is from mtcars", "Group 1 contains mpg, cyl and disp", "Group 2 contains hp, drat and wt"), notation = "symbol") ``` ### Parameters * **footnotes** (character vector) - The text for each footnote. * **notation** (character) - The notation system to use ('number', 'alphabet', 'symbol'). Defaults to 'symbol'. * **page_number** (logical) - Whether to add page numbers to footnotes (for long tables). Defaults to FALSE. * **short** (logical) - Whether to use short footnotes. Defaults to FALSE. ### Response Example (Conceptual) The function modifies the kable output to include footnotes as specified by the notation and content provided. The exact output is HTML or LaTeX code representing the table with footnotes. ``` -------------------------------- ### Drag and Select Event Handling Source: https://github.com/haozhu233/kableextra/blob/master/docs/using_kableExtra_in_radix.html Functions to manage drag start events and prevent text selection during drag operations, ensuring a smooth user experience. ```JavaScript function xn(){cr.stopImmediatePropagation()} function kn(e,t,n,a,i,d,r,o,l,s){this.target=e,this.type=t,this.subject=n,this.identifier=a,this.active=i,this.x=d,this.y=r,this.dx=o,this.dy=l,this._=s} function vn(){return!cr.button} function wn(e,t){var n=e.document.documentElement,a=wr(e).on('dragstart.drag',null);t&&(a.on('click.drag',_r,!0),setTimeout(function(){a.on('click.drag',null)},0)),'onselectstart'in n?a.on('selectstart.drag',null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)} ``` -------------------------------- ### Create and Style HTML Table with kableExtra Source: https://context7.com/haozhu233/kableextra/llms.txt Demonstrates how to create an HTML table using kable, apply Bootstrap styling, and customize row appearance with bold text, white color, and a specific background. It also shows how to save the styled table to an HTML file. ```r library(kableExtra) table <- kbl(dt, format = "html") %>% kable_styling(bootstrap_options = "striped") %>% row_spec(1, bold = TRUE, color = "white", background = "#336699") save_kable(table, "table_output.html", self_contained = TRUE) ``` -------------------------------- ### Initialize GitBook Configuration Source: https://github.com/haozhu233/kableextra/blob/master/docs/bookdown/index.html This JavaScript snippet initializes the GitBook environment with specific sharing, font, and download settings. It requires the gitbook library to be loaded and provides a structured object to define UI behavior and available export formats. ```javascript gitbook.require(["gitbook"], function(gitbook) { gitbook.start({ "sharing": { "github": false, "facebook": true, "twitter": true, "google": false, "linkedin": false, "weibo": false, "instapper": false, "vk": false, "all": ["facebook", "google", "twitter", "linkedin", "weibo", "instapaper"] }, "fontsettings": { "theme": "white", "family": "sans", "size": 2 }, "edit": { "link": null, "text": null }, "download": ["bookdown_example.pdf", "bookdown_example.epub"], "toc": { "collapse": "subsection" } }); }); ``` -------------------------------- ### Initialize UI Components Source: https://github.com/haozhu233/kableextra/blob/master/docs/plots_in_tables.html JavaScript snippets to initialize tabset dropdowns and dynamically load MathJax for rendering mathematical expressions. ```JavaScript $(document).ready(function () { window.buildTabsets("TOC"); }); $(document).ready(function () { $('.tabset-dropdown > .nav-tabs > li').click(function () { $(this).parent().toggleClass('nav-tabs-open') }); }); (function () { var script = document.createElement("script"); script.type = "text/javascript"; script.src = "https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"; document.getElementsByTagName("head")[0].appendChild(script); })(); ``` -------------------------------- ### Group Rows in Tables Source: https://github.com/haozhu233/kableextra/blob/master/docs/kableExtra_in_other_HTML_themes.html Uses the pack_rows function to group specific rows under a label. This example shows basic grouping and how to apply custom CSS to the group label row. ```R kable(mtcars[1:10, 1:6], caption = "Group Rows") %>% kable_styling("striped", full_width = F) %>% pack_rows("Group 1", 4, 7) %>% pack_rows("Group 2", 8, 10) kable(dt) %>% kable_styling("striped", full_width = F) %>% pack_rows("Group 1", 3, 5, label_row_css = "background-color: #666; color: #fff;") ``` -------------------------------- ### Handle CSS Property Hooks Source: https://github.com/haozhu233/kableextra/blob/master/docs/new_html_themes.html jQuery uses cssHooks to normalize browser-specific CSS properties like opacity and margin. This allows for consistent cross-browser behavior when setting or getting style values. ```javascript m.cssHooks.opacity = { get: function(a, b) { return Na.test((b && a.currentStyle ? a.currentStyle.filter : a.style.filter) || "") ? .01 * parseFloat(RegExp.$1) + "" : b ? "1" : ""; }, set: function(a, b) { var c = a.style, d = a.currentStyle, e = m.isNumeric(b) ? "alpha(opacity=" + 100 * b + ")" : ""; c.zoom = 1; c.filter = Ma.test(f) ? f.replace(Ma, e) : f + " " + e; } }; ``` -------------------------------- ### Initialize kableExtra and Dependencies Source: https://github.com/haozhu233/kableextra/blob/master/docs/plots_in_tables.html Loads the necessary R libraries for table manipulation, plotting, and data processing. ```R library(kableExtra) library(plotly) library(sparkline) library(tidyverse) ``` -------------------------------- ### Apply Row Alignment in LaTeX Table Source: https://github.com/haozhu233/kableextra/blob/master/tests/testthat/_snaps/row_spec.md Illustrates how to set the alignment for specific rows in a LaTeX table using the `align` argument in the `row_spec` function. This example shows applying different alignments to multiple rows. ```R row_spec(row_spec(kbl(df, format = "latex"), 1, align = "r"), 2, align = "c") ``` -------------------------------- ### Initialize kableExtra for table generation Source: https://github.com/haozhu233/kableextra/blob/master/docs/bookdown/01-cross-format.md This snippet demonstrates the necessary library imports required to begin building tables with kableExtra and dplyr in an R environment. ```r library(kableExtra) library(dplyr) ``` -------------------------------- ### Initialize jQuery Animation Tween Source: https://github.com/haozhu233/kableextra/blob/master/docs/new_html_themes.html The Za function and its prototype define the core tweening engine in jQuery. It manages the start, end, and current values of an animated property, applying easing functions and step callbacks. ```javascript function Za(a,b,c,d,e){ return new Za.prototype.init(a,b,c,d,e)} m.Tween=Za; Za.prototype = { constructor: Za, init: function(a,b,c,d,e,f) { this.elem=a; this.prop=c; this.easing=e||"swing"; this.options=b; this.start=this.now=this.cur(); this.end=d; this.unit=f||(m.cssNumber[c]?"":"px"); }, run: function(a) { var b, c=Za.propHooks[this.prop]; this.pos = b = m.easing[this.easing](a, this.options.duration*a, 0, 1, this.options.duration); this.now = (this.end-this.start)*b+this.start; if(c && c.set) c.set(this); return this; } }; ``` -------------------------------- ### Create Basic Styled Table with kableExtra Source: https://github.com/haozhu233/kableextra/blob/master/docs/using_kableExtra_in_radix.html This snippet demonstrates how to generate a basic styled table using the kableExtra package. It includes loading the library, creating a data frame, and applying the kable and kable_styling functions. ```R library(kableExtra) df <- head(mtcars) df %>% kable() %>% kable_styling(bootstrap_options = "striped", full_width = F) ``` -------------------------------- ### jQuery Data and Cache Management Source: https://github.com/haozhu233/kableextra/blob/master/docs/using_kableExtra_in_radix.html Provides utilities for managing data associated with DOM elements and general objects using a cache. It includes functions for getting, setting, and removing data, ensuring efficient data handling. ```javascript m.acceptData=function(a){var b=m.noData[(a.nodeName+" ").toLowerCase()],c=+a.nodeType||1;return 1!==c&&9!==c?!1:!b||b!==!0&&a.getAttribute("classid")===b};function O(a,b,c){if(void 0===c&&1===a.nodeType){var d="data-"+b.replace(N,"-$1").toLowerCase();if(c=a.getAttribute(d),"string"==typeof c){try{c="true"===c?!0:"false"===c?!1:"null"===c?null:+c+""===c?+c:M.test(c)?m.parseJSON(c):c}catch(e){}m.data(a,b,c)}else c=void 0}return c}function P(a){var b;for(b in a)if(("data"!==b||!m.isEmptyObject(a[b]))&&"toJSON"!==b)return!1; return!0}function Q(a,b,d,e){if(m.acceptData(a)){var f,g,h=m.expando,i=a.nodeType,j=i?m.cache:a,k=i?a[h]:a[h]&&h;if(k&&j[k]&&(e||j[k].data)||void 0!==d||"string"!=typeof b)return k||(k=i?a[h]=c.pop()||m.guid++:h),j[k]||(j[k]=i?{}:{"tojson":m.noop}),("object"==typeof b||"function"==typeof b)&&(e?j[k]=m.extend(j[k],b):j[k].data=m.extend(j[k].data,b)),g=j[k],e||(g.data||(g.data={}),g=g.data),void 0!==d&&(g[m.camelCase(b)]=d),"string"==typeof b?(f=g[b],null==f&&(f=g[m.camelCase(b)])):f=g,f}}function R(a,b,c){if(m.acceptData(a)){var d,e,f=a.nodeType,g=f?m.cache:a,h=f?a[m.expando]:m.expando;if(g[h]){if(b&&(d=c?g[h]:g[h].data)){m.isArray(b)?b=b.concat(m.map(b,m.camelCase)):b in d?b=[b]:(b=m.camelCase(b),b=b in d?[b]:b.split(" ")),e=b.length;while(e--)delete d[b[e]];(c||!P(d))&&(f?m.cleanData([a],!0):k.deleteExpando||g!=g.window?delete g[h]:g[h]=null)}}}}m.extend({cache:{},noData:{"applet ":!0,"embed ":!0,"object ":"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"},hasData:function(a){return a=a.nodeType?m.cache[a[m.expando]]:a[m.expando],!!a&&!P(a)},data:function(a,b,c){return Q(a,b,c)},removeData:function(a,b){return R(a,b)},"_data":function(a,b,c){return Q(a,b,c,!0)},"_removeData":function(a,b){return R(a,b,!0)}}),m.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(thi ``` -------------------------------- ### Set Font Size for a Row in LaTeX Table Source: https://github.com/haozhu233/kableextra/blob/master/tests/testthat/_snaps/row_spec.md This example illustrates how to adjust the font size for a specific row in a LaTeX table using the `font_size` argument within the `row_spec` function. This allows for highlighting or de-emphasizing certain rows. ```R row_spec(kbl(df, format = "latex"), 3, font_size = 10) ``` -------------------------------- ### Basic Table Formatting with kableextra Source: https://github.com/haozhu233/kableextra/blob/master/docs/plots_in_tables.html Demonstrates fundamental table formatting using kableextra, including adding a caption, specifying column formats, and basic styling. This is useful for creating clean and readable tables in R Markdown documents. ```R library(kableExtra) data(mtcars) kable(mtcars[1:5, ], caption = "Sample Data Table") %>% kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive")) %>% column_spec(1, bold = TRUE, color = "#007bff") %>% column_spec(2:3, background = "#f2f2f2") ``` -------------------------------- ### Create and Save LaTeX Table with Custom Packages Source: https://context7.com/haozhu233/kableextra/llms.txt Shows how to generate a LaTeX table with booktabs styling and save it to a PDF. It includes custom LaTeX header includes for packages like 'booktabs' and 'xcolor', and options to keep the intermediate .tex file. ```r library(kableExtra) latex_table <- kbl(dt, format = "latex", booktabs = TRUE) %>% kable_styling(latex_options = "striped") save_kable(latex_table, "latex_table.pdf", latex_header_includes = c( "\\usepackage{booktabs}", "\\usepackage{xcolor}" ), keep_tex = TRUE) ``` -------------------------------- ### jQuery AJAX Shorthand Methods Source: https://github.com/haozhu233/kableextra/blob/master/docs/plots_in_tables.html jQuery provides convenient shorthand methods for common AJAX requests: `get` for retrieving data, `post` for sending data, `getJSON` for retrieving JSON data, and `getScript` for retrieving and executing JavaScript files. ```javascript m.getJSON = function(a, b, c) { return m.get(a, b, c, "json") }; m.getScript = function(a, b) { return m.get(a, void 0, b, "script") }; m.each(["get", "post"], function(a, b) { m[b] = function(a, c, d, e) { return m.ajax({ url: a, type: b, dataType: e, data: c, success: d }) } }); ``` -------------------------------- ### Implement CSS Property Manipulation and Animation Tweening Source: https://github.com/haozhu233/kableextra/blob/master/docs/using_kableExtra_in_radix.html Provides methods for setting and getting CSS properties with support for opacity filters and shorthand expansion. It also includes a Tween constructor to handle property transitions over time with easing functions. ```javascript m.cssHooks.marginRight = La(k.reliableMarginRight, function(a, b) { return b ? m.swap(a, {display: "inline-block"}, Ja, [a, "marginRight"]) : void 0; }); function Za(a, b, c, d, e) { return new Za.prototype.init(a, b, c, d, e); } m.Tween = Za; Za.prototype = { constructor: Za, init: function(a, b, c, d, e, f) { this.elem = a; this.prop = c; this.easing = e || "swing"; this.options = b; this.start = this.now = this.cur(); this.end = d; this.unit = f || (m.cssNumber[c] ? "" : "px"); }, run: function(a) { var b, c = Za.propHooks[this.prop]; return this.options.duration ? this.pos = b = m.easing[this.easing](a, this.options.duration * a, 0, 1, this.options.duration) : this.pos = b = a, this.now = (this.end - this.start) * b + this.start, this.options.step && this.options.step.call(this.elem, this.now, this), c && c.set ? c.set(this) : Za.propHooks._default.set(this), this; } }; ```