[Tex/LaTex] Contour integrals of different kind

math-modesymbols

I'm writing a paper on general mathematics and I want to add some contour integrals. The basic command is $\oint$ which produces the known result: an integral with a circle in the middle.

How can I add the integral with the triangle in the middle and that of the box/rectangle in the middle? I have seen these symbols before but I don't know their code.

Best Answer

Here's some possibility allowing you to easily define different integral symbols with decorations adapting to the math style:

enter image description here

The code:

\documentclass{article}
\usepackage{graphicx}
\usepackage{amssymb}

\def\IntKern{}
\newcommand\MySymbolint[2][0pt]{%
  \mathchoice
  {\def\IntKern{\dimexpr-.6\wd0+#1\relax}\Symbolint\displaystyle\displaystyle{\scalebox{.8}{$#2$}}}%
  {\def\IntKern{\dimexpr-.62\wd0+#1\relax}\Symbolint\textstyle\textstyle{\scalebox{.6}{$#2$}}}%
  {\def\IntKern{\dimexpr-.642\wd0+#1\relax}\Symbolint\scriptstyle\scriptscriptstyle{\scalebox{.45}{$#2$}}}%
  {\def\IntKern{\dimexpr-.67\wd0+#1\relax}\Symbolint\scriptscriptstyle\scriptscriptstyle{\scalebox{.35}{$#2$}}}%
  \!\int}
\newcommand\Symbolint[3]{%
  {\setbox0=\hbox{$#1{#2#3}{\int}$ }%
  \vcenter{\hbox{$#2#3$ }}\kern\IntKern}
}
\def\uptriint{\MySymbolint\triangle}
\def\downtriint{\MySymbolint[0.31pt]{\rotatebox{180}{\raisebox{-2ex}{$\triangle$}}}}
\def\squareint{\MySymbolint\square}

\begin{document}

$
{\displaystyle\oint f}\quad \oint f\quad A_{\oint f} \quad A_{B_{\oint f}}
$

$
{\displaystyle\uptriint f}\quad \uptriint f\quad A_{\uptriint f} \quad A_{B_{\uptriint f}}
$

$
{\displaystyle\downtriint f}\quad \downtriint f\quad A_{\downtriint f} \quad A_{B_{\downtriint f}}
$

$
{\displaystyle\squareint f}\quad \squareint f\quad A_{\squareint f} \quad A_{B_{\squareint f}}
$

\end{document}

The code was adapted from this answer to Average integral symbol

Just for illustration of the method's versatility, here's a fancy integral sign built with the help of TikZ:

\documentclass{article}
\usepackage{graphicx}
\usepackage{amssymb}
\usepackage{tikz}

\newcommand\MyBowTie{%
  \tikz[overlay]
  {
    \fill[cyan] (-0.45em,-0.5ex) -- (-0.45em,0.5ex) -- (0,0) -- cycle;
    \fill[orange] (0.45em,-0.5ex) -- (0.45em,0.5ex) -- (0,0) -- cycle;
  }
}

\def\IntKern{}
\newcommand\MySymbolint[2][0pt]{%
  \mathchoice
  {\def\IntKern{\dimexpr-.6\wd0+#1\relax}\Symbolint\displaystyle\displaystyle{\scalebox{.8}{$#2$}}}%
  {\def\IntKern{\dimexpr-.62\wd0+#1\relax}\Symbolint\textstyle\textstyle{\scalebox{.6}{$#2$}}}%
  {\def\IntKern{\dimexpr-.642\wd0+#1\relax}\Symbolint\scriptstyle\scriptscriptstyle{\scalebox{.45}{$#2$}}}%
  {\def\IntKern{\dimexpr-.67\wd0+#1\relax}\Symbolint\scriptscriptstyle\scriptscriptstyle{\scalebox{.35}{$#2$}}}%
  \!\int}
\newcommand\Symbolint[3]{%
  {\setbox0=\hbox{$#1{#2#3}{\int}$ }%
  \vcenter{\hbox{$#2#3$ }}\kern\IntKern}
}
\def\bowtieint{\MySymbolint\MyBowTie}

\begin{document}

$
{\displaystyle\bowtieint f}\quad \bowtieint f\quad _{\bowtieint f} \quad _{_{\bowtieint f}}
$

\end{document}

enter image description here

Related Question