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.

Bryan
  • 1,771
  • 4
  • 17
  • 30
  • 5
    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. – Bryan Feb 12 '14 at 16:37

2 Answers2

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?"))
  • 10
    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. – RoyalTS Apr 02 '14 at 17:17
  • @user1953965 I would also prefer a function to wrap lines automatically, breaking lines does not really produce a beautiful table – bretauv Sep 19 '19 at 07:00
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.stack.imgur.com/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.

E_net4
  • 27,810
  • 13
  • 101
  • 139