抱歉,尽管我多次问过这个问题,但我似乎做不到。我是 LaTeX 的新手。
这是当前的代码和表格。
\documentclass[11pt, a4paper, notitlepage]{article}
\usepackage{array}
\usepackage{multirow}
\begin{table}[h]
\centering
\begin{tabular}{|l|c|c|c|c|}
\hline
\multirow{2}{*}{\parbox{8em}{Low and high voltage levels with 20\% duty cycle}} & \multicolumn{2}{c|}{voltage readings} & \multicolumn{2}{l|}{calculated values} \tabularnewline
\cline{2-5}
& DC & RMS & DC & RMS \tabularnewline
\hline
& & & & \tabularnewline
\hline
& & & & \tabularnewline
\hline
& & & & \tabularnewline
\hline
\end{tabular}
\end{table}
如上所示,左上角的长句子无法放入单元格中。我想制作这样的表格。
我很感激任何帮助。谢谢!
答案1
使用makecell
在单元格内容周围添加垂直空间,并减少第一列中的行数\linespread{0.6}\selectfont
:
Writing values in cells I left to you.
\documentclass[11pt, a4paper, notitlepage]{article}
\usepackage{array, makecell, multirow}
\usepackage{siunitx}
\begin{document}
\begin{table}[ht]
\centering
\setlength\tabcolsep{3pt}
\setcellgapes{3pt}
\makegapedcells
\renewcommand\multirowsetup{\centering} % <---
\begin{tabular}{|>{\linespread{0.6}\selectfont}p{8em}|c|c|c|c|}
\hline
\multirow{2}{=}{Low and high voltage levels with \SI{20}{\%} duty cycle}
& \multicolumn{2}{c|}{voltage readings}
& \multicolumn{2}{l|}{calculated values} \tabularnewline
\cline{2-5}
& DC & RMS & DC & RMS \tabularnewline
\hline
& & & & \tabularnewline
\hline
& & & & \tabularnewline
\hline
& & & & \tabularnewline
\hline
\end{tabular}
\end{table}
\end{document}
答案2
您可以使用 来解决您的问题,它使您能够定义在以字母为前缀的说明符(或如果您加载 则为 C )cellspace
的列中单元格顶部和底部的最小垂直间距。S
siunitx
\documentclass[11pt, a4paper, notitlepage]{article}
\usepackage{array}
\usepackage{multirow}%
\usepackage{cellspace}
\setlength{\cellspacetoplimit}{8pt}
\setlength{\cellspacebottomlimit}{8pt}
\begin{document}
\begin{table}[h]
\centering
\begin{tabular}{| >{\centering\arraybackslash}m{8em}|Sc|Sc|Sc|Sc|}
\hline
\multirow{1.8}{=}{\centering Low and high voltage levels with 20\% duty cycle} & \multicolumn{2}{Sc|}{voltage readings} & \multicolumn{2}{Sl|}{calculated values} \tabularnewline
\cline{2-5}
& DC & RMS & DC & RMS \tabularnewline
\hline
& & & & \tabularnewline
\hline
& & & & \tabularnewline
\hline
& & & & \tabularnewline
\hline
\end{tabular}
\end{table}
\end{document}