问题描述
我正在尝试为表格编码,但某些列内容重叠。我已经在这里粘贴了完整的代码。请帮助我,因为我是乳胶新手。
'50'
解决方法
您正在为表格使用 p 列,它允许自动换行,但如果您继续使用 const myArrayOfProducts = [];
const addItemToMyProducts = (item) => {
const { name,type_products } = item;
const found = myArrayOfProducts.some(p => p.name === name && p.type_products === type_products);
if (!found) {
myArrayOfProducts.push(item);
}
};
const item1 = {name: "Vinos",type_products: "Vinos",active: true};
const item2 = {name: "foo",type_products: "bar",active: true};
const item3 = {name: "Vinos",active: false};
addItemToMyProducts(item1); // Adds
addItemToMyProducts(item1); // Skips
addItemToMyProducts(item2); // Adds
addItemToMyProducts(item3); // Skips (key matches)
console.log(myArrayOfProducts);
// Returns
// [
// { name: 'Vinos',type_products: 'Vinos',active: true },// { name: 'foo',type_products: 'bar',active: true }
// ]
,您将使用没有换行符的居中单元格覆盖它。
如果你使用固定宽度的列,你会得到换行符(虽然不漂亮,因为你的页面对于这个表格布局来说太小了)。
\multicolumn{2}{c}{...}
如果你给你的桌子足够的呼吸空间,例如通过添加 \documentclass[12pt,letterpaper,thmsa]{article}
\usepackage{multirow}
\usepackage{caption}
\begin{document}
\begin{table}
\caption{Toy example to depict the STI calculation}
\centering
\begin{tabular}{|p{0.1\linewidth}|p{0.05\linewidth}|p{0.05\linewidth}|p{0.05\linewidth}|p{0.05\linewidth}|p{0.1\linewidth}|p{0.1\linewidth}|p{0.1\linewidth}|p{0.05\linewidth}|p{0.05\linewidth}|}
\hline
% after \\: \hline or \cline{col1-col2} \cline{col3-col4} ...
\multirow{2}{=}{Time Period} & \multicolumn{2}{p{0.1\linewidth}|}{Labour Productivity} & \multicolumn{2}{p{0.1\linewidth}|}{Labour force} & Change in Period & Aggregate Productivity & Growth in Productivity & \multicolumn{2}{p{0.1\linewidth}|}{Change in Labour Force}\\
\cline{2-5}
& Trad. & Mod. & $L_t$ & $L_m$ &&&&&\\
\hline
$T_0$ & 10 & 20 & 1& 0& & 10& NA& Trad.& Mod.\\
\hline
$T_1$& 20& 20 &1& 0& $T_0$ to $T_1$& 20& 10& 0& 0\\
\hline
$T_2$ & 10& 20& 0& 1& $T_0$ to $T_2$& 20& 10& -1& 1\\
\hline
\end{tabular}
\label{Toy_exp}
\end{table}
\end{document}
,您会得到更好的结果: