Derived tensor product
Here is a MWE using semantex
. The idea is to use the command
key and input the desired command. In this case, you want to over set the L on the symbol. Thus, using command=\overset{L}
will suffice.
\documentclass{article}
\usepackage{amsmath,semantex}
\NewSymbolClass\MyBinaryOperator[
definekeys={
{Lder}{command=\overset{L}},
{Rder}{upper=R},
},
]
\NewObject\MyBinaryOperator\tensor{\otimes}[
definekeys={
{der}{Lder},
},
]
\NewObject\MyBinaryOperator\fibre{\times}[
% Americans are free to call it \fiber instead
definekeys={
{der}{Rder},
},
]
\begin{document}
\begin{equation}
A\tensor[R,der] B
\end{equation}
\end{document}
I don't know how to do it with semantex
, but it's not difficult with other tools.
\documentclass{article}
\usepackage{amsmath}
%\usepackage{xparse} % not needed with LaTeX 2020-10-01 or later
\ExplSyntaxOn
\keys_define:nn { cinque/tensor }
{
der .tl_set:N = \l__cinque_tensor_upper_tl,
der .default:n = L,
unknown .code:n = \tl_set_rescan:Nnx \l__cinque_tensor_subscript_tl { } { \l_keys_key_str },
}
\tl_new:N \l__cinque_tensor_subscript_tl
\NewDocumentCommand{\tensor}{O{}}
{
\group_begin:
\keys_set:nn { cinque/tensor } { #1 }
\tl_if_empty:NTF \l__cinque_tensor_upper_tl
{ \otimes }
{ \overset{\l__cinque_tensor_upper_tl}{\otimes} }
\tl_if_empty:NF \l__cinque_tensor_subscript_tl { \sb{\l__cinque_tensor_subscript_tl} }
\group_end:
}
\ExplSyntaxOff
\begin{document}
$A\otimes B$
$A\tensor B$
$A\tensor[R] B$
$A\tensor[der,R] B$
$A\tensor[R,der] B$
$A\tensor[\mathcal{X}] B$
\end{document}
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{xparse}
\usepackage{expl3}
\usepackage{amsmath}
\ExplSyntaxOn
\clist_new:N \l_doc_tmpa_clist
\tl_new:N \l_doc_tmpa_tl
\tl_new:N \l_doc_tmpb_tl
\tl_new:N \g_doc_template_a_tl
\tl_gset:Nn \g_doc_template_a_tl {
\overset{\tiny L}{*1}
}
\cs_generate_variant:Nn \tl_set_rescan:Nnn {NnV}
\DeclareDocumentCommand{\tensor}{O{}}{
\clist_set:Nn \l_doc_tmpa_clist {#1}
\tl_set:Nn \l_doc_tmpa_tl {\otimes}
\clist_map_inline:Nn \l_doc_tmpa_clist {
\str_case:nn {##1}{
{der} {
\tl_set_eq:NN \l_doc_tmpb_tl \g_doc_template_a_tl
\regex_replace_once:nnN {*1} {\u{\l_doc_tmpa_tl}} \l_doc_tmpb_tl
\tl_set_eq:NN \l_doc_tmpa_tl \l_doc_tmpb_tl
}
}
}
\clist_map_inline:Nn \l_doc_tmpa_clist {
\str_case:nn {##1}{
{R} {
\tl_set:No \l_doc_tmpa_tl {\l_doc_tmpa_tl \c_math_subscript_token {R}}
}
}
}
\mathbin{\tl_use:N \l_doc_tmpa_tl}
}
\ExplSyntaxOff
\begin{document}
\par $a \tensor[R] b$
\par $a \tensor[R,der] b$
\par $a \tensor[der] b$
\end{document}