Long dashes for denoting omitted columns of a matrix
Here's a way, inspired by \rightarrofill
:
\documentclass{article}
\usepackage{amsmath}
\makeatletter
\newcommand{\longdash}[1][2em]{%
\makebox[#1]{$\m@th\smash-\mkern-7mu\cleaders\hbox{$\mkern-2mu\smash-\mkern-2mu$}\hfill\mkern-7mu\smash-$}}
\makeatother
\newcommand{\omitskip}{\kern-\arraycolsep}
\newcommand{\llongdash}[1][2em]{\longdash[#1]\omitskip}
\newcommand{\rlongdash}[1][2em]{\omitskip\longdash[#1]}
\begin{document}
\[
\begin{bmatrix}
\llongdash & x_{1} & \rlongdash \\
\llongdash & x_{2}+y & \rlongdash \\
\llongdash & x_{n} & \rlongdash
\end{bmatrix}
\]
\end{document}
I use \llongdash
and \rlongdash
to back up slightly and so to ensure the correct alignment of the dashes.
If dots are needed for denoting omitted rows, one can use \hdotsfor
:
\begin{bmatrix}
\llongdash & x_{1} & \rlongdash \\
\llongdash & x_{2}+y & \rlongdash \\
\hdotsfor{3} \\
\llongdash & x_{n} & \rlongdash
\end{bmatrix}
instead of the code above will produce
Alternatively, one can use only one column
\[
\begin{bmatrix}
\longdash\hfill x_{1} \hfill \longdash \\
\longdash\hfill x_{2} + y \hfill \longdash \\
\longdash\hfill x_{n} \hfill \longdash \\
\end{bmatrix}
\]
and get
Here is a solution based on TikZ
:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix}
% possible to customize here the dash aspect
\newcommand{\mydash}{
\draw(0.3,0.5ex)--(-0.3,0.5ex);
}
\begin{document}
\[P=
\begin{tikzpicture}[baseline=-0.5ex]
\matrix(m)[matrix of math nodes,left delimiter=(,right delimiter=),ampersand replacement=\&]
{
\mydash \& y_1 \& \mydash \\
\mydash \& y_2+z_2 \& \mydash \\
\mydash \& y_3 \& \mydash \\
};
\end{tikzpicture}
\]
\end{document}
which gives: