add escape to footnote;
improve full_width in latex
add latex_table_env to latex
move some latex packages to zzz
update NEWS
diff --git a/DESCRIPTION b/DESCRIPTION
index 3401b12..7bd1cb6 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -4,12 +4,14 @@
 Version: 0.4.0.9001
 Authors@R: c(
     person('Hao', 'Zhu', email = 'haozhu233@gmail.com', role = c('aut', 'cre')),
+    person('Timothy', 'Tsai', role = 'ctb'),
+    person('Thomas', 'Travison', role = 'ctb'),
     person('Will', 'Beasley', email = 'wibeasley@hotmail.com', role = 'ctb'),
     person('Yihui', 'Xie', email = 'xie@yihui.name', role = 'ctb'),
-    person('Thomas', 'Travison', email = 'tgt@hsl.harvard.edu', role = 'ctb'),
     person('GuangChuang', 'Yu', email = 'guangchuangyu@gmail.com', role = 'ctb'),
     person('Stéphane', 'Laurent', role = 'ctb'),
-    person('Rob', 'Shepherd', role = 'ctb')
+    person('Rob', 'Shepherd', role = 'ctb'),
+    person('Yoni', 'Sidi', role = 'ctb')
     )
 Description: A collection of functions to help build complex HTML or 'LaTeX' 
     tables using 'kable()' from 'knitr' and the piping syntax from 'magrittr'. 
diff --git a/R/add_footnote.R b/R/add_footnote.R
index abb618a..ce0a4a9 100644
--- a/R/add_footnote.R
+++ b/R/add_footnote.R
@@ -15,6 +15,8 @@
 #' @param threeparttable Boolean value indicating if a
 #' \href{https://www.ctan.org/pkg/threeparttable}{threeparttable} scheme should
 #' be used.
+#' @param escape Logical value controlling if the label needs to be escaped.
+#' Default is TRUE.
 #'
 #' @examples x <- knitr::kable(head(mtcars), "html")
 #' add_footnote(x, c("footnote 1", "footnote 2"), notation = "symbol")
