Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix LaTeX text size #1899

Merged
merged 2 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@

* `cols_add()` works in more cases (#1893).

* LaTeX now correctly renders if text size is changed (@olivroy, #1885).

# gt 0.11.0

## New features
Expand Down
21 changes: 12 additions & 9 deletions R/utils_render_latex.R
Original file line number Diff line number Diff line change
Expand Up @@ -1249,14 +1249,14 @@ remove_footnote_encoding <- function(x) {
convert_font_size_l <- function(x) {

size_map <- c(
`xx-small` = "\\tiny",
`x-small` = "\\scriptsize",
small = "\\small",
medium = "\\normalsize",
large = "\\large",
`x-large` = "\\Large",
`xx-large` = "\\LARGE",
`xxx-large` = "\\huge"
`xx-small` = "\\tiny ",
`x-small` = "\\scriptsize ",
small = "\\small ",
medium = "\\normalsize ",
large = "\\large ",
`x-large` = "\\Large ",
`xx-large` = "\\LARGE ",
`xxx-large` = "\\huge "
)

if (as.character(x) %in% names(size_map))
Expand Down Expand Up @@ -1497,12 +1497,15 @@ apply_cell_styles_l <- function(content, style_obj) {
"{",
.apply_style_style_l(style_obj),
.apply_style_weight_l(style_obj),
# Can generate "\small for example
.apply_style_fontsize_l(style_obj),
.apply_style_indentation_l(style_obj),
x,
"}"
)
} else out_text <- just_content
} else {
out_text <- just_content
}

ifelse(mark_side == "right",
paste0(out_text, mark),
Expand Down
Binary file modified pkgdown/assets/gt-latex.pdf
Binary file not shown.
8 changes: 4 additions & 4 deletions pkgdown/assets/gt-latex.tex
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@

\title{LaTeX Quarto test}
\author{}
\date{2024-08-14}
\date{2024-10-02}

\begin{document}
\maketitle
Expand Down Expand Up @@ -236,7 +236,7 @@
\end{Shaded}

\begin{verbatim}
[1] '1.5.54'
[1] '1.5.57'
\end{verbatim}

\newpage{}
Expand Down Expand Up @@ -292,7 +292,7 @@
\FunctionTok{tab\_spanner}\NormalTok{(}\StringTok{"Second level spanners"}\NormalTok{, }\FunctionTok{c}\NormalTok{(char, num, fctr)) }\SpecialCharTok{\%\textgreater{}\%}
\FunctionTok{tab\_stubhead}\NormalTok{(}\StringTok{"Stubhead label"}\NormalTok{) }\SpecialCharTok{\%\textgreater{}\%}
\FunctionTok{tab\_style}\NormalTok{(}
\AttributeTok{style =} \FunctionTok{list}\NormalTok{(}\FunctionTok{cell\_fill}\NormalTok{(}\StringTok{"\#f0f0f0"}\NormalTok{), }\FunctionTok{cell\_text}\NormalTok{(}\AttributeTok{weight =} \StringTok{"bold"}\NormalTok{)),}
\AttributeTok{style =} \FunctionTok{list}\NormalTok{(}\FunctionTok{cell\_fill}\NormalTok{(}\StringTok{"\#f0f0f0"}\NormalTok{), }\FunctionTok{cell\_text}\NormalTok{(}\AttributeTok{weight =} \StringTok{"bold"}\NormalTok{, }\AttributeTok{size =} \StringTok{"small"}\NormalTok{, }\AttributeTok{color =} \StringTok{"blue"}\NormalTok{)),}
\FunctionTok{cells\_stubhead}\NormalTok{()}
\NormalTok{ ) }\SpecialCharTok{\%\textgreater{}\%}
\FunctionTok{tab\_header}\NormalTok{(}\AttributeTok{title =} \StringTok{"Stubhead styling and multiple spanner levels"}\NormalTok{)}
Expand All @@ -313,7 +313,7 @@
\cmidrule(lr){3-5}
\multicolumn{2}{l}{} & \multicolumn{2}{c}{spanners} & & & & & \\
\cmidrule(lr){3-4}
\multicolumn{2}{c}{{\bfseries \cellcolor[HTML]{F0F0F0}{Stubhead label}}} & char & num & fctr & date & time & datetime & currency \\
\multicolumn{2}{c}{{\bfseries \small \cellcolor[HTML]{F0F0F0}{\textcolor[HTML]{0000FF}{Stubhead label}}}} & char & num & fctr & date & time & datetime & currency \\
\midrule\addlinespace[2.5pt]
\multirow{4}{*}{grp\_a} & row\_1 & apricot & 1.111e-01 & one & 2015-01-15 & 13:35 & 2018-01-01 02:22 & 49.950 \\
& row\_2 & banana & 2.222e+00 & two & 2015-02-15 & 14:40 & 2018-02-02 14:33 & 17.950 \\
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/_snaps/as_latex.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Code
gt_latex_styled
Output
[1] "\\begingroup\n\\fontsize{12.0pt}{14.4pt}\\selectfont\n\\setlength{\\LTpost}{0mm}\n\\begin{longtable}{l|rlcrrr}\n\\toprule\n & \\multicolumn{3}{c}{{\\itshape heading}} & & \\multicolumn{2}{c}{heading} \\\\ \n\\cmidrule(lr){2-4} \\cmidrule(lr){6-7}\n{$\\overline{\\mbox{stubhead}}$} & {NUM} & char & fctr\\textsuperscript{\\textit{1}} & time & {DATETIME} & currency \\\\ \n\\midrule\\addlinespace[2.5pt]\n\\multicolumn{7}{l}{grp\\_a} \\\\[2.5pt] \n\\midrule\\addlinespace[2.5pt]\n{\\cellcolor[HTML]{AA0000}{\\textcolor[HTML]{FFFFFF}{\\hspace*{3.75pt} row\\_1}}} & 0.1111 & apricot & {\\fontsize{15}{18.75}\\selectfont \\textcolor[HTML]{0000FF}{one}} & 13:35 & {\\scriptsize2018-01-01 02:22} & 49.95 \\\\ \n{\\slshape \\hspace{11.25pt}\\cellcolor[HTML]{AA0000}{\\textcolor[HTML]{FFFFFF}{\\hspace*{3.75pt} row\\_2}}} & 2.2220 & {\\bfseries \\hspace{15pt}banana} & {\\fontsize{15}{18.75}\\selectfont \\textcolor[HTML]{0000FF}{two}} & 14:40 & {\\scriptsize2018-02-02 14:33} & 17.95 \\\\ \n{\\cellcolor[HTML]{AA0000}{\\textcolor[HTML]{FFFFFF}{\\hspace*{3.75pt} row\\_3}}} & 33.3300 & coconut & {\\fontsize{15}{18.75}\\selectfont \\textcolor[HTML]{0000FF}{three}} & \\textsuperscript{\\textit{2}}{\\fontsize{15}{18.75}\\selectfont \\underline{\\textcolor[HTML]{FF0000}{15:45}}} & {\\scriptsize2018-03-03 03:44} & 1.39 \\\\ \n{\\slshape \\hspace{11.25pt}\\cellcolor[HTML]{AA0000}{\\textcolor[HTML]{FFFFFF}{\\hspace*{3.75pt} row\\_4}}} & 444.4000 & {\\bfseries \\hspace{15pt}durian} & {\\fontsize{15}{18.75}\\selectfont \\textcolor[HTML]{0000FF}{four}} & {\\fontsize{15}{18.75}\\selectfont \\underline{\\textcolor[HTML]{FF0000}{16:50}}} & {\\scriptsize2018-04-04 15:55} & 65100.00 \\\\ \n\\midrule \nTotal & {\\cellcolor[HTML]{00FF00}{480.06}} & — & — & — & — & {\\cellcolor[HTML]{00FF00}{65,169.29}} \\\\ \nAvg & 120.02 & — & — & — & — & 16,292.32 \\\\ \n\\midrule\\addlinespace[2.5pt]\n\\multicolumn{7}{l}{{\\bfseries \\cellcolor[HTML]{CCCCFF}{grp\\_b}}} \\\\[2.5pt] \n\\midrule\\addlinespace[2.5pt]\n{\\slshape \\hspace{11.25pt}\\cellcolor[HTML]{AA0000}{\\textcolor[HTML]{FFFFFF}{\\hspace*{3.75pt} row\\_5}}} & 5550.0000 & {\\bfseries \\hspace{15pt}NA} & {\\fontsize{15}{18.75}\\selectfont \\textcolor[HTML]{0000FF}{five}} & 17:55 & {\\scriptsize2018-05-05 04:00} & 1325.81 \\\\ \n\\midrule \n\\midrule \n{\\bfseries Grand Total} & {\\cellcolor[HTML]{AAAAAA}{6,030.06}} & {\\cellcolor[HTML]{AAAAAA}{—}} & {\\cellcolor[HTML]{AAAAAA}{—}} & {\\cellcolor[HTML]{AAAAAA}{—}} & {\\cellcolor[HTML]{AAAAAA}{—}} & {\\cellcolor[HTML]{AAAAAA}{66,495.10}} \\\\ \n\\bottomrule\n\\end{longtable}\n\\begin{minipage}{\\linewidth}\n\\textsuperscript{\\textit{1}}{\\bfseries This is a footnote in the column labels.}\\\\\n\\textsuperscript{\\textit{2}}{\\bfseries This is a footnote. With a second line.}\\\\\n{\\itshape \\fontsize{6}{7.5}\\selectfont NOTES: A mtcars example.\\\\\n}\\end{minipage}\n\\endgroup\n"
[1] "\\begingroup\n\\fontsize{12.0pt}{14.4pt}\\selectfont\n\\setlength{\\LTpost}{0mm}\n\\begin{longtable}{l|rlcrrr}\n\\toprule\n & \\multicolumn{3}{c}{{\\itshape heading}} & & \\multicolumn{2}{c}{heading} \\\\ \n\\cmidrule(lr){2-4} \\cmidrule(lr){6-7}\n{$\\overline{\\mbox{stubhead}}$} & {NUM} & char & fctr\\textsuperscript{\\textit{1}} & time & {DATETIME} & currency \\\\ \n\\midrule\\addlinespace[2.5pt]\n\\multicolumn{7}{l}{grp\\_a} \\\\[2.5pt] \n\\midrule\\addlinespace[2.5pt]\n{\\cellcolor[HTML]{AA0000}{\\textcolor[HTML]{FFFFFF}{\\hspace*{3.75pt} row\\_1}}} & 0.1111 & apricot & {\\fontsize{15}{18.75}\\selectfont \\textcolor[HTML]{0000FF}{one}} & 13:35 & {\\scriptsize 2018-01-01 02:22} & 49.95 \\\\ \n{\\slshape \\hspace{11.25pt}\\cellcolor[HTML]{AA0000}{\\textcolor[HTML]{FFFFFF}{\\hspace*{3.75pt} row\\_2}}} & 2.2220 & {\\bfseries \\hspace{15pt}banana} & {\\fontsize{15}{18.75}\\selectfont \\textcolor[HTML]{0000FF}{two}} & 14:40 & {\\scriptsize 2018-02-02 14:33} & 17.95 \\\\ \n{\\cellcolor[HTML]{AA0000}{\\textcolor[HTML]{FFFFFF}{\\hspace*{3.75pt} row\\_3}}} & 33.3300 & coconut & {\\fontsize{15}{18.75}\\selectfont \\textcolor[HTML]{0000FF}{three}} & \\textsuperscript{\\textit{2}}{\\fontsize{15}{18.75}\\selectfont \\underline{\\textcolor[HTML]{FF0000}{15:45}}} & {\\scriptsize 2018-03-03 03:44} & 1.39 \\\\ \n{\\slshape \\hspace{11.25pt}\\cellcolor[HTML]{AA0000}{\\textcolor[HTML]{FFFFFF}{\\hspace*{3.75pt} row\\_4}}} & 444.4000 & {\\bfseries \\hspace{15pt}durian} & {\\fontsize{15}{18.75}\\selectfont \\textcolor[HTML]{0000FF}{four}} & {\\fontsize{15}{18.75}\\selectfont \\underline{\\textcolor[HTML]{FF0000}{16:50}}} & {\\scriptsize 2018-04-04 15:55} & 65100.00 \\\\ \n\\midrule \nTotal & {\\cellcolor[HTML]{00FF00}{480.06}} & — & — & — & — & {\\cellcolor[HTML]{00FF00}{65,169.29}} \\\\ \nAvg & 120.02 & — & — & — & — & 16,292.32 \\\\ \n\\midrule\\addlinespace[2.5pt]\n\\multicolumn{7}{l}{{\\bfseries \\cellcolor[HTML]{CCCCFF}{grp\\_b}}} \\\\[2.5pt] \n\\midrule\\addlinespace[2.5pt]\n{\\slshape \\hspace{11.25pt}\\cellcolor[HTML]{AA0000}{\\textcolor[HTML]{FFFFFF}{\\hspace*{3.75pt} row\\_5}}} & 5550.0000 & {\\bfseries \\hspace{15pt}NA} & {\\fontsize{15}{18.75}\\selectfont \\textcolor[HTML]{0000FF}{five}} & 17:55 & {\\scriptsize 2018-05-05 04:00} & 1325.81 \\\\ \n\\midrule \n\\midrule \n{\\bfseries Grand Total} & {\\cellcolor[HTML]{AAAAAA}{6,030.06}} & {\\cellcolor[HTML]{AAAAAA}{—}} & {\\cellcolor[HTML]{AAAAAA}{—}} & {\\cellcolor[HTML]{AAAAAA}{—}} & {\\cellcolor[HTML]{AAAAAA}{—}} & {\\cellcolor[HTML]{AAAAAA}{66,495.10}} \\\\ \n\\bottomrule\n\\end{longtable}\n\\begin{minipage}{\\linewidth}\n\\textsuperscript{\\textit{1}}{\\bfseries This is a footnote in the column labels.}\\\\\n\\textsuperscript{\\textit{2}}{\\bfseries This is a footnote. With a second line.}\\\\\n{\\itshape \\fontsize{6}{7.5}\\selectfont NOTES: A mtcars example.\\\\\n}\\end{minipage}\n\\endgroup\n"
attr(,"class")
[1] "knit_asis"
attr(,"knit_meta")
Expand Down Expand Up @@ -106,7 +106,7 @@
Code
gt_latex_styled
Output
[1] "\\begin{table}[!t]\n\\fontsize{12.0pt}{14.4pt}\\selectfont\n\\begin{tabular*}{\\linewidth}{@{\\extracolsep{\\fill}}l|rlcrrr}\n\\toprule\n & \\multicolumn{3}{c}{{\\itshape heading}} & & \\multicolumn{2}{c}{heading} \\\\ \n\\cmidrule(lr){2-4} \\cmidrule(lr){6-7}\n{$\\overline{\\mbox{stubhead}}$} & {NUM} & char & fctr\\textsuperscript{\\textit{1}} & time & {DATETIME} & currency \\\\ \n\\midrule\\addlinespace[2.5pt]\n\\multicolumn{7}{l}{grp\\_a} \\\\[2.5pt] \n\\midrule\\addlinespace[2.5pt]\n{\\cellcolor[HTML]{AA0000}{\\textcolor[HTML]{FFFFFF}{\\hspace*{3.75pt} row\\_1}}} & 0.1111 & apricot & {\\fontsize{15}{18.75}\\selectfont \\textcolor[HTML]{0000FF}{one}} & 13:35 & {\\scriptsize2018-01-01 02:22} & 49.95 \\\\ \n{\\slshape \\hspace{11.25pt}\\cellcolor[HTML]{AA0000}{\\textcolor[HTML]{FFFFFF}{\\hspace*{3.75pt} row\\_2}}} & 2.2220 & {\\bfseries \\hspace{15pt}banana} & {\\fontsize{15}{18.75}\\selectfont \\textcolor[HTML]{0000FF}{two}} & 14:40 & {\\scriptsize2018-02-02 14:33} & 17.95 \\\\ \n{\\cellcolor[HTML]{AA0000}{\\textcolor[HTML]{FFFFFF}{\\hspace*{3.75pt} row\\_3}}} & 33.3300 & coconut & {\\fontsize{15}{18.75}\\selectfont \\textcolor[HTML]{0000FF}{three}} & \\textsuperscript{\\textit{2}}{\\fontsize{15}{18.75}\\selectfont \\underline{\\textcolor[HTML]{FF0000}{15:45}}} & {\\scriptsize2018-03-03 03:44} & 1.39 \\\\ \n{\\slshape \\hspace{11.25pt}\\cellcolor[HTML]{AA0000}{\\textcolor[HTML]{FFFFFF}{\\hspace*{3.75pt} row\\_4}}} & 444.4000 & {\\bfseries \\hspace{15pt}durian} & {\\fontsize{15}{18.75}\\selectfont \\textcolor[HTML]{0000FF}{four}} & {\\fontsize{15}{18.75}\\selectfont \\underline{\\textcolor[HTML]{FF0000}{16:50}}} & {\\scriptsize2018-04-04 15:55} & 65100.00 \\\\ \n\\midrule \nTotal & {\\cellcolor[HTML]{00FF00}{480.06}} & — & — & — & — & {\\cellcolor[HTML]{00FF00}{65,169.29}} \\\\ \nAvg & 120.02 & — & — & — & — & 16,292.32 \\\\ \n\\midrule\\addlinespace[2.5pt]\n\\multicolumn{7}{l}{{\\bfseries \\cellcolor[HTML]{CCCCFF}{grp\\_b}}} \\\\[2.5pt] \n\\midrule\\addlinespace[2.5pt]\n{\\slshape \\hspace{11.25pt}\\cellcolor[HTML]{AA0000}{\\textcolor[HTML]{FFFFFF}{\\hspace*{3.75pt} row\\_5}}} & 5550.0000 & {\\bfseries \\hspace{15pt}NA} & {\\fontsize{15}{18.75}\\selectfont \\textcolor[HTML]{0000FF}{five}} & 17:55 & {\\scriptsize2018-05-05 04:00} & 1325.81 \\\\ \n\\midrule \n\\midrule \n{\\bfseries Grand Total} & {\\cellcolor[HTML]{AAAAAA}{6,030.06}} & {\\cellcolor[HTML]{AAAAAA}{—}} & {\\cellcolor[HTML]{AAAAAA}{—}} & {\\cellcolor[HTML]{AAAAAA}{—}} & {\\cellcolor[HTML]{AAAAAA}{—}} & {\\cellcolor[HTML]{AAAAAA}{66,495.10}} \\\\ \n\\bottomrule\n\\end{tabular*}\n\\begin{minipage}{\\linewidth}\n\\textsuperscript{\\textit{1}}{\\bfseries This is a footnote in the column labels.}\\\\\n\\textsuperscript{\\textit{2}}{\\bfseries This is a footnote. With a second line.}\\\\\n{\\itshape \\fontsize{6}{7.5}\\selectfont NOTES: A mtcars example.\\\\\n}\\end{minipage}\n\\end{table}\n"
[1] "\\begin{table}[!t]\n\\fontsize{12.0pt}{14.4pt}\\selectfont\n\\begin{tabular*}{\\linewidth}{@{\\extracolsep{\\fill}}l|rlcrrr}\n\\toprule\n & \\multicolumn{3}{c}{{\\itshape heading}} & & \\multicolumn{2}{c}{heading} \\\\ \n\\cmidrule(lr){2-4} \\cmidrule(lr){6-7}\n{$\\overline{\\mbox{stubhead}}$} & {NUM} & char & fctr\\textsuperscript{\\textit{1}} & time & {DATETIME} & currency \\\\ \n\\midrule\\addlinespace[2.5pt]\n\\multicolumn{7}{l}{grp\\_a} \\\\[2.5pt] \n\\midrule\\addlinespace[2.5pt]\n{\\cellcolor[HTML]{AA0000}{\\textcolor[HTML]{FFFFFF}{\\hspace*{3.75pt} row\\_1}}} & 0.1111 & apricot & {\\fontsize{15}{18.75}\\selectfont \\textcolor[HTML]{0000FF}{one}} & 13:35 & {\\scriptsize 2018-01-01 02:22} & 49.95 \\\\ \n{\\slshape \\hspace{11.25pt}\\cellcolor[HTML]{AA0000}{\\textcolor[HTML]{FFFFFF}{\\hspace*{3.75pt} row\\_2}}} & 2.2220 & {\\bfseries \\hspace{15pt}banana} & {\\fontsize{15}{18.75}\\selectfont \\textcolor[HTML]{0000FF}{two}} & 14:40 & {\\scriptsize 2018-02-02 14:33} & 17.95 \\\\ \n{\\cellcolor[HTML]{AA0000}{\\textcolor[HTML]{FFFFFF}{\\hspace*{3.75pt} row\\_3}}} & 33.3300 & coconut & {\\fontsize{15}{18.75}\\selectfont \\textcolor[HTML]{0000FF}{three}} & \\textsuperscript{\\textit{2}}{\\fontsize{15}{18.75}\\selectfont \\underline{\\textcolor[HTML]{FF0000}{15:45}}} & {\\scriptsize 2018-03-03 03:44} & 1.39 \\\\ \n{\\slshape \\hspace{11.25pt}\\cellcolor[HTML]{AA0000}{\\textcolor[HTML]{FFFFFF}{\\hspace*{3.75pt} row\\_4}}} & 444.4000 & {\\bfseries \\hspace{15pt}durian} & {\\fontsize{15}{18.75}\\selectfont \\textcolor[HTML]{0000FF}{four}} & {\\fontsize{15}{18.75}\\selectfont \\underline{\\textcolor[HTML]{FF0000}{16:50}}} & {\\scriptsize 2018-04-04 15:55} & 65100.00 \\\\ \n\\midrule \nTotal & {\\cellcolor[HTML]{00FF00}{480.06}} & — & — & — & — & {\\cellcolor[HTML]{00FF00}{65,169.29}} \\\\ \nAvg & 120.02 & — & — & — & — & 16,292.32 \\\\ \n\\midrule\\addlinespace[2.5pt]\n\\multicolumn{7}{l}{{\\bfseries \\cellcolor[HTML]{CCCCFF}{grp\\_b}}} \\\\[2.5pt] \n\\midrule\\addlinespace[2.5pt]\n{\\slshape \\hspace{11.25pt}\\cellcolor[HTML]{AA0000}{\\textcolor[HTML]{FFFFFF}{\\hspace*{3.75pt} row\\_5}}} & 5550.0000 & {\\bfseries \\hspace{15pt}NA} & {\\fontsize{15}{18.75}\\selectfont \\textcolor[HTML]{0000FF}{five}} & 17:55 & {\\scriptsize 2018-05-05 04:00} & 1325.81 \\\\ \n\\midrule \n\\midrule \n{\\bfseries Grand Total} & {\\cellcolor[HTML]{AAAAAA}{6,030.06}} & {\\cellcolor[HTML]{AAAAAA}{—}} & {\\cellcolor[HTML]{AAAAAA}{—}} & {\\cellcolor[HTML]{AAAAAA}{—}} & {\\cellcolor[HTML]{AAAAAA}{—}} & {\\cellcolor[HTML]{AAAAAA}{66,495.10}} \\\\ \n\\bottomrule\n\\end{tabular*}\n\\begin{minipage}{\\linewidth}\n\\textsuperscript{\\textit{1}}{\\bfseries This is a footnote in the column labels.}\\\\\n\\textsuperscript{\\textit{2}}{\\bfseries This is a footnote. With a second line.}\\\\\n{\\itshape \\fontsize{6}{7.5}\\selectfont NOTES: A mtcars example.\\\\\n}\\end{minipage}\n\\end{table}\n"
attr(,"class")
[1] "knit_asis"
attr(,"knit_meta")
Expand Down
11 changes: 3 additions & 8 deletions tests/testthat/test-as_latex.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,10 @@ test_that("Table width correctly output in LaTeX using longtable", {
tab_options(table.width = pct(90), latex.use_longtable = TRUE) %>%
as_latex()

start_pt <- regexpr("begin\\{longtable", gt_latex_width_1)

expect_gt(start_pt, 0) # Verifies the long table command appears in the text

end_pt <- regexpr("end\\{longtable", gt_latex_width_1)

expect_gt(end_pt, 0)
expect_match(gt_latex_width_1, "begin\\{longtable")
expect_match(gt_latex_width_1, "end\\{longtable")

start_pt <- regexpr("begin\\{longtable", gt_latex_width_1)
latex_prefix <- substr(gt_latex_width_1, 1L, start_pt)

# Verify that LTleft and LTright are correctly specified
Expand All @@ -27,7 +23,6 @@ test_that("Table width correctly output in LaTeX using longtable", {
as_latex()

expect_match(gt_latex_width_2, "\\\\setlength\\\\LTleft\\{\\\\dimexpr\\(0.5\\\\linewidth - 225pt\\)\\}")

expect_match(gt_latex_width_2, "\\\\setlength\\\\LTright\\{\\\\dimexpr\\(0.5\\\\linewidth - 225pt\\)\\}")

})
Expand Down
2 changes: 1 addition & 1 deletion vignettes/gt-visual.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ tab <- exibble %>%
tab_spanner("Second level spanners", c(char, num, fctr)) %>%
tab_stubhead("Stubhead label") %>%
tab_style(
style = list(cell_fill("#f0f0f0"), cell_text(weight = "bold")),
style = list(cell_fill("#f0f0f0"), cell_text(weight = "bold", size = "small", color = "blue")),
cells_stubhead()
) %>%
tab_header(title = "Stubhead styling and multiple spanner levels")
Expand Down
Loading