2
$\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.

enter image description here

  • 4
    Is $\left[ \displaystyle\frac{u(\lambda)}{v(\lambda)} \right]$ maybe what you're looking to write? – Mico May 05 '17 at 07: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 05 '17 at 14:45

1 Answers1

5

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}
\newcommand\myhrule{\addlinespace[-0.2\aboverulesep]\cmidrule[0.4pt](l{2.3pt}r{2.3pt}){1-1}\addlinespace[-0.8\belowrulesep]}

\begin{document}%

$\left[\begin{matrix}
u(\lambda)\\\hline
v(\lambda) \\
\end{matrix}\right]$
\quad
$\left[\begin{array}{@{}c@{}}
u(\lambda)\\\hline
v(\lambda) \\
\end{array}\right]$
\quad$\begin{bmatrix}
u(\lambda)\\
\myhrule
v(\lambda) \\
\end{bmatrix}$

\end{document} 

enter image description here

Bernard
  • 271,350