8

How to input the staggered array as the expression like this: hexagonal array

The expressions are in hexagonal fashion. Are there packages for this situation?

thank you.

6

Here, I use TABstacks to make the data stacks, and the \scaleleftright[max-width]{left}{content}{right} to add the brackets. Note that in the second matrix, I actually use a small negative "tabbedgap" of -1pt (i.e., column sep) to overlap the columns slightly. By comparison, I use a +1pt gap in the first matrix

\documentclass{article}
\usepackage{scalerel,tabstackengine,amssymb,amsmath}
\stackMath
\begin{document}
\[
\setstacktabbedgap{1pt}
A_h = \scaleleftright[1.5ex]{\langle}{\tabbedCenterstack{
&0&&0&\\
0&&0&&0\\
&0&&0&
}}{\rangle}
\text{, and } 
\setstacktabbedgap{-1pt}
B_h =\scaleleftright[1.5ex]{\langle}{\tabbedCenterstack{
&-1&&-1&\\
-1&&6+\varepsilon^2&&-1\\
&-1&&-1&
}}{\rangle}
\]
\end{document}

enter image description here

While not shown here, uniform column width can be enforced by issuing \fixTABwidth{T} prior to the stacks. In so doing, a change in the tabbedgap is correspondingly called for.

If one really hates typing double &&, then this \active alternative allows the use of # to mean &&, producing the same result:

\documentclass{article}
\usepackage{scalerel,tabstackengine,amssymb,amsmath}
\stackMath
\begin{document}
\[
\catcode`#=\active \def#{&&}
\setstacktabbedgap{1pt}
A_h = \scaleleftright[1.5ex]{\langle}{\tabbedCenterstack{
&0#0&\\
0#0#0\\
&0#0&
}}{\rangle}
\text{, and } 
\setstacktabbedgap{-1pt}
B_h =\scaleleftright[1.5ex]{\langle}{\tabbedCenterstack{
&-1#-1&\\
-1#6+\varepsilon^2#-1\\
&-1#-1&
}}{\rangle}
\]
\end{document}
4

Three lines are covered by the standard \left< and \right> symbols.

Here's an hexagon environment that can receive an optional argument for setting the width of the cells (default 1em):

\documentclass{article}
\usepackage{amsmath,collcell}

\newcolumntype{h}{>{\collectcell\hd}c<{\endcollectcell}}
\newcolumntype{k}[1]{@{\hspace{-#1\hexawidth}}}
\newcommand{\hd}[1]{\makebox[\hexawidth]{$#1$}}
\newlength{\hexawidth}

\newenvironment{hexagon}[1][1em]
 {\setlength{\hexawidth}{#1}
  \left<
  \begin{array}{k{.33333}*{4}{hk{.5}}hk{.33333}}}
 {\end{array}\right>}


\begin{document}
\[
A_{h}=
  \begin{hexagon}
    & 0 && 0 \\
  0 && 0 && 0 \\
    & 0 && 0 \\
  \end{hexagon}
\qquad
B_{h}=
  \begin{hexagon}[4em]
    & -1 && -1 \\
  -1 && 6+\varepsilon^2 && -1 \\
    & -1 && -1 \\
  \end{hexagon}
\]
\end{document}

Note that the \\ in the last row is necessary because of how collcell works.

enter image description here

2

I didn't know scalerel and \scaleleftright command, so I've copied from Steven's answer. Thanks.

But I knew array which can be also used for these expressions.

\documentclass{article}
\usepackage{scalerel,amsmath,array}
\usepackage{lmodern}

\begin{document}
\[
A_h = \scaleleftright[1.5ex]{\langle}{\begin{array}{@{}c@{}c@{}c@{}c@{}c@{}c@{}}
& 0 & & 0 & \\
0 & & 0 & & 0 \\
& 0 & & 0 &\\
\end{array}}{\rangle}, 
\text{and}\ B_h = 
\scaleleftright[1.5ex]{\langle}{\begin{array}{@{}c@{}c@{}c@{}c@{}c@{}c@{}}
& -1 & & -1 & \\
-1 & & 6+\epsilon^2 & & -1 \\
& -1 & & -1 &\\
\end{array}}{\rangle}
\]
\end{document}

enter image description here

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.