# Specifying the length of \hline

$\left[\begin{matrix} u(\lambda)\\\hline v(\lambda) \\ \end{matrix}\right]$

$\left[\begin{array}{c} u(\lambda)\\\hline v(\lambda) \\ \end{array}\right]$


In the first code the \hline goes outside the brackets and in the second one there is unnecessary space. Please suggest some method to exactly place the \hline within brackets without extra space.

• Is $\left[ \displaystyle\frac{u(\lambda)}{v(\lambda)} \right]$ maybe what you're looking to write? – Mico May 5 '17 at 7:45
• I do not believe that the linked question and its answers are appropriate here. The OP wants IMO a line exactly from bracket to bracket, ideally w/o the need for manual modifications. My first idea was to use TikZ, although this is of course a bit like using a sledgehamer for cracking a nut. – Jürgen May 5 '17 at 14:45

Here a work-around solution with \cmidrule from booktabs, using its(l{somelength}r{some length}) optional argument to shorten or extend the rule on bothsides:

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{booktabs}
\usepackage{array}
$\left[\begin{matrix} u(\lambda)\\\hline v(\lambda) \\ \end{matrix}\right]$
$\left[\begin{array}{@{}c@{}} u(\lambda)\\\hline v(\lambda) \\ \end{array}\right]$
\quad$\begin{bmatrix} u(\lambda)\\ \myhrule v(\lambda) \\ \end{bmatrix}$