如何在以下饼图上添加标题?我尝试使用\stackon
。
\documentclass[10pt]{amsart}
\usepackage{mathtools,systeme,array}
\usepackage{tikz}
\usepackage{adjustbox}
\usepackage{mathtools}
\usepackage{array}
\usepackage{makecell}
\usepackage{stackengine}\setstackEOL{\cr} %EOL is abbreviation for "end of line."
\begin{document}
%\setlength\extrarowheight{2pt}
%\stackon{%
\begin{tikzpicture}[every node/.style={align=center}, pin distance=5mm]
\coordinate (O) at (0,0);
\draw (O) circle (3);
\draw (O) -- (0:3);
\draw (O) -- (90:3);
\draw (O) -- (216:3);
\draw (O) -- (234:3);
\draw (O) -- (288:3);
\path (O) -- node{Food \\ 25\%} (45:3);
\path (O) -- node{Rent and \\ Utilities \\ 35\%} (153:3);
\path (O) -- node[pin=225:Clothing \\ 5\%] {} (225:5);
\path (O) -- node{Other \\ 5\%} (261:3);
\path (O) -- node{Car \\ 20\%} (324:3);
\end{tikzpicture}
%}{\bfseries\Longstack{David's Monthly Expenses}}
\end{document}
答案1
通常图片不包含标题,这是图形标题的任务,如下所示:
text text text
\begin{figure}
... picture ...
\caption{David's Monthly Expenses}
\label{fig:david-expences}
\end{figure}
text text text
要在图片上添加图片名称——正如我在评论中所说,您需要添加一个带有图片标题的节点:
\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{angles,calc,positioning}
\begin{document}
\begin{tikzpicture}[
every node/.style={align=center},
pin distance=9mm
]
\coordinate (O) at (0,0);
\draw (O) circle (3);
\draw (O) -- (0:3);
\draw (O) -- (90:3);
\draw (O) -- (216:3);
\draw (O) -- (234:3);
\draw (O) -- (288:3);
\path (O) -- node{Food\\ 25\%} (45:3);
\path (O) -- node{Rent and\\ Utilities\\ 35\%} (153:3);
\path (O) -- node[pos=0.75,pin=225:Clothing\\ 5\%] {} (225:3);
\path (O) -- node{Other\\ 5\%} (261:3);
\path (O) -- node{Car\\ 20\%} (324:3);
\node[below=33mm of O] {\textbf{Title of picture}};%select one, which you more like
\node[right=33mm of O] {\textbf{Title of picture}};
\end{tikzpicture}
\end{document}
当然,机器人的解决方案与表格无关,除非你喜欢在表格中放图片(问题中没有说明的内容)。对于你的饼图,我使用了我对你之前一个问题的回答。