# How to make a table like this in Latex?

I am quite new to Latex and I would like to make a table like the following (possibly with more rows in the 'Series' column):

Can anyone help me with that? I tried to look it up online but the codes failed (I am using Rmarkdown but so far Latex codes have always worked).

This is the code I tried (and variations):

\begin{center}
\begin{tabular}{ | m{5cm} | m{1cm}| m{1cm} | }
\hline
cell1 dummy text dummy text dummy text& cell2 & cell3 \\
\hline
cell1 dummy text dummy text dummy text & cell5 & cell6 \\
\hline
cell7 & cell8 & cell9 \\
\hline
\end{tabular}
\end{center}

• What did you try so far? A simple \begin{tabular}{llc} should serve as a place to start from. Jun 6, 2020 at 8:26
• Looks like a 'normal' table you can simply make with the \begin{tabular} environment. Please provide a MWE that our help can be more specific. Jun 6, 2020 at 8:26
• Edited the post including the code I tried Jun 6, 2020 at 8:32
• \documentclass{article} \usepackage{booktabs} \begin{document} \begin{center} \begin{tabular}{ llr } \toprule & Series & P squared\\ \midrule & cell1 dummy text & 0.67 \\ & cell1 dummy text & 0.67 \\ Factor 1 & cell1 dummy text & 0.67 \\ & cell1 dummy text & 0.67 \\ & cell1 dummy text & 0.67 \\ \midrule & cell1 dummy text & 0.67 \\ & cell1 dummy text & 0.67 \\ Factor 2 & cell1 dummy text & 0.67 \\ & cell1 dummy text& 0.67 \\ & cell1 dummy text& 0.67 \\ \bottomrule \end{tabular} \end{center} \end{document} should serve as a place to start from. Jun 6, 2020 at 8:39
• If your table ends up being wider than the textwidth (overfull box warning), take a look at the tabularx package and use seomthing like \begin{tabularx}{\textwidth}{lXc} instead. Jun 6, 2020 at 8:40

\begin{center}
\begin{tabular}{llc}
\hline
& Series & R-squared \\
\hline
& cell2 & cell3 \\
& Industrial Turnover Index, Manufacturing & cell3 \\
Factor 1 & cell2 & cell3 \\
& cell2 & cell3 \\
& cell2 & cell3 \\
\hline
\end{tabular}
\end{center}

• thanks to you as well! Jun 6, 2020 at 8:45

You can achieve this, e.g., by having a tabularx-environment with two columns. The first column is the left-aligned factor-column. The second column is the X-column.

That second column is to hold another tabularx-environment. That other tabularx's first column is the Series-column and is an X-column. That other tabularx's second column is the R-squared-column and is a centered-column whose width equals the width of the phrase "R-squared".

The width of the entire inner tabularx-environment should be \hsize as that denotes the width of the surrounding X-column.

In order to get the horizontal spacing right, you may wish to set \tabcolsep to zero-width and to use @ for inserting horizontal space between columns according to your likings.

You may also wish to use some macros of the booktabs-package for drawing horizontal lines of different thicknesses.

This is how—after a first glimpse on the image provided in the question—I would probably approach the matter.

\documentclass{article}
\usepackage{booktabs, tabularx}
\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}

\newlength\tabcolsepcopy
\newcommand\Rsquzaredhsize{}
\newbox\tempbox

\begin{document}

\noindent\hrulefill Width of line of text \hrulefill

\bigskip

