1

I am new to Latex, and I was trying to make a table. Everything was fine, until I added the last merged row for notes. It turned out like this: enter image description here

The code I used is here below:

\pagebreak
\begin{landscape}
\begin{center}
\textit{Table 1: Table 1: Effect of earthquake intensity (MMI) on PC index}\\
\vspace*{.2in}
\begin{tabular} { l c c c c c c c c }
\hline
 & (1) & (2) & (3) & (4) & (5) & (6) & (7) & (8)\\
\hline
\underline{Independent variables}\\
\\[-2em]
Year is 2016 & .925*** & .906* & .689 & -.071 & .029 & -.219 & 1.056 & .000\\
\\[-3em]
 & (.153) & (.531) & (.481) & (.441) & (.437) & (.408) & (1.621) & (.000)\\
MMI & -.063*** & -.060* & -.047 & .107* & .097 & -.126 & -.049 & .000\\
\\[-3em]
 & (.022) & (.074) & (.070) & (.061) & (.060) & (.064) & (.243) & (.000)\\
\hline
Fixed effects & No & Yes & Yes & Yes & Yes & Yes & Yes & Yes\\
\\[-2em]
Household controls & No & No & Yes & Yes & Yes & Yes & Yes & Yes\\
\\[-2em]
Earthquake controls & No & No & No & Yes & Yes & Yes & Yes & Yes\\
\\[-2em]
Embargo controls & No & No & No & No & No & No & Yes & Yes\\
\\[-2em]
RCT treatment controls & No & No & No & No & No & No & No & Yes\\
\hline
N & 5,875 & 5,756 & 5,721 & 3,986 & 3,988 & 3,986 & 3,151 & .000\\
\\[-2em]
R-squared & .047 & .047 & .151 & .129 & .133 & .129 & .096 & .000\\
\hline
\multicolumn{9}{l}{\underline{Notes:}}\\
\multicolumn{9}{l}{Regressions (3) and (4) use the same set of controls. (3) controls for a dummy of whether the household receive any aid, and (4) controls for the total amount of aid received. Regressions in all other columns control for the dummy of aid received.}\\
\multicolumn{9}{l}{Regression (4) uses interaction of MMI with earthquake-related variables (aid received or not, death of household member, and fallen agricultural prices) instead of controlling them.}\\

\end{tabular}
\end{center}

Is there any way I can fix the width of the last row with notes to the size of the table before I added the text in the row so that it would not continue to increase horizontally as I add more text? Thanks a lot!

3
  • Welcome to TeX.SX! Please turn your code famgent into a compilable minimal working example (MWE) by adding the documentclass as well as the relevant package.
    – leandriis
    Commented Feb 21, 2019 at 21:11
  • Welcome to TeX.SE. Real quick: What are the directives \\[-3em] and \\[-2em] supposed to achieve except, possibly assure the utter unreadability of the formatted table?
    – Mico
    Commented Feb 21, 2019 at 21:11
  • 1
    For the table notes you might be interested in the threeparttable package.
    – leandriis
    Commented Feb 21, 2019 at 21:16

1 Answer 1

3

Your LaTeX code suffers from a number of fairly serious issues.

  • Do get rid of all [-2em] and [-3em] spacing modifiers.

  • To typeset table-related notes, I suggest you look into using the threeparttable package and its eponymous environment. Use \tnote directives to set footnote markers, and use a tablenotes environment to typeset the corresponding footnote. A really, really nifty aspect of using a threeparttable environment is that LaTeX will automatically calculate the width of the tablenotes environment for you, to coincide with the width of the tabular environment.

  • Please don't use underlining for emphasis. It's extremely poor typographic practice. Do use either boldfacing or italics to create emphasis.

enter image description here

\documentclass{article}
\usepackage{pdflscape,booktabs}
\usepackage[flushleft]{threeparttable}
\renewcommand\TPTtagStyle{\textit} 
\usepackage[font=it,skip=0.5\baselineskip]{caption} % italic text for captions

\begin{document}

\begin{landscape}
\begin{table}
\centering
\begin{threeparttable}
\caption{Effect of earthquake intensity (MMI) on PC index}

\begin{tabular} {@{} l *{8}{c} @{}}
\toprule
 & (1) & (2) & (3)\tnote{a,b} & (4)\tnote{b} & (5) & (6) & (7) & (8)\\
\cmidrule(l){2-9}
\emph{Independent variables}\\[1ex]
Year is 2016 & .925*** & .906* & .689 & $-$.071 & .029 & $-$.219 & 1.056 & .000\\
 & (.153) & (.531) & (.481) & (.441) & (.437) & (.408) & (1.621) & (.000)\\[1ex]
MMI & $-$.063*** & $-$.060* & $-$.047 & .107* & .097 & $-$.126 & $-$.049 & .000\\
 & (.022) & (.074) & (.070) & (.061) & (.060) & (.064) & (.243) & (.000)\\
\midrule
Fixed effects       & No & Yes & Yes & Yes & Yes & Yes & Yes & Yes\\
Household controls  & No & No  & Yes & Yes & Yes & Yes & Yes & Yes\\
Earthquake controls & No & No  & No  & Yes & Yes & Yes & Yes & Yes\\
Embargo controls    & No & No  & No  & No  & No  & No  & Yes & Yes\\
RCT treatment controls & No & No & No & No & No  & No  & No  & Yes\\
\midrule
$N$ & 5,875 & 5,756 & 5,721 & 3,986 & 3,988 & 3,986 & 3,151 & .000\\
R\textsuperscript{2} & .047 & .047 & .151 & .129 & .133 & .129 & .096 & .000\\
\bottomrule
\end{tabular}

\smallskip
\emph{Notes:}
\begin{tablenotes}
\item[a] Regressions (3) and (4) use the same set of controls. (3) controls for a dummy of whether the household receive any aid, and (4) controls for the total amount of aid received. Regressions in all other columns control for the dummy of aid received.
\item[b] Regression (4) uses interaction of MMI with earthquake-related variables (aid received or not, death of household member, and fallen agricultural prices) instead of controlling them.
\end{tablenotes}
\end{threeparttable}

\end{table}

\end{landscape}
\end{document}
3
  • Woah, thanks a lot for the detailed code. Your code has so many things done so simply that I did not think exists. One confusion is regarding the threeparttable command. Does it divide the table into three sections, I am assuming, the caption, the tabular, and the table notes?
    – Jerry
    Commented Feb 22, 2019 at 6:15
  • @SamyamShrestha - As you surmised, threeparttable can contain up to 3 elements: A \caption, a tabular-like environment (tabular, tabular*, tabularx, etc), and a tablenotes environment. The threeparttable environment then limits the widths of the caption and of the notes to the width of the tabular-like material. I wouldn't say, though, that threeparttable divides its contents into three parts or sections. A threeparttable environment doesn't actually have to contain exactly 3 elements; 2 out of 3 is ok too, as long as one element is the tabular-like environment.
    – Mico
    Commented Feb 22, 2019 at 8:42
  • Ah, okay, thanks a lot, for your wonderful answer and reply!!
    – Jerry
    Commented Feb 22, 2019 at 17:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .