![在 LaTeX beamer 中将复杂表格的内容居中对齐](https://linux22.com/image/411052/%E5%9C%A8%20LaTeX%20beamer%20%E4%B8%AD%E5%B0%86%E5%A4%8D%E6%9D%82%E8%A1%A8%E6%A0%BC%E7%9A%84%E5%86%85%E5%AE%B9%E5%B1%85%E4%B8%AD%E5%AF%B9%E9%BD%90.png)
Latex beamer 1. 如何使此表格单元格中的内容居中对齐?请参阅下面的屏幕截图和代码。
- 如何以简单的方式增加行高?
\documentclass[17pt]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usetheme{default}
\begin{document}
%\author{}
%\title{}
%\subtitle{}
%\logo{}
%\institute{}
%\date{}
%\subject{}
%\setbeamercovered{transparent}
%\setbeamertemplate{navigation symbols}{}
\author{XXYYZZ}
\title{Test YYYZZUU}
\begin{frame}[plain]
\maketitle
\end{frame}
\begin{frame}
\frametitle{corrosivity}
\footnotesize
\begin{center}
\begin{tabular}{|l|c|c|c|}
\hline
Soil Type& Resistivity ($\Omega$/cm) & Resistance& Corrosivity\\
\hline
Clay& 500 -- 2,000 & &\\
\cline{1-2}
Silt& 1,000 -- 2,000& Low & Severe\\
\hline
Loam& 3,000 -- 10,000& &\\
\cline{1-2}
Organic & & Medium& Moderate\\
\cline{1-1}
Fine Silt & 2,000 -- 10,000 & &\\
\hline
& 10,000 -- 30,000& High& Mild\\
\cline{2-4}
Sand& 30,000 -- 100,000& Very High & Unlikely\\
\hline
Gravel& 40,000 -- 200,000& Very High& Unlikely\\
\hline
\end{tabular}
\end{center}
\end{frame}
\end{document}
答案1
\multirow
您可以使用以下示例所示的方法垂直对齐单元格中的内容。我还提供了另一种方法,即使用更少的行,siunitx
对于单位,使用不同的单位来减少表格中的零数量……
\documentclass[17pt]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usetheme{default}
\usepackage{multirow} % For first example
\usepackage{booktabs} % For second example
\usepackage[per-mode=symbol]{siunitx}
\usepackage{makecell}
\begin{document}
\begin{frame}
\frametitle{corrosivity}
\footnotesize
\begin{center}
\begin{tabular}{|l|c|c|c|}
\hline
Soil Type& Resistivity ($\Omega$/cm) & Resistance& Corrosivity\\
\hline
Clay& 500 -- 2,000 & &\\
\cline{1-2}
Silt& 1,000 -- 2,000& \multirow{-2}{*}{Low} & \multirow{-2}{*}{Severe}\\
\hline
Loam& 3,000 -- 10,000& &\\
\cline{1-2}
Organic & & Medium& Moderate\\
\cline{1-1}
Fine Silt & \multirow{-2}{*}{2,000 -- 10,000} & &\\
\hline
& 10,000 -- 30,000& High& Mild\\
\cline{2-4}
\multirow{-2}{*}{Sand}& 30,000 -- 100,000& Very High & Unlikely\\
\hline
Gravel& 40,000 -- 200,000& Very High& Unlikely\\
\hline
\end{tabular}
\end{center}
\end{frame}
\begin{frame}
\frametitle{corrosivity}
% \footnotesize
\small
\begin{center}
\begin{tabular}{lr@{~--~}lcc}
\toprule
Soil Type& \multicolumn{2}{c}{\makecell{Resistivity\\ (\si{\kilo\ohm\per\cm})}} & Resistance& Corrosivity\\
\midrule
Clay& 0.5 & 2 & Low & Severe\\
Silt& 1 & 2& \\
\addlinespace
Loam& 3 & 10& Medium& Moderate\\
Organic & 2 & 10 \\
Fine Silt & 2 & 10 &\\
\addlinespace
\multirow{2}{*}{Sand} & 10 & 30& High& Mild\\
& 30 & 100& Very High & Unlikely\\
\addlinespace
Gravel& 40 & 200& \\
\bottomrule
\end{tabular}
\end{center}
\end{frame}
\end{document}