4

I have a table here, which is formatted in Microsoft Word. I wish to have the same table in LaTeX. Here is what I have tried to no avail:

\begin{table}[H]

\noindent
\begin{tabularx}{\linewidth}{|p{1cm}|p{2cm}|l|X|}
\toprule

\multicolumn{1}{c}{Aim} & \multicolumn{1}{c}{Personnel} & \multicolumn{1}{c}{Timelines} & \multicolumn{1}{c}{Outcomes} \\ 
\midrule
    1     & CI In, RA & 01/2014 - 06/2014 &  1. Collect data on fund characteristics, returns, and screening information for SRI funds. 2. Calculate Bayesian abnormal performance measures for SRI funds. 3. Determine the impact of investment screens and prior information on SRI fund performance. 4. Write working paper and send it for publication. \\
    2     & CI In, RA & 06/2014 - 11/2014 & 1. Collect data on cash flows, fund expenses, fund returns, benchmark and nonbenchmark asset returns, and screening information for SRI funds. 2. Calculate Bayesian and frequentist alphas, and apply sorting procedure. 3. Determine the impact of prior information, fund expenses, and nonbenchmark assets on SRI fund performance persistence and cash flow predictability. 4. Write working paper and send it for publication. \\
    3     & CI In, RA & 11/2014 - 05/2015 &  1. Collect data on stock characteristics, institutional ownership, analyst coverage, and screening information. 2. Model relationship between stock characteristics and stock screening policies. 3. Determine how SRI strategies influence a firm's economic behaviour. 4. Write working paper and send it for publication. \\
    4     & CI In, RA, PhD student & 05/2015 - 10/2015 & 1. Collect key economic and demographic data, SRI mutual fund, SRI indices characteristics, and return data. 2. Create database of economic and demographic factors. 3. Model relationship between SRI growth and economic and demographic factors. 4. Write working paper and send it for publication. \\
    5     & CI In, RA & 10/2015 - 03/2016 & 1. Collect fund characteristics data, screening data, and ESG rankings. 2. Create database with key analysis of types, total numbers, detailed screening process, and ethical ratings of portfolios. 3. Determine relationship between different types of fees, screening types/intensity, and ethicality of portfolios. 4. Write working paper and send it for publication. \\
    6     & CI In, RA, PhD student & 03/2016 - 12/2016 & 1. Collect available portfolio holdings data, SRI fund characteristics, and general Australian mutual fund market data. 2. Create database with calculation of competitive measure, ranked returns, and other relevant variables. 3. Determine relationship between the probability of disclosure and relevant factors. 4. Write working paper and send it for publication. \\
 \bottomrule


\end{tabularx}%
\end{table}

I would like to maintain the same borders (i.e., vertical lines between columns, horizontal lines around the entire table, etc) as in the MS Word file, however any other suggestions to make it look nicer is appreciated.

Also, this table will most likely span across 2 vertical pages (as shown in MS Word), how do I do that in LaTeX?


Here are pictures of the MS Word table:

enter image description here enter image description here

Also I just realised the MS Word table didnt format the column titles properly, the titles should all be on one row. To be honest, the MS Table doesn't look very nice, it be would be good to somehow make it look much nicer in LaTeX.


Using Excel2Latex's code:

\begin{table}[htbp]
  \centering
    \begin{tabular}{llll}
    \toprule
    Aim   & Personnel & Timeline & Outcomes \\
    \midrule
    1     & CI In, RA & 01/2014 - 06/2014 & 1. Collect data on fund characteristics, returns, and screening information for SRI funds.  \\
          &       &       & 2. Calculate Bayesian abnormal performance measures for SRI funds.  \\
          &       &       & 3. Determine the impact of investment screens and prior information on SRI fund performance.  \\
          &       &       & 4. Write working paper and send it for publication. \\
    2     & CI In, RA & 06/2014 - 11/2014 & 1. Collect data on cash flows, fund expenses, fund returns, benchmark and nonbenchmark asset returns, and screening information for SRI funds.  \\
          &       &       & 2. Calculate Bayesian and frequentist alphas, and apply sorting procedure.  \\
          &       &       & 3. Determine the impact of prior information, fund expenses, and nonbenchmark assets on SRI fund performance persistence and cash flow predictability.  \\
          &       &       & 4. Write working paper and send it for publication. \\
    3     & CI In, RA & 11/2014 - 05/2015 & 1. Collect data on stock characteristics, institutional ownership, analyst coverage, and screening information.  \\
          &       &       & 2. Model relationship between stock characteristics and stock screening policies.  \\
          &       &       & 3. Determine how SRI strategies influence a firm's economic behaviour.  \\
          &       &       & 4. Write working paper and send it for publication. \\
    4     & CI In, RA, PhD student & 05/2015 - 10/2015 & 1. Collect key economic and demographic data, SRI mutual fund, SRI indices characteristics, and return data.  \\
          &       &       & 2. Create database of economic and demographic factors.  \\
          &       &       & 3. Model relationship between SRI growth and economic and demographic factors.  \\
          &       &       & 4. Write working paper and send it for publication. \\
    5     & CI In, RA & 10/2015 - 03/2016 & 1. Collect fund characteristics data, screening data, and ESG rankings.  \\
          &       &       & 2. Create database with key analysis of types, total numbers, detailed screening process, and ethical ratings of portfolios.  \\
          &       &       & 3. Determine relationship between different types of fees, screening types/intensity, and ethicality of portfolios.  \\
          &       &       & 4. Write working paper and send it for publication. \\
    6     & CI In, RA, PhD student & 03/2016 - 12/2016 & 1. Collect available portfolio holdings data, SRI fund characteristics, and general Australian mutual fund market data.  \\
          &       &       & 2. Create database with calculation of competitive measure, ranked returns, and other relevant variables.  \\
          &       &       & 3. Determine relationship between the probability of disclosure and relevant factors.  \\
          &       &       & 4. Write working paper and send it for publication. \\
    \bottomrule
    \end{tabular}%
