11

I created the following symbol, however it doesn't work well in all math environments. How to create this so that it adjust meaningfully with respect to size in various math environments, and also works well with commands like $\big\coexist$.

\newcommand{\coexist}[1][]{\hspace{.15em}\raisebox{-.35em}{
\begin{tikzpicture}[scale=0.15]\draw[line width=0.5pt] (-.85,-0.2) -- (-1,0) -- (0.15,1.5);\draw[line width=0.5pt] (-0.45,-0.65) -- (0.15,-1.5);\draw[line width=0.5pt] (-1.15,1.5) -- (-0.55,0.65);\draw[line width=0.5pt] (-1.15,-1.5) -- (0,0) -- (-0.15,0.2);
\end{tikzpicture}
}\hspace{.15em}}

Here is the symbol in use for: $\langle \coexist\rangle$

enter image description here

5
  • 6
    please provide a complete example. you are not declaring it as a maths symbol, so the spacing will be wrong, most likely. but creating a symbol which scales is a rather different matter. if you scale a single symbol, it will not look right, which is why delimiters, for example, typically come in different sizes and/or are constructed from extensible pieces. your example should show us the way you are typesetting maths (unicode or taditional?) and so on. and you should explain the symbols functional role (atom? relation? etc.) Commented Sep 25, 2025 at 19:23
  • 1
    I feel like \langle and \rangle aren't helpful: they're so similar, I thought they were part of the symbol. Maybe a\coexist b? When you say $\big\ex$, how is that related? Do you mean $\big\coexist$? And you'll want some % at the end of your lines: tex.stackexchange.com/q/7453 Commented Sep 25, 2025 at 19:37
  • @cfr actually, I am quite uninformed about the stuff you mentioned. I will try to read up a bit.. Commented Sep 25, 2025 at 21:38
  • Even without reading up, can you provide some examples of how you use this? And can you put this into a complete document from \documentclass to \end{document}? Commented Sep 25, 2025 at 21:59
  • 1
    Related: tex.stackexchange.com/q/306004/128462 Commented Sep 26, 2025 at 5:50

1 Answer 1

13

Without a full MWE it's difficult to be 100% sure, but I hope I've understood your intent.

What you need to do here is define a new math symbol \coexist, using your TikZ drawing, and make it responsive to different math styles (\displaystyle, \textstyle, \scriptstyle, \scriptscriptstyle) by wrapping it in \mathchoice. You can control the size of the drawing in each context manually via the scale=#1 argument in the helper macro \coexistSymbol.

This is a valid approach, and it should behave correctly in various environments — including with \big, in subscripts, superscripts, etc. If needed, you can further tweak the four scale values passed in \mathchoice to improve visual balance.

enter image description here

\documentclass{article}
\usepackage{tikz}
\usepackage{amsmath}
\newcommand{\coexist}{\mathrel{
  \mathchoice
    {\coexistSymbol{0.2}}% displaystyle
    {\coexistSymbol{0.1}}% textstyle
    {\coexistSymbol{0.05}}% scriptstyle
    {\coexistSymbol{0.025}}% scriptscriptstyle
}}
\newcommand{\coexistSymbol}[1]{%
  \vcenter{\hbox{%
    \begin{tikzpicture}[scale=#1, line width=0.4pt]
      \draw (-.85,-0.2) -- (-1,0) -- (0.15,1.5);
      \draw (-0.45,-0.65) -- (0.15,-1.5);
      \draw (-1.15,1.5) -- (-0.55,0.65);
      \draw (-1.15,-1.5) -- (0,0) -- (-0.15,0.2);
    \end{tikzpicture}%
  }}%
}

\begin{document}

Inline: $\langle \coexist \rangle$

\medskip

Displaystyle:
\[
\sum_{\coexist} x_{\coexist} = \big\langle \coexist \big\rangle
\]

\medskip

Scriptstyle: $f_{\coexist}$, $a^{\coexist}$

\medskip

Scriptscriptstyle: $f_{\scriptscriptstyle\coexist}$, $a^{\scriptscriptstyle\coexist}$

\medskip

$\displaystyle \prod_{i=1}^{n_{\coexist}} x_i^{\coexist}$

\end{document}

It works also with mathabx (adding it) avoiding to load after amsmath as it conflicts with the \iint command,

LaTeX Error: Command \iint already defined.
Or name \end... illegal, see p.192 of the manual.

See the comment of @cfr: Load amsmath before mathabx.

Using the answer of @egreg baseline=-\dimexpr\fontdimen22\textfont2\relax in this question Drawing the rules for the bracket polynomial, and avoiding the spaces given of \mathrel, you will have:

enter image description here

\documentclass{article}
\usepackage{tikz}
\usepackage{amsmath}
\newcommand{\coexist}{%
  \mathchoice
    {\coexistSymbol{0.15}}% displaystyle
    {\coexistSymbol{0.1}}% textstyle
    {\coexistSymbol{0.05}}% scriptstyle
    {\coexistSymbol{0.025}}% scriptscriptstyle
}
\newcommand{\coexistSymbol}[1]{%
  \vcenter{\hbox{%
    \begin{tikzpicture}[scale=#1, line width=0.4pt, baseline=-\dimexpr\fontdimen22\textfont2\relax]
      \draw (-.85,-0.2) -- (-1,0) -- (0.15,1.5);
      \draw (-0.45,-0.65) -- (0.15,-1.5);
      \draw (-1.15,1.5) -- (-0.55,0.65);
      \draw (-1.15,-1.5) -- (0,0) -- (-0.15,0.2);
    \end{tikzpicture}%
  }}%
}
\begin{document}

Inline: $\langle \coexist \rangle$

\medskip

Displaystyle:
\[
\sum_{\coexist} x_{\coexist} = \big\langle \coexist \big\rangle
\]

\medskip

Scriptstyle: $f_{\coexist}$, $a^{\coexist}$

\medskip

Scriptscriptstyle: $f_{\scriptscriptstyle\coexist}$, $a^{\scriptscriptstyle\coexist}$

\medskip

$\displaystyle \prod_{i=1}^{n_{\coexist}} x_i^{\coexist}$

\end{document}
9
  • 1
    Very cool! Thank you very much! Commented Sep 25, 2025 at 21:41
  • 1
    don't you want \newcommand{\coexist}{\mathrel{%? Commented Sep 25, 2025 at 22:17
  • 1
    where is \iint required? Commented Sep 25, 2025 at 22:19
  • 1
    @Viśvāmitra Very happy to help you. Obviously the code can be improved and if anyone adds any other better answers I kindly ask you to assign the answer with the green checkmark to it. Commented Sep 26, 2025 at 6:19
  • 1
    @Sebastiano no, I loaded amsmath first. Commented Sep 26, 2025 at 19:15

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.