\begingroup
\tabcolsepcopy=\tabcolsep
\tabcolsep=0ex
\noindent
\begin{tabularx}{\textwidth}{l@{\hspace{2\tabcolsepcopy}}X}
\toprule&%
{%
\begin{tabularx}{\hsize}[c]{X@{\hspace{2\tabcolsepcopy}}c}%
Series&R-squared%
\setbox\tempbox\hbox{R-squared}%
\xdef\Rsquzaredhsize{\the\wd\tempbox}%
\end{tabularx}%
}%
\\
\midrule
Factor 1%
&%
{%
\begin{tabularx}{\hsize}[c]{X@{\hspace{2\tabcolsepcopy}}C{\Rsquzaredhsize}}%
Producer Prices in Industry&0.67\\
Harmonised Index of Consumer Prices&0.56\\
Industrial Turnover Index, Manufacturing&0.53\\
Compensation of Employees&0.59\\
Gross Fixed Capital Formation Price Index&0.48%
\end{tabularx}%
}%
\\
\midrule
Factor 2%
&%
{%
\begin{tabularx}{\hsize}[c]{X@{\hspace{2\tabcolsepcopy}}C{\Rsquzaredhsize}}%
Cost of Borrowing for Households for House Purchase&0.49\\
6-month Euribor&0.45\\
1-year Euribor&0.45\\
3-month Euribor&0.44\\
Long-term Interest Rate Belgium&0.43%
\end{tabularx}%
}%
\\
\midrule
Factor 3%
&%
{%
\begin{tabularx}{\hsize}[c]{X@{\hspace{2\tabcolsepcopy}}C{\Rsquzaredhsize}}%
Government Spending Italy&0.61\\
Unit Labour Cost Germany&0.61\\
Government Spending Finland&0.61\\
Unit Labour Cost Luxembourg&0.60\\
Unit Labour Cost Italy&0.60%
\end{tabularx}%
}%
\\
\midrule
Factor 4%
&%
{%
\begin{tabularx}{\hsize}[c]{X@{\hspace{2\tabcolsepcopy}}C{\Rsquzaredhsize}}%
Row 1 of factor 4&0.01\\
Row 2 of factor 4&0.02\\
Long long row 3 of factor 4 Long long row 3 of factor 4 Long long row 3 of factor 4
Long long row 3 of factor 4 Long long row 3 of factor 4 Long long row 3 of factor 4
Long long row 3 of factor 4 Long long row 3 of factor 4 Long long row 3 of factor 4
Long long row 3 of factor 4 Long long row 3 of factor 4&0.03\\
Row 4 of factor 4&0.04\\
Row 5 of factor 4&0.05\\
Row 6 of factor 4&0.06%
\end{tabularx}%
}%
\\
\bottomrule
\end{tabularx}%
\endgroup
\end{document}


If you don't need linebreak-features and wish the table to be as narrow as possible, then use tabular-environments instead of tabularx-environments:

\documentclass{article}
\usepackage{booktabs}

\newlength\tabcolsepcopy

\begin{document}

\noindent\hrulefill Width of line of text \hrulefill

\bigskip

\begingroup
\tabcolsepcopy=\tabcolsep
\tabcolsep=0ex
\noindent
\begin{tabular}{l@{\hspace{2\tabcolsepcopy}}l@{\hspace{2\tabcolsepcopy}}c}
\toprule&Series&R-squared
\\
\midrule
Factor 1%
&%
\begin{tabular}[c]{l}%
Producer Prices in Industry\\
Harmonised Index of Consumer Prices\\
Industrial Turnover Index, Manufacturing\\
Compensation of Employees\\
Gross Fixed Capital Formation Price Index%
\end{tabular}%
&%
\begin{tabular}[c]{c}%
0.67\\
0.56\\
0.53\\
0.59\\
0.48%
\end{tabular}%
\\
\midrule
Factor 2%
&%
\begin{tabular}[c]{l}%
Cost of Borrowing for Households for House Purchase\\
6-month Euribor\\
1-year Euribor\\
3-month Euribor\\
Long-term Interest Rate Belgium%
\end{tabular}%
&%
\begin{tabular}[c]{c}%
0.49\\
0.45\\
0.45\\
0.44\\
0.43%
\end{tabular}%
\\
\midrule
Factor 3%
&%
\begin{tabular}[c]{l}%
Government Spending Italy\\
Unit Labour Cost Germany\\
Government Spending Finland\\
Unit Labour Cost Luxembourg\\
Unit Labour Cost Italy%
\end{tabular}%
&%
\begin{tabular}[c]{c}%
0.61\\
0.61\\
0.61\\
0.60\\
0.60%
\end{tabular}%
\\
\midrule
Factor 4%
&%
\begin{tabular}[c]{l}%
Row 1 of factor 4\\
Row 2 of factor 4\\
Row 3 of factor 4\\
Row 4 of factor 4\\
Row 5 of factor 4\\
Row 6 of factor 4%
\end{tabular}%
&%
\begin{tabular}[c]{c}%
0.01\\
0.02\\
0.03\\
0.04\\
0.05\\
0.06%
\end{tabular}%
\\
\bottomrule
\end{tabular}
\endgroup
\end{document}