summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/letterswitharrows/letterswitharrows.sty
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2019-11-20 22:13:02 +0000
committerKarl Berry <karl@freefriends.org>2019-11-20 22:13:02 +0000
commitfab7846299dd551159350051134d1823f02e45e5 (patch)
tree50a6d0596c5fa34f2f75ef1d4b041e704c2145c0 /Master/texmf-dist/tex/latex/letterswitharrows/letterswitharrows.sty
parent9447505e72d9809d534f8ad3a0091cd2b58fbc3b (diff)
letterswitharrows (20nov19)
git-svn-id: svn://tug.org/texlive/trunk@52873 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/letterswitharrows/letterswitharrows.sty')
-rw-r--r--Master/texmf-dist/tex/latex/letterswitharrows/letterswitharrows.sty291
1 files changed, 291 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/letterswitharrows/letterswitharrows.sty b/Master/texmf-dist/tex/latex/letterswitharrows/letterswitharrows.sty
new file mode 100644
index 00000000000..e8152a0629a
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/letterswitharrows/letterswitharrows.sty
@@ -0,0 +1,291 @@
+%%
+%% This is file `letterswitharrows.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% letterswitharrows.dtx (with options: `package')
+%%
+%% File: letterswitharrows.dtx
+%% Copyright 2019 J. Maximilian Teegen
+%%
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3
+%% of this license or (at your option) any later version.
+%% The latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3 or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+%%
+%% This work has the LPPL maintenance status "maintained".
+%%
+%% The Current Maintainer of this work is J. M. Teegen.
+%%
+%% This work consists of the file letterswitharrows.dtx and its
+%% derived files letterswitharrows.sty and letterswitharrows.pdf.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesExplPackage {letterswitharrows} {2019-11-19} {} {Draw arrows over math letters.}
+\RequirePackage{expl3,xparse,l3keys2e,mathtools}
+
+\msg_new:nnn {letterswitharrows} {pdf-only} {Only~pdf~output~is~supported.}
+\AtBeginDocument{
+ \sys_if_output_pdf:F {
+ \msg_warning:nn {letterswitharrows} {pdf-only}
+ }
+}
+\cs_new:Nn \__jmt_lwa_arrow_draw_special:nnn % length, font size, sign
+{
+ \sys_if_output_pdf:TF {
+ \tex_special:D {pdf:~
+ q~
+ 1~J~1~j~
+ 1~0~0~\dim_to_decimal:n{#3#2pt/10}~0~0~cm~
+ .3~w~
+ q~
+ \dim_to_decimal:n{#3#2pt/10}~0~0~1~0~0~cm~
+ 1~0~0~1~-1~0~cm~
+ 0~1~m~
+ .25~0~1~0~1~0~c~
+ 1~0~.25~0~0~-1~c~
+ S~
+ Q~
+ 0~0~m~
+ -1~0~0~1~0~0~cm~
+ \dim_to_decimal:n{#3#1}~0~l~S~
+ Q
+ }
+ } {
+ \tex_special:D {"~
+ 1~setlinecap~1~setlinejoin~
+ 1~0~0~\dim_to_decimal:n{#3#2pt/10}~0~0~6~array~astore~concat~
+ .3~setlinewidth~
+ gsave~
+ \dim_to_decimal:n{#3#2pt/10}~0~0~1~0~0~6~array~astore~concat~
+ 1~0~0~1~-1~0~6~array~astore~concat~
+ 0~1~moveto~
+ .25~0~1~0~1~0~curveto~
+ 1~0~.25~0~0~-1~curveto~
+ stroke~
+ grestore~
+ 0~0~moveto~
+ -1~0~0~1~0~0~6~array~astore~concat~
+ \dim_to_decimal:n{#3#1}~0~lineto~stroke
+ }
+ }
+}
+
+
+\cs_new:Nn \__jmt_lwa_arrow_draw_pgf:nnn {
+ \begin{pgfpicture}
+ \pgfsetlinewidth{#2pt/30}
+ \pgfsetarrowsstart
+ {Computer~Modern~Rightarrow[width=#2pt*2/10,length=#2pt/10,sharp]}
+ % \pgfsetarrowsstart{\tl_use:N \g__jmt_lwa_pgf_arrow_style_tl}
+ \pgfpathmoveto{\pgfpointorigin}
+ \pgfpathlineto{\pgfpoint{-#3#1}{0cm}}
+ \pgfusepath{stroke}
+ \pgfresetboundingbox
+ \end{pgfpicture}
+}
+
+\cs_new_eq:NN \__jmt_lwa_arrow_draw:nnn \use_none:nnn
+
+\cs_new:Nn \__jmt_lwa_arrow_right:nn {
+ \skip_horizontal:n {#1}
+ % \rule[\dimexpr -#2pt/6\relax]{#1}{\dimexpr #2pt/3\relax}
+ \__jmt_lwa_arrow_draw:nnn {#1} {#2} {}
+}
+
+\cs_new:Nn \__jmt_lwa_arrow_left:nn {
+ \__jmt_lwa_arrow_draw:nnn {#1} {#2} {-}
+ \skip_horizontal:n {#1}
+ % \rule[\dimexpr -#2pt/6\relax]{#1}{\dimexpr #2pt/3\relax}
+}
+
+\cs_new:Npn \__jmt_lwa_arrow_overset_style:Nnncnnn #1#2#3#4#5#6#7 {
+ \hbox_set:Nn \l_tmpa_box {$\m@th#1#3$}
+ \dim_set:Nn \l_tmpa_dim {#2 pt/10}
+ \vbox:n {
+ \tex_lineskiplimit:D = \maxdimen
+ \tex_baselineskip:D = 0pt
+ \tex_lineskip:D = \dim_eval:n {\l_tmpa_dim * 3/2 + #7}
+ \tex_halign:D { ## \tex_cr:D
+ \skip_horizontal:n {\l_tmpa_dim / 2}
+ $
+ \m@th
+ #1
+ \tex_mskip:D \muskip_eval:n {#5}
+ \use:c {#4} {\dim_eval:n{\box_wd:N \l_tmpa_box * #6}} {#2}
+ $
+ \tex_cr:D
+ \box_use_drop:N \l_tmpa_box
+ \tex_cr:D
+ }
+ }
+}
+
+\cs_new:Nn \__jmt_lwa_arrow_overset:nnnnn { % content, direction, xoffset, scale, yoffset
+ \mathchoice {
+ \__jmt_lwa_arrow_overset_style:Nnncnnn
+ \displaystyle {\tf@size} {#1} {__jmt_lwa_arrow_#2:nn} {#3} {#4} {#5}
+ } {
+ \__jmt_lwa_arrow_overset_style:Nnncnnn
+ \textstyle {\tf@size} {#1} {__jmt_lwa_arrow_#2:nn} {#3} {#4} {#5}
+ } {
+ \__jmt_lwa_arrow_overset_style:Nnncnnn
+ \scriptstyle {\sf@size} {#1} {__jmt_lwa_arrow_#2:nn} {#3} {#4} {#5}
+ } {
+ \__jmt_lwa_arrow_overset_style:Nnncnnn
+ \scriptscriptstyle {\ssf@size} {#1} {__jmt_lwa_arrow_#2:nn} {#3} {#4} {#5}
+ }
+}
+
+\cs_new_protected:Npn \__jmt_lwa_arrow_overset:w {
+ \c_group_begin_token
+ \__jmt_lwa_arrow_overset_aux:w
+}
+
+\exp_args:NNx \NewDocumentCommand \__jmt_lwa_arrow_overset_aux:w
+ {s O{0mu} O{1} O{0ex} m t' e{\char_generate:nn {95}{8}} t'} {
+ \__jmt_lwa_arrow_overset:nnnnn
+ {
+ #5
+ \c_math_superscript_token {
+ \scriptscriptstyle\IfBooleanT{#6}{\prime}\IfBooleanT{#8}{\prime}
+ } % TODO: Better positioning etc?
+ \exp_args:Nf\IfValueT{\use:n#7} {
+ \c_math_subscript_token {
+ \mathrlap{#7}
+ }
+ }
+ }
+ {\IfBooleanTF{#1}{left}{right}}
+ {#2} {#3} {#4}
+
+ \exp_args:Nf\IfValueTF{\use:n#7}{
+ % TODO: Better way to do this? This is all kinds of wrong.
+ \hphantom{\!\c_math_subscript_token{#7}}
+ } {}
+ \c_group_end_token
+}
+\cs_set_eq:NN \arrowoverset \__jmt_lwa_arrow_overset:w
+\AtBeginDocument{
+ \@ifpackageloaded{hyperref}{
+ \pdfstringdefDisableCommands{
+ % Why does this only work with Expandable?
+ \DeclareExpandableDocumentCommand \__jmt_lwa_arrow_overset:w {s o o o m} {
+ \ifpdfstringunicode
+ {#5 \IfBooleanTF{#1}{\unichar{"20D6}}{\unichar{"20D7}}}
+ {#5}
+ }
+ }
+ }{}
+}
+
+\bool_new:N \g__jmt_lwa_tweak_shortcuts_bool
+\prop_new:N \g__jmt_lwa_selected_presets_prop
+\keys_define:nn {letterswitharrows} {
+ mode .choice:,
+ mode / special .code:n = {
+ \cs_set_eq:NN \__jmt_lwa_arrow_draw:nnn \__jmt_lwa_arrow_draw_special:nnn
+ },
+ mode / pgf .code:n = {
+ \RequirePackage{pgf}
+ \ExplSyntaxOff\usepgflibrary{arrows.meta}\ExplSyntaxOn
+ \cs_set_eq:NN \__jmt_lwa_arrow_draw:nnn \__jmt_lwa_arrow_draw_pgf:nnn
+ },
+ mode .initial:n = {special},
+ pgf .meta:n = {mode = pgf},
+ presets .multichoices:nn = {abc, ABC, cAcBcC, vec-cev} {
+ \int_compare:nNnTF \l_keys_choice_int = 1 {
+ \prop_gclear:N \g__jmt_lwa_selected_presets_prop
+ } {}
+ \prop_gput:NVn \g__jmt_lwa_selected_presets_prop \l_keys_choice_tl {}
+ },
+ presets .initial:n = {abc, ABC, cAcBcC},
+ tweaks .bool_set:N = \g__jmt_lwa_tweak_shortcuts_bool,
+ tweaks .initial:n = {true},
+}
+\ProcessKeysPackageOptions{letterswitharrows}
+
+\prop_if_in:NnTF \g__jmt_lwa_selected_presets_prop {abc} {
+ \int_step_inline:nnn {1} {26} {
+ \int_compare:nNnTF {#1} = {22} {
+ \cs_new:cpx {vright} {
+ \exp_not:N\__jmt_lwa_arrow_overset:w{v}
+ }
+ \cs_new:cpx {vleft} {
+ \exp_not:N\__jmt_lwa_arrow_overset:w*{v}
+ }
+ } {
+ \cs_new:cpx {v\int_to_alph:n{#1}} {
+ \exp_not:N\__jmt_lwa_arrow_overset:w{\int_to_alph:n{#1}}
+ }
+ \cs_new:cpx {\int_to_alph:n{#1}v} {
+ \exp_not:N\__jmt_lwa_arrow_overset:w*{\int_to_alph:n{#1}}
+ }
+ }
+ }
+} {}
+\prop_if_in:NnTF \g__jmt_lwa_selected_presets_prop {ABC} {
+ \int_step_inline:nnn {1} {26} {
+ \cs_new:cpx {v\int_to_Alph:n{#1}} {
+ \exp_not:N\__jmt_lwa_arrow_overset:w{\int_to_Alph:n{#1}}
+ }
+ \cs_new:cpx {\int_to_Alph:n{#1}v} {
+ \exp_not:N\__jmt_lwa_arrow_overset:w*{\int_to_Alph:n{#1}}
+ }
+ }
+} {}
+\prop_if_in:NnTF \g__jmt_lwa_selected_presets_prop {cAcBcC} {
+ \int_step_inline:nnn {1} {26} {
+ \cs_new:cpx {vc\int_to_Alph:n{#1}} {
+ \exp_not:N\__jmt_lwa_arrow_overset:w{\exp_not:N\mathcal{\int_to_Alph:n{#1}}}
+ }
+ \cs_new:cpx {c\int_to_Alph:n{#1}v} {
+ \exp_not:N\__jmt_lwa_arrow_overset:w*{\exp_not:N\mathcal{\int_to_Alph:n{#1}}}
+ }
+ }
+} {}
+\prop_if_in:NnTF \g__jmt_lwa_selected_presets_prop {vec-cev} {
+ \RenewDocumentCommand \vec {m} {
+ \__jmt_lwa_arrow_overset:w {#1} \scan_stop:
+ }
+ \DeclareDocumentCommand \cev {m} {
+ \__jmt_lwa_arrow_overset:w* {#1} \scan_stop:
+ }
+} {}
+\bool_if:NTF \g__jmt_lwa_tweak_shortcuts_bool {
+ \prop_if_in:NnTF \g__jmt_lwa_selected_presets_prop {ABC} {
+ \cs_set:cpn {vS} {
+ \__jmt_lwa_arrow_overset:w[2mu][8/10]{S}
+ }
+ } {}
+ \prop_if_in:NnTF \g__jmt_lwa_selected_presets_prop {abc} {
+ \cs_new:cpn {vell} {
+ \__jmt_lwa_arrow_overset:w{\ell}
+ }
+ \cs_new:cpn {ellv} {
+ \__jmt_lwa_arrow_overset:w{\ell}
+ }
+ } {}
+} {}
+
+\endinput
+%%
+%% End of file `letterswitharrows.sty'.