# How to define a new triangle symbol with middle line for use as a maths operator?

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:

[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}
\draw[thick]
(0, 0) -- (60:\a) -- (\a, 0) -- cycle
(\a/2, 0) -- (60:\a)
;
\end{tikzpicture}


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}


• Not ashamed to admit... This is exactly what I wished for. Thank you very much. I will accept an answer (quasirandomly) in 24 to 48 h to allow the answers to get more upvotes in the meantime. Nov 21, 2020 at 16:05

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}}
\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.

• Pretty much exactly what I wished for! Great answer, good to also see an option to incorporate tikz. Thank you! A slight rendering difference here seems to be that the parentheses are a bit lower than is usual, I think. Nov 21, 2020 at 16:06
• @LinearChristmas The parentheses are where they use to be. Nov 21, 2020 at 16:09
• @egreg I will try to see if I can recreate it using l3draw, but not sure how to implement the \fontdimen8. Can you provide a solution with l3draw? Nov 21, 2020 at 18:25
• @azetina There's still no interface for this. Nov 21, 2020 at 22:00
• @egreg Fixed: I apologise for being unclear. More clearly, I meant: draw a line that intersects the top vertex of triangle, and is [parallel] to the base. Then the parentheses for the argument lie below the [parallel] line. Constrast this behavior other mathematical operators, e.g., \sin, where the argument with its parentheses lies on the middle line of the math operator. Nov 22, 2020 at 11:48