0

How to write this formula in Latex? enter image description here

5

Another solution using tikz to draw the symbols (although I like egreg's solution better):

\documentclass[12pt]{article}
\usepackage{tikz}

\newlength{\lineheight}
\newcommand{\updateheight}{\settoheight{\lineheight}{A}}
\tikzset{ThreePoints/.style={circle, fill}}
\newcommand{\drawthreepoints}{%
    \node [ThreePoints] (first) at (0,0) {};
    \node [ThreePoints] (second) at (0.5,0.8) {};
    \node [ThreePoints] (third) at (-0.5,0.8) {};
}
\newcommand{\resizepoints}[1]{\updateheight\resizebox{!}{\lineheight}{#1}}
\newcommand{\threepoints}{\resizepoints{\begin{tikzpicture}
    \drawthreepoints
\end{tikzpicture}}}
\newcommand{\threepointsone}{\resizepoints{\begin{tikzpicture}
    \drawthreepoints
    \draw [line width=3pt] (third) -- (second);
\end{tikzpicture}}}
\newcommand{\threepointstwo}{\resizepoints{\begin{tikzpicture}
    \drawthreepoints
    \draw [line width=3pt] (third) -- (second) -- (first);
\end{tikzpicture}}}

\begin{document}
\begin{equation}
    d(G)=d(\threepoints)d(\threepoints,G)+d(\threepointsone)d(\threepointsone,G)+d(\threepointstwo)d(\threepointstwo,G)
\end{equation}
\end{document}

enter image description here

6

It's rather easy with pict2e. The argument to \TR is a three digit binary number, which sets draws the lines joining the dots; the first digit represents the top, then we proceed in clockwise order.

\documentclass{article}
\usepackage{pict2e}

\makeatletter
\newcommand{\TR}[1]{\TR@aux#1000\@nil}
\def\TR@aux#1#2#3#4\@nil{%
  \,\vcenter{\hbox{\TR@aux@i{#1}{#2}{#3}}}\,%
}
\def\TR@aux@i#1#2#3{%
  \setlength\unitlength{.5em}%
  \begin{picture}(1,0.866)
  \put(0.5,0){\circle*{.4}}
  \put(0,0.866){\circle*{.4}}
  \put(1,0.866){\circle*{.4}}
  \ifnum#1=1 \polyline(0,0.866)(1,0.866) \fi
  \ifnum#2=1 \polyline(1,0.866)(0.5,0) \fi
  \ifnum#3=1 \polyline(0.5,0)(0,0.866) \fi
  \end{picture}%
}
\makeatother

\begin{document}

\[
d(G)=
d(\TR{000})d(\TR{000},G)+
d(\TR{100})d(\TR{100},G)+
d(\TR{110})d(\TR{110},G)
\]

$\TR{000}\quad\TR{001}\quad\TR{010}\quad\TR{011}$

$\TR{100}\quad\TR{101}\quad\TR{110}\quad\TR{111}$

\end{document}

enter image description here

  • You could actually use \Line, here, instead of \polyline. And what about a standard \mathpalette wrapper? – GuM Aug 7 '17 at 22:15
  • @GuM You looked in the manual, didn't you? :-) The \mathpalette thing is left as an exercise. – egreg Aug 8 '17 at 8:13
3

Like this?

\documentclass{article}\usepackage[show frame]{geometry}
\usepackage{mathtools, stackengine,adjustbox}

\newcommand{\threedots}{\!\begin{smallmatrix} \bullet\mkern10mu\bullet \\ \bullet \end{smallmatrix}\!}

\newcommand{\threedotsl}{\!\begin{smallmatrix}\bullet\mkern-4mu\mathord{\relbar\mkern-9mu\relbar}\mkern-4mu\bullet \\
 \bullet \end{smallmatrix}\!}

\newcommand{\threedotsll}{\!\stackMath\stackinset{r}{9.7pt}{c}{0pt}{\adjustbox{rotate=-4, origin=c, scale={1}{0.8}}{$ \not $}}%
{\begin{smallmatrix}\bullet\mkern-4mu\mathord{\relbar\mkern-9mu\relbar}\mkern-4mu\bullet \\
 \bullet \end{smallmatrix}}\!}

\begin{document}

\begin{equation*}
d(G) = d\bigl(\threedots\bigr)d\bigl(\threedots, G\bigr) + d\bigl(\threedotsl\bigr)d\bigl(\threedotsl, G\bigr) + d\bigl(\threedotsll)d\bigl(\threedotsll, G)
\end{equation*}

\end{document}

enter image description here

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.