5

I want to have a 2x2 matrix of arrows (\uparrow and \downarrow) to illustrate electronic spins. I've managed to get a fraction without the horizontal line using \genfrac, but I can't figure out how to reduce the vertical spacing between the pairs of arrows down.

What I have so far (working example):

\documentclass[a4paper,10pt]{article}  
\usepackage{amsmath}  
\newcommand{\stack}[2]{\genfrac{}{}{0pt}{0}{#1}{#2}}  
\begin{document}  
$\stack{\uparrow\uparrow}{\downarrow\downarrow}$  
\end{document}

EDIT: This is what I ended up doing, after combining some of the answers here:

\newcommand{\stack}[2]{\array{c}{\scriptstyle #1}\\[-1.1ex]{\scriptstyle #2}\endarray}

And the final result, which is going into my report:

\documentclass[a4paper,10pt]{article}
\usepackage{amsmath}
\newcommand{\up}{\uparrow}
\newcommand{\dw}{\downarrow}
\newcommand{\stack}[2]{\array{c}{\scriptstyle #1}\\[-1.1ex]{\scriptstyle #2}\endarray}
\begin{document}

\begin{table}
    \centering
    \begin{tabular}{|c|c|c|c|c|}
        \hline
        Spin arrangements &Spins up &Degeneracy &Energy &Magnetization \\ \hline
        $\stack{\up\up}{\up\up}$ &4 &1 &-8J &4 \\
        $\stack{\up\up}{\up\dw}$ $\stack{\up\up}{\dw\up}$ $\stack{\up\dw}{\up\up}$ $\stack{\dw\up}{\up\up}$ &3 &4 &0 &2 \\
        $\stack{\up\up}{\dw\dw}$ $\stack{\dw\dw}{\up\up}$ $\stack{\up\dw}{\up\dw}$ $\stack{\dw\up}{\dw\up}$ &2 &4 &0 &0 \\
        $\stack{\up\dw}{\dw\up}$ $\stack{\dw\up}{\up\dw}$ &2 &2 &8J &0 \\
        $\stack{\up\dw}{\dw\dw}$ $\stack{\dw\up}{\dw\dw}$ $\stack{\dw\dw}{\up\dw}$ $\stack{\dw\dw}{\dw\up}$ &1 &4 &0 &-2 \\
        $\stack{\dw\dw}{\dw\dw}$ &0 &1 &-8J &-4 \\
        \hline
    \end{tabular}
\end{table}

\end{document}
4
  • 2
    Welcome to TeX.sx!. For this you could just use a matrix: $\begin{matrix} \uparrow\uparrow\\ \downarrow\downarrow\end{matrix}$ in the text. There is also the smallmatrix envioronment, or you can replace ` \\ ` by \\[-0.5ex] to make the lines closer if you wish. Nov 5, 2012 at 11:43
  • 1
    "If in doubt check what DEK put in plain TeX." How about $\uparrow\uparrow\atop\downarrow\downarrow$?
    – Thruston
    Nov 5, 2012 at 12:31
  • Thank you both. I think I'll go for a matrix or array as mentioned by @Herbert below here. Now, is there any way to make a shortcut like \stack{\uparrow\uparrow}{\downarrow\downarrow} from this?
    – Filip S.
    Nov 5, 2012 at 13:36
  • \atop gives me some weird amsmath errors though, know how to fix those? Package amsmath Warning: Foreign command \atop, (amsmath) \frac or \genfrac should be used instead.
    – Filip S.
    Nov 5, 2012 at 13:44

1 Answer 1

2

try

$\array{c}\uparrow\uparrow\\\downarrow\downarrow\endarray$  

You can use it in a macro as well.

3
  • 2
    Wouldn't {@{}c@{}} be better, so as to avoid introducing padding on the left and the right?
    – egreg
    Nov 5, 2012 at 11:08
  • yes and no, it depends to the context in which it should be used
    – user2478
    Nov 5, 2012 at 12:10
  • This result of this is pretty much what I already have, but if I replace \\ with \[-0.5ex], as mentioned by Andrew Swann, this does the trick.
    – Filip S.
    Nov 5, 2012 at 13:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .