[Tex/LaTex] custom \midrule length

articlebooktabsformattinglayoutrules

I just want a simple \midrule that doesn't span the entire page or cell.
For instance, with \rule, you can specify dimensions like:

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

That's as close as I can get it, but it doesn't fit nicely in the same amount of space as \midrule, it seems to take up and extra half a line (row) or so. It has this little extra buffer of empty space, like an invisible border or something. Normally it wouldn't bother me, but I have a bit of a theme happening that took me a while to get all nice and if I neglect the uniform, it's going to make the whole thing look sloppy. Is there some way to get what I want? Below is a quick example. Notice how the \midrule is all nice and snug with the others, but the \rule is being greedy, but on the other hand, it lets me specify length manually.

enter image description here

\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}

Best Answer

I am using this answer to obtain

\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}

enter image description here

Here l{5em}r{5em} indicates that the rule gets shortened by 5em on each side.