My first visit to TeX.SX came when I was looking for a symbol for a twisted product:

enter image description here

I knew about Detexify and the Comprehensive LaTeX Symbol List, but I could not find the symbol there. I tried the construction that was obvious to me, namely \overset{\scriptstyle \sim}{\times}, but the \sim was much too high. I Googled, and found this solution by @Hendrik Vogt. Thus I learned about \smash.

Later I needed the same symbol in a subscript, ultimately learning about \mathchoice and \ooalign. Since then I have found that many questions on TeX.SX needed similar techniques. I though it would be a good idea to have a single question whose answers gave visitors with modest LaTeX skills general guidelines on constructing new symbols using LaTeX and related systems.

So, how do you make your own symbol when Detexify fails?


If it's really not in Detexify, check the Comprehensive LaTeX Symbol List to see if your symbol can be found in an existing package. Note, The Comprehensive List is long! Over 300 pages. But it is searchable, well-organized, and has a good table of contents and index.

If that doesn't help, it may be time to design your own symbol. It's probably best to give your new symbol a name so it can be used repeatedly and transported more easily into another document.

If your symbol will be used as an operator with limits (like an integral or summation), you should use the \DeclareMathOperator or \DeclareMathOperator* command. Both of these use the amsmath package. The unstarred version places sub- and superscript limits to the right of the operator; the starred version places limits above and below the operator when it is in displaystyle. To illustrate:


[Note that \square uses the amssymb package.]

Then the code

\squareop_{n=1}^{\infty} a_n \qquad \triangleop_{n=1}^{\infty} a_n

will produce the following output:

enter image description here

More information on \DeclareMathOperator can be found in this answer by @Andrew Swann.

If your symbol is not going to be used in that fashion, you should probably use \newcommand.

If your symbol is a math symbol: Is it a binary operator (such as + or \times)? A binary relation (such as < or \leq)? Or an ordinary math symbol (such as ! or \infty)? The spacing is different for each case. Compare the three versions for the symbol \times:


Then \noindent $a\reltimes b \newline a\bintimes b \newline a\chrtimes b$ will produce the output:

enter image description here

Note the extra set of curly braces in \chrtimes. If you remove them you'll get the same output as \mathbin{\times}, since \times is by default a binary operator. You can enclose most math symbols in {} to turn them into ordinary math symbols.

Typically, binary relations have slightly more space than binary operators, and significantly more than ordinary symbols. However, the spacing changes when these appear as sub- or superscripts. All three examples above will look like A_{a\times b} if placed in a subscript.

Many new symbols can be created by modifying or combining existing symbols. To rotate, scale or reflect existing symbols, use the graphicx or graphics package. Documentation is here. The commands are \rotatebox, \scalebox, \resizebox and \reflectbox.

For example, if you want a \cong symbol (≅), but with the tilde reversed, the \reflectbox command from graphicx can be used. The code


will produce the desired effect with the code $A\backcong B$.

enter image description here

If you try using this code in a subscript (for example, $X_{A\backcong B}$), the new symbol will not scale down as it should. This is resolved below below using \mathchoice.

To combine multiple symbols (math or text) the \ooalign command can be used. @egreg has a detailed explanation here. The basic idea is that \ooalign creates a one-column table, with all rows superimposed on one another, and no padding outside the column. Each row of the "table" ends with \cr. Entries can be centered in the column using \hfil.

For example, to produce

enter image description here

we superimpose a \circ symbol with a text T character. The command

    \ooalign{\hfil$\circ$\hfil\cr\hfil T\hfil\cr}%

together with $A\Tcirc B$ produces the output.

To make sure your symbol looks right whether it's displayed, inline, script or scriptscript, you can use \mathchoice. (Note mathpalette (explained here by @egreg and @Werner) can be used when the four versions are identical except for style.)

  {<do this if called in \displaystyle>}
  {<do this if called in \textstyle>}
  {<do this if called in \scriptstyle>}
  {<do this if called in \scriptscriptstyle>}

The above code will produce the corresponding output for each of the four math styles.

To illustrate, here is a solution to the twisted product question that will adjust to scripts and scriptscripts.


enter image description here

S^2\twprod S^2 \quad F_{S^2\twprod S^2} \quad F_{K_{S^2\twprod S^2}}

I downsized the \sim in each style so it fit better over the \times.

Similar effects can be obtained using stackengine. Documentation is here.

If you can't create your symbol by combining or modifying others, you can design your symbol from scratch using tikz, together with the ideas above. Here is an example by @marmot.

| improve this answer | |
  • Very nicely done, have a bounty from me :) – cmhughes Aug 17 '19 at 11:50

I'd like to expand a bit on the "build the symbol from scratch" part. There are some very simple basic principles that help making the symbol scalable:

  • Use relative length scales for all dimensions. These are explained very nicely in this answer. The most important feature (for the purposes here) is that they scale with the font size.
  • Use relative length scales for the line widths.
  • Consider using the baseline option.

An example is given in this post:

\draw[line width=0.075em] (-45:0.5em) -- (105:0.5em) (-15:0.5em) -- (-165:0.5em) (-135:0.5em) -- (75:0.5em);
ABC \inftrian\ DEF

enter image description here

You can combine this with all that has been said in Sandy G's nice answer about \mathchoice. The thing I like about TikZ, though, is that it is IMHO particularly intuitive to design the symbol since it offers polar and Cartesian coordinates, and works with all common compilers (latex, pdflatex, xelatex and lualatex, and even tex, though the syntax is slightly different). A potential drawback of the simple example above is that it does not detect the font weight and so on. One can make the thingy a bit more versatile by checking the font weight and using \mathchoice as follows (taken from here):

\DeclareRobustCommand{\checkbold}[1]{% https://tex.stackexchange.com/a/24635/121799
\tikz[baseline=-0.1ex]{\draw[line width={(1+0.33*\tmp)*0.06em},->](0,0) -- (60:0.6em) -- ++ (-60:0.6em);}
\tikz[baseline=-0.1ex]{\draw[line width={(1+0.33*\tmp)*0.06em},->](0,0) -- (60:0.6em) -- ++ (-60:0.6em);}
\tikz[baseline=-0.075ex]{\draw[line width={(1+0.33*\tmp)*0.045em},->](0,0) -- (60:0.45em) -- ++(-60:0.45em);}
\tikz[baseline=-0.06ex]{\draw[line width={(1+0.33*\tmp)*0.035em},->](0,0) -- (60:0.35em) -- ++ (-60:0.35em);}
$A\wedgearrow B_{C\wedgearrow D}$ {\Large $A\wedgearrow B_{C\wedgearrow D}$}

\boldmath$A\wedgearrow B_{C\wedgearrow D}$ {\Large $A\wedgearrow B_{C\wedgearrow D}$}

enter image description here

(Note that I do not claim that this is 100% fool proof but I made a few checks it seems to work fine.)

| improve this answer | |
  • This version of \checkbold no longer works, \bfdefault has been changed. See here for a temporary workaround. – user194703 Mar 22 at 2:15

Another possibility with the \stackinset command, from stackengine:

\documentclass[border = 2pt]{standalone}

 \usepackage{stackengine, graphicx} %

{\stackinset{c}{0ex}{c}{0.9ex}{{\scalebox {0.67}{$\sim $}}}{\times}}%
{\stackinset{c}{0ex}{c}{0.9ex}{{\scalebox {0.67}{$\sim $}}}{\times}}%
{\stackinset{c}{0ex}{c}{0.7ex}{{\scalebox {0.67}{$\scriptstyle\sim $}}}{\scriptstyle\times}}%
{\stackinset{c}{0ex}{c}{0.6ex}{{\scalebox {0.67}{$\scriptscriptstyle\sim $}}}{\scriptscriptstyle\times}}%


 $ S^2 \simtimes S^2 \quad F_{S^2 \simtimes S^2} \quad F_{K_{S^2 \simtimes S^2}}$


enter image description here

| improve this answer | |

I offer this to provide a little contrast with Bernard's answer, which uses stackengine and \mathchoice. This answer, too, uses stackengine, but different in two ways:

  1. It uses \ensurestackMath{} rather than \stackMath, as the latter is a global declaration that will potentially affect other uses of stackengine in the document. It is one thing for a user to declare that all stacking should be done in math---but to bury such a declaration inside of a macro is asking for potential trouble in other areas of the document.

  2. I use \stackengine in preference to \stackinset, as the former is more efficient, and the features of the latter, to fine tune both horizontal as well as vertical placement, are not being employed in the given answer...vertical shifts alone in the overlay can be handled by all stackengine package macros.

But more significantly, I show the use of the \ThisStyle{...\SavedStyle...} feature of the scalerel package in preference to \mathchoice. Make no mistake---the former uses the \mathchoice primitive, but it allows the syntax to be compressed into a single statement, rather than a menu of 4 math choices.

So what does the \ThisStyle accomplish here? It says to stack a .67 scaled \sim atop of \times, using central horizontal alignment and specifying any vertical shifts in terms of the baselines. However, both symbols are to be taken in the current math size (style), whatever that may be (That is the function of \SavedStyle---to import the style active at the \ThisStyle invocation to places where it would otherwise be lost).

The only additional allowance I need to make to handle the various math styles is the specification of the vertical shift of the \sim overlay, which is raised by a height of \dimexpr.25ex+.8\LMex. Inside a \ThisStyle, 1\LMex is equal to a value of 1ex but scaled to the local mathstyle (.7ex in \scriptstyle and .5ex in \scriptscriptstyle, by default). Thus, in \displaystyle and \textstyle, the shift is 1.05ex. In \scriptstyle, the shift is .81ex and in \scriptscriptstyle, the shift is .65ex.

\documentclass[border = 2pt]{standalone}
  \scalebox {0.67}{$\SavedStyle\sim$}}{O}{c}{F}{F}{L}}}}}
 $ S^2 \simtimes S^2 \quad F_{S^2 \simtimes S^2} \quad 
  F_{K_{S^2 \simtimes S^2}}$

enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.