0

I am using excel2latex and then inserting the tables into a latex document.

I can get the tables looking perfect in Word or Excel, but somehow in the conversion, the table is skewed and one of the columns is way out.

Any help would be appreciated.

How I want the table to look

How the table actually looks

% Table generated by Excel2LaTeX from sheet 'Sheet1'
\begin{table}[htbp]
  \centering
  \caption{Add caption}
    \begin{tabular}{cccccc}
    \multicolumn{6}{c}{Table I} \\
    \multicolumn{6}{c}{\textbf{Summary Statistics, Monthly Excess Stock Returns}} \\
    \multicolumn{6}{c}{\textbf{S\&P 500 and US XYZ}} \\
    \multicolumn{6}{p{44.22em}}{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 Economics Data. Blank Text. } \bigstrut[b]\\
    \hline
          & Mean  & Std.  &       & Mean  & Std. \bigstrut\\
    \hline
    \textcolor[rgb]{ 0,  .439,  .753}{\textbf{S\&P 500}} & 0.01  & 9.24  & S\&P 500 & 0.01  & 0.01 \bigstrut[t]\\
    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 \\
    \end{tabular}%
  \label{tab:addlabel}%
\end{table}%



<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="css/my.css" type="text/css"?>
<?sw-tagdefs href="resource://app/res/tagdefs/latexdefs.xml" type="text/xml" ?>
<html xmlns:sw="http://www.sciword.com/namespaces/sciword" xmlns="http://www.w3.org/1999/xhtml"
xmlns:mml="http://www.w3.org/1998/Math/MathML">
  <head><sw-meta id="sw-meta" product="Scientific WorkPlace" version="2017081800" created="Wed Mar
