我有一张桌子这里,格式为 Microsoft Word。我希望在 LaTeX 中也有相同的表格。以下是我尝试过但无济于事的方法:
\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}
我希望保留与 MS Word 文件中相同的边框(即,列之间的垂直线、整个表格周围的水平线等),但是,如果能提供任何其他使其看起来更美观的建议,我们将不胜感激。
此外,该表格很可能会跨越 2 个垂直页面(如 MS Word 中所示),我如何在 LaTeX 中做到这一点?
以下是 MS Word 表格的图片:
另外,我刚刚意识到 MS Word 表格没有正确格式化列标题,标题应该全部在一行上。说实话,MS 表格看起来不太好看,如果能在 LaTeX 中让它看起来好看一点就好了。
使用Excel2Latex的代码:
\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}%
创建此输出:
答案1
booktabs
感谢您通过 excel2latex 实用程序上传文件的“原始”内容。我喜欢基本解决方案使用该包并且没有垂直规则这一事实。:-)
相对于您的基线tabular
解决方案,我建议进行以下调整:
使用
tabularx
环境,并将其宽度设置为\textwidth
(文本块的宽度)不要
l
对第 2、3 和 4 列使用列类型,而是 (a)p
对第 2 和第 3 列使用列类型(允许文本换行)和 (b)X
对第 4 列使用列类型(也允许文本换行,并且它将扩展以占据整个可用宽度)。在第 2 列和第 4 列中使用
>{RaggedRight}
可禁止“完全对齐”,同时允许连字符。如果不想允许连字符,请使用>{\raggedright}
。不要对第 4 列中的枚举数字进行硬编码,而是使用
enumerate
环境。
\toprule
另外,如果必须在列之间有垂直线,请确保将所有、\midrule
和\bottomrule
指令替换为\hline
s。
以下代码实现了这些想法。事实证明,假设边距设置和纸张大小为“正常”,表格可以很好地容纳在一页上。
\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}
附录enumerate
:如果您需要在文档主体中使用“普通”环境(这种情况很有可能发生) ,您可能不想按照 MWE 中描述的方式重新定义此环境,只是为了使其在表中“工作”。相反,您可能希望“克隆”enumerate
环境并修改克隆的环境以使其适合在表中使用。幸运的是,使用以下包可以轻松完成此操作enumitem
:
\usepackage{enumitem}
\newlist{enumtab}{enumerate}{1}
\setlist[enumtab,1]{label=\arabic*.,
before={\vspace*{-0.58\baselineskip}},
after ={\vspace*{-1\baselineskip}},
nosep,
labelindent=0pt, leftmargin=*}
该\newlist
指令创建一个名为 的列表类环境enumtab
,以基本环境为蓝本enumerate
。该\setlist
指令定义了这个新的枚举类环境的属性。
enumtab
这样设置好环境之后,就在该tabularx
环境中使用它,而不是在(现在不再修改……)enumerate
环境中使用。