4

I am attempting to typeset a notation that I use for my own work, and I am struggling to create flexible commands. The notation involves placing mathematical symbols and expressions as if on the vertices of a triangular grid, and then using these objects in equations, resulting in images like these:

notation

notation1

notation2

notation3

Until now I have been fiddling with tikzpicture and painstakingly adjusting node positions until it looks right, but I want to create some commands or a package that would allow me to select the structure, like twoOverThree in the fourth image, and input the arguments {a}{b}{c}{d}{e} whether they are single letters or slightly more complicated expressions. Any advice? The tikzpicture strategy failed to work generally because adjustments in node positioning were always necessary depending on the arguments.

  • 1
    Welcome to TeX.SX :) Would a syntax like \WeirdNotation{2/3:a,b,c,d,e} work for you? Can you show us how you currently make the expressions? (That way, we won't have to re-invent the wheel, here. This is called a minimal working example (MWE) on this site.) – Sean Allred May 19 '15 at 21:43
1

All this notation can be replicated with simple arrays, why do you need TikZ?

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

\newcommand{\twooverthree}[5]{
    \begin{array}{@{}c@{}c@{}c@{}c@{}c@{}}
        &#1&&#2\\
        #3&&#4&&#5
    \end{array}}

\newcommand{\twooverone}[3]{
    \begin{array}{@{}c@{}c@{}c@{}}
        #1&&#2\\
        &#3
    \end{array}}

\newcommand{\oneovertwo}[3]{
    \begin{array}{@{}c@{}c@{}c@{}}
        &#1\\
        #2&&#3\\
    \end{array}}

\newcommand{\oneone}[2]{
    \begin{array}{@{}c@{}c@{}}
        #1\\
        &#2\\
    \end{array}}

\begin{document}
\[
\left(\oneone{a}{b}\right)\left(\oneone{d}{e}\right)
\]

\[
\alpha\left(\twooverone{a}{c}{b}\right) = 
\oneovertwo{\alpha b}{\alpha c}{\alpha a}
\]

\[
\oneone{\oneone{a}{\overline{v}}}{\oneone{\overline{w}}{f}}
\]

\[
\twooverthree{a}{b}{c}{d}{e}
\]
\end{document}

enter image description here

4

Here's my attempt at an elegant solution to your custom notation. This solution does not require any packages whatsoever (amsmath is only included in the example for the \bar{} command in your example equations).

enter image description here

\documentclass{article}
\usepackage{amsmath}

\newcommand\slantstack[2]{%
    \raisebox{1.25ex}{$#1$}%
    \raisebox{-1.25ex}{$#2$}}

\newcommand\tristack[3]{%
    \raisebox{-1.25ex}{$#1$}\kern.5ex%
    \raisebox{1.25ex}{$#2$}%
    \raisebox{-1.25ex}{$#3$}}

\newcommand\invtristack[3]{%
    \raisebox{1.25ex}{$#1$}%
    \kern.5ex\raisebox{-1.25ex}{$#2$}%
    \kern.5ex\raisebox{1.25ex}{$#3$}}

\newcommand\quadstack[4]{%
    \raisebox{4.25ex}{$#1$}%
    \kern-.5ex\raisebox{1.25ex}{$#2$}%
    \kern-.5ex\raisebox{-1.25ex}{$#3$}%
    \kern-.5ex\raisebox{-4.25ex}{$#4$}}

\newcommand\twooverthree[5]{%
    \raisebox{-1.25ex}{#1}%
    \raisebox{1.25ex}{#2}%
    \raisebox{-1.25ex}{#3}%
    \raisebox{1.25ex}{#4}%
    \raisebox{-1.25ex}{#5}}

\begin{document}
    \begin{center}
        \begin{tabular}{ccccc}
            \multicolumn{5}{l}{Five basic commands:}\\\hline\\
            \texttt{\textbackslash slantstack}&
            \texttt{\textbackslash tristack}&
            \texttt{\textbackslash invtristack}&
            \texttt{\textbackslash quadstack}&
            \texttt{\textbackslash twooverthree}\\
            \slantstack{a}{b}&
            \tristack{a}{b}{c}&
            \invtristack{a}{b}{c}&
            \quadstack{a}{b}{c}{d}&
            \twooverthree{a}{b}{c}{d}{e}\\\\
            \multicolumn{5}{l}{Identical function in and out of math mode:}\\\hline\\
            $\slantstack{a}{b}$&
            $\tristack{a}{b}{c}$&
            $\invtristack{a}{b}{c}$&
            $\quadstack{a}{b}{c}{d}$&
            $\twooverthree{a}{b}{c}{d}{e}$\\\\
            \multicolumn{5}{l}{Works properly with \texttt{\textbackslash left} \& \texttt{\textbackslash right} commands:}\\\hline\\
            $\left(\slantstack{a}{b}\right)$&
            $\left(\tristack{a}{b}{c}\right)$&
            $\left(\invtristack{a}{b}{c}\right)$&
            $\left(\quadstack{a}{b}{c}{d}\right)$&
            $\left(\twooverthree{a}{b}{c}{d}{e}\right)$\\\\
            \multicolumn{5}{l}{Your equations:}\\\hline\\
            \multicolumn{5}{c}{$\left(\slantstack{a}{b}\right)\left(\slantstack{d}{e}\right)$
            \hfill $\alpha\left(\invtristack{a}{b}{c}\right) = \tristack{\alpha c}{\alpha b}{\alpha a}$
            \hfill \quadstack{a}{\bar{v}}{\bar{w}}{\text{f}}
            \hfill \twooverthree{a}{b}{c}{d}{e}}
        \end{tabular}
    \end{center}
\end{document}

This answer uses only basic \raisebox and \kern commands, so it works nicely in every use-case I thought of and aligns and spaces well with surrounding text and equations. This should also work flawlessly with different font sizes.

0

In order:

  1. This can be done using the solution in this answer. You would need to make line white.
  2. You could use matrices here or set a \newcommand (I'm working on it).
  3. This can be done with a foreach, only two lines of code (I don't know those letters with the above line but you get it):

    enter image description here

    \documentclass[margin=10pt]{standalone}
    \usepackage{tikz}
    
    \begin{document}
    \begin{tikzpicture}[x=2mm, y=5mm]
    
    \foreach \y/\letter [count=\x from 0] in {5/a,4/$v$,3/$w$,2/f}{
        \node at (\x,\y) {\letter};
    }   
    
    \end{tikzpicture} 
    \end{document}
    
  4. Same as number 3, can be done in a foreach (maybe even simpler than how I did it):

    enter image description here

     \documentclass[margin=10pt]{standalone}
     \usepackage{tikz}
    
     \foreach \y/\letter [count=\x from 0] in {0/a,1/b,0/c,1/d,0/e}{
     \node at (\x,\y) {\letter};
     }  
     \end{tikzpicture} 
     \end{document}
    
  • Try out \bar{v} :) – Sean Allred May 20 '15 at 1:09
0

These are trivial to set up with stackengine macros (original answer) and even easier still with the tabstackengine package (revised answer). However, I don't feel I have enough info to set up macro shortcuts, since I don't know the full extent of the desired syntax.

Since many of your data items were in upright (non-math) font, I made the default settings to be that way. If the items in your notation are generally math items, just issue \stackMath in the preamble, and the stacks will assume the arguments are math mode.

REVISED ANSWER

\documentclass{article}
\usepackage{tabstackengine}
\def\stacktype{L}\setstackgap{L}{.8\baselineskip}
\begin{document}
\[ 
\Bigl( \tabbedstackanchor{a&}{&b}\Bigr)
\Bigl( \tabbedCenterstack{d&\\&e}\Bigr)
\]

\[
\alpha\Bigl( \tabbedstackanchor{a&&c}{&b&} \Bigr) = 
  \tabbedstackanchor{&$\alpha$b&}{$\alpha$c&&$\alpha$a}
\]

\[
\tabbedCenterstack{a&&&\\&$\bar v$&&\\&&$\bar w$&\\&&&f} = 0
\]

\[
\tabbedstackanchor{&b&&d&}{a&&c&&e}
\]
\end{document}

enter image description here

ORIGINAL ANSWER (stackengine)

In the MWE below, I show various ways to get the results.

\documentclass{article}
\usepackage[usestackEOL]{stackengine}
\def\stacktype{L}\setstackgap{L}{.8\baselineskip}
\begin{document}
\[ 
\Bigl( \stackanchor{a~~}{~~b}\Bigr)
\Bigl( \Centerstack{d~~\\~~e}\Bigr)
\]

\[
\alpha\Bigl( \stackanchor{a~~c}{b} \Bigr) = 
  \stackanchor{$\alpha$b}{$\alpha$c~~~$\alpha$a}
\]

\[
\makebox[7ex]{%
\tllap[.5\dimexpr\Lstackgap\relax]{\tllap{a}$\bar v$}\brlap[.5\dimexpr\Lstackgap\relax]{$\bar w$\brlap{f}}
}  = 0
\]

\[
\stackanchor{b~~d}{a~~c~~e}
\]
\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.