我正在尝试制作这张表,但不断收到此错误
“额外的对齐标签已更改为 \cr。... width\arrayrulewidth }\endtemplate”
我使用 longtable 是因为当表格存满内容时很可能会溢出页面。
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[table,xcdraw]{xcolor}
\usepackage{multirow}
\usepackage[a4paper]{geometry}
\usepackage{tabularx}
\usepackage{longtable}
\usepackage{array}
\geometry{a4paper,tmargin=3.5cm, bmargin=2.5cm, lmargin=1.5cm, rmargin=1.5cm, headheight=3em, headsep=1.5cm, footskip=1cm}
\usepackage{color, colortbl}
\definecolor{mColor1}{rgb}{0.9,0.9,0.9}
\usepackage{tgbonum}
\usepackage{pdflscape}
\begin{document}
\renewcommand*\rmdefault{cmss}
\centering
\renewcommand{\arraystretch}{1.1}
\setlength{\arrayrulewidth}{1pt}
\begin{longtable}
{|p{\dimexpr.3\textwidth-2\tabcolsep} | p{\dimexpr.3\textwidth-2\tabcolsep} | p{\dimexpr.2\textwidth-2\tabcolsep} | p{\dimexpr.2\textwidth-2\tabcolsep} |}
\caption{List of Subsidaries/JVs/AEs}
\hline
\rowcolor{mColor1}
\\Name & CIN/FCRN & Type of Company & \% of shares held\\ABC Inc. && FBSDKSNDNI24 && Associate Enterprise & 48\\\hline\end{longtable}
\end{document}
答案1
除了解决最紧迫的问题——将两个实例替换为&&
——&
你还应该
删除
\\
第一行开头的换行指令,\\
紧接着添加一条指令\caption{...}
,并且1.25\arrayrulewidth
从四列的宽度中分别减去一个p
。由于有 5 条垂直规则,它们的总宽度为。从每列宽度指令中5\arrayrulewidth
减去该值的四分之一,即。1.25\arrayrulewidth
以系统化的方式组织表格的页眉和页脚信息。请使用包中的
\endfirsthead
、\endhead
、\endfoot
和\endlastfoot
指令longtable
。
\documentclass{article}
%% I've commented out unneeded package-loading instructions
\usepackage[utf8]{inputenc}
\usepackage[table,xcdraw]{xcolor}
%%\usepackage{multirow}
\usepackage[a4paper]{geometry}
%%\usepackage{tabularx}
\usepackage{longtable}
\usepackage{array}
\geometry{a4paper,tmargin=3.5cm, bmargin=2.5cm, lmargin=1.5cm, rmargin=1.5cm, headheight=3em, headsep=1.5cm, footskip=1cm}
%%\usepackage{color, colortbl}
\definecolor{mColor1}{rgb}{0.9,0.9,0.9}
\usepackage{tgbonum}
%%\usepackage{pdflscape}
\begin{document}
\renewcommand\rmdefault{cmss}
%%%\centering % not needed
\renewcommand{\arraystretch}{1.1}
\setlength{\arrayrulewidth}{1pt}
\begin{longtable}
{| p{\dimexpr.3\textwidth-2\tabcolsep-1.25\arrayrulewidth\relax}
| p{\dimexpr.3\textwidth-2\tabcolsep-1.25\arrayrulewidth\relax}
| p{\dimexpr.2\textwidth-2\tabcolsep-1.25\arrayrulewidth\relax}
| p{\dimexpr.2\textwidth-2\tabcolsep-1.25\arrayrulewidth\relax} |}
%% set up the table's header and footer structures
\caption{List of Subsidaries/JVs/AEs} \label{tab:list}\\
\hline
\rowcolor{mColor1}
Name & CIN/FCRN & Type of Company & \% of shares held\\
\endfirsthead
\multicolumn{4}{l}{Table \ref{tab:list}, cont'd}\\
\hline
\rowcolor{mColor1}
Name & CIN/FCRN & Type of Company & \% of shares held\\
\endhead
\hline
\multicolumn{4}{r}{(cont'd on following page)}\\
\endfoot
\hline
\endlastfoot
%% body of table
ABC Inc. & FBSDKSNDNI24 & Associate Enterprise & 48\\
\end{longtable}
\end{document}