![使用陣列在表中垂直對齊不起作用](https://rvso.com/image/391709/%E4%BD%BF%E7%94%A8%E9%99%A3%E5%88%97%E5%9C%A8%E8%A1%A8%E4%B8%AD%E5%9E%82%E7%9B%B4%E5%B0%8D%E9%BD%8A%E4%B8%8D%E8%B5%B7%E4%BD%9C%E7%94%A8.png)
請參閱下面的我的程式碼。我沒有對程式碼進行任何更改,只是重新編譯了我的 LaTeX 文檔,垂直居中對齊不再起作用。
如何恢復垂直居中對齊(如“之前”螢幕截圖中所示)?
代碼:
\documentclass[10pt]{exam}
\usepackage{array}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\begin{document}
\begin{table}
\centering
\begin{tabular}{| L{3cm} | L{8cm} | L{1.7cm} | L{1.7cm} |}
\hline
\textbf{Section} & \textbf{Description} & \textbf{Available Points} & \textbf{Earned Points}\\
\hline
\textbf{Cover Page} & Includes the title of the report, team name, and all of the team member names. & 1 & ~\\[1cm]
\hline
\textbf{Introduction} & Explains the project functionality and features. & 2 & ~\\[1cm]
\hline
\end{tabular}
\end{table}
\end{document}
前:
後:
答案1
對我來說也不起作用。我建議修改列類型的定義,以合併來自 的S
預說明符(如果加載,則可以使用另一個字母siunitx
)cellspace
。這確保了相應列中單元格頂部和底部的最小垂直間距:
\documentclass[10pt]{exam}
\usepackage{array, cellspace}
\setlength{\cellspacetoplimit}{2ex}
\setlength{\cellspacebottomlimit}{2ex}
\newcolumntype{L}[1]{>{\raggedright\arraybackslash}S{m{#1}}}
\newcolumntype{C}[1]{>{\centering\arraybackslash}S{m{#1}}}
\newcolumntype{R}[1]{>{\raggedleft\arraybackslash}S{m{#1}}}
\begin{document}
\begin{table}
\centering
\begin{tabular}{| L{3cm} |L{8cm} | L{1.7cm} | L{1.7cm} |}
\hline
\textbf{Section} & \textbf{Description} & \textbf{Available Points} & \textbf{Earned Points}\\
\hline
\textbf{Cover Page} & Includes the title of the report, team name, and all of the team member names. & 1 & ~\\
\hline
\textbf{Introduction} & Explains the project functionality and features. & 2 & ~\\
\hline
\end{tabular}
\end{table}
\end{document}