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

Column widths not porting to LaTeX #634

Closed
leachandrew opened this issue Aug 13, 2020 · 0 comments · Fixed by #1371
Closed

Column widths not porting to LaTeX #634

leachandrew opened this issue Aug 13, 2020 · 0 comments · Fixed by #1371

Comments

@leachandrew
Copy link

It seems that specified column widths are not porting to longtable in LaTeX when knitting to PDF from gt.

Here's my sample code:

grades_table<-tribble(
  ~Minimum, ~Maximum, ~Grade,
  #--|--|----
  90,100,"A+",
  85,89.99,"A",
  80,84.99,"A-"
  )
gt_test<-grades_table %>% gt()%>%
tab_header(
    title = md("Grade mapping table"),
    subtitle = "Percentages will correspond to letter grades as follows:"
  ) %>%
      cols_width(
    starts_with("M") ~ px(200),
    everything() ~ px(200)
  )%>% cols_align(align = "center")%>%
  tab_source_note(md("NB: In the event that overall percentages are lower than expected, your grade may end up above those posted here, but will not end up below."))%>% as_latex()

gt_test

When I look at the generated latex code, the cols_width specifications don't come through:

\captionsetup[table]{labelformat=empty,skip=1pt}
\begin{longtable}{ccc}
\caption*{
\large Grade mapping table\\ 
\small Percentages will correspond to letter grades as follows:\\ 
} \\ 
\toprule
Minimum & Maximum & Grade \\ 
\midrule
90 & 100.00 & A+ \\ 
85 & 89.99 & A \\ 
80 & 84.99 & A- \\ 
\bottomrule
\end{longtable}
\begin{minipage}{\linewidth}
NB: In the event that overall percentages are lower than expected, your grade may end up above those posted here, but will not end up below.\\ 
\end{minipage}

It seems that longtable is a bit fussy about alignments and widths, but it seems like the \begin{longtable} line should be something like:
\begin{longtable}{p{200px}p{200px}p{200px}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment