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

Markdown PDF and stargazer resizing table #85

Open
bjoernboening opened this issue Dec 11, 2015 · 3 comments
Open

Markdown PDF and stargazer resizing table #85

bjoernboening opened this issue Dec 11, 2015 · 3 comments

Comments

@bjoernboening
Copy link

Might be a little late, but nevertheless is driving me nuts.

Whenever I add a stargazer regression table to the markdown (knit as pdf), I only get one long column.

Is there a way to fit the table to the page?

Several forums suggest, that this issue remains untackled by the developers, might this be true, or did someone find a solution?

Thanks in advance.

@LarsMehwald
Copy link

Dear Björn,
I dont have a solution, but an idea - in case you know how to do it with LaTeX (which I dont):
You can save the LaTeX output of stargazer and manually manipulate it (with LaTeX code that does what you want). The code is explained here:
http://stackoverflow.com/questions/33543159/how-to-align-stargazer-table-to-the-left-when-type-latex
Hope that helps,
Lars

@christophergandrud
Copy link
Contributor

Is this related to having many variables in your model? If so you can omit certain variables from the table to focus on key ones using the omit argument to stargazer.

@Mark-Bergn
Copy link

I've had the same issue, best work around I found was to generate the stargazer output outside of Rmarkdown then copy and paste it into the markdown body and add the latex commands "\resizebox{\linewidth}{!}{ %% " and "} %resizebox" to fit the output to page.

i.e....

Example Stargazer Output:

\begin{table}[!htbp] \centering
\caption{}
\label{}
\resizebox{\linewidth}{!}{ %%
\begin{tabular}{@{\extracolsep{5pt}}lc}
\[-1.8ex]\hline
\hline \[-1.8ex]
& \multicolumn{1}{c}{\textit{Dependent variable:}} \
\cline{2-2}
\[-1.8ex] & y \
\hline \[-1.8ex]
x & $-$1.587 \
& (2.701) \
& \
Constant & 50.500$^{}$ \
& (2.911) \
& \
\hline \[-1.8ex]
Observations & 100 \
\hline
\hline \[-1.8ex]
\textit{Note:} & \multicolumn{1}{r}{$^{
}$p$<$0.1; $^{
}$p$<$0.05; $^{***}$p$<$0.01} \
\end{tabular}
} %resizebox
\end{table}

This solution comes from- https://stackoverflow.com/questions/16507191/automatically-adjust-latex-table-width-to-fit-pdf-using-knitr-and-rstudio

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

4 participants