@@ -22,7 +24,8 @@
 #' @export
 add_footnote <- function(input, label = NULL,
                          notation = "alphabet",
-                         threeparttable = FALSE) {
+                         threeparttable = FALSE,
+                         escape = TRUE) {
   if (is.null(label)) return(input)
 
   if (notation == "alphabet") {
@@ -96,7 +99,9 @@
   # LaTeX Tables --------------------------------
   if (attr(input, "format") == "latex") {
     # Clean the entry for labels
-    label <- escape_latex(label)
+    if (escape) {
+      label <- escape_latex(label)
+    }
     label <- gsub("\\\\", "\\\\\\\\", label)
 
     export <- enc2utf8(export)
@@ -175,8 +180,9 @@
                         "\\\\begin{threeparttable}\n\\\\caption{",
                         export)
         } else {
-          export <- sub("\\\\begin\\{tabular\\}",
-                        "\\\\begin{threeparttable}\n\\\\begin{tabular}",
+          export <- sub(paste0("\\\\begin\\{", table_info$tabular, "\\}"),
+                        paste0("\\\\begin{threeparttable}\n\\\\begin{",
+                               table_info$tabular, "}"),
                         export)
         }
         export <- gsub(
@@ -213,7 +219,9 @@
   if (attr(input, "format") == "html") {
     # Clean the entry for labels
     table_info <- magic_mirror(input)
-    label <- escape_html(label)
+    if (escape) {
+      label <- escape_html(label)
+    }
     # Replace in-table notation with appropriate symbol
     for (i in 1:count.intablenote) {
       export <- sub("\\[note\\]",
diff --git a/R/column_spec.R b/R/column_spec.R
index 409ea0c..a2d89d6 100644
--- a/R/column_spec.R
+++ b/R/column_spec.R
@@ -139,7 +139,7 @@
   kable_align_old <- paste(table_info$align_vector, collapse = align_collapse)
 
   table_info$align_vector[column] <- latex_column_align_builder(
-    table_info$align_vector[column], width, bold, italic, monospace,
+    table_info$align_vector_origin[column], width, bold, italic, monospace,
     color, background, border_left, border_right)
 
   kable_align_new <- paste(table_info$align_vector, collapse = align_collapse)
diff --git a/R/kable_as_image.R b/R/kable_as_image.R
index 34eaf3d..d01d941 100644
--- a/R/kable_as_image.R
+++ b/R/kable_as_image.R
@@ -5,8 +5,8 @@
 #' `xtable`) to generate a table, convert it to an image and put it back to a
 #' rmarkdown environment. It is a "better than nothing" solution to print high
 #' quality tables in rmarkdown Word document. By using this, you need to take
-#' the responsibility of explaining to your collaborators why they can't edit
-#' the tables they see in the Word document they received. 😂
+#' the responsibility of explaining to your collaborators why they can't make
+#' edits to the tables in Word. 😂
 #'
 #' Also, if a filename is provided, user has the option to "save" the table to
 #' an image file like `ggplot2::ggsave()`.
diff --git a/R/kable_styling.R b/R/kable_styling.R
index a4fed07..1e52b03 100644
--- a/R/kable_styling.R
+++ b/R/kable_styling.R
@@ -41,6 +41,9 @@
 #' - `repeat_header_text` is just a text string you want to append on or
 #' replace the caption.
 #' - `stripe_color` allows users to pick a different color for their strip lines.
+#' - `latex_table_env` character string to define customized table environment
+#' such as tabu or tabularx.You shouldn't expect all features could be
+#' supported in self-defined environments.
 #'
 #' @examples x_html <- knitr::kable(head(mtcars), "html")
 #' kable_styling(x_html, "striped", position = "left", font_size = 7)
@@ -177,7 +180,8 @@
                              font_size = NULL,
                              repeat_header_text = "\\textit{(continued)}",
                              repeat_header_method = c("append", "replace"),
-                             stripe_color = "gray!6") {
+                             stripe_color = "gray!6",
+                             latex_table_env = NULL) {
 
   latex_options <- match.arg(
     latex_options,
@@ -215,13 +219,26 @@
   }
 
   if (full_width) {
-    out <- styling_latex_full_width(out, table_info)
+    latex_table_env <- ifelse(table_info$tabular == "longtable",
+                              "longtabu", "tabu")
+    full_width_return <- styling_latex_full_width(out, table_info)
+    out <- full_width_return[[1]]
+    table_info$align_vector <- full_width_return[[2]]
   }
 
   if (!is.null(font_size)) {
     out <- styling_latex_font_size(out, table_info, font_size)
   }
 
+  if (!is.null(latex_table_env)) {
+    out <- styling_latex_table_env(out, table_info$tabular, latex_table_env)
+    table_info$tabular <- latex_table_env
+    table_info$begin_tabular <- sub("tabular", latex_table_env,
+                                    table_info$begin_tabular)
+    table_info$end_tabular <- sub("tabular", latex_table_env,
+                                  table_info$end_tabular)
+  }
+
   position <- match.arg(position)
   out <- styling_latex_position(out, table_info, position, latex_options)
 
@@ -323,16 +340,18 @@
 }
 
 styling_latex_full_width <- function(x, table_info) {
-  size_matrix <- sapply(sapply(table_info$contents, str_split, " & "), nchar)
-  col_max_length <- apply(size_matrix, 1, max) + 4
-  col_ratio <- round(col_max_length / sum(col_max_length), 2)
-  col_align <- paste0("p{\\\\dimexpr", col_ratio,
-                      "\\\\columnwidth-2\\\\tabcolsep}")
-  col_align <- paste0("{", paste(col_align, collapse = ""), "}")
+  col_align <- as.character(factor(
+    table_info$align_vector, c("c", "l", "r"),
+    c(">{\\\\centering}X", ">{\\\\raggedright}X", ">{\\\\raggedleft}X")
+  ))
+  col_align[is.na(col_align)] <- table_info$align_vector[is.na(col_align)]
+  col_align_vector <- col_align
+  col_align <- paste0(" to \\\\linewidth {", paste(col_align, collapse = ""), "}")
   x <- sub(paste0(table_info$begin_tabular, "\\{[^\\\\n]*\\}"),
            table_info$begin_tabular, x)
-  sub(table_info$begin_tabular,
+  x <- sub(table_info$begin_tabular,
       paste0(table_info$begin_tabular, col_align), x)
+  return(list(x, col_align_vector))
 }
 
 styling_latex_position <- function(x, table_info, position, latex_options) {
@@ -391,7 +410,7 @@
 
 styling_latex_font_size <- function(x, table_info, font_size) {
   row_height <- font_size + 2
-  if (table_info$tabular == "tabular" & table_info$table_env) {
+  if (table_info$tabular != "longtable" & table_info$table_env) {
     return(sub(table_info$begin_tabular,
                paste0("\\\\fontsize\\{", font_size, "\\}\\{", row_height,
                       "\\}\\\\selectfont\n", table_info$begin_tabular),
@@ -405,4 +424,8 @@
   ))
 }
 
+styling_latex_table_env <- function(x, current_env, latex_table_env) {
+  return(gsub(paste0("\\{", current_env, "\\}"),
+              paste0("\\{", latex_table_env, "\\}"), x))
+}
 
diff --git a/R/landscape.R b/R/landscape.R
index fd7789e..01ef2bb 100644
--- a/R/landscape.R
+++ b/R/landscape.R
@@ -26,7 +26,6 @@
 
 landscape_latex <- function(kable_input, margin) {
   kable_attrs <- attributes(kable_input)
-  usepackage_latex("pdflscape")
   out <- paste0(
     "\n\\begin{landscape}",
     enc2utf8(as.character(kable_input)),
diff --git a/R/zzz.R b/R/zzz.R
index e716b96..78d4020 100644
--- a/R/zzz.R
+++ b/R/zzz.R
@@ -6,4 +6,7 @@
   usepackage_latex("xcolor", "table")
   usepackage_latex("wrapfig")
   usepackage_latex("colortbl")
+  usepackage_latex("pdflscape")
+  usepackage_latex("tabu")
+  usepackage_latex("threeparttable")
 }
diff --git a/docs/awesome_table_in_pdf.Rmd b/docs/awesome_table_in_pdf.Rmd
index 7bb5585..f1f0f78 100644
--- a/docs/awesome_table_in_pdf.Rmd
+++ b/docs/awesome_table_in_pdf.Rmd
@@ -13,6 +13,7 @@
   - \usepackage{multirow}
   - \usepackage[table]{xcolor}
   - \usepackage{wrapfig}
+  - \usepackage{float}
 vignette: >
   %\VignetteIndexEntry{Create Awesome PDF Table with knitr::kable and kableExtra}
   %\VignetteEngine{knitr::rmarkdown}
diff --git a/docs/awesome_table_in_pdf.pdf b/docs/awesome_table_in_pdf.pdf
index 6e3ddd2..661108b 100644
--- a/docs/awesome_table_in_pdf.pdf
+++ b/docs/awesome_table_in_pdf.pdf
Binary files differ
diff --git a/inst/NEWS.md b/inst/NEWS.md
index 2f843cf..e59e5de 100644
--- a/inst/NEWS.md
+++ b/inst/NEWS.md
@@ -1,3 +1,15 @@
+kableExtra 0.5.0 
+--------------------------------------------------------------------------------
+* Now column_spec & row_spec can customize font & cell background color with 
+2 new options `color` & `background`. Also, you can draw border lines using 
+`border_left` or `border_right` when you are using `column_spec`.
+
+* Now you can change strip color for LaTeX tables. 
+
+* Added escape option for add_footnote
+
+* Fixed a bug in LaTeX for the processing of the + sign
+
 kableExtra 0.4.0
 --------------------------------------------------------------------------------
 * Add scroll_box for HTML table for extremely long/wide tables
diff --git a/man/kable_as_image.Rd b/man/kable_as_image.Rd
index ac0e71e..1fd162a 100644
--- a/man/kable_as_image.Rd
+++ b/man/kable_as_image.Rd
@@ -31,8 +31,8 @@
 \code{xtable}) to generate a table, convert it to an image and put it back to a
 rmarkdown environment. It is a "better than nothing" solution to print high
 quality tables in rmarkdown Word document. By using this, you need to take
-the responsibility of explaining to your collaborators why they can't edit
-the tables they see in the Word document they received. 😂
+the responsibility of explaining to your collaborators why they can't make
+edits to the tables in Word. 😂
 
 Also, if a filename is provided, user has the option to "save" the table to
 an image file like \code{ggplot2::ggsave()}.
diff --git a/tests/visual_tests/kable_styling_pdf.Rmd b/tests/visual_tests/kable_styling_pdf.Rmd
index 87bdc30..bb8e5dc 100644
--- a/tests/visual_tests/kable_styling_pdf.Rmd
+++ b/tests/visual_tests/kable_styling_pdf.Rmd
@@ -23,7 +23,8 @@
 Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla ullamcorper mauris quis risus dignissim pellentesque. Vivamus in est finibus, porta enim in, sagittis sapien. Mauris dapibus ex nec interdum laoreet. Suspendisse sed venenatis nunc. Donec magna mauris, imperdiet eget mi eget, fringilla vestibulum nisl. Pellentesque scelerisque a elit at blandit. Etiam maximus eget urna quis vestibulum. Cras finibus mi non aliquam condimentum. Mauris feugiat libero vitae massa posuere, et congue turpis convallis. Vestibulum aliquam, quam et accumsan posuere, magna nisl ornare nunc, ac sodales metus elit ac erat.
 
 ```{r}
-kable(dt, format = "latex", booktabs = T, longtable = T) %>%
+kable(dt, format = "latex", booktabs = T, longtable = T, caption = "something", caption.short = "sss") %>%
+  magic_mirror()
   kable_styling(latex_options = c("striped", "hold_position"), font_size = 6, position = "float_left")
 ```
 
@@ -66,7 +67,6 @@
 
 
 ```{r}
-usepackage_latex("caption", "singlelinecheck=false")
 kable(dt, format = "latex", booktabs = T, caption = "long caption long caption long caption long caption long caption long caption long caption") %>%
   kable_styling(latex_options = c("striped", "hold_position"))
 ```
diff --git a/tests/visual_tests/longtable.Rmd b/tests/visual_tests/longtable.Rmd
index 4e6a064..2e3e301 100644
--- a/tests/visual_tests/longtable.Rmd
+++ b/tests/visual_tests/longtable.Rmd
@@ -24,7 +24,7 @@
 ```
 
 ```{r}
-kable(dt, "latex", longtable = T, caption = "test", booktabs = T) %>%
+kable(dt, "latex", longtable = T, caption = "test", booktabs = T, caption.short = "sss") %>%
   kable_styling(latex_options = c("striped", "repeat_header"), repeat_header_text = "(...)")
 ```