# Table in Latex, created in Excel2Latex

Firstly, thank you for an answer from the previous post.

Here is a table that I have created, is there a way that I can have the actual table to start at the left of the text and end at the right of the text.

To make each of the columns slightly larger so it matches each side.

% Table generated by Excel2LaTeX from sheet 'Sheet1'
\begin{table}
\centering

\centering
\caption*{\textbf{Summary Statistics, Monthly Excess Stock Returns\\S\&P 500 and US XYZ}\\
\centering

This table reports summary statistics for XYZ currency excess returns (in percent) for industrialized countries. The excess return is the return on the broad market index and 123 XYZ in excess of the three-month US treasury bill rate. Data are from DataSource. FRED, Federal Reserve Economic.

\begin{tabular}{cccccc}
\hline
& Mean  & Std.  &       & Mean  & Std. \\
\hline
\textcolor[rgb]{ 0,  .439,  .753}{\textbf{S\&P 500}} & 0.01  & 9.24  & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 7.52  & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 7.98  & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 7.1   & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 7.21  & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 6.9   & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 7.87  & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 6.14  & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 7.35  & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 6.31  & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 8.61  & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 6.1   & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 9.42  & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 10.83 & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 7.3   & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 5.73  & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 7.59  & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 7.23  & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 7.69  & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 4.77  & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 9.29  & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 10.52 & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 6.53  & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 8.13  & S\&P 500 & 0.01  & 0.01 \\
\hline
\end{tabular}%

\end{table}%


Also I would appreciate if anyone could tell me how to move the :* next to Table 1.

• Please do post compilable code. What we need to help you is a so called minimal working example (MWE) – DG' Jul 31 '18 at 11:18
• I use Scientific workplace, so I am only interested in the table. – user22485 Jul 31 '18 at 11:22
• You could use tabularx like this: \begin{tabularx}{\linewidth}{*6{>{\centering\arraybackslash}X}} – Skillmon Jul 31 '18 at 11:22
• @ZarinaAkhtar And we're interested in helping you, which is easier if you provide us with compilable code. – Skillmon Jul 31 '18 at 11:23
• Take a look here on how to create a minimal working example (MWE). It should start with \documentclass and end with \end{document}, including every necessary package you need for your code snippet to run, but nothing more than the bare necessities. – Skillmon Jul 31 '18 at 11:26

The columns can be spread using the tabularx package. Per your example I have centered the caption, you can remove this in the \captionsetup call.

\documentclass{article}
\usepackage{xcolor}
\usepackage{tabularx}
\usepackage{caption}

% Remove "justification=centering" if the caption should not be centered
\captionsetup{font=bf, justification=centering}
\definecolor{blue}{rgb}{0,.439,.753}

\begin{document}

% Table generated by Excel2LaTeX from sheet 'Sheet1'
\begin{table}

\caption{Summary Statistics, Monthly Excess Stock Returns \\ S\&P 500 and US XYZ}%

This table reports summary statistics for XYZ currency excess returns (in percent) for industrialized countries. The excess return is the return on the broad market index and 123 XYZ in excess of the three-month US treasury bill rate. Data are from DataSource. FRED, Federal Reserve Economic.

\medskip

\begin{tabularx}{\linewidth}{c*5{>{\centering\arraybackslash}X}}
\hline
& Mean  & Std.  &          & Mean  & Std. \\
\hline
\textcolor{blue}{\textbf{S\&P 500}} & 0.01  & 9.24  & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 7.52  & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 7.98  & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 7.1   & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 7.21  & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 6.9   & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 7.87  & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 6.14  & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 7.35  & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 6.31  & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 8.61  & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 6.1   & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 9.42  & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 10.83 & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 7.3   & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 5.73  & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 7.59  & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 7.23  & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 7.69  & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 4.77  & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 9.29  & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 10.52 & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 6.53  & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 8.13  & S\&P 500 & 0.01  & 0.01 \\
\hline
\end{tabularx}%
\end{table}%

\end{document}


The star comes from the command \caption*{...}. To get rid of it you can either load the package "caption" with \usepackage{caption}, since the star command is defined there, or you can just ommit the star and use \caption{...} instead.

In order to specify the width (in this case \linewidth) of the table you have to use:

\begin{tabular*}{\linewidth}{cccccc}
...
\end{tabular*}


\begin{tabular}{cccccc}
...
\end{tabular}

• Ok, are you saying you don't know how to spread it across the page. – user22485 Jul 31 '18 at 11:23
• @ZarinaAkhtar in case this answer helps you, you can upvote it, but accept it only if it fully answers your original question. – Skillmon Jul 31 '18 at 11:24
• @ZarinaAkhtarI am saying that SWP and Excel2LaTeX are a messy combination. You should also clean up the code a little, e.g. \centering appears three times. – DG' Jul 31 '18 at 11:32

I suggest tabular*, with a generous amount of space in the middle.

\documentclass{article}
\usepackage{caption}
\usepackage{siunitx}
\usepackage{booktabs}
\usepackage{xcolor}

\captionsetup{font=bf}

\newcommand{\specialcell}[2]{\color{#1}\fontseries{b}\selectfont #2}

\definecolor{tableblue}{rgb}{0,.439,.753}

\begin{document}

\begin{table}
\caption{Summary Statistics, Monthly Excess Stock Returns \\ S\&P 500 and US XYZ}

This table reports summary statistics for XYZ currency excess returns (in percent) for
industrialized countries. The excess return is the return on the broad market index
and 123 XYZ in excess of the three-month US treasury bill rate. Data are from DataSource.
FRED, Federal Reserve Economic.

\medskip

\begin{tabular*}{\textwidth}{
@{\extracolsep{\fill}}
l
S[table-format=1.2]
S[table-format=2.2]
@{\hspace{6em}}
l
S[table-format=1.2]
S[table-format=2.2]
@{}
}
\toprule
& {Mean} & {Std.} & & {Mean} & {Std.} \\
\midrule
\specialcell{tableblue}{S\&P 500}
& 0.01  & 9.24  & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 7.52  & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 7.98  & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 7.1   & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 7.21  & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 6.9   & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 7.87  & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 6.14  & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 7.35  & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 6.31  & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 8.61  & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 6.1   & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 9.42  & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 10.83 & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 7.3   & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 5.73  & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 7.59  & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 7.23  & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 7.69  & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 4.77  & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 9.29  & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 10.52 & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 6.53  & S\&P 500 & 0.01  & 0.01 \\
S\&P 500 & 0.01  & 8.13  & S\&P 500 & 0.01  & 0.01 \\
\bottomrule
\end{tabular*}

\end{table}

\end{document}


Note also the use of caption to avoid \textbf in the caption text, which is wrong. For good alignment in the figures, I used siunitx features. With \fontseries{b}, the colored entry is not wider than the others in the same column, but still distinctly boldface.

• This is a great answer. Did not know about \fontseries{b}. Thanks! – chrisma Jul 31 '18 at 12:58