英文:
how to add a label to combined rows in latex?
问题
\begin{table}[ht]
\centering
\begin{tabular}{cc}
\hline
& Percentage \\
\hline
19-24 & 6\% \\
25-34 & 18\% \\
35-44 & 24\% \\
45-54 & 36\% \\
55-64 & 7\% \\
\hline
\end{tabular}
\end{table}
英文:
<!-- language: lang-html -->
\begin{table}[ht]
\centering
\begin{tabular}{cc}
\hline
AGE & Percentage \\
\hline
19-24 & 6\% \\
25-34 & 18\% \\
35-44 & 24\% \\
45-54 & 36\% \\
55-64 & 7\% \\
\hline
\end{tabular}
\end{table}
I want to remove the label "Age" and add it to the center left of the first table, like the last table.
答案1
得分: 1
你可以使用tabularray
包,这使得将多个单元格合并为一个变得容易:
\documentclass{article}
\usepackage{tabularray}
\begin{document}
\begin{table}[ht]
\centering
\begin{tblr}{Xcc}
\hline
\SetCell[r=5]{} 年龄段 & 19-24 & 6\% \\
& 25-34 & 18\% \\
& 35-44 & 24\% \\
& 45-54 & 36\% \\
& 55-64 & 7\% \\
\hline
\end{tblr}
\end{table}
\end{document}
英文:
You could use the tabularray
package, this make it easy to merge multiple cells into one:
\documentclass{article}
\usepackage{tabularray}
\begin{document}
\begin{table}[ht]
\centering
\begin{tblr}{Xcc}
\hline
\SetCell[r=5]{} Age of ...&19-24 & 6\% \\
& 25-34 & 18\% \\
& 35-44 & 24\% \\
& 45-54 & 36\% \\
& 55-64 & 7\% \\
\hline
\end{tblr}
\end{table}
\end{document}
答案2
得分: 0
另一种方式,输出类似的结果:
<!-- language: lang-latex -->
\documentclass{article}
\usepackage{booktabs,tabularx,multirow}
\begin{document}
\begin{table}[ht]
%\centering
\begin{tabularx}{\textwidth}{Xcc}
\toprule
受访者的年龄
& $\le$ 20 & 29\%\\
& 21-25 & 65\%\\
& 26-30 & 7\%\\
& $>$ 30 & 2\%\\
\bottomrule
\end{tabularx}
\end{table}
\end{document}
英文:
Another way, with similar output:
<!-- language: lang-latex -->
\documentclass{article}
\usepackage{booktabs,tabularx,multirow}
\begin{document}
\begin{table}[ht]
%\centering
\begin{tabularx}{\textwidth}{Xcc}
\toprule
\multirow{4}{*}{Age of the respondents}
& $\le$ 20 & 29\%\\
& 21-25 & 65\%\\
& 26-30 & 7\%\\
& $>$ 30 & 2\%\\
\bottomrule
\end{tabularx}
\end{table}
\end{document}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论