triangle like \textcorner

I wish to denote the algebra of all upper triangular matrices by $M_n^\textcorner(K)$ but with $\textcorner$ being a triangle. How can I create this symbol (add additional diagonal line)?

My current preamble:

\documentclass[b4paper, twoside, final, openodd, 10pt]{book}
\usepackage{etex}
\usepackage[english]{babel}
\usepackage[cp1250]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{charter}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage[framed, thmmarks]{ntheorem}
\usepackage{framed}
\usepackage{tikz}
\usepackage{hyperref}
\usepackage[numbered]{bookmark}
\usepackage[all]{xy}
\usepackage{mathtools}
\usepackage{animate}
\usepackage{subfigure}
\usepackage{caption}
\captionsetup{labelformat=empty,labelsep=none}
\usepackage{verbatim}
\usepackage{multirow}
\usepackage{multicol}
\usepackage{longtable}
\setlength{\LTpre}{0pt}\setlength{\LTpost}{0pt}
\usepackage{wrapfig}
\usepackage{cancel}
\usepackage{enumitem}
\usepackage[subfigure]{tocloft}
\usepackage[top=2.1cm, bottom=2.9cm, left=2.1cm, right=2.1cm]{geometry}
\usepackage{stmaryrd}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%        new definition of SQUARE ROOT: it renames \sqrt as \oldsqrt ()            %%
%%======http://tex.stackexchange.com/questions/29834/closed-square-root-symbol======%%
\usepackage{letltxmacro}                                                            %%
\LetLtxMacro{\oldsqrt}{\sqrt}                                                       %%
\renewcommand{\sqrt}[1][\hphantom{3}]{ \def\DHLindex{#1}\mathpalette\DHLhksqrt }    %%
\def\DHLhksqrt#1#2{ \setbox0=\hbox{$#1\oldsqrt[\DHLindex]{#2\,}$}\dimen0=\ht0       %%
\setbox2=\hbox{\vrule height\ht0 depth -\dimen0}                %%
{\box0\lower0.4pt\box2} }                                       %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%                      DASHED and DOTTED UNDERLINE (ulem)                      %%
%%==============================================================================%%
\usepackage[normalem]{ulem}                                                     %%
\def\dotuline{\bgroup                                                           %%
\ifdim\ULdepth=\maxdimen  % Set depth based on font, if not set already       %%
\markoverwith{\begingroup                                                     %%
\lower\ULdepth\hbox{\kern.15em .\kern.1em}                                    %%
\endgroup}\ULon}                                                              %%
%%------------------------------------------------------------------------------%%
\def\dashuline{\bgroup                                                          %%
\ifdim\ULdepth=\maxdimen  % Set depth based on font, if not set already       %%
\markoverwith{\kern.15em                                                      %%
\vtop{\kern\ULdepth \hrule width .3em}                                        %%
\kern.15em}\ULon}                                                             %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%==================================================================================%%
\usepackage{titlesec}   %za spreminjat chapter headinge v Article, Book, Report     %%
\usepackage{fix-cm}     %da popravi nesoglasja po redefiniranju dolžin              %%
%\titleformat{command}[shape]{format}{label}{sep}{before}[after]                    %%
\titleformat{\chapter}                                                              %%
{\bfseries\fontsize{30pt}{25pt}\selectfont}                             %%
{\thechapter}                                                           %%
{8pt}                                                                   %%
{}                                                                      %%
\titleformat{\section}                                                              %%
{\bfseries\fontsize{22pt}{16pt}\selectfont}                             %%
{\thesection}                                                           %%
{5pt}                                                                   %%
{}                                                                      %%
\titleformat{\subsection}                                                           %%
{\fontsize{18pt}{10pt}\selectfont}                                      %%
{\thesubsection}                                                        %%
{4pt}                                                                   %%
{}                                                                      %%
\titleformat{\subsubsection}                                                        %%
{\fontsize{16pt}{10pt}\selectfont}                                      %%
{\thesubsubsection}                                                     %%
{4pt}                                                                   %%
{}                                                                      %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%              CUSTOMIZED THEOREMS (ntheorem + TikZ)               %%
%-------------------------------------------------------------------%%
\theoremseparator{\bfseries :}                                      %%
\theorembodyfont{\normalfont\it}                                    %%
\newtheorem{envThm}{{\large\bfseries Theorem}}[section]             %%
%-------------------------------------------------------------------%%
\theoremseparator{\bfseries :}                                      %%
\theorembodyfont{\normalfont\it}                                    %%
\newtheorem{envPrp}[envThm]{{\large\bfseries Proposition}}          %%
%-------------------------------------------------------------------%%
\theoremseparator{\bfseries :}                                      %%
\theorembodyfont{\normalfont}                                       %%
\newtheorem{envExp}[envThm]{{\large\bfseries Examples}}             %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\renewcommand{\labelenumi}{\alph{enumi})}

