我曾经extrarowheight
在只包含文本的表格中在行之间添加一些额外的空间。虽然这很有效,但也会影响第一行。有没有办法阻止这种情况,或者只删除第一行中的额外间距?我意识到我可以用不同的方式实现行之间的空间,但如果可能的话,我想避免这种情况。蓝色箭头表示我想要减少的空间。
这是屏幕截图和 MWE。
\documentclass[12pt, a4paper]{memoir}
\usepackage[utf8]{inputenc}
\settypeblocksize{237mm}{150mm}{*} % size of text block on page
\begin{document}
\begin{table}[!htb]
\caption{Severity of identified problems and proposed changes}
\label{some_changes}
\setlength{\extrarowheight}{5mm} %add row padding
\begin{tabular}{>{\raggedright}p{3.5cm} >{\raggedright}p{8.5cm} p{1.5cm}}
\toprule
Change & Justification & Severity\\
\midrule
1. \parbox[t]{3cm}{\raggedright A few meaningful definitions} &
Just some sample text that is longer than a couple of lines. This text has
no meaning, it's just a sample text and does not do anything but fill some
space here. &
High\\
2. \parbox[t]{3cm}{\raggedright Some other thing that needs a change} &
Just some sample text that is longer than a couple of lines. This text has
no meaning, it's just a sample text and does not do anything but fill some
space here. &
Medium\\
3. \parbox[t]{3cm}{\raggedright Some other thing that needs a change} &
Just some sample text that is longer than a couple of lines. This text has
no meaning, it's just a sample text and does not do anything but fill some
space here. &
Low\\
\bottomrule
\end{tabular}
\end{table}
\end{document}
答案1
另一种解决方案:
\documentclass[12pt, a4paper]{memoir}
\usepackage[utf8]{inputenc}
\settypeblocksize{237mm}{150mm}{*} % size of text block on page
\begin{document}
\begin{table}[!htb]
\caption{Severity of identified problems and proposed changes}
\label{some_changes}
\setlength{\extrarowheight}{5mm} %add row padding
\begin{tabular}{>{\raggedright}p{3.5cm} >{\raggedright}p{8.5cm} p{1.5cm}}
\toprule
\\[-3\normalbaselineskip] % <------------- Add this
Change & Justification & Severity\\
\midrule
1. \parbox[t]{3cm}{\raggedright A few meaningful definitions} &
Just some sample text that is longer than a couple of lines. This text has
no meaning, it's just a sample text and does not do anything but fill some
space here. &
High\\
2. \parbox[t]{3cm}{\raggedright Some other thing that needs a change} &
Just some sample text that is longer than a couple of lines. This text has
no meaning, it's just a sample text and does not do anything but fill some
space here. &
Medium\\
3. \parbox[t]{3cm}{\raggedright Some other thing that needs a change} &
Just some sample text that is longer than a couple of lines. This text has
no meaning, it's just a sample text and does not do anything but fill some
space here. &
Low\\
\bottomrule
\end{tabular}
\end{table}
\end{document}
主要思想是在 后添加一个负间距,\toprule
以抵消 从 添加的填充\extrarowheight
。添加
\\[-3\normalbaselineskip]
似乎将第一行恢复到其原始高度(无填充)。但当然,您随时可以将方括号中的值更改为您想要的任何值。
答案2
\addlinespace[5mm]
从包裹中使用booktabs
对您来说是一个可以接受的选项吗?
\documentclass[12pt, a4paper]{memoir}
\usepackage[utf8]{inputenc}
\settypeblocksize{237mm}{150mm}{*} % size of text block on page
\usepackage{lipsum}
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
\begin{document}
\begin{table}[htb]
\caption{Severity of identified problems and proposed changes}
\label{some_changes}
\begin{tabular}{>{\raggedright}p{0.6cm}@{\ }>{\raggedright}p{3cm} >{\raggedright}p{8.5cm} p{1.5cm}}
\toprule
\multicolumn{2}{l}{Change} & Justification & Severity\\
\midrule\addlinespace[5mm]
1. & A few meaningful definitions &
\lipsum*[11] &
High\\ \addlinespace[5mm]
2. & \raggedright Some other thing that needs a change &
\lipsum*[11] &
Medium\\ \addlinespace[5mm]
3. & Some other thing that needs a change &
\lipsum*[11] &
Low\\
\bottomrule
\end{tabular}
\end{table}
\end{document}