How to define a new triangle symbol with middle line for use as a maths operator?
I am not a big fan of using TikZ everywhere so I propose here a more minimal version based on good old \bigtriangleup
. I also am not a big fan of \left
/\right
at all costs, so I propose a definition based on \DeclarePairedDelimiterXPP
from mathtools
. The automatic scaling can be obtained with the starred version, while manual sizes can be passed as optional parameter.
\documentclass{article}
\makeatletter
\newcommand*{\triangleline}{\mathpalette\@triangleline\relax}
\newcommand*{\@triangleline}[2]{{%
\sbox0{\m@th$#1\bigtriangleup$}%
\dimen@\fontdimen8
\ifx#1\displaystyle\textfont\else
\ifx#1\textstyle\textfont\else
\ifx#1\scriptstyle\scriptfont\else
\scriptscriptfont\fi\fi\fi 3
\ooalign{\hfil\hbox{\vrule\@width\dimen@\@height\ht0\@depth-.5\dimen@}\hfil\cr\box0}%
}}
\makeatother
\usepackage{mathtools}% for the following
\DeclarePairedDelimiterXPP{\trilineop}[1]{\mathop{\triangleline_{\mathrm{e}}}}{(}{)}{}{#1}
\begin{document}
\parskip=\bigskipamount
$\triangleline_{\triangleline_{\triangleline}}$
$2\trilineop{x}$
$2\trilineop[\big]{\frac{x}{2}}$
$2\trilineop*{\dfrac{x}{2}}$
\end{document}
Something like this?
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
%Code here to define \triangleline
\makeatletter
\DeclareRobustCommand{\triangleline}{\mathpalette\triangleline@\relax}
\newcommand{\triangleline@}[2]{%
\mspace{1mu}%
\begin{tikzpicture}[baseline=0]
\sbox\z@{$\m@th#1\Delta$}\edef\a{\the\wd\z@}
\edef\b{\the\dimexpr\triangleline@thickness{#1}}
\pgfmathsetlengthmacro\radius{\a/2 * tan(30)}
\draw[line width=\b] (0, 0) -- (60:\a) -- (\a, 0) -- cycle (\a/2, 0) -- (60:\a);
\end{tikzpicture}%
\mspace{1mu}%
}
\newcommand{\triangleline@thickness}[1]{%
\ifx#1\displaystyle 1.2\fontdimen8\textfont3\else
\ifx#1\textstyle 1.2\fontdimen8\textfont3\else
\ifx#1\scriptstyle 1.4\fontdimen8\scriptfont3\else
1.6\fontdimen8\scriptscriptfont3\fi\fi\fi
}
\makeatother
\newcommand{\trilineop}{\operatorname{\triangleline_{e}}}
\begin{document}
\[
\trilineop(\boldsymbol{A})\Delta_{\mathrm{e}}(A)
\quad
\scriptstyle\trilineop(\boldsymbol{A})
\quad
\scriptscriptstyle\trilineop(\boldsymbol{A})
\]
\end{document}
Play with the factors for the line thickness until you're happy.
Don't define \trilineop
to take an argument: supplying the parentheses makes the code cleaner; avoid \left
and \right
when they're not necessary, like here.