\end{table}%

Creates this output:

enter image description here

  • Use one of the packages for multi-page tables. – Thorsten Donig Dec 8 '13 at 14:11
  • I tried to access the .docx file from your dropbox site, but was unable to open it in my local copy of Word. (Well, I can open it, but I get a lot of binary gobbledygook.) Please check if the file got corrupted somehow during the upload process. – Mico Dec 8 '13 at 16:27
  • @Mico I've uploaded it again and also attached pictures of what the table looks like. It would be great if you could make it appear much nicer looking in LaTeX :) – TrueTears Dec 8 '13 at 16:33
  • You could try using one of the macros that export tables from word into tex code and then do adjustments. These macros usually work ok and don't need too much work afterwards. ctan.org/pkg/excel2latex is one of them. – user42358 Dec 8 '13 at 16:57
  • I've tried excel2latex and the output creates badboxes, I've edited my original post with the excel2latex code and output. Also it would be good if the 'PhD student' phrase could be entered on a new row rather than on the same row as 'CI In, RA', to minimize column width. – TrueTears Dec 8 '13 at 17:12
4

Thanks for uploading the "raw" contents of your file via the excel2latex utility. I like the fact that the base solution uses the booktabs package and features no vertical rules. :-)

Relative to your baseline tabular solution, I would suggest making the following adjustments:

  • Use a tabularx environment, and set its width to \textwidth (the width of the text block)

  • Don't use l column types for columns 2, 3, and 4, but (a) p column types for columns 2 and 3 (which allows wrapping of text) and (b) X for column 4 (which also allows wrapping of text, and it'll expand to take up the full available width).

  • Use >{RaggedRight} in columns 2 and 4 to suppress "full justification" while allowing hyphenation. If you don't want to permit hyphenation, use >{\raggedright} instead.

  • Don't hard-code the enumerated numbers in column 4 but use enumerate environments.

Separately, if you must have vertical rules between the columns, be sure to also replace all \toprule, \midrule, and \bottomrule instructions with \hlines.

The following code implements these ideas. It turns out that the table fits nicely on a single page, assuming "normal" margin settings and paper size.

enter image description here

\documentclass[a4paper]{article}
\usepackage[british]{babel} % choose a different language if necessary
\usepackage[margin=1in]{geometry} % choose margins to suit your purpose
\usepackage{tabularx,booktabs,ragged2e}
% Compute widths for columns 2 and 3
\newlength\mylena
\settowidth\mylena{PhD student}
\newlength\mylenb
\settowidth\mylenb{01/2014--}

% customize appearance of `enumerate` environment
\usepackage{enumitem}
\setlist{before={\vspace*{-0.58\baselineskip}},
         after ={\vspace*{-1\baselineskip}},
         nosep, 
         labelindent=0pt, leftmargin=*}

\begin{document}
\begin{table}[p] % tell LaTeX to typeset it on a page by itself
\begin{tabularx}{\textwidth}{@{} l 
  >{\RaggedRight}p{\mylena} 
  p{\mylenb} 
  >{\RaggedRight}X @{}}
