![表格和标题内的字体大小](https://linux22.com/image/387253/%E8%A1%A8%E6%A0%BC%E5%92%8C%E6%A0%87%E9%A2%98%E5%86%85%E7%9A%84%E5%AD%97%E4%BD%93%E5%A4%A7%E5%B0%8F.png)
假设我想通过在开头font-size
添加来更改下表的情况。\Large
table
不知何故,这并不适用于 thead,因此字体大小不同。一个明显的解决方案是进入每个 thead 并添加\Large
->
\thead{\Large Text1 and \\ \Large Text2} & A & B\\
可能存在单行解决方案或让我们说一个正确的方法来做到这一点,因为在一些变化之后它变得相当烦人,例如在更大的情况下table
?
代码:
\documentclass{article}
\usepackage[ngerman]{babel}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{makecell}
\begin{document}
{\renewcommand{\arraystretch}{2}%
\begin{table}
\Large % for demonstration purpose
\centering
\begin{tabular}{@{}ccc@{}}
\toprule
& \multicolumn{2}{c}{Text} \\
\cmidrule(r){2-3}
\thead{Text1 and \\ Text2} & A & B\\
\midrule
C & \thead{1\\and 1}& 2 \\
D & 3 & \thead{4\\ and 4} \\
\bottomrule
\end{tabular}
\end{table}} \quad
\end{document}
答案1
使用来自https://tex.stackexchange.com/a/409956
\documentclass{article}
\usepackage[ngerman]{babel}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{makecell}
\makeatletter
\newcommand{\currentfsize}{\f@size pt}
\makeatother
\newdimen\fsize
\newcommand{\setfsize}{\setlength{\fsize}{\currentfsize}}
\begin{document}
{\renewcommand{\arraystretch}{2}%
\begin{table}
\Large % for demonstration purpose
\renewcommand\theadfont{\setfsize}
\centering
\begin{tabular}{@{}ccc@{}}
\toprule
& \multicolumn{2}{c}{Text} \\
\cmidrule(r){2-3}
\thead{Text1 and \\ Text2} & A & B\\
\midrule
C & \thead{1\\and 1}& 2 \\
D & 3 & \thead{4\\ and 4} \\
\bottomrule
\end{tabular}
\end{table}} \quad
\end{document}