我,
我想让这两个 tikzpicture 并排显示。无需更改代码,可以吗?
\documentclass{article}
\usepackage{subfig}
\usepackage{amsmath}
\usepackage{tikz}
\usepackage{pgf-pie}
\usepackage{pgfplots}
\usepackage{bchart}
\usepackage{graphicx}
\usepackage{tikz,stackengine}
\def\stackalignment{r}
\setstackgap{S}{2pt}
\def\stackalignment{r}
\newcommand\pielabelon[3][0pt]{%
\abovebaseline[#3]{#2%
\makebox[-\dimexpr8pt+#1]{\smash{%
\stackunder{}{\rule{1pt}{\dimexpr#3+2.5ex}}}}}
}
\newcommand\pielabelunder[3][0pt]{%
\belowbaseline[#3]{#2%
\makebox[-\dimexpr8pt+#1]{\smash{%
\stackon{\rule{0pt}{1.3ex}}{\rule{1pt} {\dimexpr#3+2.5ex}}}}}
}
\newcommand{\slice}[4]{
\pgfmathparse{0.5*#1+0.5*#2}
\let\midangle\pgfmathresult
% slice
\draw[thick,fill=black!10] (0,0) -- (#1:1) arc (#1:#2:1) -- cycle;
% outer label
\node[label=\midangle:#4] at (\midangle:1) {};
% inner label
\pgfmathparse{min((#2-#1-10)/110*(-0.3),0)}
\let\temp\pgfmathresult
\pgfmathparse{max(\temp,-0.5) + 0.8}
\let\innerpos\pgfmathresult
\node at (\midangle:\innerpos) {#3};
}
\newcounter{a}
\newcounter{b}
\begin{document}
\begin{figure}
\centering
\subfloat[In-only]{\label{fig:in}
\begin{tikzpicture}
\newcounter{i}
\newcounter{j}
\foreach \p/\t in {
45/Absolute Return Bonds,
45/Emerging Market Debt,
7/Equity (7\%),
3/Property (3\%)}
{
\setcounter{a}{\value{b}}
\addtocounter{b}{\p}
\slice{\thea/100*360}
{\theb/100*360}
{\ifnum\p>10\relax\p\%\fi}{\t}
}
\end{tikzpicture}
}
\quad
\subfloat[In-only]{\label{fig:in}
\begin{tikzpicture}
\newcounter{e}
\newcounter{h}
\foreach \p/\t in {
45/Absolute Return Bonds,
45/Emerging Market Debt,
7/Equity (7\%),
3/Property (3\%)}
{
\setcounter{a}{\value{b}}
\addtocounter{b}{\p}
\slice{\thea/100*360}
{\theb/100*360}
{\ifnum\p>10\relax\p\%\fi}{\t}
}
\end{tikzpicture}
}
\end{figure}
\end{document}
我尝试使用 subfloat 来实现,但是没有效果。