-
There seems to be no such symbol, but have a look on tex.stackexchange.com/questions/65455/… –  Christian Hupfer Mar 8 at 4:39

I experimented a little bit with tikz library and there is a way to provide such a symbol, which scales somehow with the font size.

\documentclass{scrbook}
\usepackage{tikz}
\usepackage{xkeyval}
\usepackage{xcolor}
\usepackage{amsmath} % Not needed actually, but include if \boldmath is used
\boldmath % Not needed actually

\makeatletter
\define@key{TriSymFamily}{LineWidth}[0.05em]{%
\def\KVTriSymLineWidth{#1}}%

\define@key{TriSymFamily}{Scale}[0.01\baselineskip]{%
\def\KVTriSymScale{#1}}%

LineWidth=0.05em}{}%

\makeatother

\newcommand{\upperrighttriangle}[1][]{%
\setkeys{TriSymFamily}{#1}%
\begin{tikzpicture}[line width=\KVTriSymLineWidth,scale=\KVTriSymScale]%
%\draw (0,0) -- (1,0) -- (1,-1) -- (0,0); %
\draw (0,0) -- (1,0) -- (1,-1) -- cycle; %
\end{tikzpicture}%
}%

\begin{document}
% Now  your symbol in three sizes

\large
${M^{\upperrighttriangle}_{n} \left({ K} \right)}$

\LARGE
${M^{\upperrighttriangle}_{n} \left({ K} \right)}$

\Huge
${M^{\upperrighttriangle}_{n} \left({ K} \right)}$

\normalsize

And now in blue colour
\textcolor{blue}{%
${M^{\upperrighttriangle}_{n} \left({ K} \right)}$
} % End of \textcolor

\end{document}


I did not wrap your matrix symbol etc. in a special command, but it would be useful do to so, if you need that symbol at many positions.

The xkeyval version is not really necessary, it just simplifies to adapt the command to new scaling and linewidth. Another possibility would be to use pgfkeys.

EDIT I changed the drawing as suggested by Paul Gessler in a comment below, but in this case, one has to reduce the linewidth a little bit.

Here is an impression of the newer version:

And here the 'minimal' version

\documentclass{minimal}
\usepackage{tikz}

\newcommand{\upperrighttriangle}{%
\begin{tikzpicture}[line width={0.05em},scale=0.01\baselineskip]
\draw (0,0) -- (1,0) -- (1,-1) -- cycle;%
\end{tikzpicture}%
}%

\begin{document}
${M^{\upperrighttriangle}_{n} \left({ K} \right)}$

\end{document}

-
@LeonLampret, the corner can be fixed by replacing the final coordinate in the TikZ \draw operation with cycle, like so: \draw (0,0) -- (1,0) -- (1,-1) -- cycle;. –  Paul Gessler Mar 8 at 22:52
TriSymFamily is just a family name for the key value interface I used in my version of the command, it is short for TriangleSymbolFamily, it could be replaced by (almost) any other name. –  Christian Hupfer Mar 8 at 23:16
TriSymFamily is no command, but a little handle to define some behaviour of the size and linewidth of your symbol without changing the command any time in your class or sty file. I will post another version without xkeyval interface. –  Christian Hupfer Mar 8 at 23:27
@LeonLampret: I added the minimal version to my original answer, at the bottom. –  Christian Hupfer Mar 8 at 23:33
Now it works perfectly in superscript. Just two more requests. Why must I use M_n^{\triangleu} instead of M_n^\triangleu? Why are both symbols in M_n^{\triangleu}\triangleu of the same size? –  Leon Mar 8 at 23:49

Here's a triangle with the pict2e package.

\documentclass{article}
\usepackage{pict2e,amsmath}

\newcommand{\utriangle}{\text{\doutriangle}}

\newcommand{\doutriangle}{%
\linethickness{.1ex}%
\setlength{\unitlength}{.8ex}%
\begin{picture}(1,1)(0,-1)
\polygon(0,1)(1,0)(1,1)
\end{picture}%
}

\begin{document}
$M_n^{\utriangle}\quad X_{M_n^{\utriangle}}$

\bigskip

{\Large $M_n^{\utriangle}$}
\end{document}


-
I'd like to incorporate this into my large Texy file, which already has a lot of packages, which I've included in the opening post. Is adding pict2e really necessary? And why do you need two commands? –  Leon Mar 8 at 22:27
@LeonLampret Yes, pict2e is necessary. You might place the code for \doutriangle in the replacement text for \utriangle, but in this way it's easier to modify the inner macro, keeping the two aspects separate. –  egreg Mar 8 at 22:30
None of the packages I already have suffice for this? At this rate, each new symbol I incorporate requires a new package. Also, why doesn't \newcommand{\utriangle}{\text{\linethickness{.1ex}\setlength{\unitlength}{.8ex} \begin{picture}(1,1)(0,-1) \polygon(0,1)(1,0)(1,1) \end{picture}}} suffice? –  Leon Mar 8 at 22:35
@LeonLampret The \polygon macro is only provided by pict2e. Where's the problem? As regards the two macros instead of one, why bother? You gain probably half a nanosecond by using only one, while separating the two aspects is better programming. –  egreg Mar 8 at 22:40
Applying \reflectbox provides a way too enlarged symbol. Also, the triangle is positioned too high (overlapping with the text from the line above). –  Leon Mar 8 at 23:20

This is a variant of egreg's solution, using LuaLaTeX, MetaPost and the luamplib package.

TeX dimensions are passed to MetaPost by the \mpdim command, coming directly from the gmp package (authored by egreg, by the way ;-)). It's an example of how MetaPost drawings can be tightly integrated into a LuaLaTeX program. With other engines than LuaTeX, the code can be quickly adapted from luamplib to gmp, with the drawback of needing the shell-escape functionality for a one-pass compilation.

EDIT: I've \raised the triangle less than before (.33\trianglesize instead of .66\trianglesize). It looks more esthetic as such to me. (Maybe I'm wrong in this.)

\documentclass{article}
\usepackage{amsmath,luamplib}

\newlength{\trianglesize}
\newlength{\pensize}

\newcommand{\utriangle}{%
\text{%
\begin{mplibcode}
verbatimtex \raise .33\trianglesize etex; %box height adjustment
beginfig(1);
draw ((0, 1) -- (1, 0) -- (1, 1) -- cycle) scaled \mpdim{\trianglesize}
withpen pencircle scaled \mpdim{\pensize};
endfig;
\end{mplibcode}%
}%
}

\begin{document}
$M_n^{\utriangle}\quad X_{M_n^{\utriangle}}$

\bigskip
{\Large $M^{\utriangle}_n$}
\end{document}


-