Booktabs 和 arydshln 冲突

Booktabs 和 arydshln 冲突

我正在学习如何制作美观的表格,我想知道为什么下面的代码会产生错误“!未定义的控制序列。\adl@@cr ...tempdima \xdef \adl@rowsL {\adl@rowsL (\adl@colsL /\number \adl@... l.187 \end{xltabular}”等midrule停止工作:

\documentclass{article}
\usepackage[table]{xcolor}
\usepackage[margin=1in]{geometry}
\usepackage{tabularx}
\usepackage{enumitem}
\usepackage{booktabs}
\usepackage{arydshln}
%\setlength\dashlinedash{0.5pt}
%\setlength\dashlinegap{1.5pt}
\usepackage{lscape}
\setlist{nolistsep}
\definecolor{blue}{HTML}{008ED7}
\definecolor{mygray}{gray}{0.75}
\definecolor{lightBlue}{HTML}{e5f7ff}
\renewcommand{\familydefault}{\sfdefault}
%\renewcommand{\arraystretch}{1.5}



\usepackage{xltabular}
\usepackage{booktabs}
\usepackage{adjustbox}
\newcolumntype{L}[1]{>{\hsize=#1\hsize\linewidth=\hsize}>{\raggedright\arraybackslash}X}
\newcolumntype{R}[1]{>{\hsize=#1\hsize\linewidth=\hsize}>{\raggedleft\arraybackslash}X}
\newcolumntype{C}[1]{>{\hsize=#1\hsize\linewidth=\hsize}>{\centering\arraybackslash}X}




\begin{document}

% Table with minipage, header colors, dashline
\begin{center}
\begin{tabularx}{\textwidth}[t]{XX}
\arrayrulecolor{blue}\hline
\rowcolor{lightBlue} \textbf{\textcolor{blue}{Goal 1 Eradicate Extreme Poverty}} & \\
\hline
Target 1.A Halve, between 1990 and 2015, the proportion of the people whose income is less than \$1 a day. & 
\begin{minipage}[t]{\linewidth}%
\begin{itemize}
\item[1.1] Proportion of population below \$1 purchasing power parity (PPP) a day$^a$
\item[1.2] Poverty Gap ratio [incidence x depth of poverty]
\item[1.3] Share of the poorest quintile in national consumption
\end{itemize} 
\end{minipage}\\

\arrayrulecolor{mygray}\hline

Target 1.B Achieve full and productive employment and decent work for all, including women and young people &
\begin{minipage}[t]{\linewidth}%
\begin{itemize}
\item[1.4] Growth of GDP per person employed 
\item[1.5] Employment to population ratio
\item[1.6] Proportion of employed people living below \$1 (PP) a day
\item[1.7] Proportion of own-account and contribution family workers in total employment
\end{itemize} 
\end{minipage}\\

\hline

Target 1.C Halve, between 1990 and 2015, the proportion of people who suffer from hunger &
\begin{minipage}[t]{\linewidth}%
\begin{itemize}
\item[1.8] Prevalence of underweight children under five years of age
\item[1.9] Proportion of population below minimum level of dietary energy consumption
\end{itemize}
\end{minipage}\\

\arrayrulecolor{blue}\hline
\rowcolor{lightBlue} \textbf{\textcolor{blue}{Goal 2 Achieve universal primary education}} & \\
\hline

Target 2.A Ensure that by 2015 children everywhere, boy and girls alike, will be able to complete a full course of primary schooling. &
\begin{minipage}[t]{\linewidth}%
\begin{itemize}
\item[2.1] Net enrollment ratio in primary education
\item[2.2] Proportion of pupils starting grade 1 who reach last grade of primary education
\item[2.3] Literacy rate of 15- to 24-year-olds, women and men
\end{itemize}
\end{minipage}\\
\rowcolor{lightBlue} \multicolumn{2}{l}{%
\textbf{\textcolor{blue}{Goal 3 Promote gender equality and empower women}}} \\ \hdashline

Target 3.A Eliminate gender disparity in primary and secondary education, preferably by 2005, and in all levels of education no later than 2015 &
\begin{minipage}[t]{\linewidth}%
\begin{itemize}
\item[3.1] Ratios of girls to boys in primary, secondary and tertiary education
\item[3.2] Share of women in wage employment in the non-agricultural sector.
\end{itemize} 
\end{minipage}
\end{tabularx}
\end{center}
%\end{landscape}


\newpage

% tabularx and longtable
\begin{xltabular}{\textwidth}{C{0.2}|C{0.4}|C{0.4}}
\caption{A sample long table.} \label{tab:long} \\
\toprule
\multicolumn{3}{c}{\textbf{Table}} \\
\multicolumn{1}{c}{\textbf{First column}} & \multicolumn{1}{c}{\textbf{Second column}} & \multicolumn{1}{c}{\textbf{Third column}} \\ 
\midrule 
%\endhead

One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
\end{xltabular}

\end{document}

答案1

要找出哪些包确实相互冲突,让我们先将代码简化。下面是示例代码的一个版本,我删除了与您收到的错误消息无关的所有内容(包和内容):

\documentclass{article}

\usepackage[table]{xcolor}
\usepackage{booktabs}
\usepackage{arydshln}

\usepackage{xltabular}


\begin{document}

\begin{xltabular}{\textwidth}{X|X|X}
\toprule 
One & abcdef ghjijklmn & 123.456778 \\
\end{xltabular}

\end{document}

如果你现在将前三个包的加载顺序从

\usepackage[table]{xcolor}
\usepackage{booktabs}
\usepackage{arydshln}

\usepackage{booktabs}
\usepackage{arydshln}
\usepackage[table]{xcolor}

上述示例编译时没有任何错误。将此更改应用于示例代码也会导致代码编译时没有错误消息。


既然您提到“我正在学习如何制作美观的表格”:这是您的第一个表格的一个版本,它只是利用了该booktabs包来直观地区分各个目标和指标。我还使用了计数器来摆脱手动编号:

\documentclass{article}

\usepackage[margin=1in]{geometry}
\renewcommand{\familydefault}{\sfdefault}

\usepackage{enumitem}
\usepackage{booktabs}
\usepackage{xltabular}

\newcolumntype{L}[1]{>{\hsize=#1\hsize\linewidth=\hsize}>{\raggedright\arraybackslash}X}

\newcounter{goal}
\setcounter{goal}{0}

\newlist{tabenum}{enumerate}{1}
\setlist[tabenum]{label*=\thegoal.\arabic*.,
                  leftmargin=*, 
                  nosep,
                  before=\begin{minipage}[t]{\hsize}, 
                  after=\end{minipage}}

\newcommand{\mygoalline}[1]{\multicolumn{2}{l}{Goal \refstepcounter{goal}\thegoal\enspace #1}}




\begin{document}


\noindent
\begin{tabularx}{\textwidth}{>{\hangindent=12pt}L{0.35}L{0.65}}
\toprule
%\multicolumn{2}{@{}l}{Goal \refstepcounter{goal}\thegoal\enspace Eradicate Extreme Poverty} \\
\mygoalline{Eradicate Extreme Poverty}\\
\midrule
Target \thegoal.A Halve, between 1990 and 2015, the proportion of the people whose income is less than \$1 a day. & 
\begin{tabenum}[series=goal1]
\item Proportion of population below \$1 purchasing power parity (PPP) a day$^a$
\item Poverty Gap ratio [incidence x depth of poverty]
\item Share of the poorest quintile in national consumption
\end{tabenum} 
\\
\addlinespace

Target \thegoal.B Achieve full and productive employment and decent work for all, including women and young people &

\begin{tabenum}[resume=goal1]
\item Growth of GDP per person employed 
\item Employment to population ratio
\item Proportion of employed people living below \$1 (PP) a day
\item Proportion of own-account and contribution family workers in total employment
\end{tabenum} 
\\
\addlinespace

Target \thegoal.C Halve, between 1990 and 2015, the proportion of people who suffer from hunger &
\begin{tabenum}[resume=goal1]
\item Prevalence of underweight children under five years of age
\item Proportion of population below minimum level of dietary energy consumption
\end{tabenum}\\

\midrule
\mygoalline{Achieve universal primary education}  \\
\midrule

Target \thegoal.A Ensure that by 2015 children everywhere, boy and girls alike, will be able to complete a full course of primary schooling. &

\begin{tabenum}
\item Net enrollment ratio in primary education
\item Proportion of pupils starting grade 1 who reach last grade of primary education
\item Literacy rate of 15- to 24-year-olds, women and men
\end{tabenum}
\\

\midrule
\mygoalline{Promote gender equality and empower women} \\ 
\midrule

Target \thegoal.A Eliminate gender disparity in primary and secondary education, preferably by 2005, and in all levels of education no later than 2015 &

\begin{tabenum}
\item Ratios of girls to boys in primary, secondary and tertiary education
\item Share of women in wage employment in the non-agricultural sector.
\end{tabenum}\\ 
\bottomrule
\end{tabularx}

\end{document}

相关内容