这个问题可能是针对中文的,但我正在尝试用 Latex(实际上是 XeTex)写一些东西,所以我在这里问。
我基本上是想用 TikZ 画一个八卦符号,而且我快完成了。我只缺少与之搭配的汉字。有人能帮我告诉我应该把什么放在正确的位置吗?
最后它看起来应该是这样的:
我的 MWE 是(我留下了一些我稍后需要的三元组的长度和一些在这里没有意义的注释:它们在这个 MWE 中并不是真正需要的):
\documentclass[tikz,border=1pt]{standalone}
\usepackage{calc}
\usepackage{xcolor}
\usepackage{verbatim}
\usepackage{xeCJK}
\setCJKmainfont{KaiTi}
%Lengths definition
\newlength{\radiustai} %Radius of Taijitu symbol
\setlength{\radiustai}{1cm}
\newlength{\thickness} %Thickness of the trigram lines
\setlength{\thickness}{0.3\radiustai} %Change this factor to make the lines thicker or thinner
\newlength{\iradiusbagua} %Distance from center of Taijitu to the first line of Ba Gua.
\setlength{\iradiusbagua}{1.4\radiustai} %Change the factor to make the Ba Gua bigger or smaller. Factor 1 would make it tangent to the Taijitu.
\newlength{\smallradius} %Offset from the center for the trigram lines (see below for computation)
\newlength{\basedistance} %Base distance from lowest corner of Ba Gua trigram
\setlength{\parindent}{0pt} %It's not necessary here, but I use it anyway
%Colours definition
\definecolor{triborder}{gray}{0.7}
\definecolor{trifill}{gray}{0}
\definecolor{octafill}{gray}{0.9}
\definecolor{bckearth}{RGB}{240,230,140}
\definecolor{bckwater}{RGB}{30,144,255}
\definecolor{bckfire}{RGB}{220,20,60}
\definecolor{bckwood}{RGB}{50,205,50}
\definecolor{bckmetal}{RGB}{192,192,192}
\begin{document}
\begin{tikzpicture}
%External octagon: thanks to Mark Wibrow for the idea (from an answer on stackexchange).
\draw[line width=1,fill=octafill] (22.5:\iradiusbagua+8.5\thickness) \foreach \i in {45,90,...,315}{-- (\i+22.5:\iradiusbagua+8.5\thickness)} -- cycle;
\draw[line width=2,fill=white] (22.5:\iradiusbagua+6.5\thickness) \foreach \i in {45,90,...,315}{-- (\i+22.5:\iradiusbagua+6.5\thickness)} -- cycle;
\foreach \i in {22.5,67.5,...,337.5}{\draw[line width=1] (\i:\iradiusbagua+6.5\thickness) -- (\i:\iradiusbagua+8.5\thickness);}
\foreach \i [count=\xi from 1] in {?\ k\={u}n\ ?,?\ lì\ ?,?\ xùn\ ?,?\ zhèn\ ?} {\node[rotate=45*(\xi-2)] at (45*\xi:\iradiusbagua+6.5\thickness) {\i};}
\foreach \i [count=\xi from 5] in {?\ gèn\ 山,?\ k\v{a}n\ ?,?\ qián\ ?,?\ duì\ ?} {\node[rotate=45*(\xi+2)] at (45*\xi:\iradiusbagua+6.7\thickness) {\i};}
\end{tikzpicture}
\end{document}
只有一个是我从另一个答案中复制的(旁边gèn
),但我甚至不确定它是否正确。
答案1
你抄的那个“山”是正确的(顺便说一下,它的意思是“山”)。由于这是一个已知的形状,你可以在网上搜索它,确实有一篇包含所有字符的维基百科文章,关于八卦(意思是“八个符号”)。
我注意到你缺少了三卦,所以这是最终版本,还有阴阳。
输出
代码
\documentclass[tikz,margin=10pt]{standalone}
\usepackage{xeCJK}
\setCJKmainfont{STFangsong}
%Lengths definition
\newlength{\radiustai} %Radius of Taijitu symbol
\setlength{\radiustai}{1cm}
\newlength{\thickness} %Thickness of the trigram lines
\setlength{\thickness}{0.3\radiustai} %Change this factor to make the lines thicker or thinner
\newlength{\iradiusbagua} %Distance from center of Taijitu to the first line of Ba Gua.
\setlength{\iradiusbagua}{1.4\radiustai} %Change the factor to make the Ba Gua bigger or smaller. Factor 1 would make it tangent to the Taijitu.
\newlength{\smallradius} %Offset from the center for the trigram lines (see below for computation)
\newlength{\basedistance} %Base distance from lowest corner of Ba Gua trigram
%Colours definition
\definecolor{triborder}{gray}{0.7}
\definecolor{trifill}{gray}{0}
\definecolor{octafill}{gray}{0.9}
\definecolor{bckearth}{RGB}{240,230,140}
\definecolor{bckwater}{RGB}{30,144,255}
\definecolor{bckfire}{RGB}{220,20,60}
\definecolor{bckwood}{RGB}{50,205,50}
\definecolor{bckmetal}{RGB}{192,192,192}
\tikzset{
nodeline/.style={midway, rotate=#1, minimum height=3.5mm, minimum width=2.5mm},
}
\newcommand\trigram[2]{%
\begin{scope}[rotate=#1]% around={#1:(0,0)}
\def\alenanno{w}
\clip (-1.1,3) -- (1.1,3) -- (0,0) -- cycle;
\foreach \x [count=\xx starting from 0, evaluate=\xx as \y using (1.75+.5*\xx)] in #2{%
\ifx\x\alenanno
\draw[line width=3mm] (-1.2,\y) -- (1.2,\y) node[nodeline=#1,fill=white] {};
\else
\draw[line width=3mm] (-1.2,\y) -- (1.2,\y);
\fi
}
\end{scope}
}
\begin{document}
\begin{tikzpicture}
%External octagon: thanks to Mark Wibrow for the idea (from an answer on stackexchange).
\draw[line width=1,fill=octafill!80!black] (22.5:\iradiusbagua+8.5\thickness)
\foreach \i in {45,90,...,315}{
-- (\i+22.5:\iradiusbagua+8.5\thickness)
} -- cycle;
\draw[line width=2,fill=white] (22.5:\iradiusbagua+6.5\thickness)
\foreach \i in {45,90,...,315}{
-- (\i+22.5:\iradiusbagua+6.5\thickness)
} -- cycle;
\foreach \i in {22.5,67.5,...,337.5}{
\draw[line width=1] (\i:\iradiusbagua+6.5\thickness) -- (\i:\iradiusbagua+8.5\thickness);
}
%
\foreach \trig/\blk/\pin/\wht [count=\xi, evaluate=\xi as \angle using int((45*\xi)-90)] in {%
{w,w,w}/坤/kūn/地,
{b,w,b}/離/lì/火,
{w,b,b}/巽/xùn/風,
{b,w,w}/震/zhèn/雷,
{w,w,b}/艮/gèn/山,
{w,b,w}/坎/kǎn/水,
{b,b,b}/乾/qián/天,
{b,b,w}/兌/duì/澤
}{
\trigram{\angle}{\trig}
\ifnum\xi<5
\node[rotate=45*(\xi-2)] at (45*\xi:\iradiusbagua+6.5\thickness) {\blk~\pin~\textcolor{white}{\wht}};
\else
\node[rotate=45*(\xi+2)] at (45*\xi:\iradiusbagua+6.7\thickness) {\blk~\pin~\textcolor{white}{\wht}};
\fi
}
%
%\trigram{90}{b,w,b}
\draw (0,0) circle (1cm);
\fill (90:5mm) circle (3pt);
\fill (90:1cm) arc (90:-90:5mm) arc (90:270:5mm) arc (-90:90:1cm);
\fill[white] (-90:5mm) circle (3pt);
\end{tikzpicture}
\end{document}
答案2
我正在使用 XeLaTex 编译包含中文字符的文件。这是我的投影仪:
\documentclass[a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage{xeCJK}
\setCJKmainfont{BiauKai} % The main font you are using.
\newCJKfontfamily\Kai{魏碑-繁} % Set main font in your document.
\newCJKfontfamily\ChCal{行楷-繁} % Set a new font so that you can
\newCJKfontfamily\ChBlack{蘭亭黑-繁} % change the font in the document.
\XeTeXlinebreaklocale "zh" % Following set to break line automatically.
\XeTeXlinebreakskip = 0pt plus 1pt
\usepackage{xltxtra,xunicode}
\begin{document}
中文字測試
\end{document}
这样做,你会发现出现了中文单词。
顺便说一下,我在 Mac OS 上使用 TexShop。如果你打算在 Windows 上使用软件编译,你可以先尝试使用字体「标楷体」或「新细明体」。更多字体,你可以访问王汉宗 开放式汉字了解有关「王汉宗Open Type字体」的更多信息。