Skip to content

Instantly share code, notes, and snippets.

@arielsonic
Created April 7, 2012 22:14
Show Gist options
  • Save arielsonic/2332429 to your computer and use it in GitHub Desktop.
Save arielsonic/2332429 to your computer and use it in GitHub Desktop.
Longtable Example
\documentclass[9pt]{article}
\usepackage[landscape, total={8.5in, 5.45in}, top=1.5in, bottom=1.25in, right=1.25in, left=1.25in, centering, includefoot]{geometry}
\usepackage{longtable, lmodern, microtype, caption, bm, multirow, booktabs}
\usepackage[T1]{fontenc}
\usepackage[table]{xcolor}
\usepackage[none]{hyphenat}
% Colors
\definecolor{lblue}{HTML}{F0F3F9}
\definecolor{lgrey}{HTML}{F9F9F9}
\definecolor{rulecolor}{HTML}{dddddd}
\definecolor{tableShade2}{HTML}{F1F5FA}
\definecolor{tableShade}{HTML}{FAFAFD}
\definecolor{tableShade3}{HTML}{DFDFDF}
\definecolor{tableShade4}{HTML}{C2A5CF}
\definecolor{tableShade5}{HTML}{E7D4E8}
\definecolor{tableShade6}{HTML}{A1D99B}
\definecolor{tableShade7}{HTML}{D9F0D3}
\definecolor{tableShade1}{HTML}{FFEDA0}
\pagestyle{empty}
\renewcommand{\familydefault}{\sfdefault}
\renewcommand{\arraystretch}{1.25}
\usepackage{arydshln}
\newcolumntype{x}[1]{>{\raggedright}p{#1}}
\arrayrulecolor{tableShade3}
\begin{document}
\setlength\LTpre{-0.3cm}
\rowcolors{1}{tableShade2}{white}
\newcommand{\CTPanel}[1]{%
\multicolumn{1}{>{\columncolor{white}}r|}{#1}}
\centering
\begin{longtable}{p{6.2cm}
p{0.5cm}
p{0.5cm}!{\color{white}\vrule width 4pt}
p{0.5cm}!{\color{white}\vrule width 20pt}
p{6.2cm}
p{0.5cm}
p{0.5cm}!{\color{white}\vrule width 4pt}
p{0.5cm}}
\hiderowcolors
\multicolumn{4}{c}{\textbf{First group}} & \multicolumn{4}{c}{\textbf{second group}}\\
\cmidrule(r{20pt}){1-4}\cmidrule{5-8}
&\multicolumn{2}{c}{\textbf {CC}} & \textbf{CO} & &\multicolumn{2}{c}{\textbf{CC}} & \textbf{CO}\\
\cmidrule(r{4pt}){2-3}\cmidrule(r{20pt}){4-4}\cmidrule(lr{4pt}){6-7}\cmidrule(){8-8}
& {\small 10+} & {\small 20$-$} & {\small 10$-$} && {\small 20+} & {\small 10$-$}& {\small 20$-$}\\
\specialrule{0.01em}{0.0em}{0em}
\endhead
%Complicated legend begins
\multicolumn{8}{@{}p {4in}}
{\raggedright
\begin{tabular}{llllll}
\hiderowcolors
\addlinespace[3pt]
\multicolumn{6}{@{}l}{\textbf{LEGEND}}\\
\multicolumn{6}{@{}l}{the really really really really long long poorly written line that is flowing off the margins of this table and causing grief in general. Is this long enough? If not, here are some more words.}\\
{\cellcolor{tableShade4}${\bm+^m}$}&: Monotonic Increase, Significant&
{\cellcolor{tableShade6}${\bm-^m}$}&: Monotonic Decrease, Significant&
{\cellcolor{tableShade1}${\bm*}$}&: Non-linear, Significant \\
{\cellcolor{tableShade4}${\bm+}$}&: Increase, Significant&
{\cellcolor{tableShade6}${\bm-}$}&: Decrease, Significant&
{\cellcolor{tableShade1}${\bm\pm}$}&: Mixed, Significant\\
{\cellcolor{tableShade5}$+^m$}&: Monotonic Increase&
{\cellcolor{tableShade7}$-^m$}&: Monotonic Decrease&
{\cellcolor{tableShade2}$\pm$}&: Mixed\\
{\cellcolor{tableShade5}$+$}&: Increase&
{\cellcolor{tableShade7}$-$}&: Decrease&
-&: Not computed\\
\end{tabular}
}
\endfoot
\hline
\showrowcolors
First&{\cellcolor{tableShade7}$-$}&{\cellcolor{tableShade7}$-$}&{\cellcolor{tableShade7}$-$}&Mirrored first&{\cellcolor{tableShade7}$-$}&{\cellcolor{tableShade7}$-$}&{\cellcolor{tableShade7}$-$}
\\\hline
Second&{\cellcolor{tableShade7}$-$}&{\cellcolor{tableShade7}$-$}&{\cellcolor{tableShade7}$-$}&Second&{\cellcolor{tableShade7}$-$}&{\cellcolor{tableShade7}$-$}&{\cellcolor{tableShade6}${\bm -}$}
\\\hline
Third from the end&{\cellcolor{tableShade7}$-$}&{\cellcolor{tableShade7}$-$}&{\cellcolor{tableShade7}$-$}&Third&{\cellcolor{tableShade7}$-$}&{\cellcolor{tableShade6}${\bm -}$}&{\cellcolor{tableShade7}$-$}
\\\hline
Penultimate&{\cellcolor{tableShade7}$-$}&{\cellcolor{tableShade7}$-$}&{\cellcolor{tableShade5}$+$}&Fourth&{\cellcolor{tableShade7}$-$}&{\cellcolor{tableShade6}${\bm -}$}&{\cellcolor{tableShade7}$-$}
\\\hline
Last&{\cellcolor{tableShade7}$-$}&{\cellcolor{tableShade7}$-$}&{\cellcolor{tableShade5}$+$}&Fifth&{\cellcolor{tableShade7}$-$}&{\cellcolor{tableShade6}${\bm -}$}&{\cellcolor{tableShade7}$-$}
\\\hline
\end{longtable}
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment