0

My question is smiliar to Creating a matrix with column or row vectors as arguments: I would like to typeset a matrix by indicating just its column vectors.

However the answers in the linked questions suggest things like

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\[
\begin{pmatrix}
    \vert & \vert \\
    v_1   & v_2   \\
    \vert & \vert
\end{pmatrix}
\]

\end{document}

The downside to this is that the matrix now is three rows high. I would like to have a solution that looks nice next to a 2x2 matrix. I then tried

\begin{pmatrix}
   \shortmid  & \shortmid \\[-1ex]
    v_1       & v_2   \\[-1ex]
    \shortmid & \shortmid
\end{pmatrix}

which is better, but not good. Also, it is absolutely not suitable for regular use, as it is basically just an ad-hoc solution.

  • What if you replace \vert with \phantom{}? – Cragfelt Nov 4 '19 at 15:01
  • I would like to have some sort of vertical bar in order to make it very clear that we are talking about entire columns. – Philipp Imhof Nov 4 '19 at 15:09
  • If you use a notation where column vectors have a different appearance , like \textbf{v}_1 then you won't need to pad out columns. – John Kormylo Nov 4 '19 at 15:14
  • Use [-0.5ex] as spacing parameter. It looks more centralized. – Cragfelt Nov 4 '19 at 15:28
  • @JohnKormylo Yes and no. For me as a mathematician, even the notation (v_1,v_2) is crystal clear. The text is for students who are just getting familiar with vectors and matrices. For them, this small visual guidance might help a lot. – Philipp Imhof Nov 4 '19 at 21:16
2

This overlaps the text with two centered \rules. I threw in a 1pt gap at the top and bottom of the text.

\documentclass{article}
\usepackage{amsmath}

\newcommand{\spike}[2]% #1 = size of spike, #2 = centered text
{\bgroup
  \sbox0{#2}%
  \rlap{\usebox0}%
  \hspace{0.5\wd0}%
  \makebox[0pt][c]{\rule[\dimexpr \ht0+1pt]{0.5pt}{#1}}% top spike
  \makebox[0pt][c]{\rule[\dimexpr -\dp0-#1-1pt]{0.5pt}{#1}}% bottom spike
  \hspace{0.5\wd0}%
\egroup}

\begin{document}

\[
\begin{pmatrix}
    \spike{5pt}{$v_1$}  & \spike{5pt}{$v_2$}
\end{pmatrix}
\]

\end{document}

demo

| improve this answer | |
  • Very nice, thank you. I was experimenting with a \shortstack inside the matrix, but it did not work out. Your solution is easy to use and flexible. – Philipp Imhof Nov 5 '19 at 9:17
  • FWIW, I changed the first line to \newcommand{\spike}[2][3pt] so that I do not have to indicate the length of the spike at every invocation. – Philipp Imhof Nov 5 '19 at 9:54
  • I left it variable just to make it easier to experiment with. – John Kormylo Nov 5 '19 at 16:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.