[Tex/LaTex] How to define a new triangle symbol with middle line for use as a maths operator

definitionmath-modemath-operatorssymbols

I would like to use a specific symbol, a triangle with a middle line, as a mathematical operator. Here is roughly how the symbol ought to look like:

Triangle with middle line

[This was generated with tikz by appropriating the answer by Heiko Oberdiek to the question Harry Potter symbols].

My intended usage has nothing to do with Harry Potter, instead I would like to use it as a unary mathematical operator that behaves well with subscripts, for instance.

Intended syntax

Ideally, I would define a command \triangleline which gives the symbol along with some code that ensures it behaves well in common mathematical environments. After this, I would define \trilineop

\newcommand{\trilineop}[1]{\operatorname{\triangleline_\mathrm{e}}{\left(#1\right)}}

for use in my document.

But I am not sure how to go about this, whether this is a good plan, or what would be a better plan.
Maybe there's a neat way to build this symbol out of \triangle somehow?

(Use of \Delta in undesired because the triangle sides are asymmetric in many fonts).


Here is an example environment which might help as a starting point.

\documentclass{beamer}

\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{mathtools}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsfonts}
\usepackage{tikz}

%Code here to define \triangleline
%%
%%

\newcommand{\trilineop}[1]{\operatorname{\triangleline_\mathrm{e}}{\left(#1\right)}}

\begin{document}
    
    \begin{frame}{}
      $$\trilineop{\boldsymbol{A}}$$
    \end{frame}
  
\end{document}

Here is the tikz code mentioned earlier used to generate the example image. (I used this as a black box).

\begin{tikzpicture}[baseline=0]
    \def\a{1cm}
    \pgfmathsetlengthmacro\radius{\a/2 * tan(30)}
    \draw[thick]
    (0, 0) -- (60:\a) -- (\a, 0) -- cycle
    (\a/2, 0) -- (60:\a)
    ;
\end{tikzpicture}

Best Answer

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}

enter image description here

Related Question