15

I am looking for a 'stair' or 'stairway' symbol that I can use in math mode to denote a stair-like curve, for example to be used as an integration path. I have included some pictures as examples below:

enter image description here

enter image description here

enter image description here

and for "full" stairs:

enter image description here

enter image description here

enter image description here

Feel free to add more appropriate tags.

2
  • There might be something here.
    – luchonacho
    Commented Sep 1, 2018 at 11:42
  • @luchonacho: I thought so too, but I wasn't able to find anything even remotely close in there. Maybe I have overlooked something.
    – M.G.
    Commented Sep 1, 2018 at 12:14

2 Answers 2

21

You could build something on your own, like:

\documentclass{memoir}
\usepackage{multicol,tikz,xcolor, amsmath}
\usetikzlibrary{calc}
\tikzset{stairwayStyleLineWidth/.style={line width=0.04em}}
\tikzset{stairwayStyleRound/.style={line join=round,line cap=round,stairwayStyleLineWidth}}
\tikzset{stairwayStyleSharp/.style={stairwayStyleLineWidth}}
\tikzset{stairwayStyle/.style={stairwayStyleRound}}

\newcommand{\stairwayup}{\mathbin{
\tikz[baseline=(stairwayanchor.base)]{
    \node (stairwayanchor) {\quad}; 
    \draw[stairwayStyle] 
        ($(stairwayanchor.south west) + (0.0em,0.4em)$)
        -- ++(0.20em,0) -- ++(0,0.20em)
        -- ++(0.20em,0) -- ++(0,0.20em)
        -- ++(0.20em,0) -- ++(0,0.20em)
        -- ++(0.20em,0) %-- ++(0,0.25em)
        ;
}}
}

\newcommand{\stairwaydown}{\mathbin{
\tikz[baseline=(stairwayanchor.base)]{
    \node (stairwayanchor) {\quad}; 
    \draw[stairwayStyle] 
        ($(stairwayanchor.south east) + (0.0em,0.4em)$)
        -- ++(-0.20em,0) -- ++(0,0.20em)
        -- ++(-0.20em,0) -- ++(0,0.20em)
        -- ++(-0.20em,0) -- ++(0,0.20em)
        -- ++(-0.20em,0) %-- ++(0,-0.25em)
        ;
}}
}

\newcommand{\stairwayupfilled}{\mathbin{
\tikz[baseline=(stairwayanchor.base)]{
    \node (stairwayanchor) {\quad}; 
    \draw[stairwayStyle,fill=.] 
        ($(stairwayanchor.south west) + (0.0em,0.4em)$)
        -- ++(0,0.20em)
        -- ++(0.20em,0) -- ++(0,0.20em)
        -- ++(0.20em,0) -- ++(0,0.20em)
        -- ++(0.20em,0) %-- ++(0,0.25em)
        -- ++(0,-0.60em)
        -- cycle
        ;
}}
}

\newcommand{\stairwayuphollow}{\mathbin{
\tikz[baseline=(stairwayanchor.base)]{
    \node (stairwayanchor) {\quad}; 
    \draw[stairwayStyle] 
        ($(stairwayanchor.south west) + (0.0em,0.4em)$)
        -- ++(0,0.20em)
        -- ++(0.20em,0) -- ++(0,0.20em)
        -- ++(0.20em,0) -- ++(0,0.20em)
        -- ++(0.20em,0) %-- ++(0,0.25em)
        -- ++(0,-0.60em)
        -- cycle
        ;
}}
}

\newcommand{\stairwaydownfilled}{\mathbin{
\tikz[baseline=(stairwayanchor.base)]{
    \node (stairwayanchor) {\quad}; 
    \draw[stairwayStyle,fill=.] 
        ($(stairwayanchor.south east) + (0.0em,0.4em)$)
        -- ++(0,0.20em)
        -- ++(-0.20em,0) -- ++(0,0.20em)
        -- ++(-0.20em,0) -- ++(0,0.20em)
        -- ++(-0.20em,0) %-- ++(0,-0.25em)
        -- ++(0,-0.60em)
        -- cycle
        ;
}}
}

\newcommand{\stairwaydownhollow}{\mathbin{
\tikz[baseline=(stairwayanchor.base)]{
    \node (stairwayanchor) {\quad}; 
    \draw[stairwayStyle] 
        ($(stairwayanchor.south east) + (-0.0em,0.4em)$)
        -- ++(0,0.20em)
        -- ++(-0.20em,0) -- ++(0,0.20em)
        -- ++(-0.20em,0) -- ++(0,0.20em)
        -- ++(-0.20em,0) %-- ++(0,-0.25em)
        -- ++(0,-0.60em)
        -- cycle
        ;
}}
}



