5

Is it possible to make math or text symbols of these forms: enter image description here

Are there already available in LaTex?

These are from Bagua for your reference: https://en.wikipedia.org/wiki/Bagua

Thank you in advance!

7

The sizes can be tailored. \bagwd is the full width of the character, \baggaph is the horizontal space on the zero rows, \baggapv is the interrow vertical gap of the bagua character, and \baght is the height of each of the three black rows.

\documentclass{article}
\usepackage{stackengine}
\newlength\bagwd
\newlength\baggaph
\newlength\baggapv
\newlength\baght
\setlength\bagwd{1ex}
\setlength\baggaph{.15ex}
\setlength\baggapv{.2ex}
\setlength\baght{.2ex}
\expandafter\def\csname bag0\endcsname{%
  \rule{.5\dimexpr\bagwd-\baggaph\relax}{\baght}%
  \kern\baggaph%
  \rule{.5\dimexpr\bagwd-\baggaph\relax}{\baght}}
\expandafter\def\csname bag1\endcsname{%
  \rule{\bagwd}{\baght}}
\newcommand\bagrow[1]{\csname bag#1\endcsname}
\newcommand\bagua[3]{\setstackgap{S}{\baggapv}%
  \Shortstack{\bagrow#3 \bagrow#2 \bagrow#1}}
\begin{document}
a 
\bagua111
\bagua110
\bagua101
\bagua100
\bagua011
\bagua010
\bagua001
\bagua000
\end{document}

enter image description here

2
  • Amazing. Such elegance and the typeset look almost like a canonical textbook answer. ~1
    – wonderich
    Jul 17 at 1:01
  • @wonderich Thank you for the compliment! Jul 17 at 1:09
5

The BaGua are also in Unicode, in the Miscellanous Symbols block.

A random sample of fonts:

BaGua

and so part of the font designer's expression.

MWE

\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{fontspec}

\newcommand\bagua{☰☱☲☳☴☵☶☷ \iffontchar\font`八 八卦\fi}

\newcommand\namefbga{DejaVu Sans}
\newcommand\namefbgb{FreeMono}
\newcommand\namefbgc{FreeSerif}
\newcommand\namefbgd{Kinryu}
\newcommand\namefbge{Meiryo}
\newcommand\namefbgf{Noto Sans Symbols2}
\newcommand\namefbgg{Quivira}
\newcommand\namefbgh{Sawarabi Gothic}
\newcommand\namefbgi{Sawarabi Mincho}
\newcommand\namefbgj{UKIJ Tughra}

\newfontface\fbga{\namefbga}
\newfontface\fbgb{\namefbgb}
\newfontface\fbgc{\namefbgc}
\newfontface\fbgd{\namefbgd}
\newfontface\fbge{\namefbge}
\newfontface\fbgf{\namefbgf}
\newfontface\fbgg{\namefbgg}
\newfontface\fbgh{\namefbgh}
\newfontface\fbgi{\namefbgi}
\newfontface\fbgj{\namefbgj}

\begin{document}
\begin{tabular}{ll}
\rowcolor{blue!5}
Font & Bagua \\
\hline
\namefbga\phantom{\Large L} & \fbga\bagua \\
\namefbgb & \fbgb\bagua \\
\namefbgc & \fbgc\bagua \\
\namefbgd & \fbgd\bagua \\
\namefbge & \fbge\bagua \\
\namefbgf & \fbgf\bagua \\
\namefbgg & \fbgg\bagua \\
\namefbgh & \fbgh\bagua \\
\namefbgi & \fbgi\bagua \\
\namefbgj & \fbgj\bagua \\
\hline 
\end{tabular}
\end{document}
3

A tikz-based solution:

\documentclass{article}
\usepackage   {tikz}

\newcommand{\bagua}[1]
{%
  \begin{tikzpicture}[x=0.4ex,y=0.4ex,line width=0.15ex]
    \pgfmathtruncatemacro\number{#1}
    \foreach\i in {1,2,3}
    {%
      \pgfmathtruncatemacro\digit{Mod(div(\number,pow(10,\i-1)),10)}
      \ifnum\digit = 0
        \draw (0  ,3-\i) --++ (1,0);
        \draw (1.5,3-\i) --++ (1,0);
      \else
        \draw (0  ,3-\i) --++ (2.5,0);
      \fi
    }
  \end{tikzpicture}% <-- This prevents more space
}

\begin{document}

a
\bagua{111}
\bagua{110}
\bagua{101}
\bagua{100}
\bagua{011}
\bagua{010}
\bagua{001}
\bagua{000}

\end{document}

enter image description here

2
  • Thanks I really like your answer, but I already awarded the answer to the other person. But I made a new question maybe you can answer tex.stackexchange.com/q/605410/41144 to get extra bonus.
    – wonderich
    Jul 17 at 17:24
  • also +1 voted up, great work
    – wonderich
    Jul 17 at 17:25

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.