我使用 longtable 包制作了一个包含多行的表格。有关多行的内容如下:
\documentclass{article}
\usepackage{longtable}
\usepackage{caption}
\usepackage{chngcntr}
\counterwithout{table}{section}
\begin{document}
\begin{longtable}{| p{0.05 \textwidth} | p{0.6 \textwidth} | p{0.1 \textwidth} | p{0.1 \textwidth} |}
\caption{\bf PS(V) 1.8c-12 vs PV 3.301-539} \label{appendix3} \\
\hline
\multicolumn{1}{|c|}{\bf Steps}
& \multicolumn{1}{c|}{\bf PS(V) 1.8c-12}
& \multicolumn{1}{c|}{\bf PV 3.301-539}
& \multicolumn{1}{c|}{\bf PV 3.301-539} \\
& & \multicolumn{1}{c|}{\bf According to}
& \multicolumn{1}{c|}{\bf According to} \\
& & \multicolumn{1}{c|}{\bf Gyaltsab}
& \multicolumn{1}{c|}{\bf Kedrup} \\
\hline\hline
\endfirsthead
\multicolumn{4}{c}{{\bfseries \tablename\ \thetable{}: Outline of PS(V) 1.8c-12}} \\
\hline
\multicolumn{1}{|c|}{\bf Steps}
& \multicolumn{1}{c|}{\bf PS(V) 1.8c-12}
& \multicolumn{1}{c|}{\bf PV 3.301-539}
& \multicolumn{1}{c|}{\bf PV 3.301-539} \\
& & \multicolumn{1}{c|}{\bf According to}
& \multicolumn{1}{c|}{\bf According to} \\
& & \multicolumn{1}{c|}{\bf Gyaltsab}
& \multicolumn{1}{c|}{\bf Kedrup} \\
\hline
\endhead
\hline
\multicolumn{4}{|r|}{{\tiny Continued on next page}} \\
\hline
\endfoot
\hline \hline
\endlastfoot
1111 & 222 & \multirow{2}{*}{multi row} & 4444 \\
\cline{1-2} \cline{4-4}
111 & 222 & & 4444 \\
\hline
\end{longtable}
\end{document}
然而,单元格中的内容却是“2*”,如下。
请告诉我那有什么问题。
答案1
问题的基本问题已经解决了格诺特评论如上,所以这个答案主要关注问题的题外话:
- 使用
makecell
宏thead
可以更简单地定义列标题 - 通过正确计算列宽,表格宽度精确等于文本宽度
梅威瑟:
\documentclass{article}
\usepackage{longtable,
makecell, % <-- missed in question MWE, pointed in Gernot comment
multirow} % <-- added for columns headers
\renewcommand\theadfont{\bfseries}
\usepackage{caption}
\usepackage{chngcntr}
\counterwithout{table}{section}
\usepackage{lipsum}
\begin{document}
\lipsum[2]
{\renewcommand\arraystretch{1.2}
\begin{longtable}{| p{\dimexpr0.12\textwidth-2\tabcolsep-\arrayrulewidth\relax}
| p{\dimexpr0.40\textwidth-2\tabcolsep-\arrayrulewidth\relax}
| p{\dimexpr0.24\textwidth-2\tabcolsep-\arrayrulewidth\relax}
| p{\dimexpr0.24\textwidth-2\tabcolsep-\arrayrulewidth\relax} |}
\caption{\bf PS(V) 1.8c-12 vs PV 3.301-539}
\label{appendix3} \\
\hline
\thead[b]{Steps}
& \thead[b]{PS(V) 1.8c-12}
& \thead[b]{PV 3.301-539\\ According to\\ Gyaltsab}
& \thead[b]{PV 3.301-539\\ According to\\ Kedrup} \\
\hline\hline
\endfirsthead
\caption{\bf PS(V) 1.8c-12 vs PV 3.301-539 (cont.)} \\ % <--changed
\hline
\thead[b]{Steps}
& \thead[b]{PS(V) 1.8c-12}
& \thead[b]{PV 3.301-539\\ According to\\ Gyaltsab}
& \thead[b]{PV 3.301-539\\ According to\\ Kedrup} \\
\hline
\endhead
\hline
\multicolumn{4}{|r|}{\tiny Continued on next page} \\
\hline
\endfoot
\hline \hline
\endlastfoot
% table contents
1111 & 222 & \multirow{2}{=}{multi row} & 4444 \\
\cline{1-2} \cline{4-4}
111 & 222 & & 4444 \\
\end{longtable}
}
\end{document}
如果文本宽度比上述 MWE 中考虑的要宽,则可以相应地调整列宽。