\toprule
Aim & Personnel & Timeline & Outcomes\\
\midrule
1 & CI In, RA & 01/2014--06/2014 & 
\begin{enumerate}
\item  Collect data on fund characteristics, returns, and screening information for SRI funds. 
\item  Calculate Bayesian abnormal performance measures for SRI funds. 
\item  Determine the impact of investment screens and prior information on SRI fund performance. 
\item Write working paper and send it for publication.
\end{enumerate}\\
\midrule
2 & CI In, RA & 06/2014--11/2014 & 
\begin{enumerate}
\item  Collect data on cash flows, fund expenses, fund returns, benchmark and nonbenchmark asset returns, and screening information for SRI funds. 
\item Calculate Bayesian and frequentist alphas, and apply sorting procedure. 
\item Determine the impact of prior information, fund expenses, and nonbenchmark assets on SRI fund performance persistence and cash flow predictability. 
\item Write working paper and send it for publication.
\end{enumerate}\\
\midrule
3 & CI In, RA & 11/2014--05/2015 & 
\begin{enumerate}
\item  Collect data on stock characteristics, institutional ownership, analyst coverage, and screening information. 
\item Model relationship between stock characteristics and stock screening policies. 
\item Determine how SRI strategies influence a firm's economic behaviour. 
\item Write working paper and send it for publication.
\end{enumerate}\\
\midrule
4 & CI In, RA, PhD student & 05/2015--10/2015 & 
\begin{enumerate}
\item  Collect key economic and demographic data, SRI mutual fund, SRI indices characteristics, and return data. 
\item Create database of economic and demographic factors. 
\item Model relationship between SRI growth and economic and demographic factors. 
\item Write working paper and send it for publication.
\end{enumerate}\\
\midrule
5 & CI In, RA, PhD student & 10/2015--03/2016 & 
\begin{enumerate}
\item  Collect fund characteristics data, screening data, and ESG rankings. 
\item Create database with key analysis of types, total numbers, detailed screening process, and ethical ratings of portfolios. 
\item Determine relationship between different types of fees, screening types/intensity, and ethicality of portfolios. 
\item Write working paper and send it for publication.
\end{enumerate}\\
\midrule
6 & CI In, RA, PhD student & 03/2016--12/2016 & 
\begin{enumerate}
\item  Collect available portfolio holdings data, SRI fund characteristics, and general Australian mutual fund market data. 
\item Create database with calculation of competitive measure, ranked returns, and other relevant variables. 
\item Determine relationship between the probability of disclosure and relevant factors. 
\item Write working paper and send it for publication.
\end{enumerate}\\
\bottomrule
\end{tabularx}
\end{table}
\end{document}

Addendum: In the (fairly likely...) event that you need to use "ordinary" enumerate environments in the body of your document, you probably wouldn't want to redefine this environment in the way described in the MWE just to make it "work" in the table. Instead, you may want to "clone" the enumerate environment and modify the cloned environment to make it suitable for use in the table(s). Fortunately, it's easy to do so with the enumitem package:

\usepackage{enumitem}
\newlist{enumtab}{enumerate}{1}
\setlist[enumtab,1]{label=\arabic*.,
         before={\vspace*{-0.58\baselineskip}},
         after ={\vspace*{-1\baselineskip}},
         nosep, 
         labelindent=0pt, leftmargin=*}

The \newlist instruction creates a list-like environment called enumtab, to be patterned after the basic enumerate environment. The \setlist instruction defines the properties of this new, enumerate-like environment.

After setting up the enumtab environment in this way, use it in the tabularx environment instead of the (now no longer modified...) enumerate environment.

  • Thank you Mico, you answer was very in-depth and was precisely what I was looking for. I have two more related queries: 1. I use enumerate elsewhere in my document, so the preamble also affects those environments, is there any way I can use the customized enumerate environment just for the table? 2. Is there any way of ensuring the table automatically continues on to a newpage? I found that longtabu is the longtable version of tabularx but I am not sure regarding the syntax as I am almost illiterate when it comes to constructing non-standard LaTeX tables :-( – TrueTears Dec 9 '13 at 10:33
  • @TrueTears - Re your first question: Please see the addendum I've provided, on how to "clone" an enumerate-like environment. Re your second question: The environment ltxtable combines the capabilities of the longtable and tabularx environments. In my experience it works really well as long as you remember the requirement that the table has to be in a file by itself, loaded into the main file via an \input statement. If you need help getting this to work in practice, I would suggest you post a new query once you have a table that's longer than one page. – Mico Dec 9 '13 at 14:52
  • @TrueTears: A warning about the tabu package: it is somewhat buggy, and the package author has stated that the current version should not be used for anything important. – Charles Staats Dec 9 '13 at 14:53
  • @CharlesStaats - That's why I'm recommending using the ltxtable environment. :-) – Mico Dec 9 '13 at 14:54
  • @Charles Staats Thanks for the reminder, I will take note of that. – TrueTears Dec 10 '13 at 7:16

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.