RMarkdown PDF reference stargazer latex table output

I'm using RMarkdown separate from my R code due to the size of my data.
I'm using stargazer's latex output in my RMarkdown file.

\begin{table}[H] \centering 
  \caption{} 
  \label{table1}
... 

I'm not sure how can I reference my tables in the text. I tried \@ref(tab:table1\_stargazer), but it just returns it as text \@ref(tab:table4\_stargazer) in output.
Please suggest.

I don't have a lot of information on what you are using as format, but for referencing you should be looking into bookdown

Not sure how it works then with stargazer. If you were able to share a reproducible example of code, there may be more people ready to help on this specific case.

The solution that worked for me was switching to bookdown, as you mentioned.

bookdown::pdf_document2

And then use tab: in stargazer's latex output.

\label{tab:table1}

And to reference use

\@ref(tab:table1)

I'd also suggest checking Steve's R Markdown Templates • stevetemplates

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.