自定义 \midrule 长度

自定义 \midrule 长度

我只想要一个简单的\midrule,不跨越整个页面或单元格的。
例如,使用\rule,您可以指定如下尺寸:

\rule[0.2cm]{100pt}{0.5pt}

这是我能得到的最接近的结果,但是它不能很好地适应与 相同的空间量\midrule,它似乎占用了额外的半行(行)左右。它有一个额外的小空白缓冲区,就像一个隐形的边框或什么东西。通常它不会困扰我,但我遇到了一个主题,我花了一段时间才把一切都弄好,如果我忽略了统一,它会让整个事情看起来很草率。有没有什么方法可以得到我想要的?下面是一个简单的例子。注意 是如何\midrule与其他的都很好很舒适,但是\rule是贪婪的,但另一方面,它让我手动指定长度。

在此处输入图片描述

\documentclass[margin=6]{standalone}
\usepackage{amsmath,booktabs}

\begin{document}

\begin{tabular}{c|c}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\midrule
\multicolumn{2}{c}{\scshape Bijection} \\
\midrule
\multicolumn{2}{c}{$f:V(e) \to V(c)$} \\
\midrule
\multicolumn{2}{c}{$f(e_{1})=c_{1}\ \ \ \ \ \ 
                    f(e_{2})=c_{3}\ \ \ \ \ \ 
                    f(e_{3})=c_{5}$} \\

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\midrule
\multicolumn{2}{c}{\scshape Bijection} \\
\midrule
\multicolumn{2}{c}{$f:V(e) \to V(c)$} \\
\multicolumn{2}{c}{\rule[0.2cm]{180pt}{0.5pt}} \\
\multicolumn{2}{c}{$f(e_{1})=c_{1}\ \ \ \ \ \ 
                    f(e_{2})=c_{3}\ \ \ \ \ \ 
                    f(e_{3})=c_{5}$} \\

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\midrule
\end{tabular}

\end{document}

答案1

我在用这个答案获得

\documentclass[margin=6]{standalone}
\usepackage{amsmath,booktabs}

\begin{document}

\begin{tabular}{c|c}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\midrule
\multicolumn{2}{c}{\scshape Bijection} \\
\midrule
\multicolumn{2}{c}{$f:V(e) \to V(c)$} \\
\midrule
\multicolumn{2}{c}{$f(e_{1})=c_{1}\ \ \ \ \ \ 
                    f(e_{2})=c_{3}\ \ \ \ \ \ 
                    f(e_{3})=c_{5}$} \\

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\midrule
\multicolumn{2}{c}{\scshape Bijection} \\
\cmidrule(l{5em}r{5em}){1-2}
\multicolumn{2}{c}{$f:V(e) \to V(c)$} \\
\multicolumn{2}{c}{\rule[0.2cm]{180pt}{0.5pt}} \\
\multicolumn{2}{c}{$f(e_{1})=c_{1}\ \ \ \ \ \ 
                    f(e_{2})=c_{3}\ \ \ \ \ \ 
                    f(e_{3})=c_{5}$} \\

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\midrule
\end{tabular}
\end{document}

在此处输入图片描述

这里l{5em}r{5em}表示规则5em在两边都缩短了。

答案2

我猜你想要这样的东西。你可以通过更改来调整短规则的填充2em

避免使用\ \ \序列作为间隔:最好使用\hspace或固定块,例如\quad\qquad

\documentclass{article}
\usepackage{amsmath,booktabs}

\begin{document}

\begin{tabular}{c}
\toprule
\begin{tabular}{@{\hspace{2em}}c@{\hspace{2em}}}
  \scshape Bijection \\
  \midrule
  $f\colon V(e) \to V(c)$ \\
\end{tabular} \\
\midrule
$f(e_{1})=c_{1}$\qquad $f(e_{2})=c_{3}$\qquad $f(e_{3})=c_{5}$ \\
\bottomrule
\end{tabular}

\end{document}

在此处输入图片描述

相关内容