\begin{document}
\begin{multicols}{2}

The symbols used in Text $\stairwayupfilled \stairwayup \stairwayuphollow$ and $\stairwaydownfilled \stairwaydown \stairwaydownhollow$ and formulas:
\begin{align*}
    &5\stairwayup6 \stairwaydown 7 \\
    &\int_{\stairwayup} \omega, \int_{\stairwaydown} \omega\\
    &\stairwayupfilled \stairwayup \stairwayuphollow \\
    &\stairwaydownfilled \stairwaydown \stairwaydownhollow 
\end{align*}

Different sizes and widths: 

{\tiny $\stairwayup <$} 

{\huge $\stairwayup <$}

\begin{align*}
        {\tiny\stairwayup}
        {\huge\stairwayup}
\end{align*}

Color:
\begin{align*}
    \colorbox{blue}{\color{-blue} $\stairwayupfilled \stairwayup \stairwayuphollow$}
\end{align*}

Normalsize:
\begin{align*}
    6   &\stairwayup 5 \stairwaydown 7\\
    6   &> 5<7\\
    \int_{\stairwayup}  & \int_{\stairwaydown}
\end{align*}

\tiny Tiny:
\begin{align*}
    6   &\stairwayup 5 \stairwaydown 7\\
    6   &> 5<7\\
    \int_{\stairwayup}  & \int_{\stairwaydown}
\end{align*}

\huge Huge:
\begin{align*}
    6   &\stairwayup 5 \stairwaydown 7\\
    6   &> 5<7\\
    \int_{\stairwayup}  & \int_{\stairwaydown}
\end{align*}
\end{multicols}

\end{document}

Observe that the stairs have a round appeal. This way they blend better with <. You can choose sharp corners if you change

\tikzset{stairwayStyle/.style={stairwayStyleRound}}

to

\tikzset{stairwayStyle/.style={stairwayStyleSharp}}

if you want to. The thickness of the strokes varies with the font size and the symbols do change their color appropriately.

Tikz is very versatile once you have a basic understanding. It might be relatively slow compared to other low level software, though. My code might have some room for improvement.

enter image description here

4
  • 2
    Thanks a lot for this and for the code example! I am still very new to tikz, so the code example really helps!
    – M.G.
    Commented Sep 1, 2018 at 10:36
  • 1
    @M.G. TikZ is definitely worth learning. It comes with a great manual at ctan.org/pkg/pgf. Commented Sep 1, 2018 at 10:38
  • 1
    Thanks for including the other examples as well!
    – M.G.
    Commented Sep 2, 2018 at 9:04
  • 1
    @M.G. You may find texample.net/tikz/examples useful, too. Commented Jul 29, 2019 at 0:45
19

Yet another question of this type: I begin to think that I should seriously consider the idea of turning my halloweenmath package into a package generally aimed to making mathematical symbols out of arbitrary pictures. In this way, you get several frills for free, like the bolder look when the bold math version is in force, and automatic scaling in sub/superscripts. I see no reason, however, why the symbols in question should behave as binary operators.

% My standard header for TeX.SX answers:
\documentclass[a4paper]{article} % To avoid confusion, let us explicitly 
                                 % declare the paper format.

\usepackage[T1]{fontenc}         % Not always necessary, but recommended.
% End of standard header.  What follows pertains to the problem at hand.

\usepackage{halloweenmath} % also loads "amsmath''

\makeatletter

\newcommand*\@HwM@ironwire@stairway[2]{%
  % #1 := font selector (e.g., "\textfont")
  % #2 := line thickness, in unit of default-rule-thickness "\fontdimen"
  \begin{@HwM@small@picture}#1{4.6}{-2.3}%
    \roundcap
    \linethickness{#2\@HwM@thickness@units@for #1}%
    \polyline(\-2,-2)(\-2,-1)(\-1,-1)(\-1,0)%
            (0,0)(0,1)(\+1,1)(\+1,2)(\+2,2)\relax
  \end{@HwM@small@picture}%
}
\newcommand*\@HwM@Ironwire@Stairway[2]{%
  % #1 := style selector (e.g., "\textstyle")
  % #2 := font selector (e.g., "\textfont")
  \@HwM@choose@thicknesses{\@HwM@ironwire@stairway #2}%
        {{1.25}}%
        {{2.5}}%
}

\newcommand*\@HwM@hollow@stairway[2]{%
  % #1 := font selector (e.g., "\textfont")
  % #2 := line thickness, in unit of default-rule-thickness "\fontdimen"
  \begin{@HwM@small@picture}#1{4.6}{-2.3}%
    \roundcap
    \linethickness{#2\@HwM@thickness@units@for #1}%
    \polygon(\-2,-2)(\-2,-1)(\-1,-1)(\-1,0)%
            (0,0)(0,1)(\+1,1)(\+1,2)(\+2,2)%
            (\+2,-2)\relax
  \end{@HwM@small@picture}%
}
\newcommand*\@HwM@Hollow@Stairway[2]{%
  % #1 := style selector (e.g., "\textstyle")
  % #2 := font selector (e.g., "\textfont")
  \@HwM@choose@thicknesses{\@HwM@hollow@stairway #2}%
        {{1.25}}%
        {{2.5}}%
}

\newcommand*\mathsimplerightstair{\@HwM@set@right@dir \@HwM@mathsimplestair}
\newcommand*\mathsimpleleftstair {\@HwM@set@left@dir  \@HwM@mathsimplestair}
\newcommand*\@HwM@mathsimplestair{%
  \@HwM@general@ordinary@symbol \@HwM@Ironwire@Stairway
}
\newcommand*\mathhollowrightstair{\@HwM@set@right@dir \@HwM@mathhollowstair}
\newcommand*\mathhollowleftstair {\@HwM@set@left@dir  \@HwM@mathhollowstair}
\newcommand*\@HwM@mathhollowstair{%
  \@HwM@general@ordinary@symbol \@HwM@Hollow@Stairway
}

\makeatother



\begin{document}

In text, surrounded by square brackets so to check the sidebearings:
\( [ \mathsimplerightstair \mathsimpleleftstair] \),
or \( [\mathhollowrightstair \mathhollowleftstair] \).
Now in display:
\[
    \mathsimplerightstair + \int_{\mathsimplerightstair} f(z)\,dz
        - \mathhollowleftstair - \int_{\mathhollowleftstair} g(z)\,dz
\]
Note that the symbols get smaller in the subscript, even if the main font size
doesn't change.  This behavior extends to double scripts, \emph{e.g.},
\( [\mathhollowrightstair_{\mathhollowrightstair^{\mathhollowrightstair}}] \),
as one would expect.\footnote{Of course, changes in the main font size are 
honored too:
\( [\mathhollowrightstair_{\mathhollowrightstair^{\mathhollowrightstair}}] \).}

Furthemore, compare the looks of the four symbols in the \texttt{normal} and in 
the \texttt{bold} math versions:
\( [\mathsimplerightstair \mathsimpleleftstair
\mathhollowrightstair \mathhollowleftstair] \)
{\bfseries \boldmath versus
\( [\mathsimplerightstair \mathsimpleleftstair
\mathhollowrightstair \mathhollowleftstair] \).}

As already mentioned in a footnote, the symbols also scale with the main font 
size (compare them with the brackets).

\bigskip

{\Large This is \verb|\Large|:
\( [ \mathsimplerightstair \mathsimpleleftstair] +
\mathhollowrightstair_{\mathhollowrightstair}\).}

\bigskip

{\Huge This is \verb|\Huge|:
\( [ \mathsimplerightstair \mathsimpleleftstair] +
\mathhollowrightstair_{\mathhollowrightstair}\).}

\bigskip

{\footnotesize This is \verb|\footnotesize|:
\( [ \mathsimplerightstair \mathsimpleleftstair] +
\mathhollowrightstair_{\mathhollowrightstair}\).}

\end{document}

See the comments in halloweenmath.dtx for an explanation of how the macros work. Some fine-tuning of the sidebearings and of the line thicknesses might still be necessary, of course.

This is the output:

Output of the code


Addition: It crossed my mind that, in the above code, you might want to replace all occurrences of \roundcap with \roundcap \roundjoin, to get round joins between the segments of the stairs as well as round caps; and as a matter of fact, \roundcap is even useless in the case of \@HwM@hollow@stairway, which has no caps at all!

1
  • This is great! I will admit to my shame that I wasn't aware of the existence of your package. But now I am!
    – M.G.
    Commented Sep 1, 2018 at 15:22

You must log in to answer this question.

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