\documentclass[12pt, a4paper, oneside]{article}
\usepackage[english]{babel} % English language/hyphenation
\usepackage{lmodern}
\usepackage{textcomp}
\usepackage[utf8x]{inputenc}
\usepackage{xfrac}
%\usepackage[sc]{mathpazo}
\usepackage{sectsty} % Allows customizing section commands
\usepackage{multirow}
\usepackage{tikz}
%\usepackage{booktabs} %to use \toprule and \bottomrule without error message
\usepackage{pgfplots, pgfplotstable} %to plot figure
\usepackage{threeparttable}
\usepackage{booktabs,tabularx,caption}
\newcolumntype{C}{>{\centering\arraybackslash}X} % centered version of "X" column type
\usepackage{booktabs,siunitx}
\sisetup{table-format=1.3} % default numerical column spec
\usepackage{multirow,tabularx}
\newcolumntype{Y}{>{\centering\arraybackslash}X}
\renewcommand\arraystretch{1.5}
\renewcommand{\tabcolsep}{5pt} % default is 6pt
....(some usepackages omited here)
%\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
%\usepackage[a4paper, portrait, margin=1in]{geometry}
\usepackage{adjustbox}
\usepackage{tabularx}
\usepackage{pgfplots, pgfplotstable}
\usepackage{booktabs,csvsimple}
\usepackage{pdflscape}
\usepackage{amsmath, amsfonts, amsthm} % needed for command eqref or Math packages
\usepackage{amssymb} % needed for math fonts
\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.
%\usepackage[hyphenbreaks]{breakurl}
\usepackage{cleveref}
\usepackage{xcolor}
\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[round, authoryear]{natbib} % needed for abbrvant bibliography style
%\usepackage[nottoc]{tocbibind} % needed for displaying bibliography and other in the table of contents
\usepackage{graphicx} % needed for\includegraphics
%\imp{graphicx}
\usepackage{longtable} % needed for long tables over pages
\usepackage{bigstrut} % needed for the command \bigstrut
\usepackage{enumerate} % needed for some options in enumerate
\usepackage{blkarray}
%\usepackage{todonotes} % needed for todos
\usepackage{makeidx} % needed for creating an index
%\usepackage{xcolor}
\usepackage{blindtext} % needed for creating dummy text passage
\usepackage{lipsum}
\usepackage{setspace}
\usepackage{fancyhdr}
\usepackage{float}
\usepackage[nottoc, notlot, notlof]{tocbibind}
\usepackage[nottoc]{tocbibind} % needed for displayng bibliography and other in the able of contents
%\usepackage{figures}
\usepackage{xspace}
\usepackage{makecell}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
%\usepackage[T]{fontenc}
\usepackage{rotating,booktabs}
\usepackage{lscape}
\usepackage{array}
\makeatletter
...
\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{landscape}
\begin{table}
\caption{Sample}
\label{tab:10}
\begin{tabularx}{\textwidth}{8 CCCCCC }
\toprule
Region & National and Regional MPI=(H*A) & \multicolumn{2}{c}{Population in the MPI} & \multicolumn{2}{c}{ MPI Chronic population} \multicolumn{2}{c}{Population Vulnerable to MPI}\\
\cmidrule(lr){3-4} \cmidrule(l){5-6} \cmidrule(lr){7-8}
& Svy Yrs & Index & Headcount & Intensity & XXX & YYY & XXX & YYY\\
\midrule
Ethiopia & Z & Y & 20 & 30 &100 & 110 & 12 & 15\\
Addis Ababa & Z & Y & 20 & 30 &100 & 110 & 12 & 15 \\
Afar & Z & Y & 20 & 30 &100 & 110 & 12 & 15\\
Amhara & Z & Y & 20 & 30 &100 & 110 & 12 & 15\\\addlinespace
Benishnagul-Gumuz & Z & Y & 20 & 30 &100 & 110 & 12 & 15\\
Dire Dawa & Z & Y & 20 & 30 &100 & 110 & 12 & 15\\
Gambela & Z & Y & 20 & 30 &100 & 110 & 12 & 15\\
Harari & Z & Y & 20 & 30 &100 & 110 & 12 & 15 \\\addlinespace
Oromia & Z & Y & 20 & 30 &100 & 110 & 12 & 15 \\
Somali & Z & Y & 20 & 30 &100 & 110 & 12 & 15 \\
SNNP & Z & Y & 20 & 30 &100 & 110 & 12 & 15 \\
Tigray & Z & Y & 20 & 30&100 & 110 & 12 & 15 \\\addlinespace
\bottomrule
\end{tabularx}
\end{table}
\end{landscape}
- 但是,它没有生成预期的表格/它给出了错误。因此,我希望得到您的关注和帮助!
答案1
这是经过修正/改进的代码。我重新组织了你的序言,将所有用于表格的包分组。
\documentclass[12pt, a4paper, oneside, english]{article}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{babel} % English language/hyphenation
\usepackage{textcomp}
\usepackage{xfrac}
%\usepackage[sc]{mathpazo}
\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}
\newcolumntype{C}{>{\centering\arraybackslash}X} % centered version of "X" column type
\usepackage{siunitx}
\sisetup{table-format=1.3} % default numerical column spec
\newcolumntype{Y}{>{\centering\arraybackslash}X}
\renewcommand\arraystretch{1.5}
\usepackage{adjustbox}
\usepackage{csvsimple}
\usepackage{pdflscape}
\usepackage{amsmath, amsfonts, amssymb, amsthm} % needed for math fonts, command eqref or Math packages
%\usepackage[round, authoryear]{natbib} % needed for abbrvand bibliography style
\usepackage{graphicx} % needed for\includegraphics
\usepackage{bigstrut} % needed for the command \bigstrut
\usepackage{enumerate} % needed for some options in enumerate
%\usepackage{todonotes} % needed for todos
\usepackage{makeidx} % needed for creating an index
\usepackage{blindtext} % needed for creating dummy text passage
\usepackage{lipsum}
\usepackage{setspace}
\usepackage{fancyhdr}
\usepackage{float}
\usepackage[nottoc, notlot, notlof]{tocbibind}% needed for displaying bibliography and other in the table of contents
\usepackage{xspace}
\usepackage{rotating}
\usepackage{lscape}
\usepackage{xcolor}
\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
\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.
%\usepackage[hyphenbreaks]{breakurl}
\hypersetup{
linkcolor={c1}, % internal links
citecolor={c2}, % citations
urlcolor={c3} % external links/urls
}
\usepackage{cleveref}
%% page settings%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[top=2cm, bottom=1.8cm, hmargin=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}
\setstretch{1.5}%This affects the in spacing of my paragraphs
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\begin{landscape}
\begin{table}
\caption{Sample}
\label{tab:10}
\begin{tabularx}{\linewidth}{*8{C}}%
\toprule
Region & \multicolumn{2}{c}{\thead{National andRegional\\ MPI = (H*A)}} & \multicolumn{3}{c}{Population in the MPI} & \thead{MPI Chronic\\population} & \thead{Population\\ Vulnerable\\ to MPI} \\
\cmidrule(l{1.5em}r{1.5em}){2-3} \cmidrule(lr{1em}){4-6} \cmidrule(lr){7-7}\cmidrule(lr){8-8}
& Svy Yrs & Index & Headcount & \makecell{Intensity\\ (k)} & \makecell{Intensity\\(\%)} & YYY & XXX \\
\midrule
Ethiopia & Z & Y & 20 & 30 &100 & 110 & 12 \\
Addis Ababa & Z & Y & 20 & 30 &100 & 110 & 12 \\
Afar & Z & Y & 20 & 30 &100 & 110 & 12 \\
Amhara & Z & Y & 20 & 30 &100 & 110 & 12 \\\addlinespace[2ex]
Benishnagul\rlap{-Gumuz} & Z & Y & 20 & 30 &100 & 110 & 12 \\
Dire Dawa & Z & Y & 20 & 30 &100 & 110 & 12 \\
Gambela & Z & Y & 20 & 30 &100 & 110 & 12 \\
Harari & Z & Y & 20 & 30 &100 & 110 & 12 \\\addlinespace[2ex]
Oromia & Z & Y & 20 & 30 &100 & 110 & 12 \\
Somali & Z & Y & 20 & 30 &100 & 110 & 12 \\
SNNP & Z & Y & 20 & 30 &100 & 110 & 12 \\
Tigray & Z & Y & 20 & 30&100 & 110 & 12 \\\addlinespace
\bottomrule
\end{tabularx}
\end{table}
\end{landscape}
\end{document}