# custom \midrule length

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.

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

• @marmot there you go, i uploaded more info. I have tried \cmidrule but I couldn't get it to do what i want. Weird syntax too. All I want to do is set a custom line length. – tjt263 Mar 30 at 4:48

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}


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

• Cool. What's an em? Can i set the width / weight too? – tjt263 Mar 30 at 5:09
• @tjt263 An em is a relative unit that scales with the font size, see e.g. tex.stackexchange.com/a/4244/121799. And yes, you can change the line width. It is the optional argument, try e.g. \cmidrule[1.5pt](l{5em}r{5em}){1-2}, – marmot Mar 30 at 5:18
• Got it. \cmidrule[.5pt](l{5.5em}r{5.5em}){1-2} – tjt263 Mar 30 at 5:18
• Same time. Thanks. – tjt263 Mar 30 at 5:19
• Not sure why defining the table as c|c and then using \multicolumn{2}{c} for every row. – egreg Mar 30 at 10:47

I may guess you want something like this. You can play with the padding of the short rule by changing 2em.

Avoid \ \ \ sequences for spacing: better using \hspace or fixed chunks such as \quad or \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}