而不是出现台面,维沙巴等等,在图中,一个额外的最后一个字母再次出现,就像梅萨,维沙巴等,编译后出现在 pdf 中。有人能解决吗?
请查看下面的代码。
\begin{tikzpicture}
%
\pgfmathsetmacro{\inradi}{4.5}
\pgfmathsetmacro{\ouradi}{5.5}
\filldraw[fill=green!20!white, draw=black,thick] (0,0) -- (0:\inradi) arc (0:90:\inradi) -- cycle;
\filldraw[fill=green!20!white, draw=black,thick] (0,0) -- (180:\inradi) arc (180:270:\inradi) -- cycle;
\filldraw[fill=yellow!20!white, draw=black,thick] (0,0) -- (90:\inradi) arc (90:180:\inradi) -- cycle;
\filldraw[fill=yellow!20!white, draw=black,thick] (0,0) -- (270:\inradi) arc (270:360:\inradi) -- cycle;
%
\draw[decoration={text along path, text={|\it|Meṣa||}, text align = center,raise=0.35cm},decorate] (30:\inradi) arc (30:0:\inradi);
\draw[decoration={text along path,text={|\it|Vṛṣabha||},text align = center,raise=0.35cm},decorate] (60:\inradi) arc (60:30:\inradi);
\draw[decoration={text along path,text={|\it|Mithuna||},text align = center,raise=0.35cm},decorate] (90:\inradi) arc (90:60:\inradi);
\draw[decoration={text along path,text={|\it|Karkāṭaka||},text align = center,raise=0.35cm},decorate] (120:\inradi) arc (120:90:\inradi);
\draw[decoration={text along path,text={|\it|Siṃha||},text align = center,raise=0.35cm},decorate] (150:\inradi) arc (150:120:\inradi);
\draw[decoration={text along path,text={|\it|Kanyā||},text align = center,raise=0.35cm},decorate] (180:\inradi) arc (180:150:\inradi);
\draw[decoration={text along path,text={|\it|Tulā||},text align = center,raise=-0.65cm},decorate] (180:\inradi) arc (180:210:\inradi);
\draw[decoration={text along path,text={|\it|Vṛścika||},text align = center,raise=-0.65cm},decorate] (210:\inradi) arc (210:240:\inradi);
\draw[decoration={text along path,text={Dhanu},text align = center,raise=-0.65cm},decorate] (240:\inradi) arc (240:270:\inradi);
\draw[decoration={text along path,text={Makara},text align = center,raise=-0.65cm},decorate] (270:\inradi) arc (270:300:\inradi);
\draw[decoration={text along path,text={Kumbha},text align = center,raise=-0.65cm},decorate] (300:\inradi) arc (300:330:\inradi);
\draw[decoration={text along path,text={Mīna},text align = center,raise=-0.65cm},decorate] (330:\inradi) arc (330:360:\inradi);
%
\draw [thick] (0,0) circle (\ouradi);
\draw (210:\ouradi)[dashed] -- (30:\ouradi);
\draw (240:\ouradi)[dashed] -- (60:\ouradi);
\draw (300:\ouradi)[dashed] -- (120:\ouradi);
\draw (330:\ouradi)[dashed] -- (150:\ouradi);
\draw (-\ouradi,0)node[left]{$180^\circ$} -- (\ouradi,0) node[right]{$0^\circ$};
\draw (0,-\ouradi)node[below]{$270^\circ$} -- (0,\ouradi) node[above]{$90^\circ$};
%
\node[black] at (2,2) {{\large \textit{oja}}};
\node[black] at (-2,-2) {{\large \textit{oja}}};
\node[black] at (-2,2) {{\large \textit{anoja}}};
\node[black] at (2,-2) {{\large \textit{anoja}}};
\end{tikzpicture}}
答案1
在这种情况下我会使用它text effects along path
。这样你就不需要字符|
,并且可以用来characters={font=\itshape}
将文本变为斜体。
我还创建了样式,以使代码更清晰,更容易修改。基本样式设置配置text effects along path
。然后,其他两种样式利用此样式以直立和斜体呈现文本。
\it
不应在 LaTeX 文档中使用,因此我将其更改为\itshape
。
我不知道您使用的是哪种语言/字体设置,所以我不得不使用它lualatex
来编译它。如果您使用的是其他引擎,则可能需要保护重音字符。
\documentclass[tikz]{standalone}
% ateb https://tex.stackexchange.com/a/699772/ i gwestiwn https://tex.stackexchange.com/q/699727/
\usetikzlibrary{decorations.text}
\tikzset{%
fancy text effects/.style n args=3{%
decorate,
decoration={text effects along path,raise=#1, text={#2},text align=center,text effects/.cd, text along path, characters={font=#3}},
},
fancy italic text/.style 2 args={fancy text effects={#1}{#2}{\itshape}},
fancy text/.style 2 args={fancy text effects={#1}{#2}{\normalfont}},
oja/.style={fill=green!20!white, draw=black,thick},
anoja/.style={fill=yellow!20!white, draw=black,thick},
segment text/.style={black,font=\large\itshape},
}
\begin{document}
\begin{tikzpicture}
%
\pgfmathsetmacro{\inradi}{4.5}
\pgfmathsetmacro{\ouradi}{5.5}
\filldraw[oja] (0,0) -- (0:\inradi) arc (0:90:\inradi) -- cycle;
\filldraw[oja] (0,0) -- (180:\inradi) arc (180:270:\inradi) -- cycle;
\filldraw[anoja] (0,0) -- (90:\inradi) arc (90:180:\inradi) -- cycle;
\filldraw[anoja] (0,0) -- (270:\inradi) arc (270:360:\inradi) -- cycle;
%
\draw[fancy italic text={0.35cm}{Meṣa}] (30:\inradi) arc (30:0:\inradi);
\draw[fancy italic text={0.35cm}{Vṛṣabha}] (60:\inradi) arc (60:30:\inradi);
\draw[fancy italic text={0.35cm}{Mithuna}] (90:\inradi) arc (90:60:\inradi);
\draw[fancy italic text={0.35cm}{Karkāṭaka}] (120:\inradi) arc (120:90:\inradi);
\draw[fancy italic text={0.35cm}{Siṃha}] (150:\inradi) arc (150:120:\inradi);
\draw[fancy italic text={0.35cm}{Kanyā}] (180:\inradi) arc (180:150:\inradi);
\draw[fancy italic text={-0.65cm}{Tulā}] (180:\inradi) arc (180:210:\inradi);
\draw[fancy italic text={-0.65cm}{Vṛścika}] (210:\inradi) arc (210:240:\inradi);
\draw[fancy text={-0.65cm}{Dhanu}] (240:\inradi) arc (240:270:\inradi);
\draw[fancy text={-0.65cm}{Makara}] (270:\inradi) arc (270:300:\inradi);
\draw[fancy text={-0.65cm}{Kumbha}] (300:\inradi) arc (300:330:\inradi);
\draw[fancy text={-0.65cm}{Mīna}] (330:\inradi) arc (330:360:\inradi);
%
\draw [thick] (0,0) circle (\ouradi);
\draw (210:\ouradi)[dashed] -- (30:\ouradi);
\draw (240:\ouradi)[dashed] -- (60:\ouradi);
\draw (300:\ouradi)[dashed] -- (120:\ouradi);
\draw (330:\ouradi)[dashed] -- (150:\ouradi);
\draw (-\ouradi,0)node[left]{$180^\circ$} -- (\ouradi,0) node[right]{$0^\circ$};
\draw (0,-\ouradi)node[below]{$270^\circ$} -- (0,\ouradi) node[above]{$90^\circ$};
%
\node[segment text] at (2,2) {oja};
\node[segment text] at (-2,-2) {oja};
\node[segment text] at (-2,2) {anoja};
\node[segment text] at (2,-2) {anoja};
\end{tikzpicture}
\end{document}
答案2
您需要用括号括住非 ASCII 字符。添加{}
似乎也有帮助。
\documentclass[10pt,border=3mm,tikz]{standalone}% <<< missing
\usetikzlibrary {decorations,decorations.text}% <<< missing
\tikzset{
mydecoration/.style 2 args={
decoration={
text along path,
text align=center,
raise=#1,
text=#2,
},
decorate,
},
}
\begin{document}
\begin{tikzpicture}
%
\pgfmathsetmacro{\inradi}{4.5}
\pgfmathsetmacro{\ouradi}{5.5}
\filldraw[fill=green!20!white, draw=black,thick] (0,0) -- (0:\inradi) arc (0:90:\inradi) -- cycle;
\filldraw[fill=green!20!white, draw=black,thick] (0,0) -- (180:\inradi) arc (180:270:\inradi) -- cycle;
\filldraw[fill=yellow!20!white, draw=black,thick] (0,0) -- (90:\inradi) arc (90:180:\inradi) -- cycle;
\filldraw[fill=yellow!20!white, draw=black,thick] (0,0) -- (270:\inradi) arc (270:360:\inradi) -- cycle;
%
\draw[mydecoration={0.35cm}{|\itshape|Me{ṣ}a{}||}] (30:\inradi) arc (30:0:\inradi);
\draw[mydecoration={0.35cm}{|\itshape|V{ṛ}{ṣ}abha{}||}] (60:\inradi) arc (60:30:\inradi);
\draw[mydecoration={0.35cm}{|\itshape|Mithuna{}||}] (90:\inradi) arc (90:60:\inradi);
\draw[mydecoration={0.35cm}{|\itshape|Kark{ā}{ṭ}aka{}||}] (120:\inradi) arc (120:90:\inradi);
\draw[mydecoration={0.35cm}{|\itshape|Si{ṃ}ha{}||}] (150:\inradi) arc (150:120:\inradi);
\draw[mydecoration={0.35cm}{|\itshape|Kany{ā}{}||}] (180:\inradi) arc (180:150:\inradi);
\draw[mydecoration={-0.65cm}{|\itshape|Tul{ā}{}||}] (180:\inradi) arc (180:210:\inradi);
\draw[mydecoration={-0.65cm}{|\itshape|V{ṛ}{ś}cika{}||}] (210:\inradi) arc (210:240:\inradi);
\draw[mydecoration={-0.65cm}{Dhanu}] (240:\inradi) arc (240:270:\inradi);
\draw[mydecoration={-0.65cm}{Makara}] (270:\inradi) arc (270:300:\inradi);
\draw[mydecoration={-0.65cm}{Kumbha}] (300:\inradi) arc (300:330:\inradi);
\draw[mydecoration={-0.65cm}{M{ī}na}] (330:\inradi) arc (330:360:\inradi);
%
\draw [thick] (0,0) circle (\ouradi);
\draw (210:\ouradi)[dashed] -- (30:\ouradi);
\draw (240:\ouradi)[dashed] -- (60:\ouradi);
\draw (300:\ouradi)[dashed] -- (120:\ouradi);
\draw (330:\ouradi)[dashed] -- (150:\ouradi);
\draw (-\ouradi,0)node[left]{$180^\circ$} -- (\ouradi,0) node[right]{$0^\circ$};
\draw (0,-\ouradi)node[below]{$270^\circ$} -- (0,\ouradi) node[above]{$90^\circ$};
%
\node[black] at (2,2) {{\large \textit{oja}}};
\node[black] at (-2,-2) {{\large \textit{oja}}};
\node[black] at (-2,2) {{\large \textit{anoja}}};
\node[black] at (2,-2) {{\large \textit{anoja}}};
\end{tikzpicture}
\end{document}
我定义了一种样式来简化输入。
答案3
正如我所怀疑的,问题似乎出在和上|
。||
您的代码片段中存在许多问题,导致我无法对其进行编译。
关于解决方案
请比较这两行代码:
\draw[decoration={text along path, text={Mesa},
text align = center,raise=0.35cm},decorate] (30:\inradi) arc (30:0:\inradi);
\draw[decoration={text along path,text={|\it|Vrsabha||},
text align = center,raise=0.35cm},decorate] (60:\inradi) arc (60:30:\inradi);
第一行如果没有 ,|
则不会将最后一个字符重复,而如果有 ,则会重复。
关于您发布的代码
至少这些行对于代码的编译至关重要:
\documentclass[10pt,border=3mm,tikz]{standalone}% <<< missing
\usetikzlibrary {decorations,decorations.text}% <<< missing
由于某种原因,你}
最后有太多了:
\end{tikzpicture}%} % <<< one brace too many
因为您没有在代码中指定语言,所以我不得不替换下面的代码,才能进行编译:
Meṣa
Mesa
未解决
文本目前不是斜体。请在手册 这种字体规范的方式可以在 Tikz 中完成,并且/或者预计它位于装饰路径上。
您还可以用自定义样式替换所有这些单独的格式规范。这既提高了可读性,又减少了错误,并允许“仅在一个地方进行更改”的方法。
\documentclass[10pt,border=3mm,tikz]{standalone}% <<< missing
\usetikzlibrary {decorations,decorations.text}% <<< missing
\begin{document}
\begin{tikzpicture}
%
\pgfmathsetmacro{\inradi}{4.5}
\pgfmathsetmacro{\ouradi}{5.5}
\filldraw[fill=green!20!white, draw=black,thick] (0,0) -- (0:\inradi) arc (0:90:\inradi) -- cycle;
\filldraw[fill=green!20!white, draw=black,thick] (0,0) -- (180:\inradi) arc (180:270:\inradi) -- cycle;
\filldraw[fill=yellow!20!white, draw=black,thick] (0,0) -- (90:\inradi) arc (90:180:\inradi) -- cycle;
\filldraw[fill=yellow!20!white, draw=black,thick] (0,0) -- (270:\inradi) arc (270:360:\inradi) -- cycle;
%
\draw[decoration={text along path, text={Mesa}, text align = center,raise=0.35cm},decorate] (30:\inradi) arc (30:0:\inradi);
\draw[decoration={text along path,text={|\it|Vrsabha||},text align = center,raise=0.35cm},decorate] (60:\inradi) arc (60:30:\inradi);
%\draw[decoration={text along path,text={|\it|Mithuna||},text align = center,raise=0.35cm},decorate] (90:\inradi) arc (90:60:\inradi);
%\draw[decoration={text along path,text={|\it|Karkāṭaka||},text align = center,raise=0.35cm},decorate] (120:\inradi) arc (120:90:\inradi);
%\draw[decoration={text along path,text={|\it|Siṃha||},text align = center,raise=0.35cm},decorate] (150:\inradi) arc (150:120:\inradi);
%\draw[decoration={text along path,text={|\it|Kanyā||},text align = center,raise=0.35cm},decorate] (180:\inradi) arc (180:150:\inradi);
%\draw[decoration={text along path,text={|\it|Tulā||},text align = center,raise=-0.65cm},decorate] (180:\inradi) arc (180:210:\inradi);
%\draw[decoration={text along path,text={|\it|Vṛścika||},text align = center,raise=-0.65cm},decorate] (210:\inradi) arc (210:240:\inradi);
%\draw[decoration={text along path,text={Dhanu},text align = center,raise=-0.65cm},decorate] (240:\inradi) arc (240:270:\inradi);
%\draw[decoration={text along path,text={Makara},text align = center,raise=-0.65cm},decorate] (270:\inradi) arc (270:300:\inradi);
%\draw[decoration={text along path,text={Kumbha},text align = center,raise=-0.65cm},decorate] (300:\inradi) arc (300:330:\inradi);
%\draw[decoration={text along path,text={Mīna},text align = center,raise=-0.65cm},decorate] (330:\inradi) arc (330:360:\inradi);
%
\draw [thick] (0,0) circle (\ouradi);
\draw (210:\ouradi)[dashed] -- (30:\ouradi);
\draw (240:\ouradi)[dashed] -- (60:\ouradi);
\draw (300:\ouradi)[dashed] -- (120:\ouradi);
\draw (330:\ouradi)[dashed] -- (150:\ouradi);
\draw (-\ouradi,0)node[left]{$180^\circ$} -- (\ouradi,0) node[right]{$0^\circ$};
\draw (0,-\ouradi)node[below]{$270^\circ$} -- (0,\ouradi) node[above]{$90^\circ$};
%
\node[black] at (2,2) {{\large \textit{oja}}};
\node[black] at (-2,-2) {{\large \textit{oja}}};
\node[black] at (-2,2) {{\large \textit{anoja}}};
\node[black] at (2,-2) {{\large \textit{anoja}}};
\end{tikzpicture}%} % <<< one brace too many
\end{document}