在LaTeX中如何向合并的行添加标签?

huangapple go评论147阅读模式
英文:

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 &amp; Percentage \\ 
  \hline
19-24 &amp; 6\% \\ 
  25-34 &amp; 18\% \\ 
  35-44 &amp; 24\% \\ 
  45-54 &amp; 36\% \\ 
  55-64 &amp; 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.

在LaTeX中如何向合并的行添加标签?

在LaTeX中如何向合并的行添加标签?

答案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}

在LaTeX中如何向合并的行添加标签?

英文:

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 ...&amp;19-24 &amp; 6\% \\ 
&amp;  25-34 &amp; 18\% \\ 
&amp;  35-44 &amp; 24\% \\ 
&amp;  45-54 &amp; 36\% \\ 
&amp;  55-64 &amp; 7\% \\ 
   \hline
\end{tblr}
\end{table}


\end{document}

在LaTeX中如何向合并的行添加标签?

答案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}

在LaTeX中如何向合并的行添加标签?

英文:

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}
&amp; $\le$ 20 &amp; 29\%\\
&amp; 21-25    &amp; 65\%\\
&amp; 26-30    &amp;  7\%\\
&amp; $&gt;$ 30   &amp;  2\%\\
\bottomrule
\end{tabularx}
\end{table}

\end{document}

在LaTeX中如何向合并的行添加标签?

huangapple
  • 本文由 发表于 2023年3月7日 22:34:49
  • 转载请务必保留本文链接:https://go.coder-hub.com/75663329.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定