Quantcast
Channel: Combination of arrows with and without label - TeX - LaTeX Stack Exchange
Viewing all articles
Browse latest Browse all 3

Answer by Clément for Combination of arrows with and without label

$
0
0

I have used Steven B. Segletes's answer for many year and value it. Unfortunately, it is quite computationally expensive, and made some simple document that I had take 26 seconds to compile.

I have re-written my own solution, without the double-lined (d) variations: this is not exactly an answer to this question, but I thought it could be helpful nevertheless.

\documentclass{article}\usepackage{tikz}\usepackage{mathtools}\usetikzlibrary{calc,decorations.pathmorphing,shapes}\newcounter{sarrow}\NewDocumentCommand{\xrsquigarrow}{m}{ % Backward arrow    \stepcounter{sarrow}%    \mathrel{\begin{tikzpicture}[baseline= {( $(current bounding box.south)$ )}]            \node[inner sep=.5ex, font=\scriptsize] (\thesarrow) {$#1$};            \path[draw,->,decorate,            %decoration={zigzag,amplitude=0.7pt,segment length=1.2mm,pre=lineto,pre length=4pt}            decoration={snake,                amplitude=-1pt, segment length =1.5mm, pre=lineto, post length=2pt%, post length=3pt            }            ]             (\thesarrow.south west) -- (\thesarrow.south east);    \end{tikzpicture}}%}\newcommand{\tootip}{\mathrel{\tikz[anchor=base]{\draw[->](0,0)--(.01,0);}}} % https://tex.stackexchange.com/a/645771/34551% https://tex.stackexchange.com/a/260581/34551\newcommand{\rightarrowdbl}{\mathrel{\ooalign{ % https://tex.stackexchange.com/a/22375/34551            $\rightarrow$\cr %            \hidewidth\raise.23em\hbox{$\tootip\mkern4mu$}}}        }\newcommand{\xrightarrowdbl}[1]{%    \mathrel{\ooalign{%            $\xrightarrow{#1}$\cr%            \hidewidth\raise.23em\hbox{$\tootip\mkern4mu$}}}}\ExplSyntaxOn\RenewDocumentCommand{\r}{m o o} % m = direction (b, f, bf)% o = label% o = key% Assumption is that you will never have a key without a label.{    \str_case:nnF { #1 }    {        {f}{% Forward case            \IfValueTF{#2} % We test if the label is here.            {                \IfValueTF{#3}% We test if the key is here.                    {\xrightarrow{#2[#3]} } % Forward,  label and key                    {\xrightarrow{#2}} % Forward, a label but no key            }            { \rightarrow } % Forward, no label nor key        }        {b}{% backward case            \IfValueTF{#2} % We test if the label is here.            {                \IfValueTF{#3}% We test if the key is here.                {\xrsquigarrow{#2[#3]}} % Backward,  label and key                {\xrsquigarrow{#2}} % Backward, a label but no key            }            { \xrsquigarrow{\mkern10mu} } % Backward, no label nor key        }        {fb}{ % Forward and backward case        \IfValueTF{#2} % We test if the label is here.            {            \IfValueTF{#3}% We test if the key is here.            { \xrightarrowdbl{#2[#3]}} % Backward, label and key            { \xrightarrowdbl{#2}} % Backward, a label but no key        }        {\rightarrowdbl} % Forward and backward, no label nor key        }    }    { #1 }}\ExplSyntaxOff\begin{document}\begin{align*}    \Aboxed{P \r{f} Q} & \Aboxed{P \r{f}[\alpha] Q} & \Aboxed{P \r{f}[\alpha][k] Q}\\    \Aboxed{P \r{b} Q} & \Aboxed{P \r{b}[\alpha] Q} & \Aboxed{P \r{b}[\alpha][k] Q} \\    \Aboxed{P \r{fb} Q} & \Aboxed{P \r{fb}[\alpha] Q} & \Aboxed{P \r{fb}[\alpha][k] Q} \\\end{align*}\end{document}

gives:

enter image description here

My document went from 26 seconds to 6 seconds using this alternative way of generating arrows…


Viewing all articles
Browse latest Browse all 3

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>