我曾使用过如何在 Latex 中制作旭日图?并根据我创建旭日图的需求对其进行了定制。我需要将其中的所有文本加粗,如果可能的话,增加其中文本的大小。这是我的 MWE。
\documentclass[border=0.05in]{standalone}
\usepackage{amsmath}
\usepackage{xcolor}
\usepackage{xparse}
\usepackage{tikz}
\definecolor{pear}{rgb}{0.82, 0.89, 0.19}
\definecolor{lavender}{rgb}{0.71, 0.49, 0.86}
\usetikzlibrary{calc,positioning}
\usetikzlibrary{decorations, decorations.text}
\newlength{\layerwd}
\newcounter{outermost}
\NewDocumentEnvironment{onion}{sm}{%*= draw axes; #1: thickness of each annulus
\begin{tikzpicture}
\setlength{\layerwd}{#2}%
\setcounter{outermost}{0}
}{%
\foreach \A in {0,...,\theoutermost}{\draw[thick,] (0,0) circle (\A*\layerwd+\layerwd);}
\end{tikzpicture}
}
% *=text on a circular path; [optional fill color]; #3 layer;
% #4 start angle; #5 stop angle; #6 [optional text]
%% angles are counterclockwise in degrees
\NewDocumentCommand{\annulus}{sO{lightgray}mmmo}{%
\filldraw[thick,fill=#2,] (#4:#3*\layerwd) %% start here
arc [radius=#3*\layerwd, start angle=#4, delta angle=#5-#4] %% inner arc
-- (#5:#3*\layerwd+\layerwd) %% move out
arc [radius=#3*\layerwd+\layerwd, start angle=#5, delta angle=#4-#5,] %% outer arc
-- cycle; %% Back to the beginnning
\pgfmathsetmacro{\tmp}{(#5-#4)/2 +#4} %% Locate the middle of the arc
\IfNoValueF{#6}{%
\IfBooleanTF{#1}
{%
\begingroup
%% text is always rightside-up:
\pgfmathsetmacro{\rpTF}{ifthenelse(\tmp>180,"false","true")}
\def\\{\space} %% A safety precaution, \\ = space on decorated text
\path[rotate=\tmp-180,postaction={
decorate,
decoration={
text along path,
raise=-3pt,
text align={align=center},
reverse path=\rpTF,
text=#6
}
}] (0,0) circle (#3*\layerwd+0.5*\layerwd);
\endgroup
}%%
{%
\pgfmathsetmacro{\rpTF}{ifthenelse(\tmp>180,\tmp+90,\tmp-90)}
\node[inner sep=0pt, %%% If there is text, print it
text width=#3*\layerwd*3+\layerwd,
align=center,
rotate=\rpTF,
font=\normalsize] at (\tmp:#3*\layerwd+0.5*\layerwd)
{#6};
}%
}%
\ifnum\theoutermost<#3\setcounter{outermost}{#3}\fi
}
\begin{document}
\begin{onion}*{0.6in}
\draw[fill=red!20,thick] (0,0) circle (1.53cm);
\node[color=red,thick,font=\bfseries] at (0,0) {My research};
\annulus*[pear]{1}{0}{180}[Materials for composites]
\annulus*[pear!80]{2}{0}{180}[Working through trial and errors to find parameters]
\annulus*[pear!60]{3}{0}{180}[Conditions associated with pre and post heat treatment]
\annulus*[pear!40]{4}{20}{70}[Mechanical]
\annulus*[pear!40]{4}{0}{20}[Physical]
\annulus*[pear!40]{4}{70}{100}[Tribological]
\annulus*[pear!40]{4}{100}{150}[Microstructure(OM/SEM/TEM)]
\annulus*[pear!40]{4}{150}{180}[XRD]
\annulus[pear!25]{5}{150}{180}[2($\theta$) and \\Bulk texture]
\annulus[pear!25]{5}{100}{150}[Composites{,}\\Fracture{,}\\Wear track/debris]
\annulus*[pear!25]{5}{70}{100}[Wear rate/COF]
\annulus[pear!25]{5}{20}{40}[Hardness (Hv)]
\annulus[pear!25]{5}{0}{20}[Density]
\annulus[pear!25]{5}{40}{70}[Tensile (MPa)\\Yield (MPa)\\Elongation ($\delta$)]
\annulus*[lavender!65]{1}{180}{360}[Materials for composites]
\annulus*[lavender!55]{2}{180}{360}[Working through trial and errors to find parameters]
\annulus*[lavender!45]{3}{180}{360}[Conditions associated with pre and post heat treatment]
\annulus*[lavender!35]{4}{180}{200}[Physical]
\annulus*[lavender!35]{4}{200}{250}[Mechanical]
\annulus*[lavender!35]{4}{250}{280}[Tribological]
\annulus*[lavender!35]{4}{280}{330}[Microstructure(OM/SEM/TEM)]
\annulus*[lavender!35]{4}{330}{360}[XRD]
\annulus[lavender!25]{5}{180}{200}[Density]
\annulus[lavender!25]{5}{200}{220}[Hardness (Hv)]
\annulus[lavender!25]{5}{220}{250}[Tensile (MPa)\\Yield (MPa)\\Elongation ($\delta$)]
\annulus*[lavender!25]{5}{250}{280}[Wear rate/COF]
\annulus[lavender!25]{5}{280}{330}[Composites{,}\\Fracture{,}\\Wear track/debris]
\annulus[lavender!25]{5}{330}{360}[2($\theta$) and \\Bulk texture]
\end{onion}
\end{document}
它产生以下输出:
答案1
要更改字体样式,您需要修改文本内部的财产\环定义。具体来说,你必须改变这个:
decoration={
text along path,
raise=-3pt,
text align={align=center},
reverse path=\rpTF,
text=#6 % <-------------- HERE!
}
更改为:
text={|\customannfont|#6}
和这个:
\node[inner sep=0pt, %%% If there is text, print it
text width=#3*\layerwd*3+\layerwd,
align=center,
rotate=\rpTF,
font=\normalsize] at (\tmp:#3*\layerwd+0.5*\layerwd) % <-------------- HERE!
{#6};
更改为:
font=\customannfont] at (\tmp:#3*\layerwd+0.5*\layerwd)
注意:您可以不使用 \customannfont,而只是简单地编写字体样式,如下所示:
%%% code before
text={|\bfseries\fontsize{10}{0}\selectfont|#6}
%%% other code
font=\fontsize{10}{0}\selectfont
使字体变成 10pt 并加粗。不过,我建议在\环定义,因此您只需修改一次就可以在代码的两个地方更改它,如下所示:
\newcommand{\customannfont}{\fontsize{10}{0}\selectfont}
\documentclass[border=0.05in]{standalone}
\usepackage{amsmath}
\usepackage{xcolor}
\usepackage{xparse}
\usepackage{tikz}
\definecolor{pear}{rgb}{0.82, 0.89, 0.19}
\definecolor{lavender}{rgb}{0.71, 0.49, 0.86}
\usetikzlibrary{calc,positioning}
\usetikzlibrary{decorations, decorations.text}
\newlength{\layerwd}
\newcounter{outermost}
\NewDocumentEnvironment{onion}{sm}{%*= draw axes; #1: thickness of each annulus
\begin{tikzpicture}
\setlength{\layerwd}{#2}%
\setcounter{outermost}{0}
}{%
\foreach \A in {0,...,\theoutermost}{\draw[thick,] (0,0) circle (\A*\layerwd+\layerwd);}
\end{tikzpicture}
}
% define your custom font style
\newcommand{\customannfont}{\bfseries\fontsize{10}{0}\selectfont}
% *=text on a circular path; [optional fill color]; #3 layer;
% #4 start angle; #5 stop angle; #6 [optional text]
%% angles are counterclockwise in degrees
\NewDocumentCommand{\annulus}{sO{lightgray}mmmo}{%
\filldraw[thick,fill=#2,] (#4:#3*\layerwd) %% start here
arc [radius=#3*\layerwd, start angle=#4, delta angle=#5-#4] %% inner arc
-- (#5:#3*\layerwd+\layerwd) %% move out
arc [radius=#3*\layerwd+\layerwd, start angle=#5, delta angle=#4-#5,] %% outer arc
-- cycle; %% Back to the beginnning
\pgfmathsetmacro{\tmp}{(#5-#4)/2 +#4} %% Locate the middle of the arc
\IfNoValueF{#6}{%
\IfBooleanTF{#1}
{%
\begingroup
%% text is always rightside-up:
\pgfmathsetmacro{\rpTF}{ifthenelse(\tmp>180,"false","true")}
\def\\{\space} %% A safety precaution, \\ = space on decorated text
\path[rotate=\tmp-180,postaction={
decorate,
decoration={
text along path,
raise=-3pt,
text align={align=center},
reverse path=\rpTF,
text={|\customannfont|#6}
}
}] (0,0) circle (#3*\layerwd+0.5*\layerwd);
\endgroup
}%%
{%
\pgfmathsetmacro{\rpTF}{ifthenelse(\tmp>180,\tmp+90,\tmp-90)}
\node[inner sep=0pt, %%% If there is text, print it
text width=#3*\layerwd*3+\layerwd,
align=center,
rotate=\rpTF,
font=\customannfont] at (\tmp:#3*\layerwd+0.5*\layerwd)
{#6};
}%
}%
\ifnum\theoutermost<#3\setcounter{outermost}{#3}\fi
}
\begin{document}
\begin{onion}*{0.6in}
\draw[fill=red!20,thick] (0,0) circle (1.53cm);
\node[color=red,thick,font=\bfseries] at (0,0) {My research};
\annulus*[pear]{1}{0}{180}[Materials for composites]
\annulus*[pear!80]{2}{0}{180}[Working through trial and errors to find parameters]
\annulus*[pear!60]{3}{0}{180}[Conditions associated with pre and post heat treatment]
\annulus*[pear!40]{4}{20}{70}[Mechanical]
\annulus*[pear!40]{4}{0}{20}[Physical]
\annulus*[pear!40]{4}{70}{100}[Tribological]
\annulus*[pear!40]{4}{100}{150}[Microstructure(OM/SEM/TEM)]
\annulus*[pear!40]{4}{150}{180}[XRD]
\annulus[pear!25]{5}{150}{180}[2($\theta$) and \\Bulk texture]
\annulus[pear!25]{5}{100}{150}[Composites{,}\\Fracture{,}\\Wear track/debris]
\annulus*[pear!25]{5}{70}{100}[Wear rate/COF]
\annulus[pear!25]{5}{20}{40}[Hardness (Hv)]
\annulus[pear!25]{5}{0}{20}[Density]
\annulus[pear!25]{5}{40}{70}[Tensile (MPa)\\Yield (MPa)\\Elongation ($\delta$)]
\annulus*[lavender!65]{1}{180}{360}[Materials for composites]
\annulus*[lavender!55]{2}{180}{360}[Working through trial and errors to find parameters]
\annulus*[lavender!45]{3}{180}{360}[Conditions associated with pre and post heat treatment]
\annulus*[lavender!35]{4}{180}{200}[Physical]
\annulus*[lavender!35]{4}{200}{250}[Mechanical]
\annulus*[lavender!35]{4}{250}{280}[Tribological]
\annulus*[lavender!35]{4}{280}{330}[Microstructure(OM/SEM/TEM)]
\annulus*[lavender!35]{4}{330}{360}[XRD]
\annulus[lavender!25]{5}{180}{200}[Density]
\annulus[lavender!25]{5}{200}{220}[Hardness (Hv)]
\annulus[lavender!25]{5}{220}{250}[Tensile (MPa)\\Yield (MPa)\\Elongation ($\delta$)]
\annulus*[lavender!25]{5}{250}{280}[Wear rate/COF]
\annulus[lavender!25]{5}{280}{330}[Composites{,}\\Fracture{,}\\Wear track/debris]
\annulus[lavender!25]{5}{330}{360}[2($\theta$) and \\Bulk texture]
\end{onion}
\end{document}
答案2
\bfseries
可以用和指定字体\large
。
代码可以使用轮图包,是我写的。
弧线中的文本被赋予键arc data
。此处,可用于将文本拆分为多行。此文本的方向取决于键 中给出的\\
弧线中间的角度。此文本以 为中心位于弧线中。\WCmidangle
arc data dir
arc data pos=0.5
\documentclass[border=6pt]{standalone}
\usepackage{wheelchart}
\usetikzlibrary{decorations.text}
\begin{document}
\begin{tikzpicture}[scale=1.2]
\bfseries\large
\definecolor{lavender}{rgb}{0.71, 0.49, 0.86}
\definecolor{pear}{rgb}{0.82, 0.89, 0.19}
\pgfkeys{
/wheelchart,
arc data=\WCvarB,
arc data dir={\WCmidangle<180?1:-1},
arc data expand=f,
arc data pos=0.5,
data=,
slices style={fill=\WCcolor,draw=black,thick},
total angle=180
}
\fill[red!20] (0,0) circle[radius=1.5] node[red] {My research};
\foreach\WCstartangle/\WCcolorA/\WCcolorB/\WCcolorC/\WCcolorD/\WCcolorE in {%
180/pear/pear!80/pear!60/pear!40/pear!25,
0/lavender!65/lavender!55/lavender!45/lavender!35/lavender!25%
}{
\pgfkeys{
/wheelchart,
start angle=\WCstartangle
}
\edef\WCcolor{\WCcolorA}
\wheelchart[
radius={1.5}{3}
]{%
1/Materials for composites%
}
\edef\WCcolor{\WCcolorB}
\wheelchart[
radius={3}{4.5}
]{%
1/Working through trial and errors to find parameters%
}
\edef\WCcolor{\WCcolorC}
\wheelchart[
radius={4.5}{6}
]{%
1/Conditions associated with pre and post heat treatment%
}
\edef\WCcolor{\WCcolorD}
\wheelchart[
radius={6}{7.5}
]{%
30/XRD,
50/{Microstructure (OM/SEM/TEM)},
30/Tribological,
50/Mechanical,
20/Physical%
}
\edef\WCcolor{\WCcolorE}
\wheelchart[
radius={7.5}{9}
]{%
30/$2({\theta})$ and\\Bulk texture,
50/{Composites,\\Fracture,\\Wear track/debris},
30/{Wear rate/COF},
30/Tensile (MPa)\\Yield (MPa)\\Elongation (${\delta}$),
20/Hardness (Hv),
20/Density%
}
}
\end{tikzpicture}
\end{document}