5

I'm trying to define a dashed \Uparrow: my first try, using tikz, consists simply in drawing two white rectangle over the normal \Uparrow, manually trying to find a good positioning of the rectangles.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tikz}

\newcommand{\Dasheduparrow}{
\begin{tikzpicture}[x=1, y=1]
\node (0,0) [inner sep=0] {$\Uparrow$};
\fill[fill=white] (-3,0.5) rectangle (2,-1);
\fill[fill=white] (-3,-2) rectangle (2,-3.5);
\end{tikzpicture}}

By typing now

\begin{document}
Text $\Dasheduparrow$ $\Downarrow$ $\Uparrow$ text.
\end{document}

I get this

1

and I'm quite satisfied with the output. However, I've got three questions:

  1. How to get the same alignment of the normal \Downarrow and \Uparrow? My new symbol is aligned with the baseline of the text, while the two default ones are a little down-shifted.
  2. How to make this new symbol correctly stretchable? By doing \LARGE Text $\Dasheduparrow$ $\Downarrow$ $\Uparrow$ text. the output is 2 where it's evident that the underlying \Uparrow has been enlarged, while the white rectangles have not.
  3. Is there a better solution than the one I proposed?
  • 1
    vertical arrows, like all binary and relational operators, are vertically centered on the math axis (the same position as the horizontal bar on a plus sign). this probably won't help you lower the dashed arrow, but it explains why the other two are positioned as they are. – barbara beeton Feb 23 '16 at 19:12
3

REVISED ANSWER

The OP comments that, with my original answer, the gaps are not scaled at different font sizes (and math styles). This can be remedied by dispensing with tikz and employing my stackengine package, while scaling the gap size with the math style (using the scalerel package's \LMex [Local-Mathstyle ex] rather than cm or pt as the dimension of the white rectangle overlays).

To answer another question of the OP, the \ThisStyle{...\SavedStyle...} syntax allows the current mathstyle to be carried into a construct where it would normally be lost, in this case, into the \hbox that is being \vcentered and stacked. It is equivalent to a glorified \mathchoice, but will frequently lessen the amount of typing necessary by a significant amount.

\documentclass{article}
\usepackage[utf8]{inputenc}
%\usepackage[T1]{fontenc}
\usepackage{scalerel,stackengine,xcolor}
\newcommand{\Dasheduparrow}{\ThisStyle{\vcenter{\hbox{$%
\stackengine{0.45\LMex}{\stackengine{-.15\LMex}{$\SavedStyle\Uparrow$}
  {\textcolor{white}{\rule{1.1\LMex}{0.3\LMex}}}{O}{c}{F}{T}{L}%
 }{\textcolor{white}{\rule{1.1\LMex}{0.3\LMex}}}{O}{c}{F}{T}{L}%
$}}}}
\begin{document}
Text $\Dasheduparrow$ $\Downarrow$ $\Uparrow$ text.

$\Dasheduparrow \scriptstyle \Dasheduparrow \scriptscriptstyle \Dasheduparrow$

\LARGE
Text $\Dasheduparrow$ $\Downarrow$ $\Uparrow$ text.

\end{document}

enter image description here

ORIGINAL ANSWER

Here, I start with the OP's definitions.

However, I then use \vcenter to center it on the math axis, and also use scalerel features to preserves the math style.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usepackage{scalerel}
\newcommand{\Dasheduparrow}{\ThisStyle{\vcenter{\hbox{$
\begin{tikzpicture}[x=1, y=1]
\node (0,0) [inner sep=0] {$\SavedStyle\Uparrow$};
\fill[fill=white] (-3,0.5) rectangle (2,-1);
\fill[fill=white] (-3,-2) rectangle (2,-3.5);
\end{tikzpicture}$}}}}
\begin{document}
Text $\Dasheduparrow$ $\Downarrow$ $\Uparrow$ text.

$\Dasheduparrow \scriptstyle \Dasheduparrow \scriptscriptstyle \Dasheduparrow$
\end{document}

enter image description here

  • ok, now the vertical alignment of the symbol is good! What about the stretchability? In your example you've got the same problem as mine, i.e. the \Uparrow on the background strecthes correctly, while the white rectangles do not... Another little question: what are the \ThisStyle and \SavedStyle commands doing here? Are they necessary? – Rackbox Feb 24 '16 at 8:36
  • @Rackbox Please see my revised answer. – Steven B. Segletes Feb 24 '16 at 11:15
1

A quick workaround (may be a little unclean):

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tikz,calc}

\newcommand{\Dasheduparrow}{
\begin{tikzpicture}[x=1, y=1]
\node (0,0) [inner sep=0] {$\Uparrow$};
\fill[fill=white] (-3,0.5) rectangle (2,-1);
\fill[fill=white] (-3,-2) rectangle (2,-3.5);
\end{tikzpicture}}

\begin{document}
Text \parbox{\widthof{$\Dasheduparrow$}}{$\Dasheduparrow$} $\Downarrow$ $\Uparrow$ text.
\end{document}

enter image description here

Where I have used a parbox to center its contents.

\parbox{\widthof{$\Dasheduparrow$}}{$\Dasheduparrow$}

Another possibility is to use the math centering command:

\vcenter{\hbox{\Dasheduparrow}}

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.