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

valign does not work correctly #9

Open
dquang opened this issue May 5, 2017 · 5 comments
Open

valign does not work correctly #9

dquang opened this issue May 5, 2017 · 5 comments

Comments

@dquang
Copy link

dquang commented May 5, 2017

Hi,

Thank you very much for the excellent package.

I have a problem of valign function in output pdf document. The valign does not work as expected. The sample Rmd code is following. Output table in the PDF file has v-aligned bottom even the setting is "top". Output to HTML is correct.

Could you please check again?

Another question is: how can I justify the column to the both side?

regards,
Quang
huxtable_issue.pdf

---
output: pdf_document
#geometry: inner=3.8cm, outer=25mm, top=25mm, bottom=25mm
#documentclass: report
header_includes:
#- \usepackage{graphicx}
- \usepackage{booktabs}
#- \usepackage{tabularx}
---
library(dplyr)
library(huxtable)
lorem1 <- "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce nec quam ut tortor interdum pulvinar id vitae magna. Proin at diam vitae lectus dignissim auctor nec dictum lectus. Fusce venenatis eros congue velit feugiat, ac aliquam ipsum gravida. Cras bibendum malesuada est in tempus."

lorem2 <- "Integer vel placerat purus. Nulla facilisi. Etiam odio magna, porttitor et est nec, placerat pellentesque ex."
ht <-
huxtable(
  Col1 = c("Paragraph 1", "Paragraph 2"),
  Text = c(lorem1, lorem2), add_colnames = TRUE
) %>%
  set_wrap(value = TRUE)     %>%
  set_width(1)                 %>%
  set_col_width(c(0.3, 0.7))   %>%
  set_valign("top")
ht
valign(ht)
@hughjonesd
Copy link
Owner

See https://hughjonesd.github.io/huxtable/design-principles.html and also https://tex.stackexchange.com/questions/359415/how-can-i-find-the-cell-height-in-a-tabular for why this is unlikely to be fixable. The bottom line is, LaTeX table vertical alignment doesn't work the way you think it does, and is not actually very useful for anything. But I can't fix that without fixing LaTeX ;-)

@dquang
Copy link
Author

dquang commented May 5, 2017

Understood, thank you!
It seems that there are always problems with LaTex :)
Wish you all the best!

@eweisbrod
Copy link

Hi, I am having a similar problem. When I check valign in my huxtable, it says "top" everywhere. However, something in the huxtable latex code is coding all the parboxes as parbox[b]. I manually changed them all to parbox[t] and it fixed the table and top-aligned everything properly.

I'm not sure if I've give enough info, but is there anything you could possibly investigate to prevent huxtable from specifying parbox[b] instead of parbox[t] ?

@hughjonesd
Copy link
Owner

Yeah, I have to admit that the current setup is a mess.


library(huxtable)
library(dplyr)
tmp <- hux("shorter","Long content that should wrap")

tmp %>% set_valign("bottom") %>% set_width(0.3) %>% set_all_borders() %>% quick_pdf()

bottom

tmp %>% set_valign("top") %>% set_width(0.3) %>% set_all_borders() %>% quick_pdf()

top

@hughjonesd hughjonesd reopened this Sep 2, 2021
@hughjonesd
Copy link
Owner

On the other hand, if alignment is in response to fixing row_height() then valign doesn't really do anything.

This is a breaking change, and it might affect other situations, so will need to test before making it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants