3

I have already coded the table but I need to adjust it to stay inside the format.

\usepackage{booktabs}
\usepackage{fouriernc}
\begin{document}
   \begin{table} [h]
\centering
\begin{tabular}{l c c c c c c c c}p{2cm}
\toprule 
\toprule 
& \multicolumn{5}{c}{\textbf{Share of audited resources involving corruption}} \\ 
\cmidrule(l){2-8}
\textbf{Dependent variable} & OLS & OLS & OLS & OLS & OLS & OLS & Match & Tobit\\ 
& (1) & (2) & (3) & (4) & (5) & (6) & (7) & (8) \\       
\midrule
Mayor in first term  & -.0188012  & -.0197694 & -.0200195 & -.0235394 & -.0261273 & & -.0301907 & -.0418462  \\ 
&  (0.041) &  (-.022) & (0.044 ) & (0.014) & (0.009 ) & & 0.003 & 0.003 \\
$R^2$ & 0.0084 & 0.0772 & 0.1015 & 0.1158 & 0.1401 & & n/a & n/a \\ 
Observations & 476 & 476 & 476 & 476 & 476 & 476 & 476 & 476\\ 

\midrule 
\midrule 

\end{tabular}
\caption{The Effects of Reelection Incentives on Corruption} 
\label{tab:template}
\end{table}
\end{document}
5
  • Your code is not compilable as is. What is your document class?
    – Bernard
    Nov 11 '21 at 18:30
  • There's an error in youor column specifiers part. You probably wanted to use \begin{tabular}{l c c c c c c c c p{2cm}} instead of \begin{tabular}{l c c c c c c c c}p{2cm}. On the other hand, you don't really need this tenth column as you only really use the first nine, so \begin{tabular}{l c c c c c c c c } should also be sufficient.
    – leandriis
    Nov 11 '21 at 19:21
  • You are not asking about a figure but about a table. Nov 11 '21 at 19:23
  • What exactly do you want to adjust? The tite of your question mentions a figure, but the code only shows a table. In the body of your question, you write about "adjust it to stay inside the format". Do you refer to the table being wider than the available textwidth and flowing into the right margin or does this part refer to something else?
    – leandriis
    Nov 11 '21 at 19:24
  • Sorry, I was in a rush when I asked the question. Yes, it is a table, not a figure. My problem is that my last column will cut off and is not inside the format. So I want to make the table a little smaller. I tried what @leandriis suggested but it is still the same problem Nov 11 '21 at 20:18
4

You can reduce the font size and ask LaTeX to compute the space between columns by itself.

In the standard text width of article the table at \scriptsize fits, provided we do some adjustments, reducing the width of the first column by splitting the entry across two lines. Depending on the actual text width you might be able to use \footnotesize.

\documentclass[a4paper]{article}
\usepackage{booktabs}
\usepackage{fouriernc}
\usepackage{amsmath}

\newcommand{\splitcellnodepth}[2][c]{%
  \smash[b]{\begin{tabular}[t]{@{}#1@{}}#2\end{tabular}}%
}


\begin{document}

\begin{table}[htp]
\centering\scriptsize

\setlength{\tabcolsep}{0pt}
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}} l c c c c c c c c @{}}
\toprule 
\bfseries\splitcellnodepth[l]{Dependent \\ Variable} &
 \multicolumn{8}{c}{\textbf{Share of audited resources involving corruption}} \\ 
\cmidrule{2-9}
  & \multicolumn{6}{c}{OLS} & Match & Tobit\\ 
\cmidrule{2-7} \cmidrule{8-8} \cmidrule{9-9}
  & (1) & (2) & (3) & (4) & (5) & (6) & (7) & (8) \\       
\midrule
\splitcellnodepth[l]{Mayor in \\ first term}  &
  $-0.0188012$  & $-0.0197694$ & $-0.0200195$ & $-0.0235394$ & $-0.0261273$ & & $-0.0301907$ & $-0.0418462$  \\ 
&  $(0.041)$ &  $(-0.022)$ & $(0.044)$ & $(0.014)$ & $(0.009)$ & & $0.003$ & $0.003$ \\
\addlinespace
$R^2$ & $0.0084$ & $0.0772$ & $0.1015$ & $0.1158$ & $0.1401$ & & n/a & n/a \\ 
\addlinespace
Observations & 476 & 476 & 476 & 476 & 476 & 476 & 476 & 476\\ 
\bottomrule
\end{tabular*}

\caption{The Effects of Reelection Incentives on Corruption} 
\label{tab:template}
\end{table}

\end{document}

enter image description here

Are you sure about all those decimals in the first row?

Double rules should be avoided. Minus signs should not be hyphens, so I used math mode; also the leading zero before the decimal part should never be omitted.

2
  • 1
    This looks perfect!! Thank you so much) Nov 11 '21 at 21:15
  • 1
    @MaybelineLee For my humble opinion I would delete "looks"; it is perfect!! :-)
    – Sebastiano
    Nov 11 '21 at 21:18
0

Am I missing something? The table is too wide for the page geometry in portrait so... Rotate it?

Plenty of search-results on this sort of thing. The one I used: How to place a table on a new page with landscape orientation without clearing the current page?

In your case you have a couple options.

  1. Make the content (number of columns) adjusted to fit portrait mode rendering of that table.
  2. Rotate the table into landscape.

Or I could be completely misunderstanding the problem.

Your table, slightly marked up:

MWE

\documentclass[10pt]{article}

\usepackage{booktabs}
\usepackage{fouriernc}
\usepackage{pdflscape}

\begin{document}
\begin{landscape}
   \begin{table} [h]
\centering
\begin{tabular}{l c c c  c c c c c}
\toprule
\toprule
& \multicolumn{5}{c}{\textbf{Share of audited resources involving corruption}} \\
\cmidrule(l){2-8}
\textbf{Dependent variable} & OLS & OLS & OLS & OLS & OLS & OLS & Match & Tobit\\
& (1) & (2) & (3) & (4) & (5) & (6) & (7) & (8) \\
\midrule
Mayor in first term  & -.0188012  & -.0197694 & -.0200195 & -.0235394 & -.0261273 & & -.0301907 & -.0418462  \\
&  (0.041) &  (-.022) & (0.044 ) & (0.014) & (0.009 ) & & 0.003 & 0.003 \\
$R^2$ & 0.0084 & 0.0772 & 0.1015 & 0.1158 & 0.1401 & & n/a & n/a \\
Observations & 476 & 476 & 476 & 476 & 476 & 476 & 476 & 476\\

\midrule
\midrule

\end{tabular}
\caption{The Effects of Reelection Incentives on Corruption}
\label{tab:template}
\end{table}
\end{landscape}

\end{document}
1
  • Thank you for your work. I know that by rotating it, it would be fine but I would prefer it the usual way. Isn't there a way to just narrow the table down so it could fit the page? Nov 11 '21 at 21:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.