仍在处理该表格。这是我关于表格边框的新问题:
看来我在设置边界时做错了。这是我的代码和屏幕截图:
\documentclass{article}
\usepackage{multirow} % Used for the vertical cells
\usepackage{rotating} % Used for the vertical cells
\usepackage{xcolor} % Used for cell-colors
\usepackage{colortbl} % Used for cell-colors
\usepackage[a4paper]{geometry}% Used to set the pdf margins manually
\newgeometry{left=2cm,bottom=0.1cm}
\definecolor{grey}{HTML}{F2F2F2} % Define grey for the cells
\definecolor{red}{HTML}{FF0000} % Define red for testing
\begin{document}
\scriptsize % Use a small font size
\begin{tabular}{|p{0.6cm}|p{0.6cm}|p{0.6cm}|p{0.6cm}|p{0.6cm}|p{0.6cm}|p{0.6cm}|p{0.6cm}|p{0.6cm}|p{0.6cm}|p{0.6cm}|p{0.6cm}|p{0.6cm}|p{0.6cm}|p{0.6cm}|p{0.6cm}|p{0,6cm}|}
\cline{10-17}
\multicolumn{9}{|c|}{} & \multicolumn{2}{p{\dimexpr (0.6cm)*2+2\arrayrulewidth+2\tabcolsep\relax}|}{\cellcolor{grey}Work to retired ratio} & \multicolumn{4}{p{\dimexpr (0.6cm)*4+1\arrayrulewidth+2\tabcolsep\relax}|}{Health care sizing (per thousand)} & \multicolumn{2}{p{\dimexpr (0.6cm)*2+1\arrayrulewidth+2\tabcolsep\relax}|}{\cellcolor{grey}Inverse dependency ratio}\\\cline{3-9}
\multicolumn{2}{|c|}{} & \multicolumn{4}{c|}{\cellcolor{grey}Population (mio.)} & \multicolumn{3}{c}{Workforce (1000)} & \multicolumn{2}{|c|}{\cellcolor{grey}} & \multicolumn{2}{l|}{Physicians by} & \multicolumn{2}{l}{Nurses by} & \multicolumn{2}{|l|}{\cellcolor{grey}Old agers by}\\\hline
\multicolumn{2}{|c|}{} & \begin{sideways}\cellcolor{grey}\parbox{4cm}{Overall}\end{sideways} & \begin{sideways}\cellcolor{grey}\parbox{4cm}{Young age}\end{sideways} & \begin{sideways}\cellcolor{grey}\parbox{4cm}{Working age}\end{sideways} & \begin{sideways}\cellcolor{grey}\parbox{4cm}{Old age}\end{sideways} & \begin{sideways}\parbox{4cm}{Overall}\end{sideways} & \begin{sideways}\parbox{4cm}{Physicians (Proj: 2025)}\end{sideways} & \begin{sideways}\parbox{4cm}{Nurses (Proj: 2030)}\end{sideways} & \begin{sideways}\parbox{4cm}{\cellcolor{grey}Working age by Old age}\end{sideways} & \begin{sideways}\parbox{4cm}{\cellcolor{grey}Work force by Old age}\end{sideways} & \begin{sideways}\parbox{4cm}{Workforce}\end{sideways} & \begin{sideways}\parbox{4cm}{Working age}\end{sideways} & \begin{sideways}\parbox{4cm}{Workforce}\end{sideways} & \begin{sideways}\parbox{4cm}{Working age}\end{sideways} & \begin{sideways}\parbox{4cm}{\cellcolor{grey}1 physicians}\end{sideways} & \begin{sideways}\parbox{4cm}{\cellcolor{grey}1 nurse}\end{sideways}\\\hline
\multicolumn{2}{|l}{USA} & \multicolumn{4}{l}{\cellcolor{grey}} & \multicolumn{3}{l}{} & \multicolumn{2}{l}{\cellcolor{grey}} & \multicolumn{4}{l}{} & \multicolumn{2}{l|}{\cellcolor{grey}}\\\hline
1990/1 & & 248,6 & 71,3 & 146,1 & 31,2 & 127.500 & 615,4 & 1491,6 & 4,68 & 4,09 & 4,83 & 4,21 & 11,70 & 10,21 & 50,7 & 20,9\\\hline
1 & 2 & 3 \\\hline
\end{tabular}
\end{document}
\\\cline{3-9}\cline{12-17}
在 1 上,虽然我确实使用过那条线,但人口的顶部边界是不可见的。
在 2 中,两个边界都被向右推了一点,但我看不出有什么原因。
在第 3 行中,尽管使用了该行,但顶部边框仍然不可见\cline{10-17}
。我做错了什么?
谢谢!
答案1
正如文档中所述,colortbl
您不能使用\cline
with colortbl
,因为\cline
规则不占用垂直空间,因此会被彩色面板覆盖。您可以使用包\hhline
中的hhline
,它具有不同的语法。
正如上次提到的,垂直规则位于正确的柱子的边缘,所以使用
\multicolumn{2}{c|}{..}&
\multicolumn{2}{c|}{..}&
不是
\multicolumn{2}{|c|}{..}&
\multicolumn{2}{|c|}{..}&
否则,您将得到重复的、未对齐的垂直规则。只有一行中的第一个单元格应该在左侧有规则。
3\cline
又是。
该包对于其环境也rotating
很有用sidewaystable
,但对于旋转文本,它只是sideways
为了与上个世纪的 LaTeX2.09 包保持兼容,它使用该graphicx
包,您可以直接使用它\rotatebox{90}{..}
。
您对跨度宽度的计算也不正确。如果跨 4 列,则必须考虑 3 (= 4-1) 条缺失规则以及它们两侧的空间 =6\tabcolsep (6=2*(4-1))
\documentclass{article}
\usepackage{multirow} % Used for the vertical cells
\usepackage{graphicx} % Used for the vertical cells
\usepackage{hhline}
\usepackage{xcolor} % Used for cell-colors
\usepackage{colortbl} % Used for cell-colors
\usepackage[a4paper]{geometry}% Used to set the pdf margins manually
\newgeometry{left=2cm,bottom=0.1cm}
\definecolor{grey}{HTML}{F2F2F2} % Define grey for the cells
\definecolor{red}{HTML}{FF0000} % Define red for testing
\begin{document}
\scriptsize % Use a small font size
\begin{tabular}{|*{17}{p{0.6cm}|}}
\hhline{*9{~}*8-}
\multicolumn{9}{|c|}{}&
\multicolumn{2}{p{\dimexpr (0.6cm)*2+1\arrayrulewidth+2\tabcolsep\relax}|}{\cellcolor{grey}\centering Work to retired ratio}&
\multicolumn{4}{p{\dimexpr (0.6cm)*4+3\arrayrulewidth+6\tabcolsep\relax}|}{\centering Health care sizing\\ (per thousand)}&
\multicolumn{2}{p{\dimexpr (0.6cm)*2+1\arrayrulewidth+2\tabcolsep\relax}|}{\cellcolor{grey}\centering Inverse dependency ratio}\\
\hhline{~~------->{\arrayrulecolor{grey}}-->{\arrayrulecolor{black}}---->{\arrayrulecolor{grey}}-->{\arrayrulecolor{black}}}
\multicolumn{2}{|c|}{}&
\multicolumn{4}{c|}{\cellcolor{grey}Population (mio.)}&
\multicolumn{3}{c|}{Workforce (1000)}&
\multicolumn{2}{c|}{\cellcolor{grey}}&
\multicolumn{2}{l|}{Physicians by}&
\multicolumn{2}{l|}{Nurses by}&
\multicolumn{2}{l|}{\cellcolor{grey}Old agers by}\\
\hline
\multicolumn{2}{|c|}{}&
\rotatebox{90}{\cellcolor{grey}Overall}&
\rotatebox{90}{\cellcolor{grey}Young age}&
\rotatebox{90}{\cellcolor{grey}Working age}&
\rotatebox{90}{\cellcolor{grey}Old age}&
\rotatebox{90}{Overall}&
\rotatebox{90}{Physicians (Proj: 2025)}&
\rotatebox{90}{Nurses (Proj: 2030)}&
\rotatebox{90}{\cellcolor{grey}Working age by Old age\ }&
\rotatebox{90}{\cellcolor{grey}Work force by Old age\ }&
\rotatebox{90}{Workforce}&
\rotatebox{90}{Working age}&
\rotatebox{90}{Workforce}&
\rotatebox{90}{Working age}&
\rotatebox{90}{\cellcolor{grey}1 physicians}&
\rotatebox{90}{\cellcolor{grey}1 nurse}\\
\hline
\multicolumn{2}{|l}{USA}&
\multicolumn{4}{l}{\cellcolor{grey}}&
\multicolumn{3}{l}{}&
\multicolumn{2}{l}{\cellcolor{grey}}&
\multicolumn{4}{l}{}&
\multicolumn{2}{l|}{\cellcolor{grey}}\\\hline
1990/1&& 248,6& 71,3& 146,1& 31,2& 127.500& 615,4& 1491,6& 4,68& 4,09& 4,83& 4,21& 11,70& 10,21& 50,7& 20,9\\\hline
1& 2& 3 \\\hline
\end{tabular}
\end{document}