01 2017 11:41:53 GMT-0700 (MST)" lastrevised="Tue Jul 31 2018 11:38:53 GMT+0100 (GMT Daylight
Time)"/>
    <preamble hide="true">
      <documentclass class="article"/>
      <requirespackage package="amsfonts" pri="010"/>
      <requirespackage req="amsmath" pri="010"/>
      <preambleTeX><![CDATA[\newtheorem {theorem}{Theorem}
\newtheorem {acknowledgement}[theorem]{Acknowledgement} \newtheorem {algorithm}[theorem]{Algorithm}
\newtheorem {axiom}[theorem]{Axiom} \newtheorem {case}[theorem]{Case}
\newtheorem {claim}[theorem]{Claim} \newtheorem {conclusion}[theorem]{Conclusion}
\newtheorem {condition}[theorem]{Condition} \newtheorem {conjecture}[theorem]{Conjecture}
\newtheorem {corollary}[theorem]{Corollary} \newtheorem {criterion}[theorem]{Criterion}
\newtheorem {definition}[theorem]{Definition} \newtheorem {example}[theorem]{Example}
\newtheorem {exercise}[theorem]{Exercise} \newtheorem {lemma}[theorem]{Lemma}
\newtheorem {notation}[theorem]{Notation} \newtheorem {problem}[theorem]{Problem}
\newtheorem {proposition}[theorem]{Proposition} \newtheorem {remark}[theorem]{Remark}
\newtheorem {solution}[theorem]{Solution} \newtheorem {summary}[theorem]{Summary}
\newenvironment {proof}[1][Proof]{\noindent \textbf {#1.} }{\ \rule {0.5em}{0.5em}}]]>
      </preambleTeX>
    </preamble>
  </head>
  <body showexpanders="true" showfmbuttons="true" showshort="true" showinvis="true">
    <title xmlns="http://www.w3.org/1999/xhtml">Standard <texlogo
xmlns="http://www.w3.org/1999/xhtml" name="latex">L<sup>A</sup>T<sub>E</sub>X</texlogo> Article
    </title>
    <author> A. U. Thor
      <msibr invisDisplay="&#x21b5;" type="newLine"/>
      University of Stewart Island
      <br/>
    </author>
    <maketitle/>
    <section xmlns="http://www.w3.org/1999/xhtml" id="tsid_3141594">
      <sectiontitle>Standard <texlogo xmlns="http://www.w3.org/1999/xhtml"
name="latex">L<sup>A</sup>T<sub>E</sub>X</texlogo> Article
      </sectiontitle>
      <bodyText>This document illustrates the appearance of an article created with the shell <bold>
Standard <texlogo xmlns="http://www.w3.org/1999/xhtml"
name="latex">L<sup>A</sup>T<sub>E</sub>X</texlogo> Article</bold> or the shell <bold> Blank -
Standard <texlogo xmlns="http://www.w3.org/1999/xhtml"
name="latex">L<sup>A</sup>T<sub>E</sub>X</texlogo> Article</bold>. Both shells produce
documents with centered title information, left-justified headings, theorem environments, and
appendices.
      </bodyText>
      <bodyText>The standard <texlogo xmlns="http://www.w3.org/1999/xhtml"
name="latex">L<sup>A</sup>T<sub>E</sub>X</texlogo> shells provide the most general and portable set
of document features. You can achieve almost any typesetting effect by beginning with a standard
shell and adding    <texlogo xmlns="http://www.w3.org/1999/xhtml"
name="latex">L<sup>A</sup>T<sub>E</sub>X</texlogo> packages as necessary.
      </bodyText>
      <bodyText>The document class base file for this shell is <typewriter>article.cls</typewriter>.
      </bodyText>
      <bodyText><texb name="Table1" pre="0" pri="0"><![CDATA[% Table generated by Excel2LaTeX from
sheet 'Sheet1' \begin{table}[htbp]   \centering     \begin{tabular}{cccccc}
    \multicolumn{6}{c}{Table I} \\
    \multicolumn{6}{c}{\textbf{Summary Statistics, Monthly Excess
Stock Returns}} \\     \multicolumn{6}{c}{\textbf{S\&P 500 and US XYZ}} \\
    \multicolumn{6}{p{44.22em}}{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 Economics Data. Blank Text. } \bigstrut[b]\\
    \hline           & Mean  & Std.  &       & Mean  & Std. \bigstrut\\
    \hline
    \textcolor[rgb]{ 0,  .439,  .753}{\textbf{S\&P 500}} & 0.01  & 9.24  & S\&P 500 &
0.01  & 0.01 \bigstrut[t]\\     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 \\     \end{tabular}%
  \label{tab:addlabel}% \end{table}%]]></texb>
        <br/>
      </bodyText>
    </section>
  </body>
</html>
  • 1
    (i) welcome to tex.se! (ii) converting tables from excell to latexh usualy doesn't gives good results (iii) for help you we need a small but complete document with your table beginning with \documentclass{...} and ending by end{document}. help us to help you. – Zarko Jul 31 '18 at 9:17
  • 1
    The caption and the text shouldn't be in the \multicolumn – DG' Jul 31 '18 at 10:00
  • Thanks @DG' how should i include them then? – user22485 Jul 31 '18 at 10:43
  • I have added the full doc Zarko @Zarko I am using SWP – user22485 Jul 31 '18 at 10:43
  • what you added is not latex document ... it is not useful for many of us :-(. – Zarko Jul 31 '18 at 12:04
2

The title and description of the table should go on the caption. You can use the package caption to control how the captions are set.

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

\begin{document}


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

\caption{Summary Statistics, Monthly Excess Stock Returns} 
\caption*{\textbf{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 Economics Data. Blank Text.}


    \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 \\
    \end{tabular}%
  \label{tab:addlabel}%
\end{table}%

\end{document}

enter image description here

  • I appreciate you answer and I will accept it, however, can you see how different the table is above, can I spread the columns across so they line up with the caption and also how can I centre the captions at the top. – user22485 Jul 31 '18 at 10:45
  • 1
    I have now posted this as another question. Thanks – user22485 Jul 31 '18 at 11:04
3
  • as starting point i use answer of DG'
  • apparently you like to have table spread over whole text width (not very nice to my taste)
  • i suggest to align numbers at decimal points (usual i use S column type from the package siunitx)
  • for horizontal line use rules from the package booktabs

    \documentclass{article}
    \usepackage{xcolor}
    \usepackage{booktabs, tabularx}
    \newcolumntype{C}{>{\centering\arraybackslash}X}
    \newcommand\mcx[1]{\multicolumn{1}{C}{#1}}
    \usepackage{siunitx}
    \usepackage{caption}
    \captionsetup[table]{justification=centering, labelsep=newline, font=bf, skip=1ex} 
    
    \begin{document}
        \begin{table}[htbp]
    \caption{Summary Statistics, Monthly Excess Stock Returns S\&P 500 and US XYZ}
    \label{tab:addlabel}%
    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 Economics Data. Blank Text.
    
        \medskip
        \begin{tabularx}{\linewidth}{ C *{2}{S[table-format=2.2]}
                                      C *{2}{S[table-format=2.2]}
                                    }
        \toprule
                & \mcx{Mean}& {Std.}    &           & \mcx{Mean}& \mcx{Std.} \\
        \midrule
    \textcolor{cyan}{\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 \\
    S\&P 500    & 0.01      & 5.83      &      RF   & 0.01      & 0.01 \\
        \bottomrule
    \end{tabularx}
        \end{table}
    

enter image description here

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.