我試圖回覆OP的評論我的這個答案但我發現當我放在[...]
一行的末尾時,它會擾亂水平對齊。
\documentclass{book}
\usepackage{array}
\newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1}}
\usepackage{arydshln}
\begin{document}
\renewcommand{\arraystretch}{2.2}
Without space added:
\begin{tabular}{|M{.7cm}|}
\hline
$y$ \\
\hdashline
$a$ \\
\hdashline
$b$ \\
\hline
\end{tabular}
\vspace{10pt} with space added:
\begin{tabular}{|M{.7cm}|}
\hline
$y$ \\[2ex]
\hdashline
$a$ \\
\hdashline
$b$ \\
\hline
\end{tabular}
\end{document}
查看 的位置y
:
我究竟做錯了什麼?
答案1
問題是數學後面的空格。arydshln
重新定義內部命令(在本例中\@xargarraycr
)並忘記\unskip
原始定義:
\documentclass{book}
\usepackage{array}
\newcolumntype{M}[1]{>{\centering\arraybackslash}p{#1}}
\usepackage{arydshln}
\usepackage{etoolbox}
\begin{document}
\renewcommand{\arraystretch}{2.2}
\begin{tabular}{|M{.7cm}|}
\hline
$y$ \\[2ex]
\hdashline
$a$ \\
\hline
\end{tabular}
\begin{tabular}{|M{.7cm}|}
\hline
$y$\\[2ex] %no problem without the space
\hdashline
$a$ \\
\hline
\end{tabular}
\makeatletter
\pretocmd\@xargarraycr{\unskip}{}{\fail} %patch to add \unskip
\begin{tabular}{|M{.7cm}|}
\hline
$y$ \\[2ex]
\hdashline
$a$ \\
\hline
\end{tabular}
\end{document}