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.