Skip to content

Commit 4d9dfed

Browse files
authored
Merge pull request #2075 from thebioengineer/shortstack_alignment_investigation
Shortstack alignment
2 parents deff4bf + fe095ba commit 4d9dfed

File tree

13 files changed

+501
-166
lines changed

13 files changed

+501
-166
lines changed

.Rbuildignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ tests/testthat/test-utils_render_grid.R
205205
tests/testthat/_snaps/utils_render_grid.md
206206

207207
tests/testthat/test-utils_render_html.R
208+
tests/testthat/test-utils_render_latex.R
208209
tests/testthat/test-utils_render_rtf.R
209210
tests/testthat/test-utils_units.R
210211

NEWS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
* Fix bug where latex spanner widths were based on incorrect column widths (@shannonhaughton, #2016, #1922)
1010

11+
* Update latex to allow for horizontal alignment within cells (@thebioengineer, #2001)
12+
13+
1114
# gt 1.1.0
1215

1316
## New features

R/export.R

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -243,37 +243,41 @@ as_latex <- function(data) {
243243
# Compose the LaTeX table
244244
if (dt_options_get_value(data = data, option = "latex_use_longtable")) {
245245
knitr::asis_output(
246-
paste0(
247-
wrap_start_statement,
248-
table_width_statement,
249-
fontsize_statement,
250-
table_start,
251-
caption_component,
252-
heading_component,
253-
columns_component,
254-
body_component,
255-
table_end,
256-
footer_component,
257-
wrap_end_statement,
258-
collapse = ""
246+
latex_cleanup_multicolumn(
247+
paste0(
248+
wrap_start_statement,
249+
table_width_statement,
250+
fontsize_statement,
251+
table_start,
252+
caption_component,
253+
heading_component,
254+
columns_component,
255+
body_component,
256+
table_end,
257+
footer_component,
258+
wrap_end_statement,
259+
collapse = ""
260+
)
259261
),
260262
meta = latex_packages
261263
)
262264
} else {
263265
knitr::asis_output(
264-
paste0(
265-
wrap_start_statement,
266-
caption_component,
267-
heading_component,
268-
table_width_statement,
269-
fontsize_statement,
270-
table_start,
271-
columns_component,
272-
body_component,
273-
table_end,
274-
footer_component,
275-
wrap_end_statement,
276-
collapse = ""
266+
latex_cleanup_multicolumn(
267+
paste0(
268+
wrap_start_statement,
269+
caption_component,
270+
heading_component,
271+
table_width_statement,
272+
fontsize_statement,
273+
table_start,
274+
columns_component,
275+
body_component,
276+
table_end,
277+
footer_component,
278+
wrap_end_statement,
279+
collapse = ""
280+
)
277281
),
278282
meta = latex_packages
279283
)

0 commit comments

Comments
 (0)