How to get a stairway symbol in math mode?
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.
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:
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!