我曾經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}