[Tex/LaTex] Margin of caption of table

captionsmarginstables

I have a table which is wider than my usual margins. This results in the table violating the right margin. (putting table in landscape wont work because of the length)
I want to have a caption of the same size as the table. I can adjust the left, but not the right margin. Is there a way to make it violate the right margin as well ? Or alternatively, a way to have my table violate the left margin instead of the right.

 \documentclass[a4paper,10pt]{article}
 \usepackage[margin=3cm]{geometry}
 \usepackage{amssymb,amsmath, array, float, subfig}
 \usepackage{ragged2e, setspace}
 \usepackage{longtable}
 \usepackage{pdflscape}
 \usepackage{graphicx, natbib, cite}
 \usepackage[utf8]{inputenc}
 \usepackage{caption} 
 \usepackage{tabularx}
 \usepackage{afterpage}

\begin{document}
\begin{table}
\captionsetup{width=1.5\textwidth, margin=0em}
\setlength{\leftskip}{\captionmargin}%
\caption{Title\\ \small Columns 1 and 2 show the effect of blablablalab}
    \begin{tabular}[]{p{2,15cm}p{1.45cm} p{1.45cm} p{1.45cm} p{1.45cm} p{1.45cm} p{1.45cm} p{1.45cm} p{1.45cm}} \hline

                     & (1)      & (2)                & (3)      & (4)      & (5)      & (6)      & (7)                & (8)                \\
     Dep.Var.Name                & Dep.Var.Name & \(\Delta\)Dep.Var.Name & Dep.Var.Name & Dep.Var.Name & Dep.Var.Name & Dep.Var.Name & \(\Delta\)Dep.Var.Name & \(\Delta\)Dep.Var.Name \\ \hline
                     &          &                    &          &          & \\          
     LONG NAME FE            & Yes      & No                 & Yes      & Yes      & Yes      & Yes      & No                 & No                 \\ \hline
     \multicolumn{9}{c}{ Robust standard errors in parentheses} \\
     \multicolumn{9}{c}{ *** p$<$0.01, ** p$<$0.05, * p$<$0.1} \\
     \end{tabular}
\end{table} 
\end{document}

Best Answer

The simple way to put it is that \caption likes to be inside a minipage. BTW, I modified "Dep.Var.Name." to fit the p{} field.

I take it all those packages are there to test compatibility?

\documentclass[a4paper,10pt]{article}
 \usepackage[margin=3cm]{geometry}
 \usepackage{amssymb,amsmath, array, float, subfig}
 \usepackage{ragged2e, setspace}
 \usepackage{longtable}
 \usepackage{pdflscape}
 \usepackage{graphicx, natbib, cite}
 \usepackage[utf8]{inputenc}
 \usepackage{caption} 
 \usepackage{tabularx}
 \usepackage{afterpage}


\begin{document}
\begin{table}
\hspace*{\dimexpr -\oddsidemargin-1in}\rlap{\begin{minipage}{\paperwidth}
\caption{Title\\ \small Columns 1 and 2 show the effect of blablablalab}
\centering
    \begin{tabular}[]{p{2,15cm}p{1.45cm} p{1.45cm} p{1.45cm} p{1.45cm} p{1.45cm} p{1.45cm} p{1.45cm} p{1.45cm}} \hline
                     & (1)      & (2)                & (3)      & (4)      & (5)      & (6)      & (7)                & (8)                \\
     Dep. Var. Name                & Dep. Var. Name & $(\Delta)$Dep. Var. Name & Dep. Var. Name & Dep. Var. Name & Dep. Var. Name & Dep. Var. Name & $(\Delta)$Dep. Var. Name & $(\Delta)$Dep. Var. Name \\ \hline
                     &          &                    &          &          & \\          
     LONG NAME FE            & Yes      & No                 & Yes      & Yes      & Yes      & Yes      & No                 & No                 \\ \hline
     \multicolumn{9}{c}{ Robust standard errors in parentheses} \\
     \multicolumn{9}{c}{ *** p$<$0.01, ** p$<$0.05, * p$<$0.1} \\
     \end{tabular}
\end{minipage}}
\end{table} 
\end{document}

full width of page