Stargazer notes line wrap?
Asked Answered
D

2

11

Is there a way to get notes in stargazer to wrap lines instead of running off the page?

stargazer(fit.1, notes="A very very long note that I would like to put below the table, but currently runs off the side of the page when I compile my document. How do I get this to wrap into paragraph form?")

Which produces:

\hline \\[-1.8ex] 
\textit{Notes:} & \multicolumn{2}{l}{$^{*}$P $<$ .05} \\ 
 & \multicolumn{2}{l}{$^{**}$P $<$ .01} \\ 
 & \multicolumn{2}{l}{$^{***}$P $<$ .001} \\ 
 & \multicolumn{2}{l}{A very very long note that I would like to put below the table, but currently runs off the side of the page when I compile my document. How do I get this to wrap into paragraph form?} \\ 
\normalsize 
\end{tabular} 
\end{table} 

I couldn't find anything in the manual for adjusting this.

Dormer answered 12/2, 2014 at 6:24 Comment(1)
A quick fix is to use a parbox which would look something like this: notes="\\parbox[t]{10cm}{Very long note goes here.}" but may require manual changes if you adjust the models.Dormer
G
12

The notes argument accepts a vector of character strings, and will put each on a new line. In your example, the following should work:

stargazer(linear.1, notes=c("A very very long note that I would like to put below the table,",
                     "but currently runs off the side of the page",
                     "when I compile my document.",
                     "How do I get this to wrap into paragraph form?"))
Gillenwater answered 17/2, 2014 at 21:16 Comment(2)
It would be great if a future version of stargazer would put every such element of the vector into its own parbox as per Bryan's comment above. Breaking lines manually seems inelegant at the very least.Iselaisenberg
@Gillenwater I would also prefer a function to wrap lines automatically, breaking lines does not really produce a beautiful tableStrahan
R
2

I personally recommend a more Latex-y solution. Basically, create the table environment in your tex file, add caption etc. Then, paste or \input your stargazer output (with float = FALSE) in a minipage environment within the table environment, followed by your notes.

Ex:

\documentclass{article}
\begin{document}

\begin{table}
    \caption{Your Caption}
    \begin{minipage}{0.85\textwidth} 
        \begin{tabular}{|l|l|l|}
            \hline
            999 & 888 & 777 \\
            \hline
        \end{tabular} 
    \\
    \\
{ \footnotesize  Note: A very very long note that I would like to put below the table, but currently runs off the side of the page when I compile my document. How do I get this to wrap into paragraph form? \par} 
    \end{minipage}
\end{table}    

\end{document}

produces: https://i.sstatic.net/eCYy9.png

It's helpful to post a fully reproducible example as well. I know this is very old but the post still shows up in Google searches.

Roomful answered 1/12, 2019 at 23:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.