我有一张很大的桌子,正在用 LyX 编辑
我尝试使用 rowcolors 来获得交替行颜色,但它不起作用
这看起来取决于使用\tabularnewline
而不是\\
标题列包含多行文本(格式化为p
),所以我想\tabularnewline
必须使用
如何以最小的努力获得交替行的颜色?
样本
%% LyX 2.1.4 created this file. For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage[table]{xcolor}
\usepackage[a4paper]{geometry}
\geometry{verbose,lmargin=1cm,rmargin=1cm,headheight=1cm,headsep=1cm}
\setlength{\parindent}{0bp}
\definecolor{lightgray}{gray}{0.9}
%\usepackage{color}
\usepackage{array}
\usepackage{setspace}
\usepackage{esint}
\PassOptionsToPackage{normalem}{ulem}
\usepackage{ulem}
\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
%% Because html converters don't know tabularnewline
\providecommand{\tabularnewline}{\\}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\renewcommand{\arraystretch}{0.9}%
\setlength{\tabcolsep}{.07667em}
\makeatother
\usepackage{babel}
\begin{document}
\begin{spacing}{0.7}
\noindent \begin{flushleft}
\rowcolors{0}{lightgray}{white}
\begin{tabular*}{2cm}{@{\extracolsep{\fill}}>{\raggedright}m{28mm}|>{\centering}m{14mm}|>{\centering}m{16mm}|>{\centering}m{1.6cm}|>{\centering}m{1.8cm}|>{\centering}m{2cm}|>{\centering}m{1.8cm}|>{\centering}m{1.8cm}|}
\cline{2-8}
& {\footnotesize{}1} & {\footnotesize{}2} & {\footnotesize{}3} & {\footnotesize{}4} & {\footnotesize{}5} & {\footnotesize{}6} & {\footnotesize{}7}\tabularnewline
\cline{2-8}
{\footnotesize{}Aaaaaaaaa aaaaaa aaaa } & {\footnotesize{}n/y} & {\footnotesize{}y} & {\footnotesize{}y} & {\footnotesize{}y} & {\footnotesize{}y} & {\footnotesize{}y} & {\footnotesize{}y}\tabularnewline
\cline{2-8}
{\footnotesize{}Bbbbbb bbbbb bbbbb} & {\footnotesize{}n/y} & {\footnotesize{}n/y} & {\footnotesize{}y} & {\footnotesize{}y} & {\footnotesize{}y} & {\footnotesize{}y} & {\footnotesize{}y}\tabularnewline
\cline{2-8}
\end{tabular*}
\par\end{flushleft}
\end{spacing}
\end{document}
以下工作:
%% LyX 2.1.4 created this file. For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage[table]{xcolor}
\usepackage[a4paper]{geometry}
\geometry{verbose,lmargin=1cm,rmargin=1cm,headheight=1cm,headsep=1cm}
\setlength{\parindent}{0bp}
\definecolor{lightgray}{gray}{0.9}
%\usepackage{color}
\usepackage{array}
\usepackage{setspace}
\usepackage{esint}
\PassOptionsToPackage{normalem}{ulem}
\usepackage{ulem}
\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
%% Because html converters don't know tabularnewline
\providecommand{\tabularnewline}{\\}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\renewcommand{\arraystretch}{0.9}%
\setlength{\tabcolsep}{.07667em}
\makeatother
\usepackage{babel}
\begin{document}
\begin{spacing}{0.7}
\noindent \begin{flushleft}
\rowcolors{0}{lightgray}{white}
\begin{tabular}{@{\extracolsep{\fill}}>{\raggedright}m{28mm}|>{\centering}m{14mm}|>{\centering}m{16mm}|>{\centering}m{1.6cm}|>{\centering}m{1.8cm}|>{\centering}m{2cm}|>{\centering}m{1.8cm}|>{\centering}m{1.8cm}|}
\hline
& {\footnotesize{}1} & {\footnotesize{}2} & {\footnotesize{}3} & {\footnotesize{}4} & {\footnotesize{}5} & {\footnotesize{}6} & {\footnotesize{}7}\tabularnewline
\hline
{\footnotesize{}Aaaaaaaaa aaaaaa aaaa } & {\footnotesize{}n/y} & {\footnotesize{}y} & {\footnotesize{}y} & {\footnotesize{}y} & {\footnotesize{}y} & {\footnotesize{}y} & {\footnotesize{}y}\tabularnewline
\hline
{\footnotesize{}Bbbbbb bbbbb bbbbb} & {\footnotesize{}n/y} & {\footnotesize{}n/y} & {\footnotesize{}y} & {\footnotesize{}y} & {\footnotesize{}y} & {\footnotesize{}y} & {\footnotesize{}y}\tabularnewline
\hline
\end{tabular}
\par\end{flushleft}
\end{spacing}
\end{document}