latex中将表格中标题与比表格内文字设置为罗马字体
时间: 2024-04-15 12:09:07 浏览: 601
在 LaTeX 中,可以使用 `caption` 包来设置表格标题,使用 `array` 包来设置表格内文字的字体。具体方法如下:
1. 导入 `caption` 和 `array` 包:
```latex
\usepackage{caption} % 设置标题
\usepackage{array} % 设置表格内文字的字体
```
2. 设置表格标题的字体为罗马字体:
```latex
\captionsetup{font=rm}
```
3. 设置表格内文字的字体为罗马字体:
```latex
\newcolumntype{L}{>{\fontfamily{lmr}\selectfont}l} % 自定义列类型,用于设置表格内文字的字体
```
完整代码示例:
```latex
\documentclass{article}
\usepackage{caption} % 设置标题
\usepackage{array} % 设置表格内文字的字体
\captionsetup{font=rm} % 设置表格标题的字体为罗马字体
% 自定义列类型,用于设置表格内文字的字体
\newcolumntype{L}{>{\fontfamily{lmr}\selectfont}l}
\begin{document}
\begin{table}
\centering
\begin{tabular}{Lcc}
\hline
\multicolumn{1}{>{\centering\arraybackslash}p{5cm}}{\textbf{Table Title}} & \textbf{Column 1} & \textbf{Column 2} \\
\hline
Row 1 & Data 1 & Data 2 \\
Row 2 & Data 3 & Data 4 \\
\hline
\end{tabular}
\caption{This is a table caption.}
\end{table}
\end{document}
```
其中,`\multicolumn{1}{>{\centering\arraybackslash}p{5cm}}{\textbf{Table Title}}` 用于设置表格标题居中并且宽度为 5cm。
阅读全文
相关推荐














