8

Currently, I'm representing second and fourth order tensor with this (taken from someone, and i don't really get how it works):

    % tensor 2:
    \newcommand{\tend}[1]{\oalign{\mbox{\boldmath$#1$}\crcr\hidewidth$\scriptscriptstyle\sim$\hidewidth}}
    %tensor 4:
    \newcommand{\tenq}[1]{\tend{\tend #1}\vphantom{#1}}

Which looks like this: tensors

I very much don't like the result: boldface is strange, with scales badly, there is too much spacing for the fourth order tensor... I found the untertilde package, with looks more robust for second order, but i cannot see how to make 4th order from it. I also found this topic, bold widetilde, which doe not adress symbol stacking for 4th order.

Is there a simple elegant way to do? My main concern here is consistant boldface for the tilde and the letter, and proper vertical spacing of the 4th order.

Thanks

Napseis
  • 511
  • Can you clarify what you want: everything bold, nothing bold,...? \oalign is a plain TeX command for building minature tables, used for stacking symbols. \crcr indicates a newline. \hidewdith...\hidewidth disguises the width of the intervening material. – Andrew Swann Feb 22 '15 at 15:48

3 Answers3

12

If you like the first one, you can use the same definition for \tenq but using \approx instead of \sim.

Also use \bm from the same package instead of \boldmath.

MWE:

\documentclass{article}

\usepackage{amsmath,bm}

% tensor 2:
\newcommand{\tend}[1]{\hbox{\oalign{$\bm{#1}$\crcr\hidewidth$\scriptscriptstyle\bm{\sim}$\hidewidth}}}
%tensor 4:
\newcommand{\tenq}[1]{\hbox{\oalign{$\bm{#1}$\crcr\hidewidth$\scriptscriptstyle\bm{\approx}$\hidewidth}}}

\begin{document}

\[
\tend{\sigma}\neq\tenq{\Lambda}
\]

\end{document} 

enter image description here

karlkoeller
  • 124,410
4

Here I use stacks to recursively place \sim under the argument, based on the value of the optional argument. In the definition, the [1pt] is the under-gap from the argument and the [0pt] is the vertical separation between \sim characters in a multi-stack. These values can be altered to suit (including being made negative).

I have not used any bold font for the tensor itself, though it could be added, if desired, to the definition, or at time of invocation.

The specification of \def\useanchorwidth{T} says to ignore the width of the \sim underset in setting the horizontal spacing. The only time that could be an issue is if you, for example, used adjacent invocations on narrow arguments, e.g., \tenq[2]{i}\tenq[3]{j}. While the \useanchorwidth line could be removed, in which case \tenq with narrow arguments would always take up at least the width of a \scriptscriptstyle\sim, my first step would instead be to manually add \, space on those very rare occasions when needed.

\documentclass{article}
\usepackage{stackengine}
\stackMath
\newcommand\tenq[2][1]{%
 \def\useanchorwidth{T}%
  \ifnum#1>1%
    \stackunder[0pt]{\tenq[\numexpr#1-1\relax]{#2}}{\scriptscriptstyle\sim}%
  \else%
    \stackunder[1pt]{#2}{\scriptscriptstyle\sim}%
  \fi%
}
\begin{document}
\[
\tenq{\sigma}\neq\tenq[2]{\Lambda}\neq\tenq[3]{\Delta}\neq\tenq[4]{\psi}
\]

\end{document}

enter image description here

0

Just for fun.

\documentclass{standalone}
\usepackage{amsmath,bm}

\newlength{\fillwidth}
% creates a tilde which slightly overlaps what's above and below, centered in a space  \fillwidth wide
\newcommand{\flatsim}{\hbox to \fillwidth{\hfil\raisebox{0pt}[.05ex][.05ex]{$\scriptscriptstyle\bm{\sim}$}\hfil}}


\newcommand{\triple}[1]{\settowidth{\fillwidth}{$\bm{#1}$}%
  \vtop{\baselineskip=0pt\hbox{$\bm{#1}$}\hbox{\rule{0pt}{.2ex}}\flatsim\flatsim\flatsim}}

\begin{document}
\triple{\sigma}
\end{document}

triple tilde

John Kormylo
  • 79,712
  • 3
  • 50
  • 120