我有一张表格,其中第一条垂直线比其余的长。整个表格都是匆忙完成的,所以我可能错过了一些明显的东西。
我怀疑这与我使用多行有关,但我无法解决这个问题。我尝试使用以下解决方案表格中的垂直线太长但似乎没有什么效果。有谁知道这可能是什么原因造成的,以及我可以做什么来解决这个问题?
代码:
\begin{table}[th]
\centering
\captionsetup{justification=centering}
\caption{Table showing the Bp length of primer set 1, 2 and 3 after restriction cutting with HindIII.}
\begin{tabular}{c|c|c}
Set \textnumero & Calculations & \textbf{Bp} \\
\hline
\multirow{4}{*}{Set 1} & \footnotesize{$R-\text{Res}+1$} & \multirow{2}{*}{$512$}\\
& $23642-23131+1$ & \\
\cline{2-3}
& \footnotesize{$\text{Res}-F$} & \multirow{2}{*}{$4049$}\\
& $23131-19082$ & \\
\hline
\multirow{6}{*}{Set 2}& \footnotesize{$R-\text{Res}_2+1$} & \multirow{2}{*}{$2185$} \\
& $27342-25158+1$ & \\
\cline{2-3}
& \footnotesize{$\text{Res}_2-\text{Res}_1$} & \multirow{2}{*}{$2027$} \\
& $25158-23131$ & \\
\cline{2-3}
& \footnotesize{$\text{Res}-F$} & \multirow{2}{*}{$146$}\\
& $23131-22985$ & \\
\hline
\multirow{8}{*}{Set 3} & \footnotesize{$R-\text{Res}_3+1$} & \multirow{2}{*}{$2465$} \\
& $40049-37585+1$ & \\
\cline{2-3}
& \footnotesize{$\text{Res}_3-\text{Res}_2$} & \multirow{2}{*}{$125$} \\
& $37585-37460$ & \\
\cline{2-3}
& \footnotesize{$\text{Res}_2-\text{Res}_1$} & \multirow{2}{*}{$564$} \\
& $37460-36896$ & \\
\cline{2-3}
& \footnotesize{$\text{Res}-F$} & \multirow{2}{*}{$1442$}\\
& $36896-35454$ & \\
\label{bp:HindIII}
\end{tabular}
\end{table}
编译时:
左侧垂直线比右侧垂直线延伸得稍远。
答案1
让我将我的评论转换为答案:
- 在表格的最后一行,你有
\label{bp:HindIII}
一个不应该放在里面的tabular
。将其立即移到后面\caption{...}
- 使用包可以缩短表格的代码
tabularray
:
\documentclass{article}
\usepackage{tabularray}
\UseTblrLibrary{amsmath, booktabs}
\DeclareMathOperator{\Res}{Res}
\usepackage{caption}
\captionsetup{justification=centerlast}
\begin{document}
\begin{table}[ht]
\centering
\caption{Table showing the Bp length of primer set 1, 2 and 3 after restriction cutting with HindIII.}
\label{bp:HindIII}
\begin{tblr}{colspec={c|Q[c,mode=math]|Q[c,mode=math]},
row{1} = {mode=text, c},
cell{even}{2} = {font=\footnotesize, c},
}
Set \textnumero
& Calculations & \textbf{Bp} \\
\midrule
\SetCell[r=4]{c} Set 1
& R-\Res+1 & \SetCell[r=2]{c} 512 \\
& 23642-23131+1 & \\
\midrule
& \Res-F & \SetCell[r=2]{c} 4049 \\
& 23131-19082 & \\
\midrule
\SetCell[r=6]{c} Set 2
& R-\Res_2+1 & \SetCell[r=2]{c} 2185 \\
& 27342-25158+1 & \\
\midrule
& \Res_2-\Res_1 & \SetCell[r=2]{c} 2027 \\
& 25158-23131 & \\
\midrule
& \Res-F & \SetCell[r=2]{c} 146 \\
& 23131-22985 & \\
\midrule
\SetCell[r=8]{c} Set 3
& R-\Res_3+1 & \SetCell[r=2]{c} 2465 \\
& 40049-37585+1 & \\
\midrule
& \Res_3-\Res_2 & \SetCell[r=2]{c} 125 \\
& 37585-37460 & \\
\midrule
& \Res_2-\Res_1 & \SetCell[r=2]{c} 564 \\
& 37460-36896 & \\
\midrule
& \Res-F & \SetCell[r=2]{c} 1442 \\
& 36896-35454 & \\
\end{tblr}
\end{table}
\end{document}
编辑:
上述 MWE 的更复杂一点的版本,具有更短的表格代码,可以生成更漂亮(在我看来)的表格形式(作为使用该tabularray
包的练习):
- 偶数行之后减少垂直空间
- 水平线的绘制在文档和表格序言中定义
- 被认为是两列文档
\documentclass[twocolumn]{article}
\usepackage{tabularray}
\usepackage{amsmath}
\DeclareMathOperator{\Res}{Res}
\usepackage[font=small, labelfont=bf,
justification=centerlast
]{caption}
\begin{document}
\begin{table}[ht]
\centering
\caption{Table showing the Bp length of primer set 1, 2 and 3 after restriction cutting with HindIII.}
\label{bp:HindIII}
\begin{tblr}{colspec= {c | Q[c,mode=math] | r},
row{1} = {mode=text, c},
cell{even}{2} = {font=\footnotesize, c},
cell{even}{3} = {r=2}{ },
row{even} = {belowsep=-2pt},
hline{even[1-X]} = {0.25pt},
}
Set \textnumero
& Calculations & \textbf{Bp} \\
\SetCell[r=4]{c} Set 1
& R - \Res + 1 & 512 \\
& 23642 - 23131 + 1 & \\
& \Res-F & 4049 \\
& 23131-19082 & \\
\SetCell[r=6]{c} Set 2
& R-\Res_2+1 & 2185 \\
& 27342-25158+1 & \\
& \Res_2-\Res_1 & 2027 \\
& 25158-23131 & \\
& \Res-F & 146 \\
& 23131-22985 & \\
\SetCell[r=8]{c} Set 3
& R-\Res_3+1 & 2465 \\
& 40049-37585+1 & \\
& \Res_3-\Res_2 & 125 \\
& 37585-37460 & \\
& \Res_2-\Res_1 & 564 \\
& 37460-36896 & \\
& \Res-F & 1442 \\
& 36896-35454 & \\
\end{tblr}
\end{table}
\end{document}
答案2
如果您不习惯\\
在末尾开始新的(空)行,则可以避免此问题:
\documentclass{article}
\usepackage{multirow}
\usepackage{caption}
\usepackage{amsmath}
\begin{document}
\begin{table}[th]
\centering
\captionsetup{justification=centering}
\caption{Table showing the Bp length of primer set 1, 2 and 3 after restriction cutting with HindIII.}
\begin{tabular}{c|c|c}
Set \textnumero & Calculations & \textbf{Bp} \\
\hline
\multirow{4}{*}{Set 1} & \footnotesize{$R-\text{Res}+1$} & \multirow{2}{*}{$512$}\\
& $23642-23131+1$ & \\
\cline{2-3}
& \footnotesize{$\text{Res}-F$} & \multirow{2}{*}{$4049$}\\
& $23131-19082$ & \\
\hline
\multirow{6}{*}{Set 2}& \footnotesize{$R-\text{Res}_2+1$} & \multirow{2}{*}{$2185$} \\
& $27342-25158+1$ & \\
\cline{2-3}
& \footnotesize{$\text{Res}_2-\text{Res}_1$} & \multirow{2}{*}{$2027$} \\
& $25158-23131$ & \\
\cline{2-3}
& \footnotesize{$\text{Res}-F$} & \multirow{2}{*}{$146$}\\
& $23131-22985$ & \\
\hline
\multirow{8}{*}{Set 3} & \footnotesize{$R-\text{Res}_3+1$} & \multirow{2}{*}{$2465$} \\
& $40049-37585+1$ & \\
\cline{2-3}
& \footnotesize{$\text{Res}_3-\text{Res}_2$} & \multirow{2}{*}{$125$} \\
& $37585-37460$ & \\
\cline{2-3}
& \footnotesize{$\text{Res}_2-\text{Res}_1$} & \multirow{2}{*}{$564$} \\
& $37460-36896$ & \\
\cline{2-3}
& \footnotesize{$\text{Res}-F$} & \multirow{2}{*}{$1442$}\\
& $36896-35454$ &
\label{bp:HindIII}
\end{tabular}
\end{table}
\end{document}