我正在创建一个带有交替颜色行的表格。但是,颜色似乎延伸了表格的上下规则,这看起来不太对劲。
另外,我的标题行可能应该是多行的,但我不太清楚该怎么做。我尝试使用第一列定义为“X”的 tabularx 环境,但它似乎在 threeparttable 环境中不起作用?
请原谅我的标题很乱,但我不确定我需要哪些包,不需要哪些包,所以我不想删除任何重要的东西......
这是MWE:
% Layout preamble
\documentclass[12pt, a4paper] {article}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage[margin=2.5cm,left=2.5cm,top=3cm,bottom=3cm,includefoot,headsep=.8in]{geometry}
\usepackage[dvipsnames,table]{xcolor}
%%%% For Fancy Style Format with Headers %%%%%%%%%%%%
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\lhead{\textcolor{Cyan}{\raisebox{-.5\baselineskip}[0pt][0pt]{Group No. 1}}}
\lfoot{\thepage}
\renewcommand{\footrulewidth}{0.8pt}
\renewcommand{\headrulewidth}{0.8pt}
\renewcommand{\headrule}{\hbox to\headwidth{%
\color{Cyan}\leaders\hrule height \headrulewidth\hfill}}
%%%%%%%%%%%% BOXES AROUND SECTIONS %%%%%%%%%%%%%%
%\usepackage{color}
\usepackage{titlesec}
\usepackage{tocloft}
\renewcommand{\cftsecleader}{\cftdotfill{\cftdotsep}}
\makeatletter
\newif\if@secnum
%\definecolor{lgray}{gray}{0.75}
\titleformat{\section}[hang]{\Large\bfseries}{%
\global\@secnumtrue
}{0em}{%
{%
\setlength{\fboxsep}{0pt}%
\colorbox{Cyan!30}{\makebox[\textwidth]{\Large\strut}}%
}%
\hspace*{-\textwidth}%
\if@secnum%
\arabic{section}%
\hspace*{1em}%
\fi%
\global\@secnumfalse%
}[]
\makeatother
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Math preamble
\usepackage{mathtools}
\DeclareMathOperator{\var}{var}
\usepackage{mathdesign}
\renewcommand{\vec}[1]{\mathbf{#1}}
\providecommand\given{}
\DeclarePairedDelimiterXPP\EV[1]{E}[]{}{
\renewcommand\given{\nonscript\;\delimsize\vert\nonscript\;\mathopen{}}
#1}
%Tables preamble
\usepackage{longtable}
\usepackage{tabularx}
\usepackage{marvosym}
\usepackage{setspace}
\usepackage{booktabs, rotating, dcolumn, siunitx, array}
\usepackage{multirow}
\usepackage{threeparttable}
\usepackage{enumitem}
% Graphics preamble
\usepackage{graphicx}
\usepackage{float}
\usepackage[skip=10pt, labelfont=bf, labelsep=space]{caption}
\makeatletter
\setlength{\@fptop}{0pt}
\makeatother
% Drawing figures in document
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{backgrounds, shapes, snakes}
% avoids hyphenation of words in tables
% cllickable hyperlinks preamble
\usepackage[hidelinks]{hyperref}
\usepackage{url}
\usepackage{hyphenat}
% Bibliography preamble
\usepackage[comma]{natbib}
\usepackage{har2nat}
\hypersetup{hidelinks=true}
\usepackage{etoolbox}
\apptocmd{\thebibliography}{\raggedright}{}{}
\makeatletter
\newcommand{\addcolonandeatperiod}{\@ifnextchar.{:\@gobble}\relax}
\makeatother
% for having raggedright footnotes
\usepackage[hang,flushmargin]{footmisc}
% Timeline tabular
% Sources under figures
\newcommand{\source}[1]{{\footnotesize Source: #1}}
% For eurosymbol
\usepackage{eurosym}
% Appendix
\usepackage{appendix}
\usepackage{capt-of}
\usepackage{pdfpages}
% Table headers:
\DeclareCaptionFormat{centerlabel}{{\centering #1\par}\medskip#3\par}
\captionsetup[table]{format=centerlabel}
\newcommand\firstpart[1]{{\centering\bfseries#1\par}\medskip}
\newcommand\secondpart[1]{\small#1}
% Small tabulars:
\newcommand{\mytab}[1]{%
\begin{tabular}{@{}c@{}}
#1
\end{tabular}
}
\nocite{*}
\usepackage{transparent}
\usepackage{transparent}
\usepackage{eso-pic}
\newcommand\BackgroundIm{
\put(0,-200){
\parbox[b][\paperheight]{\paperwidth}{%
\vfill
\centering
{\transparent{0.1}\includegraphics[height=0.4\paperheight,width=\paperwidth,
keepaspectratio]{./pie}%
\vfill}}}}
%%%% Document %%%%%%%%
\begin{document}
\pagestyle{fancy}
\rowcolors{2}{Cyan!25}{white}
\begin{table}[!h]
\centering
\begin{threeparttable}
\caption[Top 20 Holdings
]{%
\firstpart{Top 20 Holdings }
\secondpart{This table displays the 20 companies with biggest weights as of 20.09.2015.}
}\label{tab: assets}
\begin{tabular}{@{}lcccc@{}}
\rowcolor{Cyan!50}
\toprule
Name of Company & Ticker & Sector & Annualised & Annualised \\
\rowcolor{Cyan!50}
& & & Return & St. Dev. \\
\midrule
Humana Inc & HUM & Health Care & 38.54\% & 29.05\% \\
Thermo Fisher Scientific Inc & TMO & Health Care & 23.95\% & 20.64\% \\
Monsanto Co & MON & Materials & 22.04\% & 26.50\% \\
Tenet Healthcare Corp & THC & Health Care & 43.77\% & 45.46\% \\
Flextronics International Ltd & FLEX & Technology & 19.85\% & 29.07\% \\
Community Health Systems Inc & CYH & Health Care & 22.87\% & 41.32\% \\
Anthem Inc & ANTM & Health Care & 30.47\% & 22.19\% \\
Aetna Inc & AET & Health Care & 39.87\% & 20.90\% \\
Endo International PLC & ENDP & Health Care & 37.64\% & 37.74\% \\
VCA Inc & WOOF & Health Care & 20.82\% & 25.67\% \\
PVH Corp & PVH & Consumer & 25.76\% & 31.87\% \\
Allergan plc & AGN & Health Care & 52.27\% & 19.95\% \\
ManpowerGroup Inc & MAN & Industrials & 21.97\% & 33.42\% \\
CBS Corp & CBS & Consumer & 38.81\% & 27.97\% \\
Laboratory Corp of America Hol & LH & Health Care & 11.39\% & 16.13\% \\
Cigna Corp & CI & Health Care & 42.20\% & 21.65\% \\
Cadence Design Systems Inc & CDNS & Technology & 30.66\% & 22.24\% \\
Applied Materials Inc & AMAT & Technology & 14.36\% & 28.95\% \\
Brookdale Senior Living Inc & BKD & Health Care & 26.26\% & 37.42\% \\
Pentair PLC & PNR & Industrials & 19.89\% & 25.07\% \\
\bottomrule
\end{tabular}
\end{threeparttable}
\end{table}
\end{document}