\documentclass[12pt, a4paper, oneside]{article}
\usepackage[english]{babel} % English language/hyphenation
\usepackage{lmodern}
\usepackage{textcomp}
\usepackage{xcolor}
\usepackage[utf8x]{inputenc}
\usepackage{xfrac}
\usepackage{lipsum}
\usepackage{sectsty} % Allows customizing section commands
\usepackage{tikz, pgfplots, pgfplotstable} %to plot figure
\usepackage{array, blkarray, tabularx, longtable, multirow,threeparttable, makecell, booktabs, caption}
\theadset{\renewcommand{\arraystretch}{0.6}}
\renewcommand\theadfont{\normalsize}
\usepackage{pgfplots, pgfplotstable} %to plot figure
\usepackage{threeparttable}
\newcolumntype{C}{>{\centering\arraybackslash}X} % centered version of "X" column type
\newcolumntype{Y}{>{\centering\arraybackslash}X}
\renewcommand\arraystretch{1.5}
\renewcommand{\tabcolsep}{5pt} % default is 6pt
\usepackage{pgfplots}
\usepackage{siunitx}
\newcommand*{\head}[1]{\textbf{#1}}% to make heads of table in BOLD, it is used with booktabs package and \head
\usepackage{cleveref}
\usepackage{url} \makeatletter \g@addto@macro{\UrlBreaks}{\UrlOrds} \makeatother
\usepackage[justification=centering]{caption}
\usepackage{csvsimple}
\usepackage{pdflscape}
\usepackage{amsmath, amsfonts, amsthm} % needed for command eqref or Math packages
\usepackage[
colorlinks=true
,breaklinks
%, ngerman
] {hyperref} % needed for creating hyperlinks in the docuent, the option colorlink=true gets rid of the awful boxes, breaklinks breaks lonk links (list of figures), and the ngerman sets everthing for german s default hyperlink languages.
\definecolor {c1}{rgb}{0,0, 1} % blue
\definecolor {c2}{rgb}{0.3,0.3, 0.9} % light blue
\definecolor {c3}{rgb}{0.3,0.3, 0.9} % red blue
\hypersetup{
linkcolor={c1}, % internal links
citecolor={c2}, % citations
urlcolor={c3} % external links/urls
}
\usepackage{longtable} % needed for long tables over pages
\usepackage{bigstrut} % needed for the command \bigstrut
\usepackage{enumerate} % needed for some options in enumerate
\usepackage{makeidx} % needed for creating an index
\usepackage{blindtext} % needed for creating dummy text passage
\usepackage{fancyhdr}
%\usepackage[T]{fontenc}
\usepackage{rotating}
\usepackage{array}
\usepackage{caption}
\usepackage{multicol}
\captionsetup[figure]{font=footnotesize,
labelsep=period}
\captionsetup[table]{font={footnotesize,sc},
labelsep=newline,
justification=centering}
\makeatletter
\long\def\ifnodedefined#1#2#3{%
\@ifundefined{pgf@sh@ns@#1}{#3}{#2}%
}
\pgfplotsset{
discontinuous/.style={
scatter,
scatter/@pre marker code/.code={
\ifnodedefined{marker}{
\pgfpointdiff{\pgfpointanchor{marker}{center}}%
{\pgfpoint{0}{0}}%
\ifdim\pgf@y>0pt
\tikzset{options/.style={mark=*, fill=white}}
\draw [densely dashed,blue] (marker-|0,0) -- (0,0);
\draw plot [mark=*] coordinates {(marker-|0,0)};
\else
\tikzset{options/.style={mark=none}}
\fi
}{
\tikzset{options/.style={mark=none}}
}
\coordinate (marker) at (0,0);
\begin{scope}[options]
},
scatter/@post marker code/.code={\end{scope}}
}
}
\makeatother
%% page settings%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[top=2cm, bottom=1.8cm, left=2.5cm, right=2.5cm]{geometry} % needed for page border stteings
\parindent=0cm % for spece of first line of new text block
\sloppy % for writing with hypenless justification (tries to)
%\usepackage[round, authoryear]{natbib} % needed for cite and abbrvnat bibliograph style
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\parindent 0ex
\pagestyle{fancy}
\fancyhf{}
\fancyhead {}
\frenchspacing
\fancyfoot{}
\fancyhead[L]{\slshape \MakeUppercase {Multidimensional Poverty Index (MPI) in Ethiopia}}
\fancyfoot[C]{\thepage}
%\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\renewcommand{\baselinestretch}{1.5}%This affects the in spacing of my paragraphes
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\theadset{\renewcommand{\arraystretch}{0.6}}
\renewcommand\theadfont{\small}
\renewcommand\theadalign{bc}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\begin{landscape}
\begin{center}
\begin{table}
\caption{Comparing Ethiopian Regulatory \\Performance with selected SSA countries}
\label{table1}
\begin{tabular}{ |p{5cm}||p{6cm}|p{6cm} |p{6cm} |p{6cm}|}
\hline
\multirow{5}{*}{Country} &
\multicolumn{2}{|c|}{Over all Ranking} &
\multicolumn{2}{|c|}{Basic Requirement} &
\multicolumn{2}{|c|}{Efficiency Enablers} &
\multicolumn{2}{|c|}{Innov. and Sophis. Factors} \\
\hline
Economy & Rank & Score & Rank & Score & Rank & Score & Rank & Score
\\
\hline
Tunisia & 95 & 3.92 & 79 & 4.41 & 103 & 3.65 & 104 & 3.32\\
\hline
Kenya & 96 & 3.9 & 115 & 3.81 & 75 & 4.03 & 40 & 4.03\\
\hline
Ethiopia & 109 & 3.77 & 106 & 3.96 & 117 & 3.47 & 74 & 3.53
\\ \hline
Cape Verde & 110 & 3.76 & 89 & 4.32 & 121 & 3.40 & 105 & 3.32
\\ \hline
\end{tabular}
\end{table}
\end{center}
\end{landscape}
--------
-------
\end{document}
我的目的是先制作一个 6 (行) x 5 (列) 的表格,然后将右侧的 4 列一分为二。我尝试过,从上面的努力可以看出。但是,LaTeX 给我一个错误,说“额外的对齐表已更改为 \cr。\endtemplate\multicolum... 您给出的 \span & 标记比正在进行的 \halign 或 \valign 序言中的多...”
我付出了巨大的努力,但还是失败了,因此我恳请您的帮助。请帮帮忙!
答案1
我建议使用这种布局,它需要hhline
和siunitx
用于表格中数字的对齐(S
列类型)。我借此机会稍微重新组织了您的序言(一些包被加载了两次,hyperref
应该是最后加载的包,只有极少数例外,最值得注意的是cleveref
,语言文件应该作为文档类的一个选项加载)。
\documentclass[12pt, a4paper, oneside, english]{article}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{babel} % English language/hyphenation
\usepackage{textcomp}
\usepackage{xfrac}
\usepackage{xcolor}
\usepackage{lipsum}
\usepackage{sectsty} % Allows customizing section commands
\usepackage{blkarray, tabularx, longtable, multirow,threeparttable, makecell, booktabs, hhline, caption}
\theadset{\renewcommand{\arraystretch}{0.6}}
\renewcommand\theadfont{\normalsize}
\newcolumntype{C}{>{\centering\arraybackslash}X} % centered version of "X" column type
% \newcolumntype{Y}{>{\centering\arraybackslash}X}
\renewcommand\arraystretch{1.5}
\setlength{\tabcolsep}{5pt} % default is 6pt
\usepackage{siunitx}
\newcommand*{\head}[1]{\textbf{#1}}% to make heads of table in BOLD, it is used with booktabs package and \head
\usepackage{url} \makeatletter \g@addto@macro{\UrlBreaks}{\UrlOrds} \makeatother
\usepackage[justification=centering]{caption}
\usepackage{csvsimple}
\usepackage{pdflscape}
\usepackage{amsmath, amsfonts, amsthm} % needed for command eqref or Math packages
\usepackage{bigstrut} % needed for the command \bigstrut
\usepackage{enumerate} % needed for some options in enumerate
\usepackage{makeidx} % needed for creating an index
\usepackage{blindtext} % needed for creating dummy text passage
\usepackage{fancyhdr}
\usepackage{rotating}
\usepackage{multicol}
\captionsetup[figure]{font=footnotesize,
labelsep=period}
\captionsetup[table]{font={footnotesize, sc},
labelsep=newline,
justification=centering}
\usepackage{tikz, pgfplots, pgfplotstable} %to plot figure
\makeatletter
\long\def\ifnodedefined#1#2#3{%
\@ifundefined{pgf@sh@ns@#1}{#3}{#2}%
}
\pgfplotsset{
discontinuous/.style={
scatter,
scatter/@pre marker code/.code={
\ifnodedefined{marker}{
\pgfpointdiff{\pgfpointanchor{marker}{center}}%
{\pgfpoint{0}{0}}%
\ifdim\pgf@y>0pt
\tikzset{options/.style={mark=*, fill=white}}
\draw [densely dashed,blue] (marker-|0,0) -- (0,0);
\draw plot [mark=*] coordinates {(marker-|0,0)};
\else
\tikzset{options/.style={mark=none}}
\fi
}{
\tikzset{options/.style={mark=none}}
}
\coordinate (marker) at (0,0);
\begin{scope}[options]
},
scatter/@post marker code/.code={\end{scope}}
}
}
\makeatother
%% page settings%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[a4paper, top=2cm, bottom=1.8cm, left=2.5cm, right=2.5cm]{geometry} % needed for page border stteings
\parindent=0cm % for spece of first line of new text block
\sloppy % for writing with hypenless justification (tries to)
%\usepackage[round, authoryear]{natbib} % needed for cite and abbrvnat bibliograph style
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[
colorlinks=true
,breaklinks
%, ngerman
] {hyperref} % needed for creating hyperlinks in the docuent, the option colorlink=true gets rid of the awful boxes, breaklinks breaks lonk links (list of figures), and the ngerman sets everything for german s default hyperlink languages.
\definecolor {c1}{rgb}{0,0, 1} % blue
\definecolor {c2}{rgb}{0.3,0.3, 0.9} % light blue
\definecolor {c3}{rgb}{0.3,0.3, 0.9} % red blue
\hypersetup{
linkcolor={c1}, % internal links
citecolor={c2}, % citations
urlcolor={c3} % external links/urls
}
\usepackage{cleveref}%% to be loaded after hyperref
%\parindent 0ex
\pagestyle{fancy}
\fancyhf{}
\fancyhead {}
\frenchspacing
\fancyfoot{}
\fancyhead[L]{\slshape \MakeUppercase {Multidimensional Poverty Index (MPI) in Ethiopia}}
\fancyfoot[C]{\thepage}
%\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\renewcommand{\baselinestretch}{1.5}%This affects the in spacing of my paragraphs
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\theadset{\renewcommand{\arraystretch}{0.6}}
\renewcommand\theadfont{\small}
\renewcommand\theadalign{bc}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\begin{landscape}
\centering\sisetup{table-alignment=center, table-column-width =2.4cm}
\setlength\doublerulesep{4pt}
\begin{table}
\caption{Comparing Ethiopian Regulatory Performance with selected SSA countries}
\label{table1}
\begin{tabularx}{\linewidth}{ |X||*{3}{S[table-format=3.0]| >{}S[table-format=1.2]||}S[table-format=3.0]| >{}S[table-format=1.2]|}
\multicolumn{1}{c}{} & \multicolumn{8}{c}{Economy}\\
\hhline{~||--||--||--||--|}
\multicolumn{1}{c!{\phantom{\vrule}\vrule}}{} &
\multicolumn{2}{c||}{Over all Ranking} &
\multicolumn{2}{c||}{Basic Requirement} &
\multicolumn{2}{c||}{Efficiency Enablers} &
\multicolumn{2}{c|}{Innov. and Sophis. Factors} \\
\hhline{|~||--||--||--||--|}
\addlinespace[4pt]
\hhline{|-||--||--||--||--|}
Country& {Rank} & {Score} & {Rank} & {Score} & {Rank }& {Score} & {Rank} & {Score}
\\
\hhline{|-||--||--||--||--|}
Tunisia & 95 & 3.92 & 79 & 4.41 & 103 & 3.65 & 104 & 3.32\\
\hhline{|-||--||--||--||--|}
Kenya & 96 & 3.9 & 115 & 3.81 & 75 & 4.03 & 40 & 4.03\\
\hhline{|-||--||--||--||--|}
Ethiopia & 109 & 3.77 & 106 & 3.96 & 117 & 3.47 & 74 & 3.53 \\
\hhline{|-||--||--||--||--|}
Cape Verde & 110 & 3.76 & 89 & 4.32 & 121 & 3.40 & 105 & 3.32 \\
\hhline{|-||--||--||--||--|}
\end{tabularx}
\end{table}
\end{landscape}
\end{document}