19

I would rather have always have my tensor product look like $A\underset{R}{\otimes}B$ but still write $A\otimes_R B$. Is there a way to make this happen by some command in the preamble? (it's ok if it only works in display mode)

  • 3
    \bigotimes is a symbol that takes limits, so use that instead. – barbara beeton Apr 16 '14 at 8:58
  • One would use that in the sense of \sum for addition. In math sometimes you have to specify over which ring one does the tensor product (of just two modules). – Peter Patzt Apr 16 '14 at 9:08
  • An idea I just had would be something like \renewcommand{\tensor}{\ensuremath\otimes\limits} but it does not work because \otimes is not a math operator. – Peter Patzt Apr 16 '14 at 9:16
  • you could then try \mathop{\opotimes}{$\otimes$} (i've forgotten which code says this takes limits, and i'm not sure this syntax is exactly correct either, but it's in the right direction). or \DeclareMathOperator from amsmath. – barbara beeton Apr 16 '14 at 9:21
23

Perhaps you like the ring to go below the tensor product symbol, but typography doesn't. Here's why:

\documentclass{article}
\usepackage{amsmath}

\newcommand{\tens}[1]{%
  \mathbin{\mathop{\otimes}\limits_{#1}}%
}

\begin{document}

Here is a tensor product $M\tens{R}N$, but note that
it will have a very bad influence on the spacing of
lines.
Here is a tensor product $M\tens{R}N$, but note that
it will have a very bad influence on the spacing of
lines.
Here is a tensor product $M\tens{R}N$, but note that
it will have a very bad influence on the spacing of
lines.
Here is a tensor product $M\tens{R}N$, but note that
it will have a very bad influence on the spacing of
lines.
Here is a tensor product $M\tens{R}N$, but note that
it will have a very bad influence on the spacing of
lines.
Here is a tensor product $M\tens{R}N$, but note that
it will have a very bad influence on the spacing of
lines.

\end{document}

enter image description here

A simple change will make what you perhaps prefer, but I'm not sure to like it very much.

\documentclass{article}
\usepackage{amsmath}

\newcommand{\tens}[1]{%
  \mathbin{\mathop{\otimes}\displaylimits_{#1}}%
}

\begin{document}

Here is a tensor product $M\tens{R}N$, note that
it won't have a very bad influence on the spacing of
lines.
Here is a tensor product $M\tens{R}N$, note that
it won't have a very bad influence on the spacing of
lines.
Here is a tensor product $M\tens{R}N$, note that
it won't have a very bad influence on the spacing of
lines.
Here is a tensor product $M\tens{R}N$, note that
it won't have a very bad influence on the spacing of
lines.
Here is a tensor product $M\tens{R}N$, note that
it won't have a very bad influence on the spacing of
lines.
Here is a tensor product $M\tens{R}N$, note that
it won't have a very bad influence on the spacing of
lines.
\[
M\tens{R}N
\]
Here is a tensor product $M\tens{R}N$, note that
it won't have a very bad influence on the spacing of
lines.

\end{document}

enter image description here


You can have \tens work with the usual syntax:

\documentclass{article}
\usepackage{xparse}

\NewDocumentCommand{\tens}{t_}
 {%
  \IfBooleanTF{#1}
   {\tensop}
   {\otimes}%
 }
\NewDocumentCommand{\tensop}{m}
 {%
  \mathbin{\mathop{\otimes}\displaylimits_{#1}}%
 }

\begin{document}
In line we have $M\tens N=M\tens_{R}N$, but displayed we have
\[
M\tens N=M\tens_{R}N
\]
\end{document}

enter image description here

A more LaTeX3 savvy implementation, using the (not so much) experimental e argument specifier (embellishment):

\documentclass{article}
\usepackage{xparse}

\NewDocumentCommand{\tens}{e{_^}}{%
  \mathbin{\mathop{\otimes}\displaylimits
    \IfValueT{#1}{_{#1}}
    \IfValueT{#2}{^{#2}}
  }%
}

\begin{document}
In line we have $M\tens N=M\tens_{R}N$, but displayed we have
\[
M\tens N=M\tens_{R}N
\]
For a derived functor $M\tens^{L}N=M\tens_{R}^{L}N$ or
\[
M\tens^{L}N=M\tens_{R}^{L}N
\]
\end{document}

enter image description here

| improve this answer | |
  • @PeterPatzt I'll tell you that in my young years as a LaTeX user I had to use \otimes many times and I too wanted the ring below it; but I realized that it's not so nice, after all. – egreg Apr 16 '14 at 9:40
  • Wow, that is pretty impressive stuff (to me)! Thanks alot. (I cannot up your answer twice :( ) – Peter Patzt Apr 16 '14 at 15:49
  • This is awesome! Is it possible to modify your xparse code to have superscripts show up above the tensor as well? I often use tensor products with an L above them (for left derived functor i.e. Tor). – ಠ_ಠ Mar 7 '17 at 9:50
  • 2
    @ಠ_ಠ Added; however, keep in mind that the feature is experimental, so it might change in the future. I believe it's unlikely it disappears, though. – egreg Mar 7 '17 at 10:08
  • 2
    @ಠ_ಠ The e argument type has undergone a breaking change, I accordingly fixed the implementation. – egreg Jun 26 '17 at